isContextRequiredForChatQuery
There are predefined recipes you can click on
export const recipesList = {
'explain-code-detailed': 'Explain selected code (detailed)',
'explain-code-high-level': 'Explain selected code (high level)',
'generate-unit-test': 'Generate a unit test',
'generate-docstring': 'Generate a docstring',
'improve-variable-names': 'Improve variable names',
'translate-to-language': 'Translate to different language',
'git-history': 'Summarize recent code changes',
}
Each Recipe’s main method is getInteraction()
ChatQuestion is also a Recipe - that’s the freeform one
If isContextRequiredForChatQuery, then append codebaseContext.getContextMessages()
embeddings
(in VSC config). For this…
(context is split into multiple human messages followed by asst responding “Ok.”, truncated by token limit)
embeddings search (via Sourcegraph servers)
Snippets are included with:
const CODE_CONTEXT_TEMPLATE = `Use following code snippet from file \\`{filePath}\\`:
\\`\\`\\`{language}
{text}
\\`\\`\\``
There’s also slightly different handling of markdown
If code or editor context required (determined from regex for “current file” etc.), then append getEditorContext()
const CURRENT_EDITOR_CODE_TEMPLATE = `I have the \\`{filePath}\\` file opened in my editor. You are able to answer questions about \\`{filePath}\\`. The following code snippet is from the currently open file in my editor \\`{filePath}\\`:
\\`\\`\\`{language}
{text}
\\`\\`\\``
Another example: GenerateTest
human:
`Generate a unit test in ${languageName} for the following code:\\n\\`\\`\\`${extension}\\n${truncatedSelectedText}\\n\\`\\`\\`\\n${MARKDOWN_FORMAT_PROMPT}`
asst:
`Here is the generated unit test:\\n\\`\\`\\`${extension}\\n`
getContextMessagesFromSelection: include similar snippets search for selection (codebase context), and include selection, using the standard codebase context stuff
Interaction(human, asst, context) = […context, human, asst]
Searches and sources are from Sourcegraph server, so it may be different from what’s local