Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

use XML instead of JSON for agent's actions [WIP]

Vasek Mlejnsky15d05759f6e3
diff --git a/api-service/codegen/prompt.py b/api-service/codegen/prompt.py
index deacf6901..1c79beceb 100644
--- a/api-service/codegen/prompt.py
+++ b/api-service/codegen/prompt.py
@@ -1,20 +1,26 @@
# - ALWAYS use `import` to import packages.
+# - Make sure any code you generate is JSON escaped.
PREFIX = """You are an AI JavaScript/Nodejs assistant.
- Follow the user's instructions carefully & to the letter.
- Minimize any other prose.
- You are building an Express server that handles REST API.
-- Make sure any code you generate is JSON escaped.
- You have access to the following tools:"""
-FORMAT_INSTRUCTIONS = """"The way you use the tools is by specifying a json blob.
-Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).
-THE ONLY VALUES THAT SHOULD BE IN THE "action" FIELD ARE: {tool_names}. NO OTHER VALUES ARE ALLOWED.
-The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:
+# THE ONLY VALUES THAT SHOULD BE IN THE "action" FIELD ARE: {tool_names}. NO OTHER VALUES ARE ALLOWED.
+# {{{{
+# "action": $TOOL_NAME,
+# "action_input": $INPUT
+# }}}}
+FORMAT_INSTRUCTIONS = """"The way you use the tools is by specifying a XML snippet.
+Specifically, this XML snippet should have a `<Action>$TOOL_NAME</Action>` element (with the name of the tool to use inside) and a `<ActionInput>$INPUT</ActionInput>` element (with the input to the tool going here).
+The XML code snippet should only contain a SINGLE action, do NOT use multiple actions at once. Here is an example of a valid XML code snippet:
```
-{{{{
- "action": $TOOL_NAME,
- "action_input": $INPUT
-}}}}
+<Action>
+$TOOL_NAME
+</Action>
+<ActionInput>
+$INPUT
+</ActionInput>
```
ALWAYS use the following format:
@@ -23,10 +29,12 @@ Instructions: the input instructions you must implement
Thought: you should always think about what to do
Action:
```
-{{{{
- "action": $TOOL_NAME,
- "action_input": $INPUT
-}}}}
+<Action>
+$TOOL_NAME
+</Action>
+<ActionInput>
+$INPUT
+</ActionInput>
```
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)