Skip to content

Commit

Permalink
Fix/oai parameters 1552 (#1557)
Browse files Browse the repository at this point in the history
* support temperature between 0 and 2

* added parsing of presence_penalty from model parameters. OAI endpoint now correctly uses (frequency penalty=parameters.repetition penalty) and (presence penalty=parameters.presence_penalty) for both chat and completion paths.

* added parsing of presence_penalty from model parameters. OAI endpoint now correctly uses (frequency penalty=parameters.repetition penalty) and (presence penalty=parameters.presence_penalty) for both chat and completion paths.
  • Loading branch information
evalstate authored Nov 11, 2024
1 parent f1da644 commit a53ca9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/server/endpoints/openai/endpointOai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export async function endpointOai(
temperature: parameters?.temperature,
top_p: parameters?.top_p,
frequency_penalty: parameters?.repetition_penalty,
presence_penalty: parameters?.presence_penalty,
};

const openAICompletion = await openai.completions.create(body, {
Expand Down Expand Up @@ -245,6 +246,7 @@ export async function endpointOai(
temperature: parameters?.temperature,
top_p: parameters?.top_p,
frequency_penalty: parameters?.repetition_penalty,
presence_penalty: parameters?.presence_penalty,
...(toolCallChoices.length > 0 ? { tools: toolCallChoices, tool_choice: "auto" } : {}),
};

Expand Down
3 changes: 2 additions & 1 deletion src/lib/server/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ const modelConfig = z.object({
endpoints: z.array(endpointSchema).optional(),
parameters: z
.object({
temperature: z.number().min(0).max(1).optional(),
temperature: z.number().min(0).max(2).optional(),
truncate: z.number().int().positive().optional(),
max_new_tokens: z.number().int().positive().optional(),
stop: z.array(z.string()).optional(),
top_p: z.number().positive().optional(),
top_k: z.number().positive().optional(),
repetition_penalty: z.number().min(-2).max(2).optional(),
presence_penalty: z.number().min(-2).max(2).optional(),
})
.passthrough()
.optional(),
Expand Down

0 comments on commit a53ca9b

Please sign in to comment.