Skip to content

Commit 706a875

Browse files
author
niuerbo1
committed
Merge branch 'feature/code-interpreter' of https://github.com/creammangopie/OxyGent into feature/code-interpreter
2 parents ffcfc21 + 321d528 commit 706a875

File tree

106 files changed

+5097
-1913
lines changed

Some content is hidden

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

106 files changed

+5097
-1913
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ assignees: ''
2525
- Other deployments:
2626

2727
**Logs and Reports**
28-
> If possible, please upload files containing `/cache_dir` or `/cache_dir_dev` for detailed error logs.
28+
> If possible, please upload files containing `/cache_dir` for detailed error logs.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,5 @@ pyproject.toml*
240240

241241
# 运行时产生的文件
242242
cache_dir/
243-
cache_dir_dev/
244243
local_file/
245244
deployment/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ All notable changes to this project will be documented in this file.
77
### Added
88
- Added support for dynamic registration of `oxy`
99

10+
---
11+
## [1.0.6.3] - 2025-10-15
12+
13+
### Added
14+
- Added fine-grained message storage, refer to [./examples/advanced/demo_save_message.py](./examples/advanced/demo_save_message.py)
15+
16+
### Changed
17+
- Updated examples. For details, see [./examples](./examples)
18+
1019
---
1120

1221
## [1.0.6.2] - 2025-10-09

CHANGELOG_zh.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99

1010
---
1111

12+
## [1.0.6.3] - 2025-10-15
13+
14+
### Added
15+
- 新增细粒度的消息存储,详见 [./examples/advanced/demo_save_message.py](./examples/advanced/demo_save_message.py)
16+
17+
### Changed
18+
- 更新示例,详见 [./examples](./examples)
19+
20+
---
21+
1222
## [1.0.6.2] - 2025-10-09
1323

1424
### Added

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For developers who want to contribute to our code, here is the guidance:
4444
python demo.py
4545
```
4646
```bash
47-
python -m examples.agents.single_demo
47+
python -m examples.agents.demo_single_agent
4848
```
4949

5050
## 4. Test

CONTRIBUTING_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ OxyGent致力于为每一位用户和开发者提供开放的智能体系统体
4545
python demo.py
4646
```
4747
```bash
48-
python -m examples.agents.single_demo
48+
python -m examples.agents.demo_single_agent
4949
```
5050

5151
## 4. 测试

