Commit 8c28040
committed
feat: preserve logprobs from chat completions API in ModelResponse
The SDK already accepts `top_logprobs` in ModelSettings and passes it to the
API, but the logprobs returned in the response were discarded during
conversion. This change:
1. Adds an optional `logprobs` field to ModelResponse dataclass
2. Extracts logprobs from `choice.logprobs.content` in the chat completions
model and includes them in the ModelResponse
This enables use cases like RLHF training, confidence scoring, and
uncertainty estimation that require access to token-level log probabilities.1 parent 9fcc68f commit 8c28040
2 files changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
359 | 366 | | |
360 | 367 | | |
361 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| |||
0 commit comments