Closed mwnu closed 2 months ago
It appears that some choices
field is missing from some API response. Your API is not sufficiently compatible.
The openai_compatible
provider is powered by the openai-rs/openai-api library (well, by our fork of it), Our fork does minor improvements - see these open PRs:
It may be possible to fix some issues there, although.. the lack of a choices
field in the API response likely indicates that your API is doing something wrong.
You have not told us what your API requests & responses look like and why you think the API is responding in a valid (OpenAI-compatible) manner. You may also wish to report (and/or fix) any potential issue upstream (at the openai-api
library's repository or in our fork).
It appears that some
choices
field is missing from some API response. Your API is not sufficiently compatible.The
openai_compatible
provider is powered by the openai-rs/openai-api library (well, by our fork of it), Our fork does minor improvements - see these open PRs:
- Add additional request params (model, style, quality) to image request openai-rs/openai-api#18
- Add additional fields (revised_prompt, b64_json) to image response openai-rs/openai-api#19
It may be possible to fix some issues there, although.. the lack of a
choices
field in the API response likely indicates that your API is doing something wrong.You have not told us what your API requests & responses look like and why you think the API is responding in a valid (OpenAI-compatible) manner. You may also wish to report (and/or fix) any potential issue upstream (at the
openai-api
library's repository or in our fork).
I am using the compatibility API as referenced in this document.
curl --location --request POST 'https://api.tryfastgpt.ai/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "abcd",
"stream": false,
"detail": false,
"variables": {
"uid": "asdfadsfasfd2323",
"name": "张三"
},
"messages": [
{
"content": "导演是谁",
"role": "user"
}
]
}'
{
"id": "adsfasf",
"model": "",
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1
},
"choices": [
{
"message": {
"role": "assistant",
"content": "电影《铃芽之旅》的导演是新海诚。"
},
"finish_reason": "stop",
"index": 0
}
]
}
In the request body, only the "messages" parameter is necessary, consistent with OpenAI. The "choices" in the response are also basically the same. It seems to be missing the "logprobs" field, which is usually null and not very necessary.
It would be better if a custom model interface could be provided, for example, through a mapping configuration file.
Have you tried using https://api.tryfastgpt.ai/api/v1
as your base_url
?
Your original error message seemed to indicate you're using some other API URL and that it's the choices
field being missing that was causing the problem.
Have you tried using
https://api.tryfastgpt.ai/api/v1
as yourbase_url
?Your original error message seemed to indicate you're using some other API URL and that it's the
choices
field being missing that was causing the problem.
Yes, I've tried that. HTTPS, HTTP, domain names, and IP addresses (local addresses) all result in errors. These addresses can all be used to test other AI bot front-ends. However, if I switch to an OpenAI proxy address, it works normally.
base_url: http://192.168.1.20:2041/v1
base_url: https://exampelecom:2042/api/v1
The field validation is overly strict. This is an API provided by my RAG application, which can be used in most applications compatible with the OpenAI API.