From 13181dc32c17f29b1c438e80d6ffc4c1a4a372ec Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 22 Nov 2024 10:58:29 -0800 Subject: [PATCH] useTools option --- core/core.ts | 1 - core/index.d.ts | 1 + extensions/vscode/config_schema.json | 5 +++++ gui/src/components/mainInput/ContinueInputBox.tsx | 5 ++++- gui/src/context/IdeMessenger.ts | 3 +++ gui/src/hooks/useChatHandler.ts | 4 ++++ 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/core.ts b/core/core.ts index 897ba50cf..edb064afb 100644 --- a/core/core.ts +++ b/core/core.ts @@ -384,7 +384,6 @@ export class Core { const model = await configHandler.llmFromTitle(msg.data.title); if (msg.data.useTools) { - // Array.isArray(config.experimental?.allowTools)) { msg.data.completionOptions.tools = allTools; } diff --git a/core/index.d.ts b/core/index.d.ts index 647712f6a..8905e5646 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1158,6 +1158,7 @@ interface ExperimentalConfig { * This is needed to crawl a large number of documentation sites that are dynamically rendered. */ useChromiumForDocsCrawling?: boolean; + useTools?: boolean; } interface AnalyticsConfig { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 7edceced4..d5c9223a4 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3023,6 +3023,11 @@ "type": "boolean", "description": "Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`.", "default": false + }, + "useTools": { + "type": "boolean", + "description": "Allow tool use. Currently only supported with Claude 3.5 Sonnet", + "default": true } } } diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index 89ecab411..ce1ebd424 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -68,6 +68,9 @@ function ContinueInputBox(props: ContinueInputBoxProps) { const availableContextProviders = useSelector( (store: RootState) => store.state.config.contextProviders, ); + const useTools = useSelector( + (store: RootState) => store.state.config.experimental?.useTools, + ); useWebviewListener( "newSessionWithPrompt", @@ -108,7 +111,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) { availableSlashCommands={availableSlashCommands} historyKey="chat" toolbarOptions={{ - hideTools: true, + hideTools: !useTools, }} /> diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index 43fc7ef56..aea398feb 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -44,6 +44,7 @@ export interface IIdeMessenger { cancelToken: AbortSignal | undefined, messages: ChatMessage[], options?: LLMFullCompletionOptions, + useTools?: boolean, ): AsyncGenerator; ide: IDE; @@ -202,6 +203,7 @@ export class IdeMessenger implements IIdeMessenger { cancelToken: AbortSignal | undefined, messages: ChatMessage[], options: LLMFullCompletionOptions = {}, + useTools?: boolean, ): AsyncGenerator { const gen = this.streamRequest( "llm/streamChat", @@ -209,6 +211,7 @@ export class IdeMessenger implements IIdeMessenger { messages, title: modelTitle, completionOptions: options, + useTools, }, cancelToken, ); diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index 8fcbb2749..e3d557f61 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -63,6 +63,8 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const streamAborter = useSelector( (store: RootState) => store.state.streamAborter, ); + const useTools = useSelector((store: RootState) => store.uiState.useTools); + const activeRef = useRef(active); const { saveSession } = useHistory(dispatch); @@ -85,6 +87,8 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { defaultModel.title, streamAborter.signal, messages, + {}, + useTools, ); let next = await gen.next();