Skip to content

Commit 4fb956b

Browse files
authored
Merge pull request #224 from om-ai-lab:develop/v0.2.4
update main to v0.2.4
2 parents fd627c3 + 979c2d9 commit 4fb956b

File tree

293 files changed

+23816
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+23816
-301
lines changed

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ OmAgent is python library for building multimodal language agents with ease. We
2828
- Native multimodal interaction support include VLM models, real-time API, computer vision models, mobile connection and etc.
2929
- A suite of state-of-the-art unimodal and multimodal agent algorithms that goes beyond simple LLM reasoning, e.g. ReAct, CoT, SC-Cot etc.
3030
- Supports local deployment of models. You can deploy your own models locally by using Ollama[Ollama](./docs/concepts/models/Ollama.md) or [LocalAI](./examples/video_understanding/docs/local-ai.md).
31+
- Fully distributed architecture, supports custom scaling. Also supports Lite mode, eliminating the need for middleware deployment.
3132

3233

3334
## 🛠️ How To Install
@@ -41,11 +42,6 @@ OmAgent is python library for building multimodal language agents with ease. We
4142
```bash
4243
pip install -e omagent-core
4344
```
44-
- Set Up Conductor Server (Docker-Compose) Docker-compose includes conductor-server, Elasticsearch, and Redis.
45-
```bash
46-
cd docker
47-
docker-compose up -d
48-
```
4945

5046
## 🚀 Quick Start
5147
### Configuration
@@ -57,9 +53,7 @@ The container.yaml file is a configuration file that manages dependencies and se
5753
cd examples/step1_simpleVQA
5854
python compile_container.py
5955
```
60-
This will create a container.yaml file with default settings under `examples/step1_simpleVQA`.
61-
62-
56+
This will create a container.yaml file with default settings under `examples/step1_simpleVQA`. For more information about the container.yaml configuration, please refer to the [container module](./docs/concepts/container.md)
6357

6458
2. Configure your LLM settings in `configs/llms/gpt.yml`:
6559

@@ -70,14 +64,6 @@ The container.yaml file is a configuration file that manages dependencies and se
7064
```
7165
You can use a locally deployed Ollama to call your own language model. The tutorial is [here](docs/concepts/models/Ollama.md).
7266

73-
3. Update settings in the generated `container.yaml`:
74-
- Configure Redis connection settings, including host, port, credentials, and both `redis_stream_client` and `redis_stm_client` sections.
75-
- Update the Conductor server URL under conductor_config section
76-
- Adjust any other component settings as needed
77-
78-
79-
For more information about the container.yaml configuration, please refer to the [container module](./docs/concepts/container.md)
80-
8167
### Run the demo
8268

8369
1. Run the simple VQA demo with webpage GUI:

docs/images/reflexion.png

Lines changed: 3 additions & 0 deletions
Loading
-85.6 KB
Loading

