continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.01k stars 1.62k forks source link

Query input box stop working of custom content provider with config.ts after 0.8.47 of visual studio code and 0.0.64 #2223

Open simonz4031 opened 2 months ago

simonz4031 commented 2 months ago

Before submitting your bug report

Relevant environment info

- OS: Mac
- Continue: 0.0.68 on intellij and 0.8.48+ of visual studio code
- IDE: Both
- Model: Any
- config.ts:

const RagContextProvider: CustomContextProvider = {
  title: "rag",
  displayTitle: "RAG",
  description:
    "Retrieve snippets from our vector database of internal documents",

  getContextItems: async (
    query: string,
    extras: ContextProviderExtras,
  ): Promise<ContextItem[]> => {
    const response = await fetch("https://internal_rag_server.com/retrieve", {
      method: "POST",
      body: JSON.stringify({ query }),
    });

    const results = await response.json();

    return results.map((result) => ({
      name: result.title,
      description: result.title,
      content: result.contents,
    }));
  },
};

Description

No input box after select the custom content provider. but the 0.0.64 of idea and 0.8.47 of vsc works fine 0.8.47:

image

0.8.48+

To reproduce

  1. write a custom content provider with query of type
  2. install 0.8.48+ in vsc or 0.0.68 in idea
  3. Type @ and select the custom provider, no query input box shown up.

Log output

can't find log in console and output tab of continue
sestinj commented 2 months ago

@simonz4031 is this still happening on 0.8.51? I'm on a Mac on 0.8.51 and seem to be able to use the URL context provider ok. Wondering if any other details might help me reproduce

simonz4031 commented 2 months ago

@simonz4031 is this still happening on 0.8.51? I'm on a Mac on 0.8.51 and seem to be able to use the URL context provider ok. Wondering if any other details might help me reproduce

Yes, it still happened on 0.8.51, the predefined content provider like url able to show the query input box. only the custom content provider won't work, you can use the example in https://docs.continue.dev/customization/context-providers or use mini configuration something as

onst GitHubPRsContextProvider: CustomContextProvider = {
  title: "github-prs",
  displayTitle: "GitHub PRs",
  description: "Search and reference GitHub Pull Requests",
  type: "query",

  getContextItems: async (
    query: string,
    extras: ContextProviderExtras
  ): Promise<ContextItem[]> => {
    // For now, just return a dummy item to verify it's working
    return [{
      name: "Test PR",
      description: `Searched for: ${query}`,
      content: `This is a test PR for the query: ${query}`,
    }];
  },
};

export function modifyConfig(config: Config): Config {
  if (!config.contextProviders) {
    config.contextProviders = [];
  }
  config.contextProviders.push(GitHubPRsContextProvider);
  return config;
}