Duibonduil commited on
Commit
98bb9c2
·
verified ·
1 Parent(s): d7ffb23

Upload 2 files

Browse files
examples/cmd/agent_deploy/gaia_agent/agent.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import json
4
+ from aworld.cmd import BaseAWorldAgent, ChatCompletionRequest
5
+ from examples.gaia.gaia_agent_runner import GaiaAgentRunner
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ class AWorldAgent(BaseAWorldAgent):
11
+ def __init__(self, *args, **kwargs):
12
+ super().__init__(*args, **kwargs)
13
+ path_cwd = os.path.dirname(os.path.abspath(__file__))
14
+ mcp_path = os.path.join(path_cwd, "mcp.json")
15
+ with open(mcp_path, "r") as f:
16
+ self.mcp_config = json.load(f)
17
+ os.makedirs(os.path.join(os.getcwd(), "static"), exist_ok=True)
18
+
19
+ async def run(self, prompt: str = None, request: ChatCompletionRequest = None):
20
+ llm_provider = os.getenv("LLM_PROVIDER_GAIA", "openai")
21
+ llm_model_name = os.getenv("LLM_MODEL_NAME_GAIA")
22
+ llm_api_key = os.getenv("LLM_API_KEY_GAIA")
23
+ llm_base_url = os.getenv("LLM_BASE_URL_GAIA")
24
+ llm_temperature = os.getenv("LLM_TEMPERATURE_GAIA", 0.0)
25
+
26
+ if not llm_model_name or not llm_api_key or not llm_base_url:
27
+ raise ValueError(
28
+ "LLM_MODEL_NAME, LLM_API_KEY, LLM_BASE_URL must be set in your envrionment variables"
29
+ )
30
+
31
+ runner = GaiaAgentRunner(
32
+ llm_provider=llm_provider,
33
+ llm_model_name=llm_model_name,
34
+ llm_base_url=llm_base_url,
35
+ llm_api_key=llm_api_key,
36
+ llm_temperature=llm_temperature,
37
+ mcp_config=self.mcp_config,
38
+ )
39
+
40
+ if prompt is None and request is not None:
41
+ prompt = request.messages[-1].content
42
+
43
+ logger.info(f">>> Gaia Agent: prompt={prompt}, runner={runner}")
44
+
45
+ async for line in runner.run(prompt):
46
+ logger.info(f">>> Gaia Agent Line: {line}")
47
+ yield line
examples/cmd/agent_deploy/gaia_agent/mcp.json ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mcpServers": {
3
+ "e2b-server": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@e2b/mcp-server"
8
+ ],
9
+ "env": {
10
+ "E2B_API_KEY": "${E2B_API_KEY}",
11
+ "SESSION_REQUEST_CONNECT_TIMEOUT": "120"
12
+ }
13
+ },
14
+ "filesystem": {
15
+ "command": "npx",
16
+ "args": [
17
+ "-y",
18
+ "@modelcontextprotocol/server-filesystem",
19
+ "${FILESYSTEM_SERVER_WORKDIR}"
20
+ ]
21
+ },
22
+ "terminal-controller": {
23
+ "command": "python",
24
+ "args": [
25
+ "-m",
26
+ "terminal_controller"
27
+ ]
28
+ },
29
+ "calculator": {
30
+ "command": "python",
31
+ "args": [
32
+ "-m",
33
+ "mcp_server_calculator"
34
+ ]
35
+ },
36
+ "excel": {
37
+ "command": "npx",
38
+ "args": [
39
+ "--yes",
40
+ "@negokaz/excel-mcp-server"
41
+ ],
42
+ "env": {
43
+ "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
44
+ }
45
+ },
46
+ "playwright": {
47
+ "command": "npx",
48
+ "args": [
49
+ "-y",
50
+ "@executeautomation/playwright-mcp-server"
51
+ ]
52
+ },
53
+ "google-search": {
54
+ "command": "npx",
55
+ "args": [
56
+ "-y",
57
+ "@adenot/mcp-google-search"
58
+ ],
59
+ "env": {
60
+ "GOOGLE_API_KEY": "${GOOGLE_API_KEY}",
61
+ "GOOGLE_SEARCH_ENGINE_ID": "${GOOGLE_SEARCH_ENGINE_ID}"
62
+ }
63
+ },
64
+ "ms-playwright": {
65
+ "command": "npx",
66
+ "args": [
67
+ "@playwright/mcp@latest",
68
+ "--isolated"
69
+ ],
70
+ "env": {
71
+ "PLAYWRIGHT_TIMEOUT": "120000",
72
+ "SESSION_REQUEST_CONNECT_TIMEOUT": "120"
73
+ }
74
+ },
75
+ "audio_server": {
76
+ "command": "python",
77
+ "args": [
78
+ "-m",
79
+ "mcp_servers.audio_server"
80
+ ]
81
+ },
82
+ "image_server": {
83
+ "command": "python",
84
+ "args": [
85
+ "-m",
86
+ "mcp_servers.image_server"
87
+ ]
88
+ },
89
+ "youtube_server": {
90
+ "command": "python",
91
+ "args": [
92
+ "-m",
93
+ "mcp_servers.youtube_server"
94
+ ]
95
+ },
96
+ "video_server": {
97
+ "command": "python",
98
+ "args": [
99
+ "-m",
100
+ "mcp_servers.video_server"
101
+ ]
102
+ },
103
+ "search_server": {
104
+ "command": "python",
105
+ "args": [
106
+ "-m",
107
+ "mcp_servers.search_server"
108
+ ]
109
+ },
110
+ "download_server": {
111
+ "command": "python",
112
+ "args": [
113
+ "-m",
114
+ "mcp_servers.download_server"
115
+ ]
116
+ },
117
+ "document_server": {
118
+ "command": "python",
119
+ "args": [
120
+ "-m",
121
+ "mcp_servers.document_server"
122
+ ]
123
+ },
124
+ "browser_server": {
125
+ "command": "python",
126
+ "args": [
127
+ "-m",
128
+ "mcp_servers.browser_server"
129
+ ]
130
+ },
131
+ "reasoning_server": {
132
+ "command": "python",
133
+ "args": [
134
+ "-m",
135
+ "mcp_servers.reasoning_server"
136
+ ]
137
+ }
138
+ }
139
+ }