xgae 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xgae might be problematic. Click here for more details.
- xgae/engine/engine_base.py +5 -1
- xgae/engine/mcp_tool_box.py +14 -8
- xgae/engine/responser/non_stream_responser.py +2 -1
- xgae/engine/responser/stream_responser.py +3 -2
- xgae/engine/task_engine.py +7 -5
- xgae/gaia2/are_engine.py +4 -3
- {xgae-0.3.0.dist-info → xgae-0.3.1.dist-info}/METADATA +3 -3
- {xgae-0.3.0.dist-info → xgae-0.3.1.dist-info}/RECORD +10 -10
- {xgae-0.3.0.dist-info → xgae-0.3.1.dist-info}/WHEEL +0 -0
- {xgae-0.3.0.dist-info → xgae-0.3.1.dist-info}/entry_points.txt +0 -0
xgae/engine/engine_base.py
CHANGED
|
@@ -6,7 +6,7 @@ class XGAError(Exception):
|
|
|
6
6
|
"""Custom exception for errors in the XGA system."""
|
|
7
7
|
pass
|
|
8
8
|
|
|
9
|
-
XGAMsgStatusType = Literal["error", "finish", "tool_started", "tool_completed", "tool_error", "tool_failed"]
|
|
9
|
+
XGAMsgStatusType = Literal["error", "stop", "finish", "tool_started", "tool_completed", "tool_error", "tool_failed"]
|
|
10
10
|
XGAResponseMsgType = Literal["user", "status", "tool", "assistant", "assistant_chunk"]
|
|
11
11
|
|
|
12
12
|
class XGAResponseMessage(TypedDict, total=False):
|
|
@@ -40,6 +40,10 @@ class XGAToolResult:
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class XGAToolBox(ABC):
|
|
43
|
+
@abstractmethod
|
|
44
|
+
async def init_tool_schemas(self):
|
|
45
|
+
pass
|
|
46
|
+
|
|
43
47
|
@abstractmethod
|
|
44
48
|
async def creat_task_tool_box(self, task_id: str, general_tools: List[str], custom_tools: List[str]):
|
|
45
49
|
pass
|
xgae/engine/mcp_tool_box.py
CHANGED
|
@@ -2,7 +2,8 @@ import json
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
|
-
from typing import List, Any, Dict, Optional, Literal
|
|
5
|
+
from typing import List, Any, Dict, Optional, Literal
|
|
6
|
+
from typing_extensions import override
|
|
6
7
|
|
|
7
8
|
from langchain_mcp_adapters.client import MultiServerMCPClient
|
|
8
9
|
from langchain_mcp_adapters.tools import load_mcp_tools
|
|
@@ -33,7 +34,11 @@ class XGAMcpToolBox(XGAToolBox):
|
|
|
33
34
|
self.mcp_tool_schemas: Dict[str, List[XGAToolSchema]] = {}
|
|
34
35
|
self.task_tool_schemas: Dict[str, Dict[str,XGAToolSchema]] = {}
|
|
35
36
|
|
|
36
|
-
self.
|
|
37
|
+
self._is_loaded_mcp_tool_schemas = False
|
|
38
|
+
|
|
39
|
+
@override
|
|
40
|
+
async def init_tool_schemas(self):
|
|
41
|
+
await self._load_mcp_tools_schema()
|
|
37
42
|
|
|
38
43
|
@override
|
|
39
44
|
async def creat_task_tool_box(self, task_id: str, general_tools: List[str], custom_tools: List[str]):
|
|
@@ -139,8 +144,8 @@ class XGAMcpToolBox(XGAToolBox):
|
|
|
139
144
|
return result
|
|
140
145
|
|
|
141
146
|
|
|
142
|
-
async def
|
|
143
|
-
if not self.
|
|
147
|
+
async def _load_mcp_tools_schema(self)-> None:
|
|
148
|
+
if not self._is_loaded_mcp_tool_schemas:
|
|
144
149
|
for server_name in self.mcp_server_names:
|
|
145
150
|
self.mcp_tool_schemas[server_name] = []
|
|
146
151
|
try:
|
|
@@ -169,11 +174,12 @@ class XGAMcpToolBox(XGAToolBox):
|
|
|
169
174
|
input_schema=input_schema,
|
|
170
175
|
metadata=metadata)
|
|
171
176
|
self.mcp_tool_schemas[server_name].append(tool_schema)
|
|
172
|
-
|
|
177
|
+
|
|
178
|
+
self._is_loaded_mcp_tool_schemas = True
|
|
173
179
|
|
|
174
180
|
async def reload_mcp_tools_schema(self) -> None:
|
|
175
|
-
self.
|
|
176
|
-
await self.
|
|
181
|
+
self._is_loaded_mcp_tool_schemas = False
|
|
182
|
+
await self.init_tool_schemas()
|
|
177
183
|
|
|
178
184
|
|
|
179
185
|
def _load_mcp_servers_config(self, mcp_config_path: str) -> Dict[str, Any]:
|
|
@@ -219,7 +225,7 @@ if __name__ == "__main__":
|
|
|
219
225
|
#mcp_tool_box = XGAMcpToolBox()
|
|
220
226
|
|
|
221
227
|
task_id = "task1"
|
|
222
|
-
await mcp_tool_box.
|
|
228
|
+
await mcp_tool_box.init_tool_schemas()
|
|
223
229
|
await mcp_tool_box.creat_task_tool_box(task_id=task_id, general_tools=["*"], custom_tools=["*"])
|
|
224
230
|
tool_schemas = mcp_tool_box.get_task_tool_schemas(task_id, "general")
|
|
225
231
|
print("general_tools_schemas" + "*"*50)
|
xgae/engine/task_engine.py
CHANGED
|
@@ -116,8 +116,7 @@ class XGATaskEngine:
|
|
|
116
116
|
general_tools.append("ask")
|
|
117
117
|
|
|
118
118
|
custom_tools = self.custom_tools or []
|
|
119
|
-
|
|
120
|
-
await self.tool_box.load_mcp_tools_schema()
|
|
119
|
+
await self.tool_box.init_tool_schemas()
|
|
121
120
|
|
|
122
121
|
await self.tool_box.creat_task_tool_box(self.task_id, general_tools, custom_tools)
|
|
123
122
|
general_tool_schemas = self.tool_box.get_task_tool_schemas(self.task_id, "general")
|
|
@@ -201,6 +200,9 @@ class XGATaskEngine:
|
|
|
201
200
|
yield error_msg
|
|
202
201
|
finally:
|
|
203
202
|
if not self.running_task_checkpoint("termination_check", iterations):
|
|
203
|
+
status_content = {'status_type': "stop", 'role': "system", 'message': "Task is termiated by Stop Command"}
|
|
204
|
+
error_msg = self.add_response_message(type="status", content=status_content, is_llm_message=False)
|
|
205
|
+
yield error_msg
|
|
204
206
|
break
|
|
205
207
|
|
|
206
208
|
async def _run_task_once(self, continuous_state: TaskRunContinuousState) -> AsyncGenerator[Dict[str, Any], None]:
|
|
@@ -239,8 +241,8 @@ class XGATaskEngine:
|
|
|
239
241
|
reverse_chunks = reversed(chunks)
|
|
240
242
|
chunk = None
|
|
241
243
|
|
|
242
|
-
if self.terminate_task:
|
|
243
|
-
|
|
244
|
+
# if self.terminate_task:
|
|
245
|
+
# return XGATaskResult(type="error", content="LLM Task is terminated !")
|
|
244
246
|
|
|
245
247
|
try:
|
|
246
248
|
finish_reason = ''
|
|
@@ -249,7 +251,7 @@ class XGATaskEngine:
|
|
|
249
251
|
if chunk_type == "status":
|
|
250
252
|
status_content = chunk['content']
|
|
251
253
|
status_type = status_content['status_type']
|
|
252
|
-
if status_type == "error":
|
|
254
|
+
if status_type == "error" or status_type == "stop":
|
|
253
255
|
error = status_content['message']
|
|
254
256
|
final_result = XGATaskResult(type="error", content=error)
|
|
255
257
|
elif status_type == "finish":
|
xgae/gaia2/are_engine.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import Any, Optional,
|
|
2
|
+
from typing import Any, Optional, Callable, Literal, Dict, List
|
|
3
|
+
from typing_extensions import override
|
|
3
4
|
|
|
4
5
|
from xgae.engine.engine_base import XGAToolBox
|
|
5
6
|
from xgae.engine.task_engine import XGATaskEngine
|
|
@@ -81,12 +82,12 @@ if __name__ == "__main__":
|
|
|
81
82
|
|
|
82
83
|
def terminate_task(agent, iterations: int) -> bool:
|
|
83
84
|
logging.info(f"terminate_task: iterations={iterations}")
|
|
84
|
-
return iterations >
|
|
85
|
+
return iterations > 3 # can test terminate by > 3
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
async def main():
|
|
88
89
|
# Before Run Exec: uv run example-fault-tools
|
|
89
|
-
# LLAMA_API_KEY ,
|
|
90
|
+
# LLAMA_API_KEY , LLAMA_API_BASE
|
|
90
91
|
tool_box = XGAMcpToolBox(custom_mcp_server_file="mcpservers/custom_servers.json")
|
|
91
92
|
system_prompt = read_file("templates/example/fault_user_prompt.txt")
|
|
92
93
|
llm_config = LLMConfig(
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xgae
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Extreme General Agent Engine
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: colorlog==6.9.0
|
|
7
7
|
Requires-Dist: langchain-mcp-adapters==0.1.9
|
|
8
8
|
Requires-Dist: langfuse==2.60.9
|
|
9
|
-
Requires-Dist: litellm==1.
|
|
10
|
-
Requires-Dist: mcp==1.
|
|
9
|
+
Requires-Dist: litellm==1.71.1
|
|
10
|
+
Requires-Dist: mcp==1.11.0
|
|
11
11
|
Provides-Extra: examples
|
|
12
12
|
Requires-Dist: chromadb==1.1.0; extra == 'examples'
|
|
13
13
|
Requires-Dist: langchain-community==0.3.29; extra == 'examples'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
xgae/__init__.py,sha256=oBX_YzTliM-343BAlR-sD7BUZmsCJ7PY2oYrGBhsdLM,79
|
|
2
2
|
xgae/engine_cli_app.py,sha256=FdmIpq8KDsgyZNfwCDgNX7FEZFeRFyGOt_H1oZF8aKs,2890
|
|
3
|
-
xgae/engine/engine_base.py,sha256=
|
|
4
|
-
xgae/engine/mcp_tool_box.py,sha256=
|
|
3
|
+
xgae/engine/engine_base.py,sha256=bXwLxli7CK7JndAcOu-Rx4uTuy0pJDh_ZOGyhym76WY,1796
|
|
4
|
+
xgae/engine/mcp_tool_box.py,sha256=7dOiP9cfBU8TfAxzbdw0V31ISF-o2TgdTVUqEemz004,11044
|
|
5
5
|
xgae/engine/prompt_builder.py,sha256=6I5rjgvNJ27QJ8DDuBTplutoPZdGs9LYFv3TSgT7zmc,5045
|
|
6
|
-
xgae/engine/task_engine.py,sha256=
|
|
6
|
+
xgae/engine/task_engine.py,sha256=QhjTPQ_aREsT19QfT1nQwNLKUMwWdSgqlfjfCNq_dho,23470
|
|
7
7
|
xgae/engine/task_langfuse.py,sha256=ifkGrPBv2daLTKE-fCfEtOoI0n4Pd-lCwhyRRL0h308,2850
|
|
8
|
-
xgae/engine/responser/non_stream_responser.py,sha256=
|
|
8
|
+
xgae/engine/responser/non_stream_responser.py,sha256=WFzrT0tHGVLi_AR1IrIPPvpQ94ne7slwbFyXaoTpCQc,5318
|
|
9
9
|
xgae/engine/responser/responser_base.py,sha256=jhl1Bdz1Fs3KofGEymThNXlQuCORFTTkTAR_U47krds,24403
|
|
10
|
-
xgae/engine/responser/stream_responser.py,sha256=
|
|
11
|
-
xgae/gaia2/are_engine.py,sha256=
|
|
10
|
+
xgae/engine/responser/stream_responser.py,sha256=5n7i2QnE_u7RP1bcJFky8sFPjYMjfYY9NcR5TeFxl9Y,7642
|
|
11
|
+
xgae/gaia2/are_engine.py,sha256=QPvyWEydeiOECQ7WfxjMIurQHD_ET7uWQCnXVCh_ZQk,5094
|
|
12
12
|
xgae/tools/without_general_tools_app.py,sha256=KqsdhxD3hvTpiygaGUVHysRFjvv_1A8zOwMKN1J0J0U,3821
|
|
13
13
|
xgae/utils/__init__.py,sha256=ElaGS-zdeZeu6is41u3Ny7lkvhg7BDSK-jMNg9j6K5A,499
|
|
14
14
|
xgae/utils/json_helpers.py,sha256=WD4G5U9Dh8N6J9O0L5wGyqj-NHi09kcXHGdLD_26nlc,3607
|
|
@@ -16,7 +16,7 @@ xgae/utils/llm_client.py,sha256=rqnu_NYXBC0hl4aozP5UOSyf0q-ONB5ywtnrXzA88OE,1505
|
|
|
16
16
|
xgae/utils/misc.py,sha256=aMWOvJ9VW52q-L9Lkjl1hvXqLwpJAmyxA-Z8jzqFG0U,907
|
|
17
17
|
xgae/utils/setup_env.py,sha256=MqNG0c2QQBDFU1kI8frxr9kB5d08Mmi3QZ1OoorgIa0,2662
|
|
18
18
|
xgae/utils/xml_tool_parser.py,sha256=Mb0d8kBrfyAEvUwW1Nqir-3BgxZRr0ZX3WymQouuFSo,4859
|
|
19
|
-
xgae-0.3.
|
|
20
|
-
xgae-0.3.
|
|
21
|
-
xgae-0.3.
|
|
22
|
-
xgae-0.3.
|
|
19
|
+
xgae-0.3.1.dist-info/METADATA,sha256=vOaoxeqkHDKwSuRUscc9--4KpuOTqM5BwEXqsCPUQ1I,470
|
|
20
|
+
xgae-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
21
|
+
xgae-0.3.1.dist-info/entry_points.txt,sha256=wmvgtMQbtzTbDPETS-tbQJD7jVlcs4hp0w6wOB0ooCc,229
|
|
22
|
+
xgae-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|