openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.56k stars 466 forks source link

fix: logprobs may not exist on completion response choice #375

Open sohelzerdoumi opened 2 months ago

sohelzerdoumi commented 2 months ago

What:

Description:

Some openai server implementation miss logprobs attributes (localai).

curl http://localhost:8000/v1/completions -H "Content-Type: application/json" -d '{
          "model": "custom",
          "prompt": "Calculate 2*2"
}'
{
  "created": 1713099889,
  "object": "text_completion",
  "id": "59fd6975-64ff-4220-8576-9b6e3a6848b5",
  "model": "custom",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "text": "2 * 2 = 4"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 11,
    "total_tokens": 11
  }
}

Related:

debjit commented 2 months ago

When I was working with other compatible OpenAI APIs, I also discovered this issue. Should have been marked.