docs/tutorials/run_agent_full.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Run the full version of OmAgent
2+
OmAgent now supports free switching between Full and Lite versions, the differences between the two versions are as follows:
3+
- The Full version has better concurrency performance, can view workflows as well as run logs with the help of the orchestration system GUI, and supports more device types (e.g. smartphone apps). Note that running the Full version requires a Docker deployment middleware dependencies.
4+
- The Lite version is suitable for developers who want to get started faster. It eliminates the steps of installing and deploying Docker, and is suitable for rapid prototyping and debugging.
5+
6+
## Instruction of how to use Full version
7+
### 🛠️ How To Install
8+
- python >= 3.10
9+
- Install omagent_core
10+
Use pip to install omagent_core latest release.
11+
```bash
12+
pip install omagent-core
13+
```
14+
Or install the latest version from the source code like below.
15+
```bash
16+
pip install -e omagent-core
17+
```
18+
- Set Up Conductor Server (Docker-Compose) Docker-compose includes conductor-server, Elasticsearch, and Redis.
19+
```bash
20+
cd docker
21+
docker-compose up -d
22+
```
23+
24+
### 🚀 Quick Start
25+
#### Configuration
26+
27+
The container.yaml file is a configuration file that manages dependencies and settings for different components of the system. To set up your configuration:
28+
29+
1. Generate the container.yaml file:
30+
```bash
31+
cd examples/step1_simpleVQA
32+
python compile_container.py
33+
```
34+
This will create a container.yaml file with default settings under `examples/step1_simpleVQA`.
35+
36+
37+
38+
2. Configure your LLM settings in `configs/llms/gpt.yml`:
39+
40+
- Set your OpenAI API key or compatible endpoint through environment variable or by directly modifying the yml file
41+
```bash
42+
export custom_openai_key="your_openai_api_key"
43+
export custom_openai_endpoint="your_openai_endpoint"
44+
```
45+
You can use a locally deployed Ollama to call your own language model. The tutorial is [here](docs/concepts/models/Ollama.md).
46+
47+
3. Update settings in the generated `container.yaml`:
48+
- Configure Redis connection settings, including host, port, credentials, and both `redis_stream_client` and `redis_stm_client` sections.
49+
- Update the Conductor server URL under conductor_config section
50+
- Adjust any other component settings as needed
51+
52+
53+
For more information about the container.yaml configuration, please refer to the [container module](./docs/concepts/container.md)
54+
55+
#### Run the demo
56+
57+
1. Set the OmAgent to Full version by setting environment variable `OMAGENT_MODE`
58+
```bash
59+
export OMAGENT_MODE=full
60+
```
61+
or
62+
```pyhton
63+
os.environ["OMAGENT_MODE"] = "full"
64+
```
65+
2. Run the simple VQA demo with webpage GUI:
66+
67+
For WebpageClient usage: Input and output are in the webpage
68+
```bash
69+
cd examples/step1_simpleVQA
70+
python run_webpage.py
71+
```
72+
Open the webpage at `http://127.0.0.1:7860`, you will see the following interface:
73+
<img src="docs/images/simpleVQA_webpage.png" width="400"/>

examples/PoT/eval_aqua_zeroshot.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Import required modules and components
2+
import os
3+
os.environ["OMAGENT_MODE"] = "lite"
4+
25
from omagent_core.utils.container import container
36
from omagent_core.engine.workflow.conductor_workflow import ConductorWorkflow
47
from omagent_core.advanced_components.workflow.pot.workflow import PoTWorkflow
58
from pathlib import Path
69
from omagent_core.utils.registry import registry
7-
from omagent_core.clients.devices.programmatic.client import ProgrammaticClient
10+
from omagent_core.clients.devices.programmatic import ProgrammaticClient
811
from omagent_core.utils.logger import logging
912
import argparse
1013
import json
@@ -50,6 +53,7 @@ def main():
5053
# Setup logging and paths
5154
logging.init_logger("omagent", "omagent", level="INFO")
5255
CURRENT_PATH = Path(__file__).parents[0]
56+
container.register_stm("SharedMemSTM")
5357

