1
1
import { test as base } from '@playwright/test' ;
2
2
import { AutoConfig } from './types' ;
3
3
import { sessionManager , context } from './browser' ;
4
- import { ChatOpenAI } from "@langchain/openai" ;
5
4
import { createReactAgent } from "@langchain/langgraph/prebuilt" ;
6
5
import { HumanMessage } from "@langchain/core/messages" ;
7
- import dotenv from 'dotenv ' ;
6
+ import { createLLMModel } from './llm ' ;
8
7
import {
9
8
browser_click , browser_type , browser_get_text , browser_navigate , browser_snapshot ,
10
9
browser_hover , browser_drag , browser_select_option , browser_take_screenshot ,
11
10
browser_go_back , browser_wait , browser_press_key , browser_save_pdf , browser_choose_file ,
12
11
browser_go_forward , browser_assert
13
12
} from './tools' ;
14
13
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
-
24
14
// Extend base test to automatically track page
25
15
export const test = base . extend ( {
26
16
page : async ( { page } , use ) => {
@@ -31,7 +21,7 @@ export const test = base.extend({
31
21
32
22
// Initialize the LangChain agent with more detailed instructions
33
23
const initializeAgent = ( ) => {
34
- const model = openai_model ;
24
+ const model = createLLMModel ( ) ;
35
25
36
26
const prompt =
37
27
`You are a web automation assistant. When given a natural language instruction:
@@ -67,8 +57,6 @@ const initializeAgent = () => {
67
57
return { agent } ;
68
58
} ;
69
59
70
-
71
-
72
60
// Main auto function that processes instructions
73
61
export async function auto ( instruction : string , config ?: AutoConfig ) : Promise < any > {
74
62
console . log ( `[Auto] Processing instruction: "${ instruction } "` ) ;
0 commit comments