diff --git a/crates/avante-templates/src/lib.rs b/crates/avante-templates/src/lib.rs index c77879d..246a535a 100644 --- a/crates/avante-templates/src/lib.rs +++ b/crates/avante-templates/src/lib.rs @@ -45,6 +45,7 @@ struct TemplateContext { memory: Option, todos: Option, enable_fastapply: Option, + use_react_prompt: Option, } // 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()) diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index c555d51..8aa1e0c 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -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 diff --git a/lua/avante/templates/_tools-guidelines.avanterules b/lua/avante/templates/_tools-guidelines.avanterules index 6120b71..6156023 100644 --- a/lua/avante/templates/_tools-guidelines.avanterules +++ b/lua/avante/templates/_tools-guidelines.avanterules @@ -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 -%} + {"name": "attempt_completion", "input": {"result": "[**Generated Response Following the Greeting Response Guideline**]"}} + {% else -%} ```json { "tool_calls": [ @@ -47,3 +50,4 @@ TOOLS USAGE GUIDE ] } ``` + {% endif %}