5458
# Initialize agent modules and configuration
5559
registry.import_module(project_path=CURRENT_PATH.joinpath('agent'))
@@ -84,7 +88,7 @@ def main():
8488
for r, w in zip(res, workflow_input_list):
8589
output_json.append({
8690
"id": w['id'],
87-
"question": w['query'],
91+
"question": w['query']+'\nOptions: '+str(question['options']),
8892
"last_output": r['last_output'],
8993
"prompt_tokens": r['prompt_tokens'],
9094
"completion_tokens": r['completion_tokens']
@@ -101,7 +105,7 @@ def main():
101105
# Save results to output file
102106
if not os.path.exists(args.output_path):
103107
os.makedirs(args.output_path)
104-
with open(f'{args.output_path}/{dataset_name}_{model_id}_POT_output.json', 'w') as f:
108+
with open(f'{args.output_path}/{dataset_name}_{model_id.replace("/","-")}_POT_output.json', 'w') as f:
105109
json.dump(final_output, f, indent=4)
106110

107111
# Cleanup

examples/PoT/eval_gsm8k_fewshot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import os
2+
os.environ["OMAGENT_MODE"] = "lite"
3+
14
# Import required modules and components
25
from omagent_core.utils.container import container
36
from omagent_core.engine.workflow.conductor_workflow import ConductorWorkflow
47
from omagent_core.advanced_components.workflow.pot.workflow import PoTWorkflow
58
from pathlib import Path
69
from omagent_core.utils.registry import registry
7-
from omagent_core.clients.devices.programmatic.client import ProgrammaticClient
10+
from omagent_core.clients.devices.programmatic import ProgrammaticClient
811
from omagent_core.utils.logger import logging
912
import argparse
1013
import json
@@ -114,6 +117,7 @@ def main():
114117
# Setup logging and paths
115118
logging.init_logger("omagent", "omagent", level="INFO")
116119
CURRENT_PATH = Path(__file__).parents[0]
120+
container.register_stm("SharedMemSTM")
117121

118122
# Initialize agent modules and configuration
119123
registry.import_module(project_path=CURRENT_PATH.joinpath('agent'))
@@ -164,7 +168,7 @@ def main():
164168
# Save results to output file
165169
if not os.path.exists(args.output_path):
166170
os.makedirs(args.output_path)
167-
with open(f'{args.output_path}/{dataset_name}_{model_id}_POT_output.json', 'w') as f:
171+
with open(f'{args.output_path}/{dataset_name}_{model_id.replace("/","-")}_POT_output.json', 'w') as f:
168172
json.dump(final_output, f, indent=4)
169173

170174
# Cleanup

examples/PoT/run_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# Import core modules and components for the Program of Thought (PoT) workflow
2+
import os
3+
os.environ["OMAGENT_MODE"] = "lite"
4+
25
from omagent_core.utils.container import container
36
from omagent_core.engine.workflow.conductor_workflow import ConductorWorkflow
47
from omagent_core.engine.workflow.task.simple_task import simple_task
58
from agent.input_interface.input_interface import PoTInputInterface
69
from omagent_core.advanced_components.workflow.pot.workflow import PoTWorkflow
710
from pathlib import Path
811
from omagent_core.utils.registry import registry
9-
from omagent_core.clients.devices.cli.client import DefaultClient
12+
from omagent_core.clients.devices.cli import DefaultClient
13+
1014
from omagent_core.utils.logger import logging
1115

1216

examples/PoT/run_programmatic.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# Import required modules and components
1+
# Import core modules and components for the Program of Thought (PoT) workflow
2+
import os
3+
os.environ["OMAGENT_MODE"] = "lite"
4+
25
from omagent_core.utils.container import container
36
from omagent_core.engine.workflow.conductor_workflow import ConductorWorkflow
47
from omagent_core.advanced_components.workflow.pot.workflow import PoTWorkflow
58
from pathlib import Path
69
from omagent_core.utils.registry import registry
7-
from omagent_core.clients.devices.programmatic.client import ProgrammaticClient
10+
from omagent_core.clients.devices.programmatic import ProgrammaticClient
811
from omagent_core.utils.logger import logging
912

1013

@@ -17,6 +20,8 @@
1720
# Load custom agent modules from the project directory
1821
registry.import_module(project_path=CURRENT_PATH.joinpath('agent'))
1922

23+
container.register_stm("SharedMemSTM")
24+
2025
# Load container configuration from YAML file
2126
container.from_config(CURRENT_PATH.joinpath('container.yaml'))
2227

examples/ToT/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Tree-of-Thought Example
2+
3+
In computer science, "Tree of Thought" (ToT) is a tree-structured solution that maintains a tree of thoughts represented by a coherent sequence of language, which is the intermediate steps in solving the problem. Using this approach, LLM is able to evaluate the intermediate thoughts of a rigorous reasoning process. LLM combines the ability to generate and evaluate thoughts with search algorithms such as breadth-first search and depth-first search, which can verify forward and backward when systematically exploring thoughts.
4+
5+
This example demonstrates how to use the framework for a simple, ToT task. The example code can be found in the "examples/ToT" directory.
6+
7+
```bash
8+
cd examples/ToT
9+
```
10+
11+
## Overview
12+
13+
This example implements a general ToT workflow that consists of following components:
14+
15+
1. **ToT Input**
16+
- Handles user input containing questions, requirements, and examples(if has)
17+
18+
2. **ToT Workflow**
19+
- Generate possible next thoughts
20+
- Evaluate the thoughts
21+
- Search the best thought
22+
23+
3. **ToT Output**
24+
- Output the last output in final result
25+
26+
### This whole workflow is looked like the following diagram:
27+
28+
![ToT Workflow](./docs/images/tot_run_structure.png)
29+
30+
## Prerequisites
31+
32+
- Python 3.11+
33+
- Required packages installed (see requirements.txt)
34+
- Access to OpenAI API or compatible endpoint (see configs/llms/*.yml)
35+
- Redis server running locally or remotely
36+
- Conductor server running locally or remotely
37+
38+
## Configuration
39+
40+
The container.yaml file is a configuration file that manages dependencies and settings for different components of the system, including Conductor connections, Redis connections, and other service configurations. To set up your configuration:
41+
42+
1. Generate the container.yaml file:
43+
```bash
44+
python compile_container.py
45+
```
46+
This will create a container.yaml file with default settings under `examples/ToT`.
47+
48+
49+
2. Configure your LLM and tool settings in `configs/llms/*.yml` and `configs/tools/*.yml`:
50+
- Set your OpenAI API key or compatible endpoint through environment variable or by directly modifying the yml file
51+
```bash
52+
export custom_model_id="your_model_id"
53+
export custom_openai_key="your_openai_api_key"
54+
export custom_openai_endpoint="your_openai_endpoint"
55+
```
56+
57+
- Configure other model settings like temperature as needed through environment variable or by directly modifying the yml file
58+
59+
3. Update settings in the generated `container.yaml`:
60+
- Modify Redis connection settings:
61+
- Set the host, port and credentials for your Redis instance
62+
- Configure both `redis_stream_client` and `redis_stm_client` sections
63+
- Update the Conductor server URL under conductor_config section
64+
- Adjust any other component settings as needed
65+
66+
## Running the Example
67+
68+
3. Run the general ToT example:
69+
70+
For terminal/CLI usage:
71+
```bash
72+
python run_cli.py
73+
```
74+
75+
You can now run the ToT workflow in `pro` mode or `lite` mode by changing the `OMAGENT_MODE` environment variable. The default mode is `pro` which use the conductor and redis server to run the workflow. The `lite` mode will run the workflow in the current python process without using the conductor and redis server.
76+
77+
For pro mode:
78+
```bash
79+
export OMAGENT_MODE="pro"
80+
python run_cli.py
81+
```
82+
83+
For lite mode:
84+
```bash
85+
export OMAGENT_MODE="lite"
86+
python run_cli.py
87+
```
88+
89+
90+
91+
## Troubleshooting
92+
93+
If you encounter issues:
94+
- Verify Redis is running and accessible
95+
- Check your OpenAI API key is valid
96+
- Check your Bing API key is valid if search results are not as expected
97+
- Ensure all dependencies are installed correctly
98+
- Review logs for any error messages
99+
- **Open an issue on GitHub if you can't find a solution, we will do our best to help you out!**
100+
101+
102+
## Set up your own ToT workflow
103+
104+
ToT has many other complex settings. If you want to learn more about ToT settings, please follow this document.[ToT User Book](./docs/files/user_book.md)

examples/ToT/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)