Skip to content

Commit

Permalink
feat(openai): max_completion_tokens now used over max_tokens for chat…
Browse files Browse the repository at this point in the history
…_completeions endpoint.
  • Loading branch information
KeganHollern committed Dec 7, 2024
1 parent 4c2de79 commit 2eabd3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/server/endpoints/openai/endpointOai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export const endpointOAIParametersSchema = z.object({
}),
})
.default({}),
/* enable use of max_completion_tokens in place of max_tokens */
useCompletionTokens: z.boolean().default(true),
});

export async function endpointOai(
Expand All @@ -125,6 +127,7 @@ export async function endpointOai(
defaultQuery,
multimodal,
extraBody,
useCompletionTokens,
} = endpointOAIParametersSchema.parse(input);

let OpenAI;
Expand Down Expand Up @@ -246,7 +249,7 @@ export async function endpointOai(
model: model.id ?? model.name,
messages: messagesOpenAI,
stream: true,
max_tokens: parameters?.max_new_tokens,
...(useCompletionTokens) ? {max_completion_tokens: parameters?.max_new_tokens} : {max_tokens: parameters?.max_new_tokens},
stop: parameters?.stop,
temperature: parameters?.temperature,
top_p: parameters?.top_p,
Expand Down

0 comments on commit 2eabd3b

Please sign in to comment.