Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from OpenBMB:main #8

Open
wants to merge 115 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
aa54608
feat: add azure openai
JetSquirrel Oct 7, 2023
6045f49
fix miss register
JetSquirrel Oct 8, 2023
e762c1e
Update README.md
chenweize1998 Oct 8, 2023
4f76ad6
Merge pull request #49 from JetSquirrel/azure_openai
chenweize1998 Oct 8, 2023
f717bc0
fix: openai llm default parameter and the missing import of bmtools #46
chenweize1998 Oct 8, 2023
62676a1
fix: critic agent initialization argument error
chenweize1998 Oct 8, 2023
ad67c70
ci: add a Github Actions workflow for smoke test
minleminzui Oct 8, 2023
e7acdd4
Merge pull request #50 from minleminzui/main
chenweize1998 Oct 8, 2023
5bbd355
report spend at the end of a task solving session
kierangilliam Oct 8, 2023
031d3d9
remove abstract requirement
kierangilliam Oct 8, 2023
f6d60c0
report metrics for simulations
kierangilliam Oct 8, 2023
abd444e
Merge pull request #52 from kierangilliam/report-usage
chenweize1998 Oct 9, 2023
bc58c02
update README.md
chenweize1998 Oct 9, 2023
d359c76
fix: allows users to customize config.yaml of the task (#53)
minleminzui Oct 9, 2023
ff67cff
ci skip. Update README.md
chenweize1998 Oct 9, 2023
0360286
fix: fix the incompatible simulation configs. ci skip
chenweize1998 Oct 10, 2023
8107ee4
Merge branch 'main' of github.com:OpenBMB/AgentVerse into main
chenweize1998 Oct 10, 2023
ccf4319
fix: complete the command line (#55)
minleminzui Oct 10, 2023
6bdce1d
refactor: reorganize script location
chenweize1998 Oct 10, 2023
6d42bb6
bump version to 0.1.5
chenweize1998 Oct 10, 2023
7954f21
ci skip. Update README.md
chenweize1998 Oct 10, 2023
7c8dbca
ci skip. Update README.md
chenweize1998 Oct 10, 2023
63b2d33
ci skip. Update README.md
chenweize1998 Oct 10, 2023
c4205bd
manually merge #19.
chenweize1998 Oct 10, 2023
9b03c91
fix: format error in some benchmark configs
chenweize1998 Oct 11, 2023
0208699
fix: update MANIFEST.in [ci skip]
chenweize1998 Oct 11, 2023
88744f1
fix: arrange output parser classes (#59)
minleminzui Oct 11, 2023
7739cba
bump version to 0.1.8 #60
chenweize1998 Oct 12, 2023
7aeed34
fix: fix a bug about updating kwargs
minleminzui Oct 13, 2023
3af33f8
Merge pull request #62 from OpenBMB/gyt_dev
minleminzui Oct 13, 2023
af34300
update
yushengsu-thu Oct 14, 2023
0a1a225
update
yushengsu-thu Oct 14, 2023
362dfce
update
yushengsu-thu Oct 14, 2023
86f10c3
update
yushengsu-thu Oct 14, 2023
1b2a86b
update
yushengsu-thu Oct 14, 2023
f1261cf
update
yushengsu-thu Oct 14, 2023
e477d7e
update
yushengsu-thu Oct 14, 2023
0b1ed5e
update
yushengsu-thu Oct 14, 2023
b529052
update
yushengsu-thu Oct 14, 2023
51f4c8b
update
yushengsu-thu Oct 14, 2023
bc9216e
update
yushengsu-thu Oct 14, 2023
dd49c21
update
yushengsu-thu Oct 14, 2023
558e8b2
update
yushengsu-thu Oct 14, 2023
7733c92
update
yushengsu-thu Oct 14, 2023
c853084
update
yushengsu-thu Oct 14, 2023
b0b018a
update
yushengsu-thu Oct 14, 2023
d13c412
update
yushengsu-thu Oct 14, 2023
af4b455
update
yushengsu-thu Oct 14, 2023
e72820a
update
yushengsu-thu Oct 14, 2023
5292621
add simulation ui params (#63)
JetSquirrel Oct 15, 2023
5b5f7fe
feat: agent order independence in config (#65)
1rubbishyuan Oct 16, 2023
519701e
update
yushengsu-thu Oct 16, 2023
7738f85
update
yushengsu-thu Oct 16, 2023
927955c
update
yushengsu-thu Oct 16, 2023
8a9a6b6
update
yushengsu-thu Oct 16, 2023
7209df3
update
yushengsu-thu Oct 16, 2023
d738273
Update README.md
yushengsu-thu Oct 16, 2023
fef985b
update
yushengsu-thu Oct 16, 2023
4bced67
update
yushengsu-thu Oct 16, 2023
eea1a8c
Merge pull request #66 from OpenBMB/56-to-do-update-the-readme
yushengsu-thu Oct 16, 2023
8a9f38e
Update README.md
yushengsu-thu Oct 16, 2023
31dc92d
Update README.md
yushengsu-thu Oct 16, 2023
6493304
doc: modify README.md (#67) [ci skip]
ASL-r Oct 17, 2023
b001a32
update requirements.txt [ci skip]
chenweize1998 Oct 18, 2023
53f2ec0
fix: session expired bug in tool calling
chenweize1998 Oct 18, 2023
39faec3
feat: support local llms (#68)
cheesewafer Oct 19, 2023
2b67776
Update README.md [ci skip]
chenweize1998 Oct 20, 2023
f50dbe9
Update README.md [ci skip]
chenweize1998 Oct 20, 2023
4451c41
Update README.md
yushengsu-thu Oct 21, 2023
03fdab7
Update README.md
yushengsu-thu Oct 22, 2023
d861178
Merge pull request #71 from OpenBMB/yushengsu-thu-patch-1
yushengsu-thu Oct 22, 2023
d108100
Update README.md [ci skip]
chenweize1998 Oct 22, 2023
f4718a5
Update README.md
yushengsu-thu Oct 22, 2023
7cabb5b
Merge pull request #74 from OpenBMB/yushengsu-thu-patch-1
yushengsu-thu Oct 22, 2023
193088a
Update README.md
yushengsu-thu Oct 22, 2023
dd4e651
fix: typo in logger call and error path in gui [ci skip]
chenweize1998 Oct 23, 2023
118c5fe
add PR template
yushengsu-thu Oct 23, 2023
970f344
Merge pull request #78 from OpenBMB/77-pull_request_templatemd
yushengsu-thu Oct 23, 2023
fb02336
Update README.md
yushengsu-thu Oct 23, 2023
eb6109b
Merge pull request #79 from OpenBMB/yushengsu-thu-patch-1
yushengsu-thu Oct 23, 2023
78387ee
Update README.md
yushengsu-thu Oct 23, 2023
dc0921b
Merge pull request #80 from OpenBMB/yushengsu-thu-patch-1
yushengsu-thu Oct 23, 2023
5fab7fc
fix: import error in alice home task #76
chenweize1998 Oct 23, 2023
0c1e7f2
Update README.md
yushengsu-thu Oct 25, 2023
0f82e26
Merge pull request #85 from OpenBMB/yushengsu-thu-patch-1
yushengsu-thu Oct 25, 2023
14a8f34
fix: bug in simulation gui. [ci skip]
chenweize1998 Oct 25, 2023
641290d
fix: bug in simulation gui.
chenweize1998 Oct 25, 2023
fab0ab8
Update agentverse.py
Kunlun-Zhu Oct 26, 2023
c9c0dbe
bump: 0.1.8.1
chenweize1998 Oct 27, 2023
64db306
feat: add tool support (#86)
minleminzui Oct 27, 2023
81a964c
doc: update readme on multi-agent tool using.
chenweize1998 Oct 27, 2023
f0ddd0e
Merge branch 'main' of github.com:OpenBMB/AgentVerse into main
chenweize1998 Oct 27, 2023
8ad97cb
doc: update installation and dependency
chenweize1998 Oct 30, 2023
067aae4
fix: remove debugging code. [ci skip]
chenweize1998 Oct 31, 2023
b0eeeea
fix: update outdated configs and fix logging #95
chenweize1998 Nov 7, 2023
42e5799
fix: some bugs in config file
chenweize1998 Nov 7, 2023
38cc573
feat: improve local model support and doc #96
chenweize1998 Nov 7, 2023
ddd9a88
doc: Update config.yaml typo [ci skip]
Divine-Shadow Nov 8, 2023
2e59ccb
doc: Fix typo in README.md (#90) [ci skip]
eltociear Nov 8, 2023
d882566
doc: update README.md (#92) [ci skip]
eltociear Nov 8, 2023
2557283
doc: update README.md [ci skip]
chenweize1998 Nov 10, 2023
abacf5a
fix: encoding for local llm. #100
chenweize1998 Nov 12, 2023
ffc3d39
Update README.md
yushengsu-thu Nov 12, 2023
c16ee0a
fix: local llm support #100
chenweize1998 Nov 13, 2023
d434c5a
fix: output parser error in demo case [ci skip]
chenweize1998 Nov 15, 2023
1c92dbe
doc: add a simple documentation (#91)
elolelo Nov 20, 2023
33e61d1
feat: support docker (#107)
soulteary Dec 28, 2023
5fb1f77
feat: allow custom openai base url (#108)
soulteary Dec 28, 2023
4c16c42
Update README.md on the news (#118)
Kunlun-Zhu Jan 18, 2024
ebcf88b
fix: dependency and typing error #120
chenweize1998 Mar 6, 2024
fa916e1
Update README.md
yushengsu-thu Mar 21, 2024
c7e5c1c
OpenAI 1.0 and vLLMs support (#127)
chenweize1998 Mar 24, 2024
6e6dff6
fix: github action
chenweize1998 Mar 24, 2024
c755193
Update openai.py
1ring2rta Apr 25, 2024
4dd772d
fix: openai async client bug #130
chenweize1998 Apr 25, 2024
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
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

**AgentVerse** offers a versatile framework that streamlines the process of creating custom multi-agent environments for large language models (LLMs). Designed to facilitate swift development and customization with minimal effort, our framework empowers researchers to concentrate on their research, rather than being bogged down by implementation details.

⚠️⚠️⚠️ We're presently in the process of refactoring our code to offer you the flexibility to construct both simulation environments (without a predefined goal) and task-solving environments (with a specific goal). Please note that our README is currently outdated, we will update it very soon. If you require a stable version of our code that exclusively supports simulation environments, you can find it in our [`release-1.0`](https://github.com/OpenBMB/AgentVerse/tree/release-1.0) branch.
⚠️⚠️⚠️ We're refactoring the code, and the goal is to provide a flexibility to construct simulation(without a predefined goal) and task-solving(with a specific goal) environments. Please note that this README is outdated, we will update it soon. If you require a stable version that exclusively supports simulation environments, you can use [`release-1.0`](https://github.com/OpenBMB/AgentVerse/tree/release-1.0) branch.

---

Expand Down Expand Up @@ -79,7 +79,7 @@ In the NLP class, the professor and students engage in interactive communication

Use the following command to launch the NLP Classroom example:
```bash
python main_demo.py --task nlp_classroom_9players
python main_simulation_gui.py --task nlp_classroom_9players
```

https://github.com/OpenBMB/AgentVerse/assets/11704492/6ea07850-595e-4a28-a82e-f863011353c2
Expand All @@ -90,7 +90,7 @@ A prisoner's Dilemma is a thought experiment that challenges two completely rati

Use the following command to launch the Prisoner Dilemma example:
```bash
python main_demo.py --task prisoner_dilemma
python main_simulation_cli.py --task prisoner_dilemma
```

https://github.com/OpenBMB/AgentVerse/assets/11704492/017c46e5-c738-4fca-9352-b008e2d518bd
Expand All @@ -112,7 +112,7 @@ https://github.com/OpenBMB/AgentVerse/assets/11704492/5058066a-abee-490d-8659-b4
In the database diagnosis scenario, the Chief DBA monitors the system anomalies (e.g., slow queries, locks, crash down). If detected, the domain experts are alerted to analyze root causes, share insights, and suggest optimization solutions together. The Chief DBA then provides a summarized report to the user.

```bash
python main_demo.py --task db_diag
python main_simulation_gui.py --task db_diag
```

https://github.com/OpenBMB/AgentVerse/assets/11704492/c633419d-afbb-47d4-bb12-6bb512e7af3a
Expand Down Expand Up @@ -195,10 +195,19 @@ pip install -r requirements.txt
```
Some users have reported problems installing the `orjson` required by `gradio`. One simple workaround is to install it with Anaconda `conda install -c conda-forge orjson`.

You also need to export your OpenAI API key as follows
You also need to export your OpenAI API key as follows
```bash
# Export your OpenAI API key
export OPENAI_API_KEY="your_api_key_here"
# Or if you are using Azure
export AZURE_OPENAI_API_KEY="your_api_key_here"
export AZURE_OPENAI_API_BASE="your_api_base_here"
```

If you want use Azure OpenAI services, pleas export your Azure OpenAI key and OpenAI API base as follows:
```bash
export AZURE_OPENAI_API_KEY="your_api_key_here"
export AZURE_OPENAI_API_BASE="your_api_base_here"
```

If you want to use the tools provided by BMTools, you need to install BMTools as follows:
Expand Down Expand Up @@ -231,7 +240,7 @@ python3 main.py --task nlp_classroom_9players
We also provide a local website demo for this environment. You can launch it with

```shell
python3 main_demo.py --task nlp_classroom_9players
python3 main_simulation_gui.py --task nlp_classroom_9players
```
After successfully launching the local server, you can visit [http:https://127.0.0.1:7860/](http:https://127.0.0.1:7860/) to view the classroom environment.

Expand Down
5 changes: 5 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ pip install -r requirements.txt
# 导出你的OpenAI API密钥
export OPENAI_API_KEY="your_api_key_here"
```
或者您想使用 Azure OpenAI 服务,请按照以下方式配置 OpenAI API 密钥和 API base:
```bash
export AZURE_OPENAI_API_KEY="your_api_key_here"
export AZURE_OPENAI_API_BASE="your_api_base_here"
```

如果您想使用BMTools提供的工具,您需要按如下方式安装BMTools:
```bash
Expand Down
38 changes: 23 additions & 15 deletions agentverse/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,27 @@
is_openai_available = False
logging.warning("openai package is not installed")
else:
openai.api_key = os.environ.get("OPENAI_API_KEY")
# openai.proxy = os.environ.get("http_proxy")
# if openai.proxy is None:
# openai.proxy = os.environ.get("HTTP_PROXY")
if openai.api_key is None:
if os.environ.get("OPENAI_API_KEY")!=None:
openai.api_key = os.environ.get("OPENAI_API_KEY")
is_openai_available = True
elif os.environ.get("AZURE_OPENAI_API_KEY")!=None:
openai.api_type = "azure"
openai.api_key = os.environ.get("AZURE_OPENAI_API_KEY")
openai.api_base = os.environ.get("AZURE_OPENAI_API_BASE")
openai.api_version = "2023-05-15"
is_openai_available = True
else:
logging.warning(
"OpenAI API key is not set. Please set the environment variable OPENAI_API_KEY"
)
is_openai_available = False
else:
is_openai_available = True

is_openai_available = False

class OpenAIChatArgs(BaseModelArgs):
model: str = Field(default="gpt-3.5-turbo")
deployment_id: str = Field(default="gpt-35-turbo")
max_tokens: int = Field(default=2048)
temperature: float = Field(default=1.0)
top_p: int = Field(default=1)
Expand Down Expand Up @@ -85,7 +91,7 @@ class OpenAIChatArgs(BaseModelArgs):
# total_tokens=response["usage"]["total_tokens"],
# )


@llm_registry.register("gpt-35-turbo")
@llm_registry.register("gpt-3.5-turbo")
@llm_registry.register("gpt-4")
class OpenAIChat(BaseChatModel):
Expand All @@ -94,21 +100,19 @@ class OpenAIChat(BaseChatModel):
def __init__(self, max_retry: int = 3, **kwargs):
args = OpenAIChatArgs()
args = args.dict()

for k, v in args.items():
args[k] = kwargs.pop(k, v)
if len(kwargs) > 0:
logging.warning(f"Unused arguments: {kwargs}")
super().__init__(args=args, max_retry=max_retry)

# def _construct_messages(self, history: List[Message]):
# return history + [{"role": "user", "content": query}]

@retry(
stop=stop_after_attempt(20),
wait=wait_exponential(multiplier=1, min=4, max=10),
reraise=True,
)

def generate_response(
self,
prepend_prompt: str = "",
Expand All @@ -118,10 +122,9 @@ def generate_response(
) -> LLMResult:
messages = self.construct_messages(prepend_prompt, history, append_prompt)
logger.log_prompt(messages)

try:
# Execute function call
if functions != []:
if functions != []:
response = openai.ChatCompletion.create(
messages=messages,
functions=functions,
Expand Down Expand Up @@ -283,9 +286,14 @@ def construct_messages(
def get_embedding(text: str, attempts=3) -> np.array:
try:
text = text.replace("\n", " ")
embedding = openai.Embedding.create(
input=[text], model="text-embedding-ada-002"
)["data"][0]["embedding"]
if openai.api_type=="azure":
embedding = openai.Embedding.create(
input=[text], deployment_id="text-embedding-ada-002"
)["data"][0]["embedding"]
else:
embedding = openai.Embedding.create(
input=[text], model="text-embedding-ada-002"
)["data"][0]["embedding"]
return tuple(embedding)
except Exception as e:
attempt += 1
Expand Down