From 48197c7d541136255710aefd158b85e48e6bfb80 Mon Sep 17 00:00:00 2001 From: kannoixia Date: Thu, 21 Nov 2024 23:22:21 +0900 Subject: [PATCH] feat: fix options setting --- scripts/konjacbot/translate.mts | 6 +++++- scripts/konjacbot/utils.mts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/konjacbot/translate.mts b/scripts/konjacbot/translate.mts index c73f265..4b27ff7 100644 --- a/scripts/konjacbot/translate.mts +++ b/scripts/konjacbot/translate.mts @@ -22,6 +22,7 @@ const defaults = { promptDir: path.join(import.meta.dirname, `prompt`), isCI: process.env.CI ?? false, temperature: 0, + model: 'gpt-4o', } as const const log = createLogger(basename(import.meta.filename)) @@ -54,7 +55,10 @@ const command = await (async () => { apiKey: defaults.apiKey, maxRetries: defaults.maxRetries, }), - { temperature: defaults.temperature } + { + temperature: defaults.temperature, + model: defaults.model, + } ) const systemContent = ( diff --git a/scripts/konjacbot/utils.mts b/scripts/konjacbot/utils.mts index 4c7f27c..7a3b7d6 100644 --- a/scripts/konjacbot/utils.mts +++ b/scripts/konjacbot/utils.mts @@ -241,7 +241,7 @@ export function createLogger(prefix: string) { */ export function createOpenAIClient( openai: OpenAI, - options: { temperature?: number } = {} + options: Omit ): (prompt: { system: string; user: string }) => Promise { async function fetch(prompt: { system: string @@ -256,10 +256,9 @@ export function createOpenAIClient( while (!isComplete) { const response = await openai.chat.completions.create({ - model: 'gpt-4o', + ...options, messages, stream: false, - temperature: options.temperature, }) const choice = response.choices[0]