fix: ReAct parser (#2330)
This commit is contained in:
@@ -16,21 +16,32 @@ You have access to a set of tools that are executed upon the user's approval. Yo
|
||||
|
||||
# Tool Use Formatting
|
||||
|
||||
Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
||||
Tool use is formatted using XML-style tags. Each tool use is wrapped in a <tool_use> tag. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
||||
|
||||
<tool_use>
|
||||
<tool_name>
|
||||
<parameter1_name>value1</parameter1_name>
|
||||
<parameter2_name>value2</parameter2_name>
|
||||
...
|
||||
</tool_name>
|
||||
</tool_use>
|
||||
|
||||
For example:
|
||||
|
||||
<tool_use>
|
||||
<attempt_completion>
|
||||
<result>
|
||||
I have completed the task...
|
||||
</result>
|
||||
</attempt_completion>
|
||||
</tool_use>
|
||||
|
||||
<tool_use>
|
||||
<bash>
|
||||
<path>./src</path>
|
||||
<command>npm run dev</command>
|
||||
</bash>
|
||||
</tool_use>
|
||||
|
||||
ALWAYS ADHERE TO this format for the tool use to ensure proper parsing and execution.
|
||||
|
||||
@@ -60,11 +71,12 @@ Parameters:
|
||||
end
|
||||
if tool.param.usage then
|
||||
tool_prompt = tool_prompt
|
||||
.. ("Usage:\n<{{name}}>\n"):gsub("{{([%w_]+)}}", function(name) return tool[name] end)
|
||||
.. ("Usage:\n<tool_use>\n<{{name}}>\n"):gsub("{{([%w_]+)}}", function(name) return tool[name] end)
|
||||
for k, v in pairs(tool.param.usage) do
|
||||
tool_prompt = tool_prompt .. "<" .. k .. ">" .. tostring(v) .. "</" .. k .. ">\n"
|
||||
end
|
||||
tool_prompt = tool_prompt .. ("</{{name}}>\n"):gsub("{{([%w_]+)}}", function(name) return tool[name] end)
|
||||
tool_prompt = tool_prompt
|
||||
.. ("</{{name}}>\n</tool_use>\n"):gsub("{{([%w_]+)}}", function(name) return tool[name] end)
|
||||
end
|
||||
tools_prompts = tools_prompts .. tool_prompt .. "\n"
|
||||
end
|
||||
@@ -77,13 +89,16 @@ Parameters:
|
||||
|
||||
## Example 1: Requesting to execute a command
|
||||
|
||||
<tool_use>
|
||||
<bash>
|
||||
<path>./src</path>
|
||||
<command>npm run dev</command>
|
||||
</bash>
|
||||
</tool_use>
|
||||
|
||||
## Example 2: Requesting to create a new file
|
||||
|
||||
<tool_use>
|
||||
<write_to_file>
|
||||
<path>src/frontend-config.json</path>
|
||||
<content>
|
||||
@@ -103,9 +118,11 @@ Parameters:
|
||||
}
|
||||
</content>
|
||||
</write_to_file>
|
||||
</tool_use>
|
||||
|
||||
## Example 3: Requesting to make targeted edits to a file
|
||||
|
||||
<tool_use>
|
||||
<replace_in_file>
|
||||
<path>src/components/App.tsx</path>
|
||||
<diff>
|
||||
@@ -138,9 +155,11 @@ return (
|
||||
+++++++ REPLACE
|
||||
</diff>
|
||||
</replace_in_file>
|
||||
</tool_use>
|
||||
|
||||
## Example 4: Complete current task
|
||||
|
||||
<tool_use>
|
||||
<attempt_completion>
|
||||
<result>
|
||||
I've successfully created the requested React component with the following features:
|
||||
@@ -150,6 +169,39 @@ I've successfully created the requested React component with the following featu
|
||||
- API integration
|
||||
</result>
|
||||
</attempt_completion>
|
||||
</tool_use>
|
||||
|
||||
## Example 5: Add todos
|
||||
|
||||
<tool_use>
|
||||
<add_todos>
|
||||
<todos>
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"content": "Implement a responsive layout",
|
||||
"status": "todo",
|
||||
"priority": "low"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"content": "Add dark/light mode toggle",
|
||||
"status": "todo",
|
||||
"priority": "medium"
|
||||
},
|
||||
]
|
||||
</todos>
|
||||
</add_todos>
|
||||
</tool_use>
|
||||
|
||||
## Example 6: Update todo status
|
||||
|
||||
<tool_use>
|
||||
<update_todo_status>
|
||||
<id>1</id>
|
||||
<status>done</status>
|
||||
</update_todo_status>
|
||||
</tool_use>
|
||||
]]
|
||||
end
|
||||
return system_prompt
|
||||
|
||||
Reference in New Issue
Block a user