Skip to content

Commit

Permalink
feat: fix options setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kannoixia committed Nov 21, 2024
1 parent fb8c49a commit 48197c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion scripts/konjacbot/translate.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 = (
Expand Down
5 changes: 2 additions & 3 deletions scripts/konjacbot/utils.mts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function createLogger(prefix: string) {
*/
export function createOpenAIClient(
openai: OpenAI,
options: { temperature?: number } = {}
options: Omit<OpenAI.ChatCompletionCreateParams, 'messages'>
): (prompt: { system: string; user: string }) => Promise<string> {
async function fetch(prompt: {
system: string
Expand All @@ -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]
Expand Down

0 comments on commit 48197c7

Please sign in to comment.