-
Notifications
You must be signed in to change notification settings - Fork 260
feat(ai): added troubleshooting for generative apis #4230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
ai-data/generative-apis/troubleshooting/fixing-common-issues.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| meta: | ||
| title: Fixing common issues with Generative APIs | ||
| description: This page lists common issues that you may encounter while using Scaleway's Generative APIs, their causes and recommended solutions. | ||
| content: | ||
| h1: Fixing common issues with Generative APIs | ||
| paragraph: Generative APIs offer serverless AI models hosted at Scaleway - no need to configure hardware or deploy your own models | ||
| tags: generative-apis ai-data common-issues | ||
| dates: | ||
| validation: 2025-01-16 | ||
| posted: 2025-01-16 | ||
| --- | ||
|
|
||
| Below are common issues that you may encounter when using Generative APIs, their causes, and recommended solutions. | ||
|
|
||
| ## 504: Timeout | ||
|
|
||
| ### Cause | ||
| - The query is too long. | ||
| - The model goes into an infinite loop while processing the input. | ||
|
|
||
| ### Solution | ||
| - Set a stricter **maximum token limit** to prevent overly long responses. | ||
| - Reduce the size of the input tokens, or split the input into multiple API requests. | ||
| - Use [Managed Inference](/ai-data/managed-inference/), where no query timeout is enforced. | ||
|
|
||
| ## Structured output (e.g., JSON) is not working correctly | ||
|
|
||
| ### Cause | ||
| - Incorrect field naming in the request, such as using `"format"` instead of the correct `"response_format"` field. | ||
| - Lack of a JSON schema, which can lead to ambiguity in the output structure. | ||
|
|
||
| ### Solution | ||
| - Ensure the proper field `"response_format"` is used in the query. | ||
| - Provide a JSON schema in the request to guide the model's structured output. | ||
| - Refer to the [documentation on structured outputs](/ai-data/generative-apis/how-to/use-structured-outputs/) for examples and additional guidance. | ||
|
|
||
|
|
||
| ## Multiple "role": "user" successive messages | ||
|
|
||
| ### Cause | ||
| - Successive messages with `"role": "user"` are sent in the API request instead of alternating between `"role": "user"` and `"role": "assistant"`. | ||
|
|
||
| ### Solution | ||
| - Ensure the `"messages"` array alternates between `"role": "user"` and `"role": "assistant"`. | ||
| - If multiple `"role": "user"` messages need to be sent, concatenate them into one `"role": "user"` message or intersperse them with appropriate `"role": "assistant"` responses. | ||
|
|
||
| #### Example error message (for Mistral models) | ||
| ```json | ||
| { | ||
| "object": "error", | ||
| "message": "After the optional system message, conversation roles must alternate user/assistant/user/assistant/...", | ||
| "type": "BadRequestError", | ||
| "param": null, | ||
| "code": 400 | ||
| } | ||
| ``` | ||
|
|
||
| ## Best practices for optimizing model performance | ||
|
|
||
| ### Input size management | ||
| - Avoid overly long input sequences; break them into smaller chunks if needed. | ||
| - Use summarization techniques for large inputs to reduce token count while maintaining relevance. | ||
|
|
||
| ### Use proper parameter configuration | ||
| - Double-check parameters like `"temperature"`, `"max_tokens"`, and `"top_p"` to ensure they align with your use case. | ||
| - For structured output, always include a `"response_format"` and, if possible, a detailed JSON schema. | ||
|
|
||
| ### Debugging silent errors | ||
| - For cases where no explicit error is returned: | ||
| - Verify all fields in the API request are correctly named and formatted. | ||
| - Test the request with smaller and simpler inputs to isolate potential issues. | ||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| meta: | ||
| title: Generative APIs - Troubleshooting | ||
| description: Generative APIs - Troubleshooting | ||
| content: | ||
| h1: Generative APIs - Troubleshooting | ||
| paragraph: Generative APIs - Troubleshooting | ||
| --- |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.