diff --git a/src/auto.ts b/src/auto.ts index 77497d2..91f07c7 100644 --- a/src/auto.ts +++ b/src/auto.ts @@ -56,7 +56,7 @@ async function runTask( snapshot: await getSnapshot(page), options: options ? { - model: options.model ?? "gpt-4-1106-preview", + model: options.model ?? "gpt-4o", debug: options.debug ?? false, openaiApiKey: options.openaiApiKey, openaiBaseUrl: options.openaiBaseUrl, diff --git a/src/completeTask.ts b/src/completeTask.ts index a387a07..166e21a 100644 --- a/src/completeTask.ts +++ b/src/completeTask.ts @@ -25,7 +25,7 @@ export const completeTask = async ( const runner = openai.beta.chat.completions .runTools({ - model: task.options?.model ?? "gpt-4-1106-preview", + model: task.options?.model ?? "gpt-4o", messages: [{ role: "user", content: prompt(task) }], tools: Object.values(actions).map((action) => ({ type: "function", @@ -39,9 +39,13 @@ export const completeTask = async ( if ( message.role === "assistant" && - message.function_call?.name.startsWith("result") + message.tool_calls && + message.tool_calls.length > 0 && + message.tool_calls[0].function.name.startsWith("result") ) { - lastFunctionResult = JSON.parse(message.function_call.arguments); + lastFunctionResult = JSON.parse( + message.tool_calls[0].function.arguments + ); } });