config.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"max_tokens": 4096,
2525
"top_p": 1
2626
},
27-
"cache": {"save_dir": "./cache_dir"},
27+
"cache": {
28+
"save_dir": "./cache_dir"
29+
},
2830
"message": {
2931
"is_send_tool_call": true,
3032
"is_send_observation": true,
@@ -58,7 +60,7 @@
5860
},
5961
"agent": {
6062
"prompt": "",
61-
"llm_model": "",
63+
"llm_model": "default_llm",
6264
"input_schema": {
6365
"properties": {"query": {"description": "Query question"}},
6466
"required": ["query"]
@@ -70,8 +72,8 @@
7072
}
7173
},
7274
"dev": {
73-
"cache": {
74-
"save_dir": "./cache_dir_dev"
75+
"app": {
76+
"name": "app-dev"
7577
},
7678
"es": {
7779
"hosts": [

demo.py

Lines changed: 15 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,48 @@
11
import asyncio
22
import os
33

4-
from pydantic import Field
5-
6-
from oxygent import MAS, Config, OxyRequest, OxyResponse, oxy
7-
from oxygent.prompts import INTENTION_PROMPT
4+
from oxygent import MAS, Config, oxy, preset_tools
85

96
Config.set_agent_llm_model("default_llm")
107

118

12-
async def workflow(oxy_request: OxyRequest):
13-
short_memory = oxy_request.get_short_memory()
14-
print("--- History record --- :", short_memory)
15-
master_short_memory = oxy_request.get_short_memory(master_level=True)
16-
print("--- History record-User layer --- :", master_short_memory)
17-
print("user query:", oxy_request.get_query(master_level=True))
18-
await oxy_request.send_message({"type": "msg_type", "content": "msg_content"})
19-
oxy_response = await oxy_request.call(
20-
callee="time_agent",
21-
arguments={"query": "What time is it now in Asia/Shanghai?"},
22-
)
23-
print("--- Current time --- :", oxy_response.output)
24-
oxy_response = await oxy_request.call(
25-
callee="default_llm",
26-
arguments={
27-
"messages": [
28-
{"role": "system", "content": "You are a helpful assistant."},
29-
{"role": "user", "content": "Hello!"},
30-
],
31-
"llm_params": {"temperature": 0.6},
32-
},
33-
)
34-
print(oxy_response.output)
35-
import re
36-
37-
numbers = re.findall(r"\d+", oxy_request.get_query())
38-
if numbers:
39-
n = numbers[-1]
40-
oxy_response = await oxy_request.call(callee="calc_pi", arguments={"prec": n})
41-
return f"Save {n} positions: {oxy_response.output}"
42-
else:
43-
return "Save 2 positions: 3.14, or you could ask me to save how many positions you want."
44-
45-
46-
fh = oxy.FunctionHub(name="joke_tools")
47-
48-
49-
@fh.tool(description="a tool for telling jokes")
50-
async def joke_tool(joke_type: str = Field(description="The type of the jokes")):
51-
import random
52-
53-
jokes = [
54-
"Teacher: Can you use the word 'because' in a sentence? \n Student: I didn't do my homework because… because I didn't do my homework.",
55-
"Patient: Doctor, I feel like a pair of curtains.\nDoctor: Pull yourself together!",
56-
"How many software engineers does it take to change a light bulb?\nNone. That's a hardware problem.",
57-
]
58-
print("The type of the jokes", joke_type)
59-
return random.choice(jokes)
60-
61-
62-
def update_query(oxy_request: OxyRequest) -> OxyRequest:
63-
print(oxy_request.shared_data)
64-
user_query = oxy_request.get_query(master_level=True)
65-
current_query = oxy_request.get_query()
66-
print(user_query + "\n" + current_query)
67-
oxy_request.arguments["who"] = oxy_request.callee
68-
return oxy_request
69-
70-
71-
def format_output(oxy_response: OxyResponse) -> OxyResponse:
72-
oxy_response.output = "Answer: " + oxy_response.output
73-
return oxy_response
74-
75-
769
oxy_space = [
7710
oxy.HttpLLM(
7811
name="default_llm",
7912
api_key=os.getenv("DEFAULT_LLM_API_KEY"),
8013
base_url=os.getenv("DEFAULT_LLM_BASE_URL"),
8114
model_name=os.getenv("DEFAULT_LLM_MODEL_NAME"),
82-
llm_params={"temperature": 0.01},
83-
semaphore=4,
84-
),
85-
oxy.ChatAgent(name="intent_agent", prompt=INTENTION_PROMPT),
86-
fh,
87-
oxy.StdioMCPClient(
88-
name="time_tools",
89-
params={
90-
"command": "uvx",
91-
"args": ["mcp-server-time", "--local-timezone=Asia/Shanghai"],
92-
},
93-
),
94-
oxy.StdioMCPClient(
95-
name="file_tools",
96-
params={
97-
"command": "npx",
98-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./local_file"],
99-
},
100-
),
101-
oxy.StdioMCPClient(
102-
name="my_tools",
103-
params={
104-
"command": "uv",
105-
"args": ["--directory", "./mcp_servers", "run", "my_tools.py"],
106-
},
107-
),
108-
oxy.ReActAgent(
109-
name="master_agent",
110-
sub_agents=["time_agent", "file_agent", "math_agent"],
111-
additional_prompt="You may get several types of tasks, please choose correct tools to finish tasks.",
112-
is_master=True,
113-
func_format_output=format_output,
114-
timeout=100,
115-
llm_model="default_llm",
11615
),
16+
preset_tools.time_tools,
11717
oxy.ReActAgent(
11818
name="time_agent",
119-
desc="A tool for time query.",
120-
additional_prompt="Do not send other information except time.",
19+
desc="A tool that can query the time",
12120
tools=["time_tools"],
122-
func_process_input=update_query,
123-
trust_mode=False,
124-
timeout=10,
12521
),
22+
preset_tools.file_tools,
12623
oxy.ReActAgent(
12724
name="file_agent",
128-
desc="A tool for file operation.",
25+
desc="A tool that can operate the file system",
12926
tools=["file_tools"],
13027
),
131-
oxy.WorkflowAgent(
28+
preset_tools.math_tools,
29+
oxy.ReActAgent(
13230
name="math_agent",
133-
desc="A tool for pi query",
134-
sub_agents=["time_agent"],
135-
tools=["my_tools"],
136-
func_workflow=workflow,
137-
is_retain_master_short_memory=True,
31+
desc="A tool that can perform mathematical calculations.",
32+
tools=["math_tools"],
33+
),
34+
oxy.ReActAgent(
35+
is_master=True,
36+
name="master_agent",
37+
sub_agents=["time_agent", "file_agent", "math_agent"],
13838
),
139-
# oxy.StreamableMCPClient(name="test_stream", server_url="http://127.0.0.1:9000/mcp"),
14039
]
14140

14241

14342
async def main():
144-
"""
145-
new instance:
146-
Method 1: async with MAS(oxy_space=oxy_space) as mas:
147-
Method 2: mas = await MAS.create(oxy_space=oxy_space)
148-
call directly:
149-
await mas.call(callee="joke_tool", arguments={"joke_type": "comic"})
150-
start:
151-
await mas.start_cli_mode(first_query="Get what time it is and save in `log.txt` under `/local_file`")
152-
await mas.start_web_service(first_query="Get what time it is and save in `log.txt` under `/local_file`")
153-
await mas.start_batch_processing(["Hello", "What time is it now", "200 positions of Pi"])
154-
"""
15543
async with MAS(oxy_space=oxy_space) as mas:
15644
await mas.start_web_service(
157-
first_query="Please calculate the 20 positions of Pi",
158-
welcome_message="Hi, I’m OxyGent. How can I assist you?",
45+
first_query="What time is it now? Please save it into time.txt."
15946
)
16047

16148

demo_in_readme.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/development/api/tools/sse_mcp_client.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The position of the class is:
4646

4747
```python
4848
oxy.SSEMCPClient(
49-
name="my_tools",
50-
sse_url="http://127.0.0.1:9000/sse"
49+
name="math_tools",
50+
sse_url="http://127.0.0.1:8000/sse"
5151
)
5252
```

0 commit comments

Comments
 (0)