Openai Supported AI Providers [fireworks.ai] #779
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.
Describe the change
I was testing fireworks AI to create the embedding, and it threw an error due to an extra parameter (
user) being included in the request body even when it was an empty string. This PR modifies the code to ensure theuserparameter is omitted when it is empty, aligning with fireworks AI's requirements.Provide OpenAI documentation link
Relevant API documentation can be found here.
Describe your solution
The solution involves adding the
omitemptyJSON tag to theuserfield in theEmbeddingRequeststruct. This ensures that if theuserfield is empty, it will not be included in the JSON payload sent to the API. This change allows the request to be accepted by fireworks AI without triggering an error due to an emptyuserfield.Tests
I tested the change by making a request to the fireworks AI API using the modified code and verified that the request was successful. The test involved creating an embedding with the following details:
{ "input": ["hi satya"], "model": "nomic-ai/nomic-embed-text-v1.5", "encoding_format": "float", "dimensions": 100 }Additional context
Example error response before the fix:
{ "error": { "object": "error", "type": "internal_server_error", "message": "server had an error while processing your request, please retry again after a brief wait" }, "raw_output": null }Example successful response after the fix:
{ "data": [ { "index": 0, "embedding": [ -0.1552734375, 0.09490966796875, -0.90283203125, 0.1776123046875, 0.11700439453125, -0.00719451904296875, -0.119873046875, -0.1888427734375, -0.22216796875, 0.08270263671875 ], "object": "embedding" } ], "model": "nomic-ai/nomic-embed-text-v1.5", "object": "list", "usage": { "prompt_tokens": 3, "total_tokens": 3 } }go code