fix: replace anthropic SDK with openai SDK for Groq API#2
Merged
Conversation
- Groq uses OpenAI-compatible API, not Anthropic SDK - Changed import from 'anthropic' to 'openai' (OpenAI class) - Updated _try_groq_generation to use chat.completions.create() - Response parsing now uses choices[0].message.content format - Token counting uses completion_tokens + prompt_tokens - Added requirements.txt with correct dependencies - Updated CI workflow to use pip install -r requirements.txt Co-authored-by: HackMyTask <271546871+HackMyTask@users.noreply.github.com>
Deploying agc-website with
|
| Latest commit: |
e1f84b1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2e46898f.agc-website.pages.dev |
| Branch Preview URL: | https://fix-groq-openai-sdk.agc-website.pages.dev |
- All scripts now write/read from src/content/glossary/ (was content/glossary/) - Migrated [slug].astro from manual import.meta.glob + string parsing to proper Astro Content Collections with getCollection() + render() - Added src/content.config.ts with Zod schema validation for frontmatter - Created src/content/glossary/.gitkeep placeholder directory - Updated maintenance.yml paths to match - Keywords and related_terms now properly parsed as arrays
- Added 'import random' module - Added random_pick parameter to generate_batch() - When --random is used, pending list is shuffled before slicing - Without --random, behavior stays sequential (no change)
- Fix CI loop: added paths-ignore for generated content dirs - Fix site URL: use env var SITE_URL with fallback to pages.dev - Fix font loading: replace render-blocking @import with link preconnect - Fix canonical URL: use Astro.site instead of hardcoded domain - Fix homepage: use getCollection(), render gracefully with 0 articles - Fix .gitignore: remove stale content/glossary pattern - Build verified: npm run build passes with 3 pages
- Always rotate after failure (fixes stuck-on-last-key bug) - Next term now starts from next key, not the same exhausted one - Added _is_rate_limit_error() with comprehensive detection: rate_limit, 429, too many requests, tokens/requests per minute/day - Removed broken fallback that would send full comma-string as key - Better logging: shows attempt count and retry context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was generated by @kiro-agent 👻
Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent
Summary
Bug kritis #1 —
api_client.pymenggunakan Anthropic SDK untuk memanggil Groq API, padahal Groq menggunakan format OpenAI-compatible API.Changes
scripts/api_client.py:import anthropic→from openai import OpenAI_try_groq_generationsekarang menggunakanclient.chat.completions.create()response.choices[0].message.contentcompletion_tokens + prompt_tokensrequirements.txt(NEW):openai>=1.0.0google-generativeai>=0.3.0requests>=2.28.0.github/workflows/generate-content.yml:pip install requests→pip install -r requirements.txtWhy This Was Broken
Groq API is OpenAI-compatible (
/v1/chat/completions). The Anthropic SDK uses a different message format (/v1/messages) that does not work with Groq's endpoint. This caused a runtime error every time content generation was triggered.