fix CHROME_PERSISTENT_SESSION error

This commit is contained in:
vvincent1234
2025-01-24 09:42:42 +08:00
parent a123e94e08
commit 748d253c31
5 changed files with 6 additions and 4 deletions

View File

@@ -61,6 +61,7 @@ RUN pip install --no-cache-dir -r requirements.txt
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN playwright install --with-deps chromium
RUN playwright install-deps
RUN apt-get install -y google-chrome-stable
# Copy the application code
COPY . .

View File

@@ -5,6 +5,7 @@
# @FileName: browser.py
import asyncio
import pdb
from playwright.async_api import Browser as PlaywrightBrowser
from playwright.async_api import (

View File

@@ -17,7 +17,7 @@ def default_config():
"llm_temperature": 1.0,
"llm_base_url": "",
"llm_api_key": "",
"use_own_browser": False,
"use_own_browser": os.getenv("CHROME_PERSISTENT_SESSION", False),
"keep_browser_open": False,
"headless": False,
"disable_security": True,

View File

@@ -58,7 +58,7 @@ startsecs=3
depends_on=x11vnc
[program:persistent_browser]
command=bash -c 'if [ "%(ENV_CHROME_PERSISTENT_SESSION)s" = "true" ]; then mkdir -p /app/data/chrome_data && sleep 8 && google-chrome --user-data-dir=/app/data/chrome_data --window-position=0,0 --window-size=%(ENV_RESOLUTION_WIDTH)s,%(ENV_RESOLUTION_HEIGHT)s --start-maximized --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --disable-setuid-sandbox --no-first-run --no-default-browser-check --no-experiments --ignore-certificate-errors --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 "data:text/html,<html><body style=\"background: \#f0f0f0; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; font-family: Arial;\"><h1>Browser Ready for AI Interaction</h1></body></html>"; else echo "Persistent browser disabled"; fi'
command=bash -c 'mkdir -p /app/data/chrome_data && sleep 8 && google-chrome --user-data-dir=/app/data/chrome_data --window-position=0,0 --window-size=%(ENV_RESOLUTION_WIDTH)s,%(ENV_RESOLUTION_HEIGHT)s --start-maximized --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --disable-setuid-sandbox --no-first-run --no-default-browser-check --no-experiments --ignore-certificate-errors --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 "data:text/html,<html><body style=\"background: \#f0f0f0; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; font-family: Arial;\"><h1>Browser Ready for AI Interaction</h1></body></html>"'
autorestart=%(ENV_CHROME_PERSISTENT_SESSION)s
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

View File

@@ -127,5 +127,5 @@ if __name__ == '__main__':
# test_openai_model()
# test_gemini_model()
# test_azure_openai_model()
# test_deepseek_model()
test_ollama_model()
test_deepseek_model()
# test_ollama_model()