Skip to content

Commit 48f8abd

Browse files
committed
Revert "Check responding api_key is it loaded properly with load dotenv"
This reverts commit 0ad4d5c.
1 parent 0ad4d5c commit 48f8abd

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

examples/ui/command_line.py

+3-25
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
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-
"""
141
import os
152
import sys
163
import argparse
@@ -19,31 +6,22 @@
196
# Ensure local repository (browser_use) is accessible
207
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
218

22-
from dotenv import load_dotenv
9+
# Third-party imports
10+
from langchain_openai import ChatOpenAI
2311

12+
# Local module imports
2413
from browser_use import Agent
2514
from browser_use.browser.browser import Browser, BrowserConfig
2615
from browser_use.controller.service import Controller
2716

2817

29-
load_dotenv()
30-
3118
def get_llm(provider: str):
3219
if provider == 'anthropic':
3320
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-
3821
return ChatAnthropic(
3922
model_name='claude-3-5-sonnet-20240620', timeout=25, stop=None, temperature=0.0
4023
)
4124
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-
4725
return ChatOpenAI(model='gpt-4o', temperature=0.0)
4826

4927
else:

examples/ui/gradio_demo.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import os
21
import asyncio
2+
import os
33
from dataclasses import dataclass
44
from typing import List, Optional
55

6-
# Third-party imports
76
import gradio as gr
87
from dotenv import load_dotenv
98
from langchain_openai import ChatOpenAI
109
from rich.console import Console
1110
from rich.panel import Panel
1211
from rich.text import Text
1312

14-
# Local module imports
1513
from browser_use import Agent
1614

1715
load_dotenv()

0 commit comments

Comments
 (0)