From 928e73d5d3e6f2fa122fd429e90984da83382835 Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Tue, 17 Sep 2024 20:46:40 -0700 Subject: [PATCH 01/15] fix-aws-expired-profile --- core/indexing/embeddings/BedrockEmbeddingsProvider.ts | 3 ++- core/llm/llms/Bedrock.ts | 1 + core/llm/llms/BedrockImport.ts | 3 ++- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/indexing/embeddings/BedrockEmbeddingsProvider.ts b/core/indexing/embeddings/BedrockEmbeddingsProvider.ts index aa9e8bd41..bf3bcac88 100644 --- a/core/indexing/embeddings/BedrockEmbeddingsProvider.ts +++ b/core/indexing/embeddings/BedrockEmbeddingsProvider.ts @@ -78,7 +78,8 @@ class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { try { return await fromIni({ - profile: this.profile + profile: this.profile, + ignoreCache: true })(); } catch (e) { console.warn( diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index db2603c03..485b87015 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -153,6 +153,7 @@ class Bedrock extends BaseLLM { try { return await fromIni({ profile: this.profile, + ignoreCache: true })(); } catch (e) { console.warn( diff --git a/core/llm/llms/BedrockImport.ts b/core/llm/llms/BedrockImport.ts index f53d4b15e..a265c7679 100644 --- a/core/llm/llms/BedrockImport.ts +++ b/core/llm/llms/BedrockImport.ts @@ -82,7 +82,8 @@ class BedrockImport extends BaseLLM { try { return await fromIni({ - profile: this.profile + profile: this.profile, + ignoreCache: true })(); } catch (e) { console.warn( diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8bb784a0e..37235f0fc 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.211", + "version": "0.9.212", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.211", + "version": "0.9.212", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9277bd90e..5c712d2b5 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.211", + "version": "0.9.212", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From dcf5e71358028f22ec615c7494365c5f9df0045a Mon Sep 17 00:00:00 2001 From: mq200 Date: Tue, 17 Sep 2024 21:30:33 -0700 Subject: [PATCH 02/15] watsonx - randomness parameters + remove extra params in deployment request --- core/llm/llms/WatsonX.ts | 89 ++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/core/llm/llms/WatsonX.ts b/core/llm/llms/WatsonX.ts index 68dfef47c..c479f8f98 100644 --- a/core/llm/llms/WatsonX.ts +++ b/core/llm/llms/WatsonX.ts @@ -20,8 +20,8 @@ class WatsonX extends BaseLLM { super(options); } async getBearerToken(): Promise<{ token: string; expiration: number }> { - if ( + this.watsonxFullUrl?.includes("cloud.ibm.com") || this.watsonxUrl?.includes("cloud.ibm.com") ) { // watsonx SaaS @@ -43,14 +43,12 @@ class WatsonX extends BaseLLM { }; } else { // watsonx Software - if ( - !this.watsonxCreds?.includes(":") - ) { - // Using ZenApiKey auth - return { - token: this.watsonxCreds ?? "", - expiration: -1, - }; + if (!this.watsonxCreds?.includes(":")) { + // Using ZenApiKey auth + return { + token: this.watsonxCreds ?? "", + expiration: -1, + }; } else { // Using username/password auth const userPass = this.watsonxCreds?.split(":"); @@ -84,6 +82,13 @@ class WatsonX extends BaseLLM { } } + getWatsonxEndpoint(): string { + return ( + this.watsonxFullUrl ?? + `${this.watsonxUrl}/ml/v1/text/generation_stream?version=${this.watsonxApiVersion}` + ); + } + static providerName: ModelProvider = "watsonx"; protected _convertMessage(message: ChatMessage) { @@ -128,9 +133,8 @@ class WatsonX extends BaseLLM { protected _getHeaders() { return { "Content-Type": "application/json", - Authorization: `${ - watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer" - } ${watsonxConfig.accessToken.token}`, + Authorization: `${watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer" + } ${watsonxConfig.accessToken.token}`, }; } @@ -174,8 +178,7 @@ class WatsonX extends BaseLLM { watsonxConfig.accessToken = await this.getBearerToken(); } else { console.log( - `Reusing token (expires in ${ - (watsonxConfig.accessToken.expiration - now) / 60 + `Reusing token (expires in ${(watsonxConfig.accessToken.expiration - now) / 60 } mins)`, ); } @@ -186,31 +189,38 @@ class WatsonX extends BaseLLM { const stopToken = this.watsonxStopToken ?? (options.model?.includes("granite") ? "<|im_end|>" : undefined); - var response = await this.fetch( - `${this.watsonxUrl}/ml/v1/text/generation_stream?version=${this.watsonxApiVersion}`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `${ - watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer" - } ${watsonxConfig.accessToken.token}`, - }, - body: JSON.stringify({ - input: messages[messages.length - 1].content, - parameters: { - decoding_method: "greedy", - max_new_tokens: options.maxTokens ?? 1024, - min_new_tokens: 1, - stop_sequences: stopToken ? [stopToken] : [], - include_stop_sequence: false, - repetition_penalty: 1, - }, - model_id: options.model, - project_id: this.watsonxProjectId - }), - }, - ); + const url = this.getWatsonxEndpoint(); + const headers = this._getHeaders(); + + const parameters = { + decoding_method: "greedy", + max_new_tokens: options.maxTokens ?? 1024, + min_new_tokens: 1, + stop_sequences: stopToken ? [stopToken] : [], + include_stop_sequence: false, + repetition_penalty: 1, + }; + if (!!options.temperature) { + parameters.decoding_method = "sample"; + parameters.temperature = options.temperature; + parameters.top_p = options.topP || 1; + parameters.top_k = options.topK; + } + + const payload = { + input: messages[messages.length - 1].content, + parameters: parameters, + }; + if (!this.watsonxFullUrl) { + payload.model_id = options.model; + payload.project_id = this.watsonxProjectId; + } + + var response = await this.fetch(url, { + method: "POST", + headers: headers, + body: JSON.stringify(payload), + }); if (!response.ok || response.body === null) { throw new Error( @@ -218,7 +228,6 @@ class WatsonX extends BaseLLM { ); } else { for await (const value of streamResponse(response)) { - const lines = value.split("\n"); let generatedChunk = ""; let generatedTextIndex = undefined; From 8bd1a42e27c79c1c2c6eb0c1b5341fa75daf0af5 Mon Sep 17 00:00:00 2001 From: mq200 Date: Tue, 17 Sep 2024 21:31:59 -0700 Subject: [PATCH 03/15] watsonx - default top p set to 1.0 --- core/llm/llms/WatsonX.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/WatsonX.ts b/core/llm/llms/WatsonX.ts index c479f8f98..4e0b690b4 100644 --- a/core/llm/llms/WatsonX.ts +++ b/core/llm/llms/WatsonX.ts @@ -203,7 +203,7 @@ class WatsonX extends BaseLLM { if (!!options.temperature) { parameters.decoding_method = "sample"; parameters.temperature = options.temperature; - parameters.top_p = options.topP || 1; + parameters.top_p = options.topP || 1.0; parameters.top_k = options.topK; } From af89900c2c68f65609b7f41abb98ff3cc771ffd4 Mon Sep 17 00:00:00 2001 From: mq200 Date: Thu, 19 Sep 2024 15:54:27 -0700 Subject: [PATCH 04/15] watsonx - add any types typescript --- core/llm/llms/WatsonX.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/WatsonX.ts b/core/llm/llms/WatsonX.ts index 4e0b690b4..d9b61a3f1 100644 --- a/core/llm/llms/WatsonX.ts +++ b/core/llm/llms/WatsonX.ts @@ -192,7 +192,7 @@ class WatsonX extends BaseLLM { const url = this.getWatsonxEndpoint(); const headers = this._getHeaders(); - const parameters = { + const parameters: any = { decoding_method: "greedy", max_new_tokens: options.maxTokens ?? 1024, min_new_tokens: 1, @@ -207,7 +207,7 @@ class WatsonX extends BaseLLM { parameters.top_k = options.topK; } - const payload = { + const payload: any = { input: messages[messages.length - 1].content, parameters: parameters, }; From 4f8026dd200f41cc4e0070c4fd14a7c19e24da54 Mon Sep 17 00:00:00 2001 From: Lester Hairston Date: Thu, 19 Sep 2024 19:27:36 -0500 Subject: [PATCH 05/15] groq gemma 2 update --- core/config/types.ts | 2 ++ core/index.d.ts | 2 ++ core/llm/llms/Groq.ts | 1 + extensions/intellij/src/main/resources/config_schema.json | 1 + extensions/vscode/config_schema.json | 1 + extensions/vscode/continue_rc_schema.json | 1 + 6 files changed, 8 insertions(+) diff --git a/core/config/types.ts b/core/config/types.ts index e69c312ab..c571b44df 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -647,6 +647,8 @@ declare global { | "deepseek-7b" | "deepseek-33b" | "neural-chat-7b" + | "gemma-7b-it" + | "gemma2-9b-it" // Anthropic | "claude-3-5-sonnet-20240620" | "claude-3-opus-20240229" diff --git a/core/index.d.ts b/core/index.d.ts index 0c7c9b521..16c48a3ad 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -691,6 +691,8 @@ export type ModelName = | "deepseek-7b" | "deepseek-33b" | "neural-chat-7b" + | "gemma-7b-it" + | "gemma2-9b-it" // Anthropic | "claude-3-5-sonnet-20240620" | "claude-3-opus-20240229" diff --git a/core/llm/llms/Groq.ts b/core/llm/llms/Groq.ts index 7115bcc32..bc05263c9 100644 --- a/core/llm/llms/Groq.ts +++ b/core/llm/llms/Groq.ts @@ -12,6 +12,7 @@ class Groq extends OpenAI { "llama2-70b": "llama2-70b-4096", "mistral-8x7b": "mixtral-8x7b-32768", gemma: "gemma-7b-it", + gemma2: "gemma2-9b-it", "llama3-8b": "llama3-8b-8192", "llama3-70b": "llama3-70b-8192", "llama3.1-8b": "llama-3.1-8b-instant", diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 911278ebb..5a20c6daf 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1044,6 +1044,7 @@ "llama2-70b", "mistral-8x7b", "gemma", + "gemma2", "llama3-8b", "llama3-70b", "llama3.1-8b", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 911278ebb..5a20c6daf 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1044,6 +1044,7 @@ "llama2-70b", "mistral-8x7b", "gemma", + "gemma2", "llama3-8b", "llama3-70b", "llama3.1-8b", diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 101296fe6..7a7e54764 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1149,6 +1149,7 @@ "llama2-70b", "mistral-8x7b", "gemma", + "gemma2", "llama3-8b", "llama3-70b", "llama3.1-8b", From 6419cb0dfadfbc20050a278777498b1e4083401f Mon Sep 17 00:00:00 2001 From: YouJiacheng <1503679330@qq.com> Date: Fri, 20 Sep 2024 15:39:14 +0800 Subject: [PATCH 06/15] chore: add maxBatchSize to config_schema.json --- extensions/vscode/config_schema.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 911278ebb..b15b81f48 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2114,6 +2114,13 @@ "minimum": 128, "exclusiveMaximum": 2147483647 }, + "maxBatchSize": { + "title": "Maximum Batch Size", + "description": "The maximum number of chunks that can be sent to the embeddings provider in a single request", + "type": "integer", + "minimum": 1, + "exclusiveMaximum": 2147483647 + }, "region": { "title": "Region", "description": "The region where the model is hosted", From ebbc2fd55df1fc43e1eacceba042fa4c0bc38e77 Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 20 Sep 2024 13:46:26 -0700 Subject: [PATCH 07/15] fix: use exponential backoff when checking ollama --- .../OnboardingCard/hooks/useCheckOllamaModels.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts b/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts index e763c0d9a..7a3205627 100644 --- a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts +++ b/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts @@ -1,6 +1,7 @@ import { useContext, useEffect } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding"; +import { withExponentialBackoff } from "core/util/withExponentialBackoff"; const CHECK_OLLAMA_CONNECTION_INTERVAL = 1000; @@ -11,9 +12,11 @@ export const useCheckOllamaModels = ( useEffect(() => { const fetchDownloadedModels = async () => { - const result = (await ideMessenger.request("llm/listModels", { - title: ONBOARDING_LOCAL_MODEL_TITLE, - })) as any; + const result = await withExponentialBackoff(() => + ideMessenger.request("llm/listModels", { + title: ONBOARDING_LOCAL_MODEL_TITLE, + }) + ); if (result.status === "success") { const models = result.content; From 8b836ebd4c09178efb76611d11fd6a076487c2be Mon Sep 17 00:00:00 2001 From: Yuya Kanai <14835424+Cactice@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:14:49 +0900 Subject: [PATCH 08/15] Update autocomplete.md --- docs/docs/customize/deep-dives/autocomplete.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index c84523f54..49c2de949 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -119,7 +119,7 @@ To ensure that you receive multi-line completions, you can set `"multilineComple Yes, in VS Code, if you don't want to be shown suggestions automatically you can: -1. Set `"editor.inlineSuggest.enabled": false` in VS Code settings to disabe automatic suggestions +1. Set `"editor.inlineSuggest.enabled": false` in VS Code settings to disable automatic suggestions 2. Open "Keyboard Shortcuts" (cmd/ctrl+k, cmd/ctrl+s) and search for `editor.action.inlineSuggest.trigger` 3. Click the "+" icon to add a new keybinding 4. Press the key combination you want to use to trigger suggestions (e.g. `ctrl+space`) From cd93dbf1564a86ddc336402341fda27ba7086ba0 Mon Sep 17 00:00:00 2001 From: Test Date: Sat, 21 Sep 2024 09:27:27 -0700 Subject: [PATCH 09/15] WIP: Exponential backoff for ollama --- .../customize/model-types/autocomplete.md | 2 +- .../components/OllamaStatus.tsx | 16 +++--- .../hooks/useCheckOllamaModels.ts | 52 ++++++++++++------- .../tabs/OnboardingLocalTab.tsx | 7 +-- gui/src/components/OnboardingCard/utils.ts | 2 +- gui/src/components/index.ts | 4 ++ 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index a21f6be87..8ecac28e6 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -7,7 +7,7 @@ sidebar_position: 1 An "autocomplete model" is an LLM that is trained on a special format called fill-in-the-middle (FIM). This format is designed to be given the prefix and suffix of a code file and predict what goes between. This task is very specific, which on one hand means that the models can be smaller (even a 3B parameter model can perform well). On the other hand, this means that Chat models, though larger, will perform poorly. -In Continue, these models are used to display inline [Autocomplete](../../chat/how-to-use-it.md) suggestions as you type. +In Continue, these models are used to display inline [Autocomplete](../../autocomplete/how-to-use-it.md) suggestions as you type. ## Recommended Autocomplete models diff --git a/gui/src/components/OnboardingCard/components/OllamaStatus.tsx b/gui/src/components/OnboardingCard/components/OllamaStatus.tsx index 546ddff5d..9cc323ec6 100644 --- a/gui/src/components/OnboardingCard/components/OllamaStatus.tsx +++ b/gui/src/components/OnboardingCard/components/OllamaStatus.tsx @@ -5,31 +5,27 @@ import { import { useState, useContext } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { providers } from "../../../pages/AddNewModel/configs/providers"; -import { useCheckOllamaModels } from "../hooks/useCheckOllamaModels"; import { StyledActionButton } from "../.."; import OllamaCompletedStep from "./OllamaCompletedStep"; import { OllamaConnectionStatuses } from "../utils"; interface OllamaStatusProps { - onConnectionVerified: () => void; + isOllamaConnected: boolean; } const { ollama: { downloadUrl }, } = providers; -export function OllamaStatus({ onConnectionVerified }: OllamaStatusProps) { +export function OllamaStatus({ isOllamaConnected }: OllamaStatusProps) { const ideMessenger = useContext(IdeMessengerContext); const [status, setStatus] = useState( - OllamaConnectionStatuses.WaitingToDownload, + isOllamaConnected + ? OllamaConnectionStatuses.Connected + : OllamaConnectionStatuses.WaitingToDownload, ); - useCheckOllamaModels((models) => { - setStatus(OllamaConnectionStatuses.Verified); - onConnectionVerified(); - }); - function onClickDownload() { ideMessenger.post("openUrl", downloadUrl); setStatus(OllamaConnectionStatuses.Downloading); @@ -52,7 +48,7 @@ export function OllamaStatus({ onConnectionVerified }: OllamaStatusProps) { ); - case OllamaConnectionStatuses.Verified: + case OllamaConnectionStatuses.Connected: return ( ); diff --git a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts b/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts index 7a3205627..21bafe384 100644 --- a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts +++ b/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts @@ -1,43 +1,57 @@ -import { useContext, useEffect } from "react"; +import { useContext, useEffect, useRef } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding"; -import { withExponentialBackoff } from "core/util/withExponentialBackoff"; -const CHECK_OLLAMA_CONNECTION_INTERVAL = 1000; +const MAX_RETRIES = 10; +const INITIAL_DELAY = 1000; export const useCheckOllamaModels = ( onDownloadedModels: (models: string[]) => void, ) => { const ideMessenger = useContext(IdeMessengerContext); + const retryCountRef = useRef(0); + const timeoutRef = useRef(null); useEffect(() => { const fetchDownloadedModels = async () => { - const result = await withExponentialBackoff(() => - ideMessenger.request("llm/listModels", { + try { + const result = (await ideMessenger.request("llm/listModels", { title: ONBOARDING_LOCAL_MODEL_TITLE, - }) - ); + })) as any; - if (result.status === "success") { - const models = result.content; + if (result.status === "success") { + const models = result.content; - if (Array.isArray(models)) { - onDownloadedModels(models); - clearInterval(interval); + if (Array.isArray(models)) { + onDownloadedModels(models); + return; + } + } + + throw new Error("Failed to fetch models"); + } catch (error) { + if (retryCountRef.current < MAX_RETRIES) { + const delay = INITIAL_DELAY * Math.pow(2, retryCountRef.current); + console.debug( + `Failed to connect to Ollama - retrying in ${delay}ms...`, + ); + timeoutRef.current = setTimeout(() => { + retryCountRef.current += 1; + fetchDownloadedModels(); + }, delay); + } else { + console.debug( + `Max retries (${MAX_RETRIES}) reached. Unable to fetch Ollama models.`, + ); } } }; fetchDownloadedModels(); - const interval = setInterval( - fetchDownloadedModels, - CHECK_OLLAMA_CONNECTION_INTERVAL, - ); - return () => { - if (interval) { - clearInterval(interval); + if (timeoutRef.current) { + clearTimeout(timeoutRef.current); } }; }, [ideMessenger, onDownloadedModels]); diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx index 03d940163..96753c59e 100644 --- a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx @@ -54,17 +54,14 @@ function OnboardingLocalTab() { useCheckOllamaModels((models) => { setDownloadedOllamaModels(models); - }); - - function onConnectionVerified() { setIsOllamaConnected(true); - } + }); return (

Install Ollama

- +
Date: Sun, 22 Sep 2024 20:03:51 -0700 Subject: [PATCH 10/15] check ollama status every 3s --- .../components/OnboardingCard/hooks/index.ts | 2 +- .../hooks/useCheckOllamaModels.ts | 58 ------------------- .../tabs/OnboardingLocalTab.tsx | 36 ++++++++++-- 3 files changed, 32 insertions(+), 64 deletions(-) delete mode 100644 gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts diff --git a/gui/src/components/OnboardingCard/hooks/index.ts b/gui/src/components/OnboardingCard/hooks/index.ts index 88f66d231..f2340f5f6 100644 --- a/gui/src/components/OnboardingCard/hooks/index.ts +++ b/gui/src/components/OnboardingCard/hooks/index.ts @@ -1,2 +1,2 @@ -export * from "./useCheckOllamaModels"; export * from "./useSubmitOnboarding"; +export * from "./useOnboardingCard"; diff --git a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts b/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts deleted file mode 100644 index 21bafe384..000000000 --- a/gui/src/components/OnboardingCard/hooks/useCheckOllamaModels.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { useContext, useEffect, useRef } from "react"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding"; - -const MAX_RETRIES = 10; -const INITIAL_DELAY = 1000; - -export const useCheckOllamaModels = ( - onDownloadedModels: (models: string[]) => void, -) => { - const ideMessenger = useContext(IdeMessengerContext); - const retryCountRef = useRef(0); - const timeoutRef = useRef(null); - - useEffect(() => { - const fetchDownloadedModels = async () => { - try { - const result = (await ideMessenger.request("llm/listModels", { - title: ONBOARDING_LOCAL_MODEL_TITLE, - })) as any; - - if (result.status === "success") { - const models = result.content; - - if (Array.isArray(models)) { - onDownloadedModels(models); - return; - } - } - - throw new Error("Failed to fetch models"); - } catch (error) { - if (retryCountRef.current < MAX_RETRIES) { - const delay = INITIAL_DELAY * Math.pow(2, retryCountRef.current); - console.debug( - `Failed to connect to Ollama - retrying in ${delay}ms...`, - ); - timeoutRef.current = setTimeout(() => { - retryCountRef.current += 1; - fetchDownloadedModels(); - }, delay); - } else { - console.debug( - `Max retries (${MAX_RETRIES}) reached. Unable to fetch Ollama models.`, - ); - } - } - }; - - fetchDownloadedModels(); - - return () => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - } - }; - }, [ideMessenger, onDownloadedModels]); -}; diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx index 96753c59e..5dab35f7b 100644 --- a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx @@ -13,7 +13,9 @@ import { hasPassedFTL } from "../../../util/freeTrial"; import AddModelButtonSubtext from "../../AddModelButtonSubtext"; import OllamaModelDownload from "../components/OllamaModelDownload"; import { OllamaStatus } from "../components/OllamaStatus"; -import { useCheckOllamaModels, useSubmitOnboarding } from "../hooks"; +import { useSubmitOnboarding } from "../hooks"; + +const OLLAMA_CHECK_INTERVAL_MS = 3000; function OnboardingLocalTab() { const dispatch = useDispatch(); @@ -52,10 +54,34 @@ function OnboardingLocalTab() { } }, [downloadedOllamaModels, isOllamaConnected]); - useCheckOllamaModels((models) => { - setDownloadedOllamaModels(models); - setIsOllamaConnected(true); - }); + useEffect(() => { + const fetchDownloadedModels = async () => { + try { + const result = (await ideMessenger.request("llm/listModels", { + title: ONBOARDING_LOCAL_MODEL_TITLE, + })) as any; + + if (result.status === "success" && Array.isArray(result.content)) { + setDownloadedOllamaModels(result.content); + setIsOllamaConnected(true); + } else { + throw new Error("Failed to fetch models"); + } + } catch (error) { + console.error("Error fetching models:", error); + setIsOllamaConnected(false); + } + }; + + const intervalId = setInterval( + fetchDownloadedModels, + OLLAMA_CHECK_INTERVAL_MS, + ); + + fetchDownloadedModels(); + + return () => clearInterval(intervalId); + }, []); return (
From fa3afd52e766c298a9bfa62c57e8a9b6e695b1d6 Mon Sep 17 00:00:00 2001 From: lolikung Date: Mon, 23 Sep 2024 14:56:07 +0800 Subject: [PATCH 11/15] fix: config-types "useSuffix" to "useFileSuffix" --- packages/config-types/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index 822312969..14ff2b4bd 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -128,7 +128,7 @@ export type UiOptions = z.infer; export const tabAutocompleteOptionsSchema = z.object({ disable: z.boolean(), useCopyBuffer: z.boolean(), - useSuffix: z.boolean(), + useFileSuffix: z.boolean(), maxPromptTokens: z.number(), debounceDelay: z.number(), maxSuffixPercentage: z.number(), From 7f214adcbdca33ebb7270f721fd57eeeb0bac1e8 Mon Sep 17 00:00:00 2001 From: Shigma Date: Mon, 23 Sep 2024 18:02:31 +0800 Subject: [PATCH 12/15] fix: fix 100% indexing progress --- core/core.ts | 2 +- core/indexing/CodebaseIndexer.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/core.ts b/core/core.ts index f33ab17d4..3e5129a62 100644 --- a/core/core.ts +++ b/core/core.ts @@ -140,7 +140,7 @@ export class Core { // Respect pauseCodebaseIndexOnStart user settings if (ideSettings.pauseCodebaseIndexOnStart) { await this.messenger.request("indexProgress", { - progress: 100, + progress: 1, desc: "Initial Indexing Skipped", status: "paused", }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index bc53539f4..bf16b2a5d 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -249,10 +249,11 @@ export class CodebaseIndexer { } } yield { - progress: 100, + progress: 1, desc: "Indexing Complete", status: "done", }; + this.logProgress(beginTime, 0, 1); } private handleErrorAndGetProgressUpdate( From 2376dafce325c87d87090e7cf995beffcb98d3b4 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 23 Sep 2024 11:33:35 -0700 Subject: [PATCH 13/15] feat: improve prompt log formatting + detail --- core/llm/index.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index ff950929e..fd36222c9 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -262,16 +262,29 @@ export abstract class BaseLLM implements ILLM { prompt: string, completionOptions: CompletionOptions, ): string { - const dict = { contextLength: this.contextLength, ...completionOptions }; - const settings = Object.entries(dict) - .map(([key, value]) => `${key}: ${value}`) - .join("\n"); - return `Settings: -${settings} + const completionOptionsLog = JSON.stringify( + { + contextLength: this.contextLength, + ...completionOptions, + }, + null, + 2, + ); -############################################ + let requestOptionsLog = ""; + if (this.requestOptions) { + requestOptionsLog = JSON.stringify(this.requestOptions, null, 2); + } -${prompt}`; + return ( + "##### Completion options #####\n" + + completionOptionsLog + + (requestOptionsLog + ? "\n\n##### Request options #####\n" + requestOptionsLog + : "") + + "\n\n##### Prompt #####\n" + + prompt + ); } private _logTokensGenerated( @@ -703,9 +716,6 @@ ${prompt}`; this.providerName, autodetectTemplateType(this.model), ); - if (!templateMessages) { - return rendered; - } return templateMessages(rendered); } return rendered; From 9f426035bcca9d8f628533a0183d2455644d48c2 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 23 Sep 2024 11:54:42 -0700 Subject: [PATCH 14/15] Update context-providers.md --- docs/docs/customize/context-providers.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/docs/customize/context-providers.md b/docs/docs/customize/context-providers.md index daed6d63b..c186171f9 100644 --- a/docs/docs/customize/context-providers.md +++ b/docs/docs/customize/context-providers.md @@ -380,7 +380,13 @@ Reference table schemas from Sqlite, Postgres, and MySQL databases. } ``` -Each connection should include a unique name, the connection_type (e.g., postgres, sqlite), and the necessary connection parameters specific to each database type. +Each connection should include a unique name, the `connection_type`, and the necessary connection parameters specific to each database type. + +Available connection types: + +- `postgres` +- `mysql` +- `sqlite` ### `@Locals` From 666f4648f97fc066cb28ab50b83e4d7f2bdea905 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 23 Sep 2024 11:59:43 -0700 Subject: [PATCH 15/15] Update autodetect.ts --- core/llm/autodetect.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index e87e7417e..31eccfc8f 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -74,6 +74,7 @@ const MODEL_SUPPORTS_IMAGES: string[] = [ "sonnet", "opus", "haiku", + "pixtral", ]; function modelSupportsImages(