fix: ReAct tool use format in few-shot (#2542)
This commit is contained in:
@@ -45,6 +45,7 @@ struct TemplateContext {
|
||||
memory: Option<String>,
|
||||
todos: Option<String>,
|
||||
enable_fastapply: Option<bool>,
|
||||
use_react_prompt: Option<bool>,
|
||||
}
|
||||
|
||||
// Given the file name registered after add, the context table in Lua, resulted in a formatted
|
||||
@@ -74,6 +75,7 @@ fn render(state: &State, template: &str, context: TemplateContext) -> LuaResult<
|
||||
memory => context.memory,
|
||||
todos => context.todos,
|
||||
enable_fastapply => context.enable_fastapply,
|
||||
use_react_prompt => context.use_react_prompt,
|
||||
})
|
||||
.map_err(LuaError::external)
|
||||
.unwrap())
|
||||
|
||||
@@ -296,6 +296,8 @@ function M.generate_prompts(opts)
|
||||
|
||||
selected_files = vim.iter(selected_files):filter(function(file) return viewed_files[file.path] == nil end):totable()
|
||||
|
||||
local provider_conf = Providers.parse_config(provider)
|
||||
|
||||
local template_opts = {
|
||||
ask = opts.ask, -- TODO: add mode without ask instruction
|
||||
code_lang = opts.code_lang,
|
||||
@@ -308,6 +310,7 @@ function M.generate_prompts(opts)
|
||||
model_name = provider.model or "unknown",
|
||||
memory = opts.memory,
|
||||
enable_fastapply = Config.behaviour.enable_fastapply,
|
||||
use_react_prompt = provider_conf.use_ReAct_prompt,
|
||||
}
|
||||
|
||||
-- Removed the original todos processing logic, now handled in context_messages
|
||||
|
||||
@@ -34,6 +34,9 @@ TOOLS USAGE GUIDE
|
||||
**Crucial Example of Correct Behavior:**
|
||||
* **User Input:** "Hi there"
|
||||
* **Your REQUIRED Output (as a tool call):**
|
||||
{% if use_react_prompt -%}
|
||||
<tool_use>{"name": "attempt_completion", "input": {"result": "[**Generated Response Following the Greeting Response Guideline**]"}}</tool_use>
|
||||
{% else -%}
|
||||
```json
|
||||
{
|
||||
"tool_calls": [
|
||||
@@ -47,3 +50,4 @@ TOOLS USAGE GUIDE
|
||||
]
|
||||
}
|
||||
```
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user