Chat Tools API (#213273)

* Implement a chat skills API

* Move around

* Rename to 'tools' and make variables part of it

* Updates

* value

* Differentiate 'tool invocation' and 'reference'

* Just one interface, ChatReference

* dts updates

* Rename "skills" to "tools"

* Fix up

* Add static registration of tools

* string

* Updates

* Fix

* Rename 'chat' in API

* Rename "chatTool"
This commit is contained in:
Rob Lourens
2024-06-18 16:38:20 -07:00
committed by GitHub
parent 5acb82336f
commit 88b4dc75bd
10 changed files with 367 additions and 2 deletions

View File

@@ -107,6 +107,7 @@ import { checkProposedApiEnabled, isProposedApiEnabled } from 'vs/workbench/serv
import { ProxyIdentifier } from 'vs/workbench/services/extensions/common/proxyIdentifier';
import { TextSearchCompleteMessageType } from 'vs/workbench/services/search/common/searchExtTypes';
import type * as vscode from 'vscode';
import { ExtHostLanguageModelTools } from 'vs/workbench/api/common/extHostLanguageModelTools';
export interface IExtensionRegistries {
mine: ExtensionDescriptionRegistry;
@@ -211,6 +212,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
rpcProtocol.set(ExtHostContext.ExtHostInteractive, new ExtHostInteractive(rpcProtocol, extHostNotebook, extHostDocumentsAndEditors, extHostCommands, extHostLogService));
const extHostChatAgents2 = rpcProtocol.set(ExtHostContext.ExtHostChatAgents2, new ExtHostChatAgents2(rpcProtocol, extHostLogService, extHostCommands, initData.quality));
const extHostChatVariables = rpcProtocol.set(ExtHostContext.ExtHostChatVariables, new ExtHostChatVariables(rpcProtocol));
const extHostLanguageModelTools = rpcProtocol.set(ExtHostContext.ExtHostLanguageModelTools, new ExtHostLanguageModelTools(rpcProtocol));
const extHostAiRelatedInformation = rpcProtocol.set(ExtHostContext.ExtHostAiRelatedInformation, new ExtHostRelatedInformation(rpcProtocol));
const extHostAiEmbeddingVector = rpcProtocol.set(ExtHostContext.ExtHostAiEmbeddingVector, new ExtHostAiEmbeddingVector(rpcProtocol));
const extHostStatusBar = rpcProtocol.set(ExtHostContext.ExtHostStatusBar, new ExtHostStatusBar(rpcProtocol, extHostCommands.converter));
@@ -1436,7 +1438,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
createDynamicChatParticipant(id: string, dynamicProps: vscode.DynamicChatParticipantProps, handler: vscode.ChatExtendedRequestHandler): vscode.ChatParticipant {
checkProposedApiEnabled(extension, 'chatParticipantPrivate');
return extHostChatAgents2.createDynamicChatAgent(extension, id, dynamicProps, handler);
}
},
};
// namespace: lm
@@ -1479,7 +1481,19 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
} else {
return extHostEmbeddings.computeEmbeddings(embeddingsModel, input, token);
}
}
},
registerTool(toolId: string, tool: vscode.LanguageModelTool) {
checkProposedApiEnabled(extension, 'chatVariableResolver');
return extHostLanguageModelTools.registerTool(extension, toolId, tool);
},
invokeTool(toolId: string, parameters: Object, token: vscode.CancellationToken) {
checkProposedApiEnabled(extension, 'chatVariableResolver');
return extHostLanguageModelTools.invokeTool(toolId, parameters, token);
},
get tools() {
checkProposedApiEnabled(extension, 'chatVariableResolver');
return extHostLanguageModelTools.tools;
},
};
// namespace: speech