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 the user parameter is omitted when it is empty, aligning with fireworks AI's requirements.
The solution involves adding the omitempty JSON tag to the user field in the EmbeddingRequest struct. This ensures that if the user field 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 empty user field.
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:
{
"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
}
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 theuser
parameter 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
omitempty
JSON tag to theuser
field in theEmbeddingRequest
struct. This ensures that if theuser
field 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 emptyuser
field.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:
Additional context
Example error response before the fix:
Example successful response after the fix:
go code