handles Azure deviation from OpenAI spec on logprobs param
This commit is contained in:
parent
ad465be363
commit
4a4b60ebcd
|
@ -18,6 +18,16 @@ export const addAzureKey: RequestPreprocessor = (req) => {
|
|||
|
||||
req.key = keyPool.get(model);
|
||||
req.body.model = model;
|
||||
|
||||
// Handles the sole Azure API deviation from the OpenAI spec (that I know of)
|
||||
if (req.body.logrpobs || req.body.top_logprobs) {
|
||||
// OpenAI wants logprobs: true/false and top_logprobs: number
|
||||
// Azure seems to just want to combine them into logprobs: number
|
||||
if (typeof req.body.logprobs === "boolean") {
|
||||
req.body.logprobs = req.body.top_logprobs || undefined;
|
||||
delete req.body.top_logprobs
|
||||
}
|
||||
}
|
||||
|
||||
req.log.info(
|
||||
{ key: req.key.hash, model },
|
||||
|
|
|
@ -87,6 +87,9 @@ export const OpenAIV1ChatCompletionSchema = z
|
|||
logit_bias: z.any().optional(),
|
||||
user: z.string().max(500).optional(),
|
||||
seed: z.number().int().optional(),
|
||||
// Be warned that Azure OpenAI combines these two into a single field.
|
||||
// It's the only deviation from the OpenAI API that I'm aware of so I have
|
||||
// special cased it in `addAzureKey` rather than expecting clients to do it.
|
||||
logprobs: z.boolean().optional().default(false),
|
||||
top_logprobs: z.number().int().optional(),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue