diff --git a/Dockerfile.backend b/Dockerfile.backend index 1526dbe..f6dec0f 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -2,9 +2,6 @@ FROM --platform=linux/amd64 python:3.11-slim ENV DEBIAN_FRONTEND=noninteractive -#RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome -#USER chrome - # Install essential packages and Chrome dependencies RUN apt-get update -y && apt-get install -y \ wget \ @@ -102,7 +99,5 @@ COPY config.ini . EXPOSE 8000 -#RUN chown -R chrome:chrome /app -#RUN chown -R chrome:chrome /tmp # Run the application CMD ["python3", "api.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 55d98a1..5c8f408 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -84,7 +84,7 @@ services: environment: - SEARXNG_URL=${SEARXNG_BASE_URL:-http://searxng:8080} - REDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0} - - WORK_DIR_HOST=${WORK_DIR_HOST:-.} + - WORK_DIR=/opt/workspace - OPENAI_API_KEY=${OPENAI_API_KEY} - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY} - OPENROUTER_API_KEY=${OPENROUTER_API_KEY} diff --git a/requirements.txt b/requirements.txt index eba75e1..cbc657d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -42,6 +42,7 @@ selenium_stealth>=1.0.6 undetected-chromedriver>=3.5.5 sentencepiece>=0.2.0 python-dotenv>=1.0.0 +together>=1.5.0 tqdm>4 openai sniffio diff --git a/sources/tools/tools.py b/sources/tools/tools.py index 25b9fac..cb63869 100644 --- a/sources/tools/tools.py +++ b/sources/tools/tools.py @@ -49,20 +49,16 @@ class Tools(): def set_allow_language_exec_bash(value: bool) -> None: self.allow_language_exec_bash = value - - def check_config_dir_validity(self): - """Check if the config directory is valid.""" - path = self.config['MAIN']['work_dir'] - if path == "": - print("WARNING: Work directory not set in config.ini") - return False - if path.lower() == "none": - print("WARNING: Work directory set to none in config.ini") - return False - if not os.path.exists(path): - print(f"WARNING: Work directory {path} does not exist") - return False - return True + + def safe_get_work_dir_path(self): + path = None + path = os.getenv('WORK_DIR', path) + if path is None or path == "": + path = self.config['MAIN']['work_dir'] if 'MAIN' in self.config and 'work_dir' in self.config['MAIN'] else None + if path is None or path == "": + print("No work directory specified, using default.") + path = self.create_work_dir() + return path def config_exists(self): """Check if the config file exists.""" @@ -73,11 +69,10 @@ class Tools(): default_path = os.path.dirname(os.getcwd()) if self.config_exists(): self.config.read('./config.ini') - config_path = self.config['MAIN']['work_dir'] or os.getenv('WORK_DIR') - dir_path = default_path if not self.check_config_dir_validity() else config_path + workdir_path = self.safe_get_work_dir_path() else: - dir_path = default_path - return dir_path + workdir_path = default_path + return workdir_path @abstractmethod def execute(self, blocks:[str], safety:bool) -> str: