Skip to content

Commit

Permalink
Revert "🐛 fix: Update baichuan param (lobehub#3356)"
Browse files Browse the repository at this point in the history
This reverts commit 29bced1.
  • Loading branch information
sxjeru authored Sep 10, 2024
1 parent c7fde14 commit 1555b04
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/libs/agent-runtime/baichuan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ export const LobeBaichuanAI = LobeOpenAICompatibleFactory({
baseURL: 'https://api.baichuan-ai.com/v1',
chatCompletion: {
handlePayload: (payload: ChatStreamPayload) => {
const { temperature, ...rest } = payload;
const { frequency_penalty, ...rest } = payload;

return {
...rest,
temperature:
temperature !== undefined
? temperature / 2
: undefined,
} as OpenAI.ChatCompletionCreateParamsStreaming;
let adjustedFrequencyPenalty = frequency_penalty ?? 1;

if (frequency_penalty !== undefined) {
if (frequency_penalty < 1) {
// If less than 1 (including negative values), add 1 to bring it into the 1-2 range
adjustedFrequencyPenalty = Math.min(Math.max(frequency_penalty + 1, 1), 2);
} else if (frequency_penalty > 2) {
// If greater than 2, cap it at 2
adjustedFrequencyPenalty = 2;
}
// If between 1 and 2, keep the original value
}

return { ...rest, frequency_penalty: adjustedFrequencyPenalty } as OpenAI.ChatCompletionCreateParamsStreaming;
},
},
debug: {
Expand Down

0 comments on commit 1555b04

Please sign in to comment.