Skip to content

Commit

Permalink
style: apply style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Nov 14, 2023
1 parent 01fc156 commit 9d0509b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/completeTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createActions } from "./createActions";
const defaultDebug = process.env.AUTO_PLAYWRIGHT_DEBUG === "true";

type Snapshot = {
steps: {name: string, arguments: string}[];
steps: { name: string; arguments: string }[];
};

export const completeTask = async (
Expand All @@ -20,7 +20,7 @@ export const completeTask = async (

const actions = createActions(page);

const debug = task.options?.debug?? defaultDebug;
const debug = task.options?.debug ?? defaultDebug;

const snapshot: Snapshot = {
steps: [],
Expand All @@ -37,7 +37,7 @@ export const completeTask = async (
console.log("> message", message);
}

if (message.role === 'assistant' && message.function_call) {
if (message.role === "assistant" && message.function_call) {
snapshot.steps.push(message.function_call);
}

Expand Down
26 changes: 15 additions & 11 deletions src/createActions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Page } from "@playwright/test";
import { randomUUID } from "crypto";
import { RunnableFunctionWithParse, RunnableFunctionWithoutParse } from "openai/lib/RunnableFunction";
import {
RunnableFunctionWithParse,
RunnableFunctionWithoutParse,
} from "openai/lib/RunnableFunction";
import { z } from "zod";

export const createActions = (page: Page): (RunnableFunctionWithoutParse | RunnableFunctionWithParse<any>)[] => {
export const createActions = (
page: Page
): (RunnableFunctionWithoutParse | RunnableFunctionWithParse<any>)[] => {
const locatorMap = new Map();

const getLocator = (elementId: string) => {
Expand Down Expand Up @@ -52,10 +57,7 @@ export const createActions = (page: Page): (RunnableFunctionWithoutParse | Runna
},
},
{
function: async (args: {
attributeName: string;
elementId: string;
}) => {
function: async (args: { attributeName: string; elementId: string }) => {
return {
attributeValue: await getLocator(args.elementId).getAttribute(
args.attributeName
Expand Down Expand Up @@ -493,15 +495,16 @@ export const createActions = (page: Page): (RunnableFunctionWithoutParse | Runna
},
},
{
function: (args: {actual: string; expected: string}) => {
function: (args: { actual: string; expected: string }) => {
return {
actual: args.actual,
expected: args.expected,
success: args.actual === args.expected,
};
},
name: "expect_toBe",
description: "Asserts that the actual value is equal to the expected value.",
description:
"Asserts that the actual value is equal to the expected value.",
parse: (args: string) => {
return z
.object({
Expand All @@ -523,15 +526,16 @@ export const createActions = (page: Page): (RunnableFunctionWithoutParse | Runna
},
},
{
function: (args: {actual: string; expected: string}) => {
function: (args: { actual: string; expected: string }) => {
return {
actual: args.actual,
expected: args.expected,
success: args.actual !== args.expected,
};
},
name: "expect_notToBe",
description: "Asserts that the actual value is not equal to the expected value.",
description:
"Asserts that the actual value is not equal to the expected value.",
parse: (args: string) => {
return z
.object({
Expand Down Expand Up @@ -636,4 +640,4 @@ export const createActions = (page: Page): (RunnableFunctionWithoutParse | Runna
},
},
];
};
};

0 comments on commit 9d0509b

Please sign in to comment.