11import { test as base } from '@playwright/test' ;
22import { AutoConfig } from './types' ;
33import { sessionManager , context } from './browser' ;
4- import { ChatOpenAI } from "@langchain/openai" ;
54import { createReactAgent } from "@langchain/langgraph/prebuilt" ;
65import { HumanMessage } from "@langchain/core/messages" ;
7- import dotenv from 'dotenv ' ;
6+ import { createLLMModel } from './llm ' ;
87import {
98 browser_click , browser_type , browser_get_text , browser_navigate , browser_snapshot ,
109 browser_hover , browser_drag , browser_select_option , browser_take_screenshot ,
1110 browser_go_back , browser_wait , browser_press_key , browser_save_pdf , browser_choose_file ,
1211 browser_go_forward , browser_assert
1312} from './tools' ;
1413
15- // Load environment variables
16- dotenv . config ( ) ;
17- const openai_llm_model = process . env . LLM_MODEL || 'gpt-4o-mini' ;
18-
19- const openai_model = new ChatOpenAI ( {
20- modelName : openai_llm_model ,
21- temperature : 0 ,
22- } ) ;
23-
2414// Extend base test to automatically track page
2515export const test = base . extend ( {
2616 page : async ( { page } , use ) => {
@@ -31,7 +21,7 @@ export const test = base.extend({
3121
3222// Initialize the LangChain agent with more detailed instructions
3323const initializeAgent = ( ) => {
34- const model = openai_model ;
24+ const model = createLLMModel ( ) ;
3525
3626 const prompt =
3727 `You are a web automation assistant. When given a natural language instruction:
@@ -67,8 +57,6 @@ const initializeAgent = () => {
6757 return { agent } ;
6858} ;
6959
70-
71-
7260// Main auto function that processes instructions
7361export async function auto ( instruction : string , config ?: AutoConfig ) : Promise < any > {
7462 console . log ( `[Auto] Processing instruction: "${ instruction } "` ) ;
0 commit comments