[Bugfix] Support logprobs when using guided_json and other constrained decoding fields (#4149)

This commit is contained in:
James Whedbee
2024-04-18 16:12:55 -05:00
committed by GitHub
parent 705578ae14
commit e1bb2fd52d
2 changed files with 33 additions and 1 deletions

View File

@@ -116,7 +116,9 @@ class OpenAIServing:
if num_output_top_logprobs:
logprobs.top_logprobs.append({
p.decoded_token: p.logprob
# Convert float("-inf") to the
# JSON-serializable float that OpenAI uses
p.decoded_token: max(p.logprob, -9999.0)
for i, p in step_top_logprobs.items()
} if step_top_logprobs else None)