Skip to content

Commit 0156409

Browse files
feat: use s3 for global docs cache on all docs
1 parent 70e443e commit 0156409

File tree

12 files changed

+153
-576
lines changed

12 files changed

+153
-576
lines changed

CONTRIBUTING.md

-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
- [Writing Context Providers](#writing-context-providers)
2727
- [Adding an LLM Provider](#adding-an-llm-provider)
2828
- [Adding Models](#adding-models)
29-
- [Adding Pre-indexed Documentation](#adding-pre-indexed-documentation)
3029
- [📐 Continue Architecture](#-continue-architecture)
3130
- [Continue VS Code Extension](#continue-vs-code-extension)
3231
- [Continue JetBrains Extension](#continue-jetbrains-extension)
@@ -212,10 +211,6 @@ While any model that works with a supported provider can be used with Continue,
212211
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models).
213212
- [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates.
214213

215-
### Adding Pre-indexed Documentation
216-
217-
Continue's @docs context provider lets you easily reference entire documentation sites and then uses embeddings to add the most relevant pages to context. To make the experience as smooth as possible, we pre-index many of the most popular documentation sites. If you'd like to add new documentation to this list, just add an object to the list in [preIndexedDocs.ts](./core/indexing/docs/preIndexedDocs.ts). `startUrl` is where the crawler will start and `rootUrl` will filter out any pages not on that site and under the path of `rootUrl`.
218-
219214
## 📐 Continue Architecture
220215

221216
Continue consists of 2 parts that are split so that it can be extended to work in other IDEs as easily as possible:

core/context/providers/DocsContextProvider.ts

+9-45
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
LoadSubmenuItemsArgs,
1010
} from "../..";
1111
import DocsService from "../../indexing/docs/DocsService";
12-
import preIndexedDocs from "../../indexing/docs/preIndexedDocs";
1312

1413
import { INSTRUCTIONS_BASE_ITEM } from "./utils";
1514

@@ -64,23 +63,12 @@ class DocsContextProvider extends BaseContextProvider {
6463
return chunksCopy;
6564
}
6665

67-
private _sortByPreIndexedDocs(
66+
private _sortAlphabetically(
6867
submenuItems: ContextSubmenuItem[],
6968
): ContextSubmenuItem[] {
70-
// Sort submenuItems such that the objects with titles which don't occur in configs occur first, and alphabetized
69+
// Sort submenu items alphabetically by title
7170
return submenuItems.sort((a, b) => {
72-
const aTitleInConfigs = a.metadata?.preIndexed ?? false;
73-
const bTitleInConfigs = b.metadata?.preIndexed ?? false;
74-
75-
// Primary criterion: Items not in configs come first
76-
if (!aTitleInConfigs && bTitleInConfigs) {
77-
return -1;
78-
} else if (aTitleInConfigs && !bTitleInConfigs) {
79-
return 1;
80-
} else {
81-
// Secondary criterion: Alphabetical order when both items are in the same category
82-
return a.title.toString().localeCompare(b.title.toString());
83-
}
71+
return a.title.toString().localeCompare(b.title.toString());
8472
});
8573
}
8674

@@ -165,46 +153,22 @@ class DocsContextProvider extends BaseContextProvider {
165153
}
166154
await docsService.isInitialized;
167155

168-
// Create map of docs url -> submenu item
169-
const submenuItemsMap = new Map<string, ContextSubmenuItem>();
156+
// Create an array to hold submenu items
157+
const submenuItems: ContextSubmenuItem[] = [];
170158

171-
// Add custom docs from config
159+
// Get all indexed docs from the database
172160
const docs = (await docsService.listMetadata()) ?? [];
173161
for (const { startUrl, title, favicon } of docs) {
174-
submenuItemsMap.set(startUrl, {
162+
submenuItems.push({
175163
title,
176164
id: startUrl,
177165
description: new URL(startUrl).hostname,
178166
icon: favicon,
179167
});
180168
}
181169

182-
// Add pre-indexed docs if supported
183-
const canUsePreindexedDocs = await docsService.canUsePreindexedDocs();
184-
if (canUsePreindexedDocs) {
185-
for (const { startUrl, title } of Object.values(preIndexedDocs)) {
186-
// Skip if overridden in config
187-
if (docs.find((d) => d.startUrl === startUrl)) {
188-
continue;
189-
}
190-
submenuItemsMap.set(startUrl, {
191-
title,
192-
id: startUrl,
193-
description: new URL(startUrl).hostname,
194-
metadata: {
195-
preIndexed: true,
196-
},
197-
});
198-
}
199-
}
200-
201-
// Create array and sort if pre-indexed is supported
202-
const submenuItems = Array.from(submenuItemsMap.values());
203-
if (canUsePreindexedDocs) {
204-
return this._sortByPreIndexedDocs(submenuItems);
205-
}
206-
207-
return submenuItems;
170+
// Sort alphabetically
171+
return this._sortAlphabetically(submenuItems);
208172
}
209173
}
210174

core/index.d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ export interface ILLM extends LLMOptions {
164164
}
165165

166166
export interface ModelInstaller {
167-
installModel(modelName: string, signal: AbortSignal, progressReporter?: (task: string, increment: number, total: number) => void): Promise<any>;
167+
installModel(
168+
modelName: string,
169+
signal: AbortSignal,
170+
progressReporter?: (task: string, increment: number, total: number) => void,
171+
): Promise<any>;
168172
}
169173

170174
export type ContextProviderType = "normal" | "query" | "submenu";
@@ -240,7 +244,6 @@ export interface DocsIndexingDetails {
240244
config: SiteIndexingConfig;
241245
indexingStatus: IndexingStatus | undefined;
242246
chunks: Chunk[];
243-
isPreIndexedDoc: boolean;
244247
}
245248

246249
export interface IContextProvider {

0 commit comments

Comments
 (0)