From 334a10dbc5167a5357be85d26f9a3dfd427323f7 Mon Sep 17 00:00:00 2001 From: Brad <46579244+bradAGI@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:08:40 -0500 Subject: [PATCH 1/5] fix get encoding model for deepseek --- inference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference.py b/inference.py index d87ad9e..0b66acb 100755 --- a/inference.py +++ b/inference.py @@ -163,7 +163,7 @@ def query_model(model_str, prompt, system_prompt, openai_api_key=None, anthropic if model_str in ["o1-preview", "o1-mini", "claude-3.5-sonnet", "o1"]: encoding = tiktoken.encoding_for_model("gpt-4o") elif model_str in ["deepseek-chat"]: - encoding = tiktoken.encoding_for_model("cl100k_base") + encoding = tiktoken.get_encoding("cl100k_base") else: encoding = tiktoken.encoding_for_model(model_str) if model_str not in TOKENS_IN: From a812c5bc8cf94721bf6ca7d3429bea1d5427d883 Mon Sep 17 00:00:00 2001 From: Brad <46579244+bradAGI@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:15:02 -0500 Subject: [PATCH 2/5] update README for Dockerfile --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f067ed9..8d576bd 100755 --- a/README.md +++ b/README.md @@ -87,6 +87,20 @@ To run Agent Laboratory in copilot mode, simply set the copilot-mode flag to `"t `python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --copilot-mode "true"` ----- + +## Docker Option + +1. Build the Docker image + +```bash docker build -t agentlab .``` + +2. Run the container (Replace API_KEY with your actual API key) + +```bash docker run -it -v $(pwd)/research_dir:/app/research_dir agentlab --research-topic "your research topic" --llm-backend "deepseek-chat" --api-key "API_KEY"``` + +Note: The research_dir will be mounted from your local machine, allowing you to access the generated files outside the container + + ## Tips for better research outcomes From 11cf313c0dabcfbc376431c2eaa7c550e20d972c Mon Sep 17 00:00:00 2001 From: Brad <46579244+bradAGI@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:15:59 -0500 Subject: [PATCH 3/5] update README for Dockerfile --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d576bd..70b7b1e 100755 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ To run Agent Laboratory in copilot mode, simply set the copilot-mode flag to `"t 2. Run the container (Replace API_KEY with your actual API key) -```bash docker run -it -v $(pwd)/research_dir:/app/research_dir agentlab --research-topic "your research topic" --llm-backend "deepseek-chat" --api-key "API_KEY"``` +```bash docker run -it -v $(pwd)/research_dir:/app/research_dir agentlab --research-topic "your research topic" --llm-backend "deepseek-chat" --api-key "API_KEY" ``` Note: The research_dir will be mounted from your local machine, allowing you to access the generated files outside the container From 747f4f8d5c052a5571bb7330c95c0aa8e26a51be Mon Sep 17 00:00:00 2001 From: Brad <46579244+bradAGI@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:18:07 -0500 Subject: [PATCH 4/5] fix README for Dockerfile use --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70b7b1e..5bafcff 100755 --- a/README.md +++ b/README.md @@ -92,11 +92,11 @@ To run Agent Laboratory in copilot mode, simply set the copilot-mode flag to `"t 1. Build the Docker image -```bash docker build -t agentlab .``` +```docker build -t agentlab .``` 2. Run the container (Replace API_KEY with your actual API key) -```bash docker run -it -v $(pwd)/research_dir:/app/research_dir agentlab --research-topic "your research topic" --llm-backend "deepseek-chat" --api-key "API_KEY" ``` +```docker run -it -v $(pwd)/research_dir:/app/research_dir agentlab --research-topic "your research topic" --llm-backend "deepseek-chat" --api-key "API_KEY" ``` Note: The research_dir will be mounted from your local machine, allowing you to access the generated files outside the container From 00c34c88637a028e4a357b0b0282240205285313 Mon Sep 17 00:00:00 2001 From: Brad <46579244+bradAGI@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:23:08 -0500 Subject: [PATCH 5/5] add Dockerfile / fix dir exists error --- Dockerfile | 23 +++++++++++++++++++++++ ai_lab_repo.py | 10 +++++----- 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eae9948 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + git \ + texlive-latex-base \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-latex-extra \ + texlive-science \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENV PYTHONUNBUFFERED=1 + +RUN mkdir -p /app/research_dir + +ENTRYPOINT ["python3", "ai_lab_repo.py"] diff --git a/ai_lab_repo.py b/ai_lab_repo.py index dbe9541..93f9d97 100755 --- a/ai_lab_repo.py +++ b/ai_lab_repo.py @@ -86,15 +86,15 @@ def __init__(self, research_topic, openai_api_key, max_steps=100, num_papers_lit self.ml_engineer = MLEngineerAgent(model=self.model_backbone, notes=self.notes, max_steps=self.max_steps, openai_api_key=self.openai_api_key) self.sw_engineer = SWEngineerAgent(model=self.model_backbone, notes=self.notes, max_steps=self.max_steps, openai_api_key=self.openai_api_key) - # remove previous files + # remove previous files remove_figures() remove_directory("research_dir") # make src and research directory if not os.path.exists("state_saves"): - os.mkdir(os.path.join(".", "state_saves")) - os.mkdir(os.path.join(".", "research_dir")) - os.mkdir(os.path.join("./research_dir", "src")) - os.mkdir(os.path.join("./research_dir", "tex")) + os.makedirs("state_saves", exist_ok=True) + os.makedirs("research_dir", exist_ok=True) + os.makedirs("research_dir/src", exist_ok=True) + os.makedirs("research_dir/tex", exist_ok=True) def set_model(self, model): self.set_agent_attr("model", model)