Skip to content

Fix max_completion_tokens error for Groq API#1242

Open
majiayu000 wants to merge 1 commit intokhoj-ai:masterfrom
majiayu000:fix/groq-max-completion-tokens
Open

Fix max_completion_tokens error for Groq API#1242
majiayu000 wants to merge 1 commit intokhoj-ai:masterfrom
majiayu000:fix/groq-max-completion-tokens

Conversation

@majiayu000
Copy link

Summary

  • Limit max_completion_tokens to 8192 for Groq API to prevent BadRequestError: 400
  • Add GROQ_MAX_COMPLETION_TOKENS constant for the Groq API limit
  • Apply the limit in both completion_with_backoff and chat_completion_with_backoff functions
  • Add unit tests for the is_groq_api function and the new constant

Test plan

  • Ruff check passes
  • Ruff format passes
  • CI tests pass

Fixes #1236

Limit max_completion_tokens to 8192 for Groq API to prevent
BadRequestError: 400 when using models with lower token limits.

Fixes khoj-ai#1236

Signed-off-by: majiayu000 <1835304752@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BadRequestError: 400 when using Free Groq/OpenAI compatible APIs due to max_completion_tokens mismatch

1 participant