Skip to content

Commit

Permalink
consolidate browser settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Apr 18, 2023
1 parent 9d14b11 commit d6b1aa6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ BROWSE_CHUNK_MAX_LENGTH=8192
# USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
# AI_SETTINGS_FILE - Specifies which AI Settings file to use (defaults to ai_settings.yaml)
AI_SETTINGS_FILE=ai_settings.yaml
# USE_WEB_BROWSER - Sets the web-browser drivers to use with selenium (defaults to chrome).
# Note: set this to either 'chrome', 'firefox', or 'safari' depending on your current browser
# USE_WEB_BROWSER=chrome

################################################################################
### LLM PROVIDER
Expand Down Expand Up @@ -138,8 +135,11 @@ GITHUB_USERNAME=your-github-username
################################################################################

### BROWSER
# HEADLESS_BROWSER - Whether to run the browser in headless mode
HEADLESS_BROWSER=True
# USE_WEB_BROWSER - Sets the web-browser drivers to use with selenium (defaults to chrome).
# HEADLESS_BROWSER - Whether to run the browser in headless mode (defaults to True)
# Note: set this to either 'chrome', 'firefox', or 'safari' depending on your current browser
# USE_WEB_BROWSER=chrome
# HEADLESS_BROWSER=True

### GOOGLE
# GOOGLE_API_KEY - Google API key (Example: my-google-api-key)
Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/web_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
options.add_argument("--remote-debugging-port=9222")

options.add_argument("--no-sandbox")
if CFG.headless_browser:
if CFG.selenium_headless:
options.add_argument("--headless")
options.add_argument("--disable-gpu")

Expand Down
9 changes: 6 additions & 3 deletions autogpt/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def __init__(self) -> None:
self.skip_reprompt = False
self.allow_downloads = False

self.selenium_web_browser = os.getenv("USE_WEB_BROWSER", "chrome")
self.ai_settings_file = os.getenv("AI_SETTINGS_FILE", "ai_settings.yaml")
self.fast_llm_model = os.getenv("FAST_LLM_MODEL", "gpt-3.5-turbo")
self.smart_llm_model = os.getenv("SMART_LLM_MODEL", "gpt-4")
Expand Down Expand Up @@ -87,15 +86,19 @@ def __init__(self) -> None:
"HUGGINGFACE_AUDIO_TO_TEXT_MODEL"
)

# User agent headers to use when browsing web
# Selenium browser settings
self.selenium_web_browser = os.getenv("USE_WEB_BROWSER", "chrome")
self.selenium_headless = os.getenv("HEADLESS_BROWSER", "True") == "True"

# User agent header to use when making HTTP requests
# Some websites might just completely deny request with an error code if
# no user agent was found.
self.user_agent = os.getenv(
"USER_AGENT",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36"
" (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
)
self.headless_browser = os.getenv('HEADLESS_BROWSER',"True") == "True"

self.redis_host = os.getenv("REDIS_HOST", "localhost")
self.redis_port = os.getenv("REDIS_PORT", "6379")
self.redis_password = os.getenv("REDIS_PASSWORD", "")
Expand Down

0 comments on commit d6b1aa6

Please sign in to comment.