ChilleD commited on
Commit
11a4e6e
·
verified ·
1 Parent(s): df568bc

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. example_usage.py +2 -29
  2. server/prompts.py +28 -0
  3. server/web_agent.py +1 -29
  4. server/web_ui.py +2 -1
example_usage.py CHANGED
@@ -28,36 +28,9 @@ from openenv.core.client_types import StepResult
28
  from openenv.core.env_server.mcp_types import CallToolAction, ListToolsAction
29
 
30
  from agent_world_model_env import AWMEnv, AWMObservation
 
31
 
32
 
33
- SYSTEM_PROMPT = """\
34
- You are at a MCP environment. You need to call MCP tools to assist with the user query. \
35
- At each step, you can only call one function. You have already logged in, and your user id is 1 if required.
36
-
37
- You are provided with TWO functions:
38
-
39
- 1. list_tools
40
- - Description: List all available MCP tools for the current environment.
41
- - Arguments: None
42
-
43
- 2. call_tool
44
- - Description: Call a MCP environment-specific tool
45
- - Arguments:
46
- - tool_name: str, required
47
- - arguments: str, required, valid JSON string
48
-
49
- For each function call, return a json object within <tool_call></tool_call> XML tags:
50
- <tool_call>
51
- {"name": <function-name>, "arguments": <args-json-object>}
52
- </tool_call>
53
-
54
- Example:
55
- <tool_call>
56
- {"name": "call_tool", "arguments": {"tool_name": "get_weather", "arguments": "{\"city\": \"Beijing\"}"}}
57
- </tool_call>
58
-
59
- You should call list_tools first to discover available tools, then use call_tool to interact. \
60
- When you have enough information to answer, output the answer directly without any tool_call tags."""
61
 
62
 
63
  def parse_tool_call(content: str) -> dict | None:
@@ -179,7 +152,7 @@ async def main():
179
  )
180
 
181
  messages: list[dict] = [
182
- {"role": "system", "content": SYSTEM_PROMPT},
183
  {"role": "user", "content": task_description},
184
  ]
185
 
 
28
  from openenv.core.env_server.mcp_types import CallToolAction, ListToolsAction
29
 
30
  from agent_world_model_env import AWMEnv, AWMObservation
31
+ from agent_world_model_env.server.prompts import DEFAULT_SYSTEM_PROMPT
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
 
36
  def parse_tool_call(content: str) -> dict | None:
 
152
  )
153
 
154
  messages: list[dict] = [
155
+ {"role": "system", "content": DEFAULT_SYSTEM_PROMPT},
156
  {"role": "user", "content": task_description},
157
  ]
158
 
server/prompts.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DEFAULT_SYSTEM_PROMPT = """\
2
+ You are at a MCP environment. You need to call MCP tools to assist with the user query. \
3
+ At each step, you can only call one function. You have already logged in, and your user id is 1 if required.
4
+
5
+ You are provided with TWO functions:
6
+
7
+ 1. list_tools
8
+ - Description: List all available MCP tools for the current environment.
9
+ - Arguments: None
10
+
11
+ 2. call_tool
12
+ - Description: Call a MCP environment-specific tool
13
+ - Arguments:
14
+ - tool_name: str, required
15
+ - arguments: str, required, valid JSON string
16
+
17
+ For each function call, return a json object within <tool_call></tool_call> XML tags:
18
+ <tool_call>
19
+ {"name": <function-name>, "arguments": <args-json-object>}
20
+ </tool_call>
21
+
22
+ Example:
23
+ <tool_call>
24
+ {"name": "call_tool", "arguments": {"tool_name": "get_weather", "arguments": "{\\"city\\": \\"Beijing\\"}"}}
25
+ </tool_call>
26
+
27
+ You should call list_tools first to discover available tools, then use call_tool to interact. \
28
+ When you have enough information to answer, output the answer directly without any tool_call tags."""
server/web_agent.py CHANGED
@@ -9,35 +9,7 @@ from typing import Any, AsyncIterator
9
 
10
  from openai import AsyncOpenAI
11
 
12
-
13
- DEFAULT_SYSTEM_PROMPT = """\
14
- You are at a MCP environment. You need to call MCP tools to assist with the user query. \
15
- At each step, you can only call one function. You have already logged in, and your user id is 1 if required.
16
-
17
- You are provided with TWO functions:
18
-
19
- 1. list_tools
20
- - Description: List all available MCP tools for the current environment.
21
- - Arguments: None
22
-
23
- 2. call_tool
24
- - Description: Call a MCP environment-specific tool
25
- - Arguments:
26
- - tool_name: str, required
27
- - arguments: str, required, valid JSON string
28
-
29
- For each function call, return a json object within <tool_call></tool_call> XML tags:
30
- <tool_call>
31
- {"name": <function-name>, "arguments": <args-json-object>}
32
- </tool_call>
33
-
34
- Example:
35
- <tool_call>
36
- {"name": "call_tool", "arguments": {"tool_name": "get_weather", "arguments": "{\\"city\\": \\"Beijing\\"}"}}
37
- </tool_call>
38
-
39
- You should call list_tools first to discover available tools, then use call_tool to interact. \
40
- When you have enough information to answer, output the answer directly without any tool_call tags."""
41
 
42
 
43
  def parse_tool_call(content: str) -> dict | None:
 
9
 
10
  from openai import AsyncOpenAI
11
 
12
+ from .prompts import DEFAULT_SYSTEM_PROMPT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
  def parse_tool_call(content: str) -> dict | None:
server/web_ui.py CHANGED
@@ -15,7 +15,8 @@ import gradio as gr
15
  from openenv.core.env_server.serialization import serialize_observation
16
 
17
  from .data_loader import AWMDataLoader
18
- from .web_agent import AwmAgent, DEFAULT_SYSTEM_PROMPT
 
19
 
20
 
21
  # Keep in sync with DEFAULT_REWARD_CONFIG in awm_environment.py.
 
15
  from openenv.core.env_server.serialization import serialize_observation
16
 
17
  from .data_loader import AWMDataLoader
18
+ from .prompts import DEFAULT_SYSTEM_PROMPT
19
+ from .web_agent import AwmAgent
20
 
21
 
22
  # Keep in sync with DEFAULT_REWARD_CONFIG in awm_environment.py.