Skip to content

Saving chat using chat title #586

Answered by deathbeam
thezetrax asked this question in Q&A
Discussion options

You must be logged in to vote
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, --

Replies: 8 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by deathbeam
Comment options

You must be logged in to vote
3 replies
@deathbeam
Comment options

@thezetrax
Comment options

@deathbeam
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #551 on November 21, 2024 18:16.