From 7c3dfb7bae37a7d0412a8696393b6189cf2a42cb Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Sun, 24 Dec 2023 17:24:04 +0800 Subject: [PATCH] feat: support custom gemini pro params --- app/client/platforms/google.ts | 9 ++ app/components/model-config.tsx | 143 +++++++++++++++++--------------- 2 files changed, 83 insertions(+), 69 deletions(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 3192d5d5..ec7d7956 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -34,6 +34,15 @@ export class GeminiProApi implements LLMApi { }; const requestPayload = { contents: messages, + generationConfig: { + // stopSequences: [ + // "Title" + // ], + temperature: modelConfig.temperature, + maxOutputTokens: modelConfig.max_tokens, + topP: modelConfig.top_p, + // "topK": modelConfig.top_k, + }, // stream: options.config.stream, // model: modelConfig.model, // temperature: modelConfig.temperature, diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx index a077b82c..b9f81167 100644 --- a/app/components/model-config.tsx +++ b/app/components/model-config.tsx @@ -91,79 +91,84 @@ export function ModelConfigList(props: { } > - - { - props.updateConfig( - (config) => - (config.presence_penalty = - ModalConfigValidator.presence_penalty( - e.currentTarget.valueAsNumber, - )), - ); - }} - > - - - { - props.updateConfig( - (config) => - (config.frequency_penalty = - ModalConfigValidator.frequency_penalty( - e.currentTarget.valueAsNumber, - )), - ); - }} - > - + {props.modelConfig.model === "gemini-pro" ? null : ( + <> + + { + props.updateConfig( + (config) => + (config.presence_penalty = + ModalConfigValidator.presence_penalty( + e.currentTarget.valueAsNumber, + )), + ); + }} + > + - - - props.updateConfig( - (config) => - (config.enableInjectSystemPrompts = e.currentTarget.checked), - ) - } - > - + + { + props.updateConfig( + (config) => + (config.frequency_penalty = + ModalConfigValidator.frequency_penalty( + e.currentTarget.valueAsNumber, + )), + ); + }} + > + - - - props.updateConfig( - (config) => (config.template = e.currentTarget.value), - ) - } - > - + + + props.updateConfig( + (config) => + (config.enableInjectSystemPrompts = + e.currentTarget.checked), + ) + } + > + + + + props.updateConfig( + (config) => (config.template = e.currentTarget.value), + ) + } + > + + + )}