Continue offers several way to provide your custom context to the extension.
@HTTP
context provider to your configuration like this:
hello
endpoint in context_provider_server.py for an example that uses FastAPI.
The "options"
property can be used to send additional parameters to your endpoint. The full request body has the following shape:
config.ts
placed in your Continue global directory (~/.continue
for MacOS, %USERPROFILE%/.continue
for Windows). You can implement the CustomContextProvider
interface in your config.ts
getContextItems
must be an array of objects that have all of the following properties:
name
: The name of the context item, which will be displayed as a titledescription
: A longer description of the context itemcontent
: The actual content of the context item, which will be fed to the LLM as contextconfig.ts
like so:
~/.continue/config.ts
getContextItems
. To implement a “query” context provider, simply set "type": "query"
in your custom context provider object.
The “submenu” type is used when you want to display a list of searchable items in the dropdown. Built-in examples include “issue” and “folder”. To implement a “submenu” context provider, set "type": "submenu"
and implement the loadSubmenuItems
and getContextItems
functions. Here is an example that shows a list of all README files in the current workspace:
~/.continue/config.ts
@readme
and selects it from the dropdown, now displaying the submenu where they can search for any item returned by loadSubmenuItems
.id
of the chosen ContextSubmenuItem
is passed to getContextItems
as the query
argument. In this case it is the filepath of the README.getContextItems
function can then use the query
to retrieve the full contents of the README and format the content before returning the context item which will be included in the prompt.npm install <module_name>
from the ~/.continue
directory, and then import them in config.ts.
Continue will use esbuild to bundle your config.ts
and any dependencies into a single Javascript file. The exact configuration used can be found here.
CustomContextProvider
Referencetitle
: An identifier for the context provider
displayTitle
(optional): The title displayed in the dropdown
description
(optional): The longer description displayed in the dropdown when hovered
type
(optional): The type of context provider. Options are “normal”, “query”, and “submenu”. Defaults to “normal”.
renderInlineAs
(optional): The string that will be rendered inline at the top of the prompt. If no value is provided, the displayTitle
will be used. An empty string can be provided to prevent rendering the default displayTitle
.
getContextItems
: A function that returns the documents to include in the prompt. It should return a list of ContextItem
s, and is given access to the following arguments:
extras.fullInput
: A string representing the user’s full input to the text box. This can be used for example to generate an embedding to compare against a set of other embedded documentsextras.embeddingsProvider
: The embeddings provider has an embed
function that will convert text (such as fullInput
) to an embeddingextras.llm
: The current default LLM, which you can use to make completion requestsextras.ide
: An instance of the IDE
class, which lets you gather various sources of information from the IDE, including the contents of the terminal, the list of open files, or any warnings in the currently open file.query
: (not currently used) A string representing the queryloadSubmenuItems
(optional): A function that returns a list of ContextSubmenuItem
s to display in a submenu. It is given access to an IDE
, the same that is passed to getContextItems
. .
package.json
:
package.json
package.json
:
package.json
registerCustomContextProvider
function to register your context provider. Your custom context provider must implement the IContextProvider
interface. Here is an example:
myCustomContextProvider.ts
MyCustomProvider
with Continue!