Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b0cb490
chore: update mlesolver.py
eltociear Jan 9, 2025
03f1338
Update README.md
N4SIRODDIN3 Jan 19, 2025
3d045ce
Merge pull request #1 from N4SIRODDIN3/N4SIRODDIN3-patch-1
N4SIRODDIN3 Jan 19, 2025
f2110be
add gradio for fast configuration
whats2000 Feb 8, 2025
29ae2ea
add support for more provider
whats2000 Feb 8, 2025
174a7da
Update requirements.txt
whats2000 Feb 8, 2025
73e9bae
fix the check point not update
whats2000 Feb 8, 2025
0862c92
Add the missing json import
whats2000 Feb 9, 2025
e27295b
Fix: Fix the check name to openai_api_key
whats2000 Feb 9, 2025
705fb0f
add torchvison,torchaudio and gradio version
whats2000 Feb 10, 2025
07f5760
update the layout of the web ui
whats2000 Feb 10, 2025
be5b74c
add valid check for API key in web ui
whats2000 Feb 10, 2025
dab197b
fix the issue that model_backbone type
whats2000 Feb 10, 2025
b29b7e2
add a pause for user to read the review
whats2000 Feb 10, 2025
ba22078
fix the model estimate for Claude and Gemini
whats2000 Feb 10, 2025
62057d4
fix the check of missing key
whats2000 Feb 10, 2025
11e402f
add all of the config to the `config.py`
whats2000 Feb 11, 2025
83a5f50
add try to wrap the full main function
whats2000 Feb 11, 2025
9a7c6bc
add ollama max token config
whats2000 Feb 14, 2025
6107a00
add the cleaner for deal with the "think token"
whats2000 Feb 14, 2025
f54fc3d
update the instruction in README.md to install
whats2000 Feb 17, 2025
5ca617a
fix the format in the README for readability
whats2000 Feb 17, 2025
2dec422
fix the format of README
whats2000 Feb 17, 2025
ae2c97e
fix the indent in README.md
whats2000 Feb 17, 2025
22cfb67
add the new model to front for support information
whats2000 Feb 17, 2025
4519d14
fix the incorrect Claude model name
whats2000 Feb 21, 2025
3c0d062
change to allow more flexible Claude model compute the cost
whats2000 Feb 21, 2025
9312269
add a storage for restore web ui settings
whats2000 Feb 21, 2025
04fc69a
fix the missing temperature issue in Anthropic
whats2000 Feb 21, 2025
0183178
Merge branch 'pr/62'
whats2000 Feb 21, 2025
c41364e
Merge branch 'pr/3'
whats2000 Feb 21, 2025
dc7d533
add webui option with flask base react app
whats2000 Feb 22, 2025
d8d6725
add the texlive-science to installation guild
whats2000 Feb 22, 2025
f48799f
Update mlesolver.py
NinoRisteski Feb 24, 2025
5b7128f
Merge branch 'pr/77'
whats2000 Feb 26, 2025
cde562a
Add: Add the fetch and update web ui
whats2000 Mar 1, 2025
5d2c0b2
Add: Add a endpoint for load task note settings
whats2000 Mar 4, 2025
b30d49a
Feat: Automatic append the task note file path if exist
whats2000 Mar 4, 2025
53dd3bc
Add: Add support for o3-mini and 3.7 Sonnet
whats2000 Mar 13, 2025
08f9266
Add: Add error handler for sub process invoke
whats2000 Mar 13, 2025
3f68812
Fix: Fix the catch error logic to instruct to install yarn
whats2000 Mar 14, 2025
df7166c
Add: Add a try and catch for handle arxiv API
whats2000 Mar 20, 2025
1bd0aae
Add: Add support for calculate latest model
whats2000 Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ research_dir/*
state_saves/*
__pycache__/*
Figure*.png
testrun.py
testrun.py
/data/
/.vscode
/settings/user_settings.json
/AgentLaboratoryWebUI
settings/task_note_llm_config.json
254 changes: 202 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,95 +33,229 @@

### 👾 Currently supported models

* **OpenAI**: o1, o1-preview, o1-mini, gpt-4o
* **OpenAI**:
* GPT-5 series: gpt-5.2, gpt-5.2-pro, gpt-5-mini
* GPT-4.1 series: gpt-4.1, gpt-4.1-mini, gpt-4.1-nano
* GPT-4o series: gpt-4o, gpt-4o-mini
* o-series (reasoning): o1, o1-preview, o1-mini, o3-mini, o4-mini
* **DeepSeek**: deepseek-chat (deepseek-v3)
* **Anthropic**:
* Claude 4.5: claude-4.5-opus, claude-4.5-sonnet, claude-4.5-haiku
* Claude 4.1: claude-4.1-opus
* Claude 4: claude-4-opus, claude-4-sonnet
* Claude 3.x: claude-3-5-sonnet, claude-3-5-haiku, claude-3-7-sonnet
* **Google**:
* Gemini 3.0: gemini-3.0-pro, gemini-3.0-flash
* Gemini 2.5: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite
* Gemini 2.0: gemini-2.0-flash
* **Ollama**: Any model that you can find in the [Ollama Website](https://ollama.com/search)

To select a specific llm set the flag `--llm-backend="llm_model"` for example `--llm-backend="gpt-4o"` or `--llm-backend="deepseek-chat"`. Please feel free to add a PR supporting new models according to your need!

## 🖥️ Installation

### Python venv option

* We recommend using python 3.12
> [!IMPORTANT]
> We recommend using python 3.12

1. **Clone the GitHub Repository**: Begin by cloning the repository using the command:
```bash
git clone git@github.com:SamuelSchmidgall/AgentLaboratory.git
```
```bash
git clone git@github.com:SamuelSchmidgall/AgentLaboratory.git
```

2. **Set up and Activate Python Environment**
```bash
python -m venv venv_agent_lab
```
- Now activate this environment:
```bash
source venv_agent_lab/bin/activate
```

Python venv option
```bash
python -m venv venv_agent_lab
source venv_agent_lab/bin/activate
```

Conda option
```bash
conda create -n agent_lab python=3.12
conda activate agent_lab
```

3. **Install required libraries**
```bash
pip install -r requirements.txt
```

4. **Install pdflatex [OPTIONAL]**
```bash
sudo apt install pdflatex
```
- This enables latex source to be compiled by the agents.
- **[IMPORTANT]** If this step cannot be run due to not having sudo access, pdf compiling can be turned off via running Agent Laboratory via setting the `--compile-latex` flag to false: `--compile-latex "false"`



5. **Now run Agent Laboratory!**

`python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA"`

or, if you don't have pdflatex installed

`python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --compile-latex "false"`

### Co-Pilot mode

To run Agent Laboratory in copilot mode, simply set the copilot-mode flag to `"true"`

`python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --copilot-mode "true"`
```bash
pip install -r requirements.txt
```

4. **Install Higher Version of Gradio**
```bash
pip install gradio==4.44.1
```

> [!NOTE]
> This is only required for the current version of web interface.
> We will move to `Flask` in the future for capability of the package.

5. **Install pdflatex [OPTIONAL]**

## Instructions for Ubuntu:
```bash
sudo apt install pdflatex
```

If you find the package is not available,
you can install it via the following commands:
```bash
sudo apt-get install texlive-latex-base

sudo apt-get install texlive-fonts-recommended
sudo apt-get install texlive-fonts-extra

sudo apt-get install texlive-latex-extra
sudo apt-get install texlive-science
```

## Instructions for Windows Users

To have a TeX engine on Windows, you need to install the MikTeX software. Follow these steps:

1. Go to the [MikTeX download page](https://miktex.org/download).
2. Download the installer for your version of Windows.
3. Run the installer and follow the on-screen instructions to complete the installation.
4. Once installed, you can verify the installation by opening a command prompt and typing `latex --version`.

- This enables latex source to be compiled by the agents.
> [!IMPORTANT]
> If this step cannot be run due to not having sudo access,
pdf compiling can be turned off via running Agent Laboratory
via setting the `--compile-latex` flag to false: `--compile-latex "false"`.
Or you can disable by unchecked the `Compile LaTeX` option in the web interface.

## 🚀 Quick Start

1. **Set up the configuration file**

- You can set up the configuration file by editing the `config.py` file.
- See the [configuration file](./config.py) for more details.

2. **Now run Agent Laboratory!**

#### Basic Usage of Agent Laboratory in Web Interface
```bash
python config_gradio.py
```

#### Basic Usage of Agent Laboratory in CLI

##### 1. A simple command to run Agent Laboratory
```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA"
```

##### 2. Available Configuration Options

**API Keys:**
- `--api-key`: OpenAI API key or set to "ollama" for Ollama usage **(required)**
- `--deepseek-api-key`: DeepSeek API key
- `--google-api-key`: Google API key
- `--anthropic-api-key`: Anthropic API key

**LLM Settings:**
- `--llm-backend`: Backend LLM to use (default: "o1-mini"), please ensure your model string is correct, here is some common models:
- OpenAI: "o1", "o1-preview", "o1-mini", "gpt-4o"
- DeepSeek: "deepseek-chat" (deepseek-v3)
- Anthropic: "claude-3-5-sonnet-latest", "claude-3-5-haiku-latest"
- Google: "gemini-2.0-flash", "gemini-2.0-flash"
- Ollama: Any model that you can find in the [Ollama Website](https://ollama.com/search)
- `--ollama-max-tokens`: Max tokens for OLLAMA (default: 2048),

**Research Parameters:**
- `--research-topic`: Your research topic/idea or a open-ended question to ask, this **must be provided**
- `--language`: Operating language (default: "English") which will instruct the agents to perform research in your preferred language (Not fully supported yet)
- `--num-papers-lit-review`: Number of papers for literature review (default: 5)
- `--mlesolver-max-steps`: Steps for MLE solver (default: 3)
- `--papersolver-max-steps`: Steps for paper solver (default: 5)

**Operation Modes:**
- `--copilot-mode`: Enable human interaction mode (default: "false"), you need check terminal for input in this mode
- `--compile-latex`: Enable LaTeX PDF compilation (default: "true"), **please ensure you have pdflatex installed**

**State Management:**
- `--load-existing`: Load from existing state (default: "false")
- `--load-existing-path`: Path to load state from (e.g., "state_saves/results_interpretation.pkl")

<details>
<summary>📚 Example Usage</summary>

Basic run without PDF compilation:
```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --compile-latex "false"
```

Run in copilot mode:
```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --copilot-mode "true"
```

Run with custom solver steps and language:
```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --llm-backend "o1-mini" --research-topic "YOUR RESEARCH IDEA" --mlesolver-max-steps "5" --papersolver-max-steps "7" --language "Spanish"
```

Load from the existing state:
```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --load-existing "true" --research-topic "YOUR RESEARCH IDEA" --load-existing-path "state_saves/results_interpretation.pkl"
```
</details>

> [!NOTE]
> You must at least provide an API key for use.
> Even when you run a local Ollama, you must provide an "ollama" string as the API key.

> [!TIP]
> - Set the `--ollama-max-tokens` to the model real context length (Ex: 128000 for `qwen2.5:32b`) for much better performance.
> - Use the model that supports `tools` as the Agent Laboratory will instruct the model to output formatted code or actions (This is kinda needed for the current version of Agent Laboratory).

-----

## Tips for better research outcomes


#### [Tip #1] 📝 Make sure to write extensive notes! 📝

**Writing extensive notes is important** for helping your agent understand what you're looking to accomplish in your project, as well as any style preferences. Notes can include any experiments you want the agents to perform, providing API keys, certain plots or figures you want included, or anything you want the agent to know when performing research.
**Writing extensive notes is important** for helping your agent understand what you're looking to accomplish in your project,
as well as any style preferences. Notes can include any experiments you want the agents to perform, providing API keys, certain plots or figures you want included, or anything you want the agent to know when performing research.

This is also your opportunity to let the agent know **what compute resources it has access to**, e.g. GPUs (how many, what type of GPU, how many GBs), CPUs (how many cores, what type of CPUs), storage limitations, and hardware specs.
This is also your opportunity to let the agent know **what compute resources it has access to**,
e.g. GPUs (how many, what type of GPU, how many GBs), CPUs (how many cores, what type of CPUs), storage limitations, and hardware specs.

In order to add notes, you must modify the task_notes_LLM structure inside of `ai_lab_repo.py`. Provided below is an example set of notes used for some of our experiments.
In order to add notes, you must modify the TASK_NOTE_LLM structure inside of `config.py`.
Provided below is an example set of notes used for some of our experiments.


```
task_notes_LLM = [
TASK_NOTE_LLM = [
{"phases": ["plan formulation"],
"note": f"You should come up with a plan for TWO experiments."},

{"phases": ["plan formulation", "data preparation", "running experiments"],
{"phases": ["plan formulation", "data preparation", "running experiments"],
"note": "Please use gpt-4o-mini for your experiments."},

{"phases": ["running experiments"],
"note": f'Use the following code to inference gpt-4o-mini: \nfrom openai import OpenAI\nos.environ["OPENAI_API_KEY"] = "{api_key}"\nclient = OpenAI()\ncompletion = client.chat.completions.create(\nmodel="gpt-4o-mini-2024-07-18", messages=messages)\nanswer = completion.choices[0].message.content\n'},
"note": 'Use the following code to inference gpt-4o-mini: \nfrom openai import OpenAI\nos.environ["OPENAI_API_KEY"] = "{{api_key}}"\nclient = OpenAI()\ncompletion = client.chat.completions.create(\nmodel="gpt-4o-mini-2024-07-18", messages=messages)\nanswer = completion.choices[0].message.content\n'},

{"phases": ["running experiments"],
"note": f"You have access to only gpt-4o-mini using the OpenAI API, please use the following key {api_key} but do not use too many inferences. Do not use openai.ChatCompletion.create or any openai==0.28 commands. Instead use the provided inference code."},
"note": "You have access to only gpt-4o-mini using the OpenAI API, please use the following key {{api_key}} but do not use too many inferences. Do not use openai.ChatCompletion.create or any openai==0.28 commands. Instead use the provided inference code."},

{"phases": ["running experiments"],
"note": "I would recommend using a small dataset (approximately only 100 data points) to run experiments in order to save time. Do not use much more than this unless you have to or are running the final tests."},

{"phases": ["data preparation", "running experiments"],
"note": "You are running on a MacBook laptop. You can use 'mps' with PyTorch"},
"note": "You are running on a Ubuntu System. You can use 'cuda' with PyTorch"},

{"phases": ["data preparation", "running experiments"],
"note": "Generate figures with very colorful and artistic design."},
]

{"phases": ["literature review", "plan formulation",
"data preparation", "running experiments",
"results interpretation", "report writing",
"report refinement"],
"note": "You should always write in the following language to converse and to write the report {{language}}"}
]
```

--------
Expand All @@ -138,9 +272,22 @@ When resources are limited, **optimize by fine-tuning smaller models** on your s

#### [Tip #3] ✅ You can load previous saves from checkpoints ✅

**If you lose progress, internet connection, or if a subtask fails, you can always load from a previous state.** All of your progress is saved by default in the `state_saves` variable, which stores each individual checkpoint. Just pass the following arguments when running `ai_lab_repo.py`
**If you lose progress, internet connection, or if a subtask fails, you can always load from a previous state.**
All of your progress is saved by default in the `state_saves` variable, which stores each individual checkpoint.

##### **For Web Interface**

You can check out the `Resume Previous Research` section to load from a previous state.
By checking the `Load Existing Research State` flag and then select the stage you want to load from, you can easily load from a previous state.
If the state is not up-to-date, you can always click the `Refresh Saved States` button to refresh the saved states.

##### **For CLI**

`python ai_lab_repo.py --api-key "API_KEY_HERE" --research-topic "YOUR RESEARCH IDEA" --llm-backend "o1-mini" --load-existing True --load-existing-path "state_saves/LOAD_PATH"`
Just pass the following arguments when running `ai_lab_repo.py`

```bash
python ai_lab_repo.py --api-key "API_KEY_HERE" --research-topic "YOUR RESEARCH IDEA" --llm-backend "o1-mini" --load-existing True --load-existing-path "state_saves/LOAD_PATH"
```

-----

Expand All @@ -150,8 +297,11 @@ When resources are limited, **optimize by fine-tuning smaller models** on your s

If you are running Agent Laboratory in a language other than English, no problem, just make sure to provide a language flag to the agents to perform research in your preferred language. Note that we have not extensively studied running Agent Laboratory in other languages, so be sure to report any problems you encounter.

For example, if you are running in Chinese:
##### **For Web Interface**
You can select the language in the dropdown menu. If the language you want is not available, you can edit the `config_gradio.py` file to add the language you want.

##### **For CLI**
If you are running in Chinese, you can run the following command:
`python ai_lab_repo.py --api-key "API_KEY_HERE" --research-topic "YOUR RESEARCH IDEA (in your language)" --llm-backend "o1-mini" --language "中文"`

----
Expand Down
2 changes: 2 additions & 0 deletions agents.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from utils import *
from tools import *
from inference import *
Expand Down
Loading
Loading