Replies: 8 comments 3 replies
-
Hmm so :CopilotChatSave/:CopilotChatLoad is not enough with specifying custom title? The load function also has autocomplete so it shouldnt be that hard to use I think. And imo if saving chat its better to specify custom name anyway as thats more accurate, but depends on what other ppl think. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to configure something similar? using the available api? |
Beta Was this translation helpful? Give feedback.
-
Technically yes, you can set up default callback with response, then get for example first line of response, set it to some variable if the variable is not set and then generate some name from that, then create command that calls .save/load methods with this saved variable on |
Beta Was this translation helpful? Give feedback.
-
ok tried playing with it a bit and this kinda works (e.g feeding the response to AI, then using AI to generate the chat title) local function generate_title(response)
local prompt = [[
Generate chat title for:
```
%s
```
Output only the title and nothing else in your response.
]]
chat.ask(prompt:format(response), {
callback = function(gen_response)
print(response)
end
})
end and setting that as default callback. but currently it also prints this to chat so there is no way to prevent that. but i can add option for not printing to chat. |
Beta Was this translation helpful? Give feedback.
-
@deathbeam awesome, will try it thank you |
Beta Was this translation helpful? Give feedback.
-
ok tried to add boolean config for not using chat and history, looks like it works (thats messages buffer at bottom) |
Beta Was this translation helpful? Give feedback.
-
local chat = require('CopilotChat')
vim.keymap.set({ 'n', 'v' }, '<leader>ax', function()
vim.g.chat_title = nil
chat.reset()
end)
chat.setup({
-- Your other configs etc...
callback = function(response)
if vim.g.chat_title then
chat.save(vim.g.chat_title)
return
end
local prompt = [[
Generate chat title in filepath-friendly format for:
```
%s
```
Output only the title and nothing else in your response.
]]
-- use AI to generate prompt title based on first AI response to user question
chat.ask(vim.trim(prompt:format(response)), {
headless = true, -- disable updating chat buffer and history with this question
callback = function(gen_response)
vim.g.chat_title = vim.trim(gen_response)
print('Chat title set to: ' .. vim.g.chat_title)
chat.save(vim.g.chat_title)
end
})
end,
}) ok here is working implementation. it saves the generated chat title to vim.g.chat_title. It also auto saves the chat under that title. It also adds custm keybind for copilot chat reset as you probably want to reset the title as well when you reset the chat. |
Beta Was this translation helpful? Give feedback.
-
@deathbeam Can this be a |
Beta Was this translation helpful? Give feedback.
-
Is it possible to take a generated title from the chat and use it to save the chat? Like something in zed.dev? Automatically save the chat using a generated title from the chat itself?
Beta Was this translation helpful? Give feedback.
All reactions