|
1 |
| -""" |
2 |
| -To Use it: |
3 |
| -
|
4 |
| -Example 1: Using OpenAI (default), with default task: 'go to reddit and search for posts about browser-use' |
5 |
| -python command_line.py |
6 |
| -
|
7 |
| -Example 2: Using OpenAI with a Custom Query |
8 |
| -python command_line.py --query "go to google and search for browser-use" |
9 |
| -
|
10 |
| -Example 3: Using Anthropic's Claude Model with a Custom Query |
11 |
| -python command_line.py --query "find latest Python tutorials on Medium" --provider anthropic |
12 |
| -
|
13 |
| -""" |
14 | 1 | import os
|
15 | 2 | import sys
|
16 | 3 | import argparse
|
|
19 | 6 | # Ensure local repository (browser_use) is accessible
|
20 | 7 | sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
21 | 8 |
|
22 |
| -from dotenv import load_dotenv |
| 9 | +# Third-party imports |
| 10 | +from langchain_openai import ChatOpenAI |
23 | 11 |
|
| 12 | +# Local module imports |
24 | 13 | from browser_use import Agent
|
25 | 14 | from browser_use.browser.browser import Browser, BrowserConfig
|
26 | 15 | from browser_use.controller.service import Controller
|
27 | 16 |
|
28 | 17 |
|
29 |
| -load_dotenv() |
30 |
| - |
31 | 18 | def get_llm(provider: str):
|
32 | 19 | if provider == 'anthropic':
|
33 | 20 | from langchain_anthropic import ChatAnthropic
|
34 |
| - api_key = os.getenv("ANTHROPIC_API_KEY") |
35 |
| - if not api_key: |
36 |
| - raise ValueError("Error: ANTHROPIC_API_KEY is not set. Please provide a valid API key.") |
37 |
| - |
38 | 21 | return ChatAnthropic(
|
39 | 22 | model_name='claude-3-5-sonnet-20240620', timeout=25, stop=None, temperature=0.0
|
40 | 23 | )
|
41 | 24 | elif provider == 'openai':
|
42 |
| - from langchain_openai import ChatOpenAI |
43 |
| - api_key = os.getenv("OPENAI_API_KEY") |
44 |
| - if not api_key: |
45 |
| - raise ValueError("Error: OPENAI_API_KEY is not set. Please provide a valid API key.") |
46 |
| - |
47 | 25 | return ChatOpenAI(model='gpt-4o', temperature=0.0)
|
48 | 26 |
|
49 | 27 | else:
|
|
0 commit comments