OpenAI GPT-4 Chat Completions API response looks as follows:
Код: Выделить всё
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "The 2020 World Series was played in Texas at Globe Life Field in Arlington.",
"role": "assistant"
},
"logprobs": null
}
]
}
}
The finish_reason field in the OpenAI API's response indicates why the model stopped generating text for a particular completion.
"stop": This means that the generation was stopped because the model encountered a stop sequence specified in the prompt or by the parameters in the API call. Stop sequences can be explicit (like a specific word or punctuation mark that signals the end of a text) or implicit based on the prompt structure.
"length": This value indicates that the generation reached the maximum length specified in the request. The API allows users to set a maximum number of tokens to be generated, and if the completion reaches this limit, the generation will stop with "length" as the finish_reason.
"token_limit": Similar to "length", this indicates that the generation has reached the total token limit set for the API call. It's a constraint on the maximum size of the output, ensuring that responses don't exceed the bounds set by the user or the limits of the API
Each of these finish reasons helps in understanding the boundaries of the generated text and can be useful in debugging or refining API requests. For example, if you consistently receive "length" as the finish_reason, you might consider increasing the maximum token limit for your requests if you need longer responses. .
Я посмотрел
Печатает просто строку из одного слова: