Skip to content

Commit

Permalink
feat: ➕ add top_p feature support in constants
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 11, 2024
1 parent 610a432 commit ce19095
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export const MODEL_PROVIDERS: readonly {
url: string
seed?: boolean
logit_bias?: boolean
top_p?: boolean
}[] = Object.freeze([
{
id: MODEL_PROVIDER_OPENAI,
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ export const OpenAIChatCompletion: ChatCompletionHandler = async (
trace.itemValue(`logit_bias`, `disabled`)
delete postReq.logit_bias // some providers do not support logit_bias
}
if (!isNaN(postReq.top_p) && features?.top_p === false) {
logVerbose(`top_p: disabled, not supported by ${provider}`)
trace.itemValue(`top_p`, `disabled`)
delete postReq.top_p
}

// stream_options fails in some cases
if (model === "gpt-4-turbo-v" || /mistral/i.test(model)) {
Expand Down

0 comments on commit ce19095

Please sign in to comment.