Reputation: 3
An error occurred when I made the api call. I am at a loss as to the cause. Does anyone know what the problem is?
The following is the response from the API call.
{"error": {"requestid": "c4f88e85-98f0-46e0-8ffa-xxxxxxxxxxxx", "code": 400, "message": "Invalid JSON in request body"}}
The following is the content of the API call.
api_base="https://test_api.openai.azure.com/"
api_key="xxxxxxxxxxxxxxxxxxxxxxxxx"
deployment_id="gpt-4-32k-test"
search_endpoint="https://test_api.search.windows.net"
search_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
search_index="index_name"
curl -i -X POST $api_base/openai/deployments/$deployment_id/extensions/chat/completions?api-version=2023-08-01-preview \
-H "Content-Type: application/json" \
-H "api-key: $api_key" \
-d \
'
{
"dataSources": [
{
"type": "AzureCognitiveSearch",
"parameters": {
"endpoint": "'$search_endpoint'",
"key": "'$search_key'",
"indexName": "'$search_index'"
}
}
],
"messages": [{"role":"system","content":"You are an AI assistant that helps people find information."}],
}
'
I think the json format and parameter information is correct,
Upvotes: 0
Views: 699
Reputation: 402
I think you still need to provide more parameters, like the Fields binding, and also to add at least one "user" message, not just the system prompt. Take a look to this sample I created using that API from an SPFx webpart: https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-azure-openai-connector/src/webparts/ourHotelsFinder/models/CompletionsRequestBuilder.ts
Let me know if it helps. Cheers.
Upvotes: 0