Skip to content

Commit e24de3a

Browse files
Fixing prettier issues
1 parent fda59dd commit e24de3a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/auto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async function runTask(
5656
snapshot: await getSnapshot(page),
5757
options: options
5858
? {
59-
model: options.model ?? "gpt-4-1106-preview",
59+
model: options.model ?? "gpt-4o",
6060
debug: options.debug ?? false,
6161
openaiApiKey: options.openaiApiKey,
6262
openaiBaseUrl: options.openaiBaseUrl,

src/completeTask.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ export const completeTask = async (
99
page: Page,
1010
task: TaskMessage
1111
): Promise<TaskResult> => {
12-
const openai = new OpenAI({
13-
apiKey: task.options?.openaiApiKey,
14-
baseURL: task.options?.openaiBaseUrl,
15-
defaultQuery: task.options?.openaiDefaultQuery,
16-
defaultHeaders: task.options?.openaiDefaultHeaders,
17-
});
12+
const openai = new OpenAI({ apiKey: task.options?.openaiApiKey });
1813

1914
let lastFunctionResult: null | { errorMessage: string } | { query: string } =
2015
null;
@@ -25,7 +20,7 @@ export const completeTask = async (
2520

2621
const runner = openai.beta.chat.completions
2722
.runTools({
28-
model: task.options?.model ?? "gpt-4-1106-preview",
23+
model: task.options?.model ?? "gpt-4o",
2924
messages: [{ role: "user", content: prompt(task) }],
3025
tools: Object.values(actions).map((action) => ({
3126
type: "function",
@@ -39,9 +34,13 @@ export const completeTask = async (
3934

4035
if (
4136
message.role === "assistant" &&
42-
message.function_call?.name.startsWith("result")
37+
message.tool_calls &&
38+
message.tool_calls.length > 0 &&
39+
message.tool_calls[0].function.name.startsWith("result")
4340
) {
44-
lastFunctionResult = JSON.parse(message.function_call.arguments);
41+
lastFunctionResult = JSON.parse(
42+
message.tool_calls[0].function.arguments
43+
);
4544
}
4645
});
4746

0 commit comments

Comments
 (0)