Skip to content

feat: allow disabling context tip #1174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ Below are all available configuration options with their default values:
auto_insert_mode = false, -- Automatically enter insert mode when opening window and on new prompt
insert_at_end = false, -- Move cursor to end of buffer when inserting text
clear_chat_on_new_prompt = false, -- Clears chat on every new prompt
disable_context_tip = false, -- Disable context tip/help in the system prompts (this lists tools available in the current context and hints the LLM to use them)

-- Static config starts here (can be configured only via setup function)

Expand Down
9 changes: 6 additions & 3 deletions lua/CopilotChat/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
---@field agent string?
---@field temperature number
---@field on_progress? fun(response: string):nil
---@field disable_context_tip boolean?

---@class CopilotChat.Client.model : CopilotChat.Provider.model
---@field provider string
Expand Down Expand Up @@ -199,13 +200,15 @@ end
--- @param prompt string
--- @param system_prompt string
--- @param generated_messages table<CopilotChat.Provider.input>
local function generate_ask_request(history, contexts, prompt, system_prompt, generated_messages)
--- @param opts table?
local function generate_ask_request(history, contexts, prompt, system_prompt, generated_messages, opts)
local messages = {}
opts = opts or {}

system_prompt = vim.trim(system_prompt)

-- Include context help
if contexts and not vim.tbl_isempty(contexts) then
if contexts and not vim.tbl_isempty(contexts) and not opts.disable_context_tip then
local help_text = [[When you need additional context, request it using this format:

> #<command>:`<input>`
Expand Down Expand Up @@ -657,7 +660,7 @@ function Client:ask(prompt, opts)

local headers = self:authenticate(provider_name)
local request = provider.prepare_input(
generate_ask_request(history, opts.contexts, prompt, opts.system_prompt, generated_messages),
generate_ask_request(history, opts.contexts, prompt, opts.system_prompt, generated_messages, opts),
options
)
local is_stream = request.stream
Expand Down
2 changes: 2 additions & 0 deletions lua/CopilotChat/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ local select = require('CopilotChat.select')
---@field auto_insert_mode boolean?
---@field insert_at_end boolean?
---@field clear_chat_on_new_prompt boolean?
---@field disable_context_tip boolean?

--- CopilotChat default configuration
---@class CopilotChat.config : CopilotChat.config.shared
Expand Down Expand Up @@ -101,6 +102,7 @@ return {
auto_insert_mode = false, -- Automatically enter insert mode when opening window and on new prompt
insert_at_end = false, -- Move cursor to end of buffer when inserting text
clear_chat_on_new_prompt = false, -- Clears chat on every new prompt
disable_context_tip = false, -- Disable context tip/help in the prompts

-- Static config starts here (can be configured only via setup function)

Expand Down
1 change: 1 addition & 0 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ function M.ask(prompt, config)
model = selected_model,
agent = selected_agent,
temperature = config.temperature,
disable_context_tip = config.disable_context_tip,
on_progress = vim.schedule_wrap(function(token)
local out = config.stream and config.stream(token, state.source) or nil
if out == nil then
Expand Down