Skip to content

Commit

Permalink
fix prettier issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshdavidbabu committed Mar 31, 2024
1 parent 56e8c47 commit d67719f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/completeTask.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import OpenAI from 'openai';
import { type Page, TaskMessage, TaskResult } from './types';
import { prompt } from './prompt';
import { createActions } from './createActions';
import OpenAI from "openai";
import { type Page, TaskMessage, TaskResult } from "./types";
import { prompt } from "./prompt";
import { createActions } from "./createActions";

const defaultDebug = process.env.AUTO_PLAYWRIGHT_DEBUG === 'true';
const defaultDebug = process.env.AUTO_PLAYWRIGHT_DEBUG === "true";

export const completeTask = async (
page: Page,
Expand All @@ -20,21 +20,21 @@ export const completeTask = async (

const runner = openai.beta.chat.completions
.runTools({
model: task.options?.model ?? 'gpt-4-1106-preview',
messages: [{ role: 'user', content: prompt(task) }],
model: task.options?.model ?? "gpt-4-1106-preview",
messages: [{ role: "user", content: prompt(task) }],
tools: Object.values(actions).map((action) => ({
type: 'function',
type: "function",
function: action,
})),
})
.on('message', (message) => {
.on("message", (message) => {
if (debug) {
console.log('> message', message);
console.log("> message", message);
}

if (
message.role === 'assistant' &&
message.function_call?.name.startsWith('result')
message.role === "assistant" &&
message.function_call?.name.startsWith("result")
) {
lastFunctionResult = JSON.parse(message.function_call.arguments);
}
Expand All @@ -43,15 +43,15 @@ export const completeTask = async (
const finalContent = await runner.finalContent();

if (debug) {
console.log('> finalContent', finalContent);
console.log("> finalContent", finalContent);
}

if (!lastFunctionResult) {
throw new Error('Expected to have result');
throw new Error("Expected to have result");
}

if (debug) {
console.log('> lastFunctionResult', lastFunctionResult);
console.log("> lastFunctionResult", lastFunctionResult);
}

return lastFunctionResult;
Expand Down

0 comments on commit d67719f

Please sign in to comment.