@theia/ai-chat 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/lib/browser/ai-chat-frontend-module.d.ts +4 -0
- package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -0
- package/lib/browser/ai-chat-frontend-module.js +51 -0
- package/lib/browser/ai-chat-frontend-module.js.map +1 -0
- package/lib/browser/ai-chat-preferences.d.ts +4 -0
- package/lib/browser/ai-chat-preferences.d.ts.map +1 -0
- package/lib/browser/ai-chat-preferences.js +32 -0
- package/lib/browser/ai-chat-preferences.js.map +1 -0
- package/lib/browser/frontend-chat-service.d.ts +8 -0
- package/lib/browser/frontend-chat-service.d.ts.map +1 -0
- package/lib/browser/frontend-chat-service.js +67 -0
- package/lib/browser/frontend-chat-service.js.map +1 -0
- package/lib/common/chat-agent-service.d.ts +34 -0
- package/lib/common/chat-agent-service.d.ts.map +1 -0
- package/lib/common/chat-agent-service.js +75 -0
- package/lib/common/chat-agent-service.js.map +1 -0
- package/lib/common/chat-agents-variable-contribution.d.ts +17 -0
- package/lib/common/chat-agents-variable-contribution.d.ts.map +1 -0
- package/lib/common/chat-agents-variable-contribution.js +51 -0
- package/lib/common/chat-agents-variable-contribution.js.map +1 -0
- package/lib/common/chat-agents.d.ts +86 -0
- package/lib/common/chat-agents.d.ts.map +1 -0
- package/lib/common/chat-agents.js +307 -0
- package/lib/common/chat-agents.js.map +1 -0
- package/lib/common/chat-model.d.ts +319 -0
- package/lib/common/chat-model.d.ts.map +1 -0
- package/lib/common/chat-model.js +527 -0
- package/lib/common/chat-model.js.map +1 -0
- package/lib/common/chat-request-parser.d.ts +20 -0
- package/lib/common/chat-request-parser.d.ts.map +1 -0
- package/lib/common/chat-request-parser.js +158 -0
- package/lib/common/chat-request-parser.js.map +1 -0
- package/lib/common/chat-request-parser.spec.d.ts +2 -0
- package/lib/common/chat-request-parser.spec.d.ts.map +1 -0
- package/lib/common/chat-request-parser.spec.js +108 -0
- package/lib/common/chat-request-parser.spec.js.map +1 -0
- package/lib/common/chat-service.d.ts +72 -0
- package/lib/common/chat-service.d.ts.map +1 -0
- package/lib/common/chat-service.js +170 -0
- package/lib/common/chat-service.js.map +1 -0
- package/lib/common/command-chat-agents.d.ts +33 -0
- package/lib/common/command-chat-agents.d.ts.map +1 -0
- package/lib/common/command-chat-agents.js +327 -0
- package/lib/common/command-chat-agents.js.map +1 -0
- package/lib/common/index.d.ts +10 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +28 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/orchestrator-chat-agent.d.ts +22 -0
- package/lib/common/orchestrator-chat-agent.d.ts.map +1 -0
- package/lib/common/orchestrator-chat-agent.js +140 -0
- package/lib/common/orchestrator-chat-agent.js.map +1 -0
- package/lib/common/parsed-chat-request.d.ts +66 -0
- package/lib/common/parsed-chat-request.d.ts.map +1 -0
- package/lib/common/parsed-chat-request.js +83 -0
- package/lib/common/parsed-chat-request.js.map +1 -0
- package/lib/common/universal-chat-agent.d.ts +15 -0
- package/lib/common/universal-chat-agent.d.ts.map +1 -0
- package/lib/common/universal-chat-agent.js +102 -0
- package/lib/common/universal-chat-agent.js.map +1 -0
- package/package.json +54 -0
- package/src/browser/ai-chat-frontend-module.ts +66 -0
- package/src/browser/ai-chat-preferences.ts +32 -0
- package/src/browser/frontend-chat-service.ts +66 -0
- package/src/common/chat-agent-service.ts +85 -0
- package/src/common/chat-agents-variable-contribution.ts +81 -0
- package/src/common/chat-agents.ts +384 -0
- package/src/common/chat-model.ts +776 -0
- package/src/common/chat-request-parser.spec.ts +120 -0
- package/src/common/chat-request-parser.ts +220 -0
- package/src/common/chat-service.ts +236 -0
- package/src/common/command-chat-agents.ts +352 -0
- package/src/common/index.ts +24 -0
- package/src/common/orchestrator-chat-agent.ts +151 -0
- package/src/common/parsed-chat-request.ts +112 -0
- package/src/common/universal-chat-agent.ts +109 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - AI Chat EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/ai-chat` extension provides the concept of a language model chat to Theia.
|
|
16
|
+
It serves as the basis for `@theia/ai-chat-ui` to provide the Chat UI.
|
|
17
|
+
|
|
18
|
+
## Additional Information
|
|
19
|
+
|
|
20
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
21
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
26
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
27
|
+
|
|
28
|
+
## Trademark
|
|
29
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
30
|
+
https://www.eclipse.org/theia
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-chat-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-chat-frontend-module.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAiB/D,wBA6BG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const common_1 = require("@theia/ai-core/lib/common");
|
|
19
|
+
const core_1 = require("@theia/core");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const common_2 = require("../common");
|
|
23
|
+
const command_chat_agents_1 = require("../common/command-chat-agents");
|
|
24
|
+
const orchestrator_chat_agent_1 = require("../common/orchestrator-chat-agent");
|
|
25
|
+
const universal_chat_agent_1 = require("../common/universal-chat-agent");
|
|
26
|
+
const ai_chat_preferences_1 = require("./ai-chat-preferences");
|
|
27
|
+
const chat_agents_variable_contribution_1 = require("../common/chat-agents-variable-contribution");
|
|
28
|
+
const frontend_chat_service_1 = require("./frontend-chat-service");
|
|
29
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
30
|
+
(0, core_1.bindContributionProvider)(bind, common_1.Agent);
|
|
31
|
+
(0, core_1.bindContributionProvider)(bind, common_2.ChatAgent);
|
|
32
|
+
bind(common_2.ChatAgentServiceImpl).toSelf().inSingletonScope();
|
|
33
|
+
bind(common_2.ChatAgentService).toService(common_2.ChatAgentServiceImpl);
|
|
34
|
+
bind(common_2.DefaultChatAgentId).toConstantValue({ id: orchestrator_chat_agent_1.OrchestratorChatAgentId });
|
|
35
|
+
bind(common_1.AIVariableContribution).to(chat_agents_variable_contribution_1.ChatAgentsVariableContribution).inSingletonScope();
|
|
36
|
+
bind(common_2.ChatRequestParserImpl).toSelf().inSingletonScope();
|
|
37
|
+
bind(common_2.ChatRequestParser).toService(common_2.ChatRequestParserImpl);
|
|
38
|
+
bind(frontend_chat_service_1.FrontendChatServiceImpl).toSelf().inSingletonScope();
|
|
39
|
+
bind(common_2.ChatService).toService(frontend_chat_service_1.FrontendChatServiceImpl);
|
|
40
|
+
bind(orchestrator_chat_agent_1.OrchestratorChatAgent).toSelf().inSingletonScope();
|
|
41
|
+
bind(common_1.Agent).toService(orchestrator_chat_agent_1.OrchestratorChatAgent);
|
|
42
|
+
bind(common_2.ChatAgent).toService(orchestrator_chat_agent_1.OrchestratorChatAgent);
|
|
43
|
+
bind(universal_chat_agent_1.UniversalChatAgent).toSelf().inSingletonScope();
|
|
44
|
+
bind(common_1.Agent).toService(universal_chat_agent_1.UniversalChatAgent);
|
|
45
|
+
bind(common_2.ChatAgent).toService(universal_chat_agent_1.UniversalChatAgent);
|
|
46
|
+
bind(command_chat_agents_1.CommandChatAgent).toSelf().inSingletonScope();
|
|
47
|
+
bind(common_1.Agent).toService(command_chat_agents_1.CommandChatAgent);
|
|
48
|
+
bind(common_2.ChatAgent).toService(command_chat_agents_1.CommandChatAgent);
|
|
49
|
+
bind(browser_1.PreferenceContribution).toConstantValue({ schema: ai_chat_preferences_1.aiChatPreferences });
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=ai-chat-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-chat-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-chat-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;A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I,CAAC,yCAAkB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACrD,IAAI,CAAC,cAAK,CAAC,CAAC,SAAS,CAAC,yCAAkB,CAAC,CAAC;IAC1C,IAAI,CAAC,kBAAS,CAAC,CAAC,SAAS,CAAC,yCAAkB,CAAC,CAAC;IAE9C,IAAI,CAAC,sCAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACnD,IAAI,CAAC,cAAK,CAAC,CAAC,SAAS,CAAC,sCAAgB,CAAC,CAAC;IACxC,IAAI,CAAC,kBAAS,CAAC,CAAC,SAAS,CAAC,sCAAgB,CAAC,CAAC;IAE5C,IAAI,CAAC,gCAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,uCAAiB,EAAE,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
2
|
+
export declare const DEFAULT_CHAT_AGENT_PREF = "ai-features.chat.defaultChatAgent";
|
|
3
|
+
export declare const aiChatPreferences: PreferenceSchema;
|
|
4
|
+
//# sourceMappingURL=ai-chat-preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-chat-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/ai-chat-preferences.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAE/F,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAE3E,eAAO,MAAM,iBAAiB,EAAE,gBAU/B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.aiChatPreferences = exports.DEFAULT_CHAT_AGENT_PREF = void 0;
|
|
19
|
+
const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
|
|
20
|
+
exports.DEFAULT_CHAT_AGENT_PREF = 'ai-features.chat.defaultChatAgent';
|
|
21
|
+
exports.aiChatPreferences = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
[exports.DEFAULT_CHAT_AGENT_PREF]: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Optional: <agent-name> of the Chat Agent that shall be invoked, if no agent is explicitly mentioned with @<agent-name> in the user query.\
|
|
27
|
+
If no Default Agent is configured, Theia´s defaults will be applied.',
|
|
28
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=ai-chat-preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-chat-preferences.js","sourceRoot":"","sources":["../../src/browser/ai-chat-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,wFAA2F;AAG9E,QAAA,uBAAuB,GAAG,mCAAmC,CAAC;AAE9D,QAAA,iBAAiB,GAAqB;IAC/C,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,+BAAuB,CAAC,EAAE;YACvB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE;iFACwD;YACrE,KAAK,EAAE,+CAAyB;SACnC;KACJ;CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChatAgent, ChatServiceImpl, ParsedChatRequest } from '../common';
|
|
2
|
+
import { PreferenceService } from '@theia/core/lib/browser';
|
|
3
|
+
export declare class FrontendChatServiceImpl extends ChatServiceImpl {
|
|
4
|
+
protected preferenceService: PreferenceService;
|
|
5
|
+
protected getAgent(parsedRequest: ParsedChatRequest): ChatAgent | undefined;
|
|
6
|
+
protected getConfiguredDefaultChatAgent(): ChatAgent | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=frontend-chat-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-chat-service.d.ts","sourceRoot":"","sources":["../../src/browser/frontend-chat-service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,qBACa,uBAAwB,SAAQ,eAAe;IAGxD,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;cAE5B,QAAQ,CAAC,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS;IA8BpF,SAAS,CAAC,6BAA6B,IAAI,SAAS,GAAG,SAAS;CAQnE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FrontendChatServiceImpl = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const common_1 = require("../common");
|
|
22
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
23
|
+
const ai_chat_preferences_1 = require("./ai-chat-preferences");
|
|
24
|
+
let FrontendChatServiceImpl = class FrontendChatServiceImpl extends common_1.ChatServiceImpl {
|
|
25
|
+
getAgent(parsedRequest) {
|
|
26
|
+
var _a;
|
|
27
|
+
const agentPart = this.getMentionedAgent(parsedRequest);
|
|
28
|
+
if (agentPart) {
|
|
29
|
+
return this.chatAgentService.getAgent(agentPart.agentId);
|
|
30
|
+
}
|
|
31
|
+
const configuredDefaultChatAgent = this.getConfiguredDefaultChatAgent();
|
|
32
|
+
if (configuredDefaultChatAgent) {
|
|
33
|
+
return configuredDefaultChatAgent;
|
|
34
|
+
}
|
|
35
|
+
if (this.defaultChatAgentId) {
|
|
36
|
+
const defaultAgent = this.chatAgentService.getAgent(this.defaultChatAgentId.id);
|
|
37
|
+
// the default agent could be disabled
|
|
38
|
+
if (defaultAgent) {
|
|
39
|
+
return defaultAgent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// check whether "Universal" is available
|
|
43
|
+
const universalAgent = this.chatAgentService.getAgent('Universal');
|
|
44
|
+
if (universalAgent) {
|
|
45
|
+
return universalAgent;
|
|
46
|
+
}
|
|
47
|
+
this.logger.warn('No default chat agent is configured or available and the "Universal" Chat Agent is unavailable too. Falling back to first registered agent.');
|
|
48
|
+
return (_a = this.chatAgentService.getAgents()[0]) !== null && _a !== void 0 ? _a : undefined;
|
|
49
|
+
}
|
|
50
|
+
getConfiguredDefaultChatAgent() {
|
|
51
|
+
const configuredDefaultChatAgentId = this.preferenceService.get(ai_chat_preferences_1.DEFAULT_CHAT_AGENT_PREF, undefined);
|
|
52
|
+
const configuredDefaultChatAgent = configuredDefaultChatAgentId ? this.chatAgentService.getAgent(configuredDefaultChatAgentId) : undefined;
|
|
53
|
+
if (configuredDefaultChatAgentId && !configuredDefaultChatAgent) {
|
|
54
|
+
this.logger.warn(`The configured default chat agent with id '${configuredDefaultChatAgentId}' does not exist.`);
|
|
55
|
+
}
|
|
56
|
+
return configuredDefaultChatAgent;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.FrontendChatServiceImpl = FrontendChatServiceImpl;
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
62
|
+
tslib_1.__metadata("design:type", Object)
|
|
63
|
+
], FrontendChatServiceImpl.prototype, "preferenceService", void 0);
|
|
64
|
+
exports.FrontendChatServiceImpl = FrontendChatServiceImpl = tslib_1.__decorate([
|
|
65
|
+
(0, inversify_1.injectable)()
|
|
66
|
+
], FrontendChatServiceImpl);
|
|
67
|
+
//# sourceMappingURL=frontend-chat-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-chat-service.js","sourceRoot":"","sources":["../../src/browser/frontend-chat-service.ts"],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AAC,CAAC,mCAAI,SAAS,CAAC;IAC7D,CAAC;IAES,6BAA6B;QACnC,MAAM,4BAA4B,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAS,6CAAuB,EAAE,SAAS,CAAC,CAAC;QAC5G,MAAM,0BAA0B,GAAG,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3I,IAAI,4BAA4B,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8CAA8C,4BAA4B,mBAAmB,CAAC,CAAC;QACpH,CAAC;QACD,OAAO,0BAA0B,CAAC;IACtC,CAAC;CACJ,CAAA;AA3CY,0DAAuB;AAGtB;IADT,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;kEACqB;kCAHtC,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CA2CnC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ContributionProvider, ILogger } from '@theia/core';
|
|
2
|
+
import { ChatAgent } from './chat-agents';
|
|
3
|
+
import { AgentService } from '@theia/ai-core';
|
|
4
|
+
export declare const ChatAgentService: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* The ChatAgentService provides access to the available chat agents.
|
|
7
|
+
*/
|
|
8
|
+
export interface ChatAgentService {
|
|
9
|
+
/**
|
|
10
|
+
* Returns all available agents.
|
|
11
|
+
*/
|
|
12
|
+
getAgents(): ChatAgent[];
|
|
13
|
+
/**
|
|
14
|
+
* Returns the specified agent, if available
|
|
15
|
+
*/
|
|
16
|
+
getAgent(id: string): ChatAgent | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns all agents, including disabled ones.
|
|
19
|
+
*/
|
|
20
|
+
getAllAgents(): ChatAgent[];
|
|
21
|
+
}
|
|
22
|
+
export declare class ChatAgentServiceImpl implements ChatAgentService {
|
|
23
|
+
protected readonly agentContributions: ContributionProvider<ChatAgent>;
|
|
24
|
+
protected logger: ILogger;
|
|
25
|
+
protected agentService: AgentService;
|
|
26
|
+
protected _agents: ChatAgent[];
|
|
27
|
+
protected get agents(): ChatAgent[];
|
|
28
|
+
registerChatAgent(agent: ChatAgent): void;
|
|
29
|
+
getAgent(id: string): ChatAgent | undefined;
|
|
30
|
+
getAgents(): ChatAgent[];
|
|
31
|
+
getAllAgents(): ChatAgent[];
|
|
32
|
+
private _agentIsEnabled;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=chat-agent-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agent-service.d.ts","sourceRoot":"","sources":["../../src/common/chat-agent-service.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,SAAS,IAAI,SAAS,EAAE,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5C;;OAEG;IACH,YAAY,IAAI,SAAS,EAAE,CAAC;CAC/B;AACD,qBACa,oBAAqB,YAAW,gBAAgB;IAGzD,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAGvE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAG1B,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IAErC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,CAAM;IAEpC,SAAS,KAAK,MAAM,IAAI,SAAS,EAAE,CAIlC;IAED,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAIzC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAM3C,SAAS,IAAI,SAAS,EAAE;IAGxB,YAAY,IAAI,SAAS,EAAE;IAI3B,OAAO,CAAC,eAAe;CAG1B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
/*---------------------------------------------------------------------------------------------
|
|
18
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
20
|
+
*--------------------------------------------------------------------------------------------*/
|
|
21
|
+
// Partially copied from https://github.com/microsoft/vscode/blob/a2cab7255c0df424027be05d58e1b7b941f4ea60/src/vs/workbench/contrib/chat/common/chatAgents.ts
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.ChatAgentServiceImpl = exports.ChatAgentService = void 0;
|
|
24
|
+
const tslib_1 = require("tslib");
|
|
25
|
+
const core_1 = require("@theia/core");
|
|
26
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
27
|
+
const chat_agents_1 = require("./chat-agents");
|
|
28
|
+
const ai_core_1 = require("@theia/ai-core");
|
|
29
|
+
exports.ChatAgentService = Symbol('ChatAgentService');
|
|
30
|
+
let ChatAgentServiceImpl = class ChatAgentServiceImpl {
|
|
31
|
+
constructor() {
|
|
32
|
+
this._agents = [];
|
|
33
|
+
}
|
|
34
|
+
get agents() {
|
|
35
|
+
// We can't collect the contributions at @postConstruct because this will lead to a circular dependency
|
|
36
|
+
// with chat agents reusing the chat agent service (e.g. orchestrator)
|
|
37
|
+
return [...this.agentContributions.getContributions(), ...this._agents];
|
|
38
|
+
}
|
|
39
|
+
registerChatAgent(agent) {
|
|
40
|
+
this._agents.push(agent);
|
|
41
|
+
}
|
|
42
|
+
getAgent(id) {
|
|
43
|
+
if (!this._agentIsEnabled(id)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return this.getAgents().find(agent => agent.id === id);
|
|
47
|
+
}
|
|
48
|
+
getAgents() {
|
|
49
|
+
return this.agents.filter(a => this._agentIsEnabled(a.id));
|
|
50
|
+
}
|
|
51
|
+
getAllAgents() {
|
|
52
|
+
return this.agents;
|
|
53
|
+
}
|
|
54
|
+
_agentIsEnabled(id) {
|
|
55
|
+
return this.agentService.isEnabled(id);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.ChatAgentServiceImpl = ChatAgentServiceImpl;
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
61
|
+
(0, inversify_1.named)(chat_agents_1.ChatAgent),
|
|
62
|
+
tslib_1.__metadata("design:type", Object)
|
|
63
|
+
], ChatAgentServiceImpl.prototype, "agentContributions", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, inversify_1.inject)(core_1.ILogger),
|
|
66
|
+
tslib_1.__metadata("design:type", Object)
|
|
67
|
+
], ChatAgentServiceImpl.prototype, "logger", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, inversify_1.inject)(ai_core_1.AgentService),
|
|
70
|
+
tslib_1.__metadata("design:type", Object)
|
|
71
|
+
], ChatAgentServiceImpl.prototype, "agentService", void 0);
|
|
72
|
+
exports.ChatAgentServiceImpl = ChatAgentServiceImpl = tslib_1.__decorate([
|
|
73
|
+
(0, inversify_1.injectable)()
|
|
74
|
+
], ChatAgentServiceImpl);
|
|
75
|
+
//# sourceMappingURL=chat-agent-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agent-service.js","sourceRoot":"","sources":["../../src/common/chat-agent-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF;;;gGAGgG;AAChG,6JAA6J;;;;AAE7J,sCAA4D;AAC5D,4DAAyE;AACzE,+CAA0C;AAC1C,4CAA8C;AAEjC,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAmBpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAA1B;QAWO,YAAO,GAAgB,EAAE,CAAC;IA4BxC,CAAC;IA1BG,IAAc,MAAM;QAChB,uGAAuG;QACvG,sEAAsE;QACtE,OAAO,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED,iBAAiB,CAAC,KAAgB;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ,CAAC,EAAU;QACf,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IACD,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEO,eAAe,CAAC,EAAU;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAA;AAvCY,oDAAoB;AAGV;IADlB,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAAE,IAAA,iBAAK,EAAC,uBAAS,CAAC;;gEACwB;AAG7D;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;oDACU;AAGhB;IADT,IAAA,kBAAM,EAAC,sBAAY,CAAC;;0DACgB;+BAT5B,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAuChC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MaybePromise } from '@theia/core';
|
|
2
|
+
import { AIVariable, AIVariableContext, AIVariableContribution, AIVariableResolutionRequest, AIVariableResolver, AIVariableService, ResolvedAIVariable } from '../../../ai-core/src/common/variable-service';
|
|
3
|
+
import { ChatAgentService } from './chat-agent-service';
|
|
4
|
+
export declare const CHAT_AGENTS_VARIABLE: AIVariable;
|
|
5
|
+
export interface ChatAgentDescriptor {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ChatAgentsVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
11
|
+
protected readonly agents: ChatAgentService;
|
|
12
|
+
registerVariables(service: AIVariableService): void;
|
|
13
|
+
canResolve(request: AIVariableResolutionRequest, _context: AIVariableContext): MaybePromise<number>;
|
|
14
|
+
resolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<ResolvedAIVariable | undefined>;
|
|
15
|
+
resolveAgentsVariable(_request: AIVariableResolutionRequest): ResolvedAIVariable;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=chat-agents-variable-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agents-variable-contribution.d.ts","sourceRoot":"","sources":["../../src/common/chat-agents-variable-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACrB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,eAAO,MAAM,oBAAoB,EAAE,UAIlC,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,qBACa,8BAA+B,YAAW,sBAAsB,EAAE,kBAAkB;IAG7F,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAE5C,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAInD,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC;IAO7F,OAAO,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAMxH,qBAAqB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,kBAAkB;CASnF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatAgentsVariableContribution = exports.CHAT_AGENTS_VARIABLE = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
6
|
+
const chat_agent_service_1 = require("./chat-agent-service");
|
|
7
|
+
exports.CHAT_AGENTS_VARIABLE = {
|
|
8
|
+
id: 'chatAgents',
|
|
9
|
+
name: 'chatAgents',
|
|
10
|
+
description: 'Returns the list of chat agents available in the system'
|
|
11
|
+
};
|
|
12
|
+
let ChatAgentsVariableContribution = class ChatAgentsVariableContribution {
|
|
13
|
+
registerVariables(service) {
|
|
14
|
+
service.registerResolver(exports.CHAT_AGENTS_VARIABLE, this);
|
|
15
|
+
}
|
|
16
|
+
canResolve(request, _context) {
|
|
17
|
+
if (request.variable.name === exports.CHAT_AGENTS_VARIABLE.name) {
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
return -1;
|
|
21
|
+
}
|
|
22
|
+
async resolve(request, context) {
|
|
23
|
+
if (request.variable.name === exports.CHAT_AGENTS_VARIABLE.name) {
|
|
24
|
+
return this.resolveAgentsVariable(request);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
resolveAgentsVariable(_request) {
|
|
28
|
+
const agents = this.agents.getAgents().map(agent => ({
|
|
29
|
+
id: agent.id,
|
|
30
|
+
name: agent.name,
|
|
31
|
+
description: agent.description
|
|
32
|
+
}));
|
|
33
|
+
const value = agents.map(agent => prettyPrintInMd(agent)).join('\n');
|
|
34
|
+
return { variable: exports.CHAT_AGENTS_VARIABLE, value };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.ChatAgentsVariableContribution = ChatAgentsVariableContribution;
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, inversify_1.inject)(chat_agent_service_1.ChatAgentService),
|
|
40
|
+
tslib_1.__metadata("design:type", Object)
|
|
41
|
+
], ChatAgentsVariableContribution.prototype, "agents", void 0);
|
|
42
|
+
exports.ChatAgentsVariableContribution = ChatAgentsVariableContribution = tslib_1.__decorate([
|
|
43
|
+
(0, inversify_1.injectable)()
|
|
44
|
+
], ChatAgentsVariableContribution);
|
|
45
|
+
function prettyPrintInMd(agent) {
|
|
46
|
+
return `- ${agent.id}
|
|
47
|
+
- *ID*: ${agent.id}
|
|
48
|
+
- *Name*: ${agent.name}
|
|
49
|
+
- *Description*: ${agent.description.replace(/\n/g, ' ')}`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=chat-agents-variable-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agents-variable-contribution.js","sourceRoot":"","sources":["../../src/common/chat-agents-variable-contribution.ts"],"names":[],"mappings":";;;;AAgBA,4DAAkE;AAUlE,6DAAwD;AAE3C,QAAA,oBAAoB,GAAe;IAC5C,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,yDAAyD;CACzE,CAAC;AASK,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAKvC,iBAAiB,CAAC,OAA0B;QACxC,OAAO,CAAC,gBAAgB,CAAC,4BAAoB,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,UAAU,CAAC,OAAoC,EAAE,QAA2B;QACxE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,4BAAoB,CAAC,IAAI,EAAE,CAAC;YACtD,OAAO,CAAC,CAAC;QACb,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAoC,EAAE,OAA0B;QAC1E,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,4BAAoB,CAAC,IAAI,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAED,qBAAqB,CAAC,QAAqC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjD,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;SACjC,CAAC,CAAC,CAAC;QACJ,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,OAAO,EAAE,QAAQ,EAAE,4BAAoB,EAAE,KAAK,EAAE,CAAC;IACrD,CAAC;CACJ,CAAA;AA/BY,wEAA8B;AAGpB;IADlB,IAAA,kBAAM,EAAC,qCAAgB,CAAC;;8DACmB;yCAHnC,8BAA8B;IAD1C,IAAA,sBAAU,GAAE;GACA,8BAA8B,CA+B1C;AAED,SAAS,eAAe,CAAC,KAAyD;IAC9E,OAAO,KAAK,KAAK,CAAC,EAAE;YACZ,KAAK,CAAC,EAAE;cACN,KAAK,CAAC,IAAI;qBACH,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CommunicationRecordingService, LanguageModel, LanguageModelRequirement, LanguageModelResponse, PromptService, ResolvedPromptTemplate, ToolRequest } from '@theia/ai-core';
|
|
2
|
+
import { Agent, LanguageModelRegistry, MessageActor } from '@theia/ai-core/lib/common';
|
|
3
|
+
import { CancellationToken, ILogger } from '@theia/core';
|
|
4
|
+
import { ChatAgentService } from './chat-agent-service';
|
|
5
|
+
import { ChatModel, ChatRequestModel, ChatRequestModelImpl, ChatResponseContent } from './chat-model';
|
|
6
|
+
/**
|
|
7
|
+
* A conversation consists of a sequence of ChatMessages.
|
|
8
|
+
* Each ChatMessage is either a user message, AI message or a system message.
|
|
9
|
+
*
|
|
10
|
+
* For now we only support text based messages.
|
|
11
|
+
*/
|
|
12
|
+
export interface ChatMessage {
|
|
13
|
+
actor: MessageActor;
|
|
14
|
+
type: 'text';
|
|
15
|
+
query: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* System message content, enriched with function descriptions.
|
|
19
|
+
*/
|
|
20
|
+
export interface SystemMessageDescription {
|
|
21
|
+
text: string;
|
|
22
|
+
/** All functions references in the system message. */
|
|
23
|
+
functionDescriptions?: Map<string, ToolRequest>;
|
|
24
|
+
}
|
|
25
|
+
export declare namespace SystemMessageDescription {
|
|
26
|
+
function fromResolvedPromptTemplate(resolvedPrompt: ResolvedPromptTemplate): SystemMessageDescription;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The location from where an chat agent may be invoked.
|
|
30
|
+
* Based on the location, a different context may be available.
|
|
31
|
+
*/
|
|
32
|
+
export declare enum ChatAgentLocation {
|
|
33
|
+
Panel = "panel",
|
|
34
|
+
Terminal = "terminal",
|
|
35
|
+
Notebook = "notebook",
|
|
36
|
+
Editor = "editor"
|
|
37
|
+
}
|
|
38
|
+
export declare namespace ChatAgentLocation {
|
|
39
|
+
const ALL: ChatAgentLocation[];
|
|
40
|
+
function fromRaw(value: string): ChatAgentLocation;
|
|
41
|
+
}
|
|
42
|
+
export declare const ChatAgent: unique symbol;
|
|
43
|
+
/**
|
|
44
|
+
* A chat agent is a specialized agent with a common interface for its invocation.
|
|
45
|
+
*/
|
|
46
|
+
export interface ChatAgent extends Agent {
|
|
47
|
+
locations: ChatAgentLocation[];
|
|
48
|
+
iconClass?: string;
|
|
49
|
+
invoke(request: ChatRequestModelImpl, chatAgentService?: ChatAgentService): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export declare abstract class AbstractChatAgent {
|
|
52
|
+
id: string;
|
|
53
|
+
languageModelRequirements: LanguageModelRequirement[];
|
|
54
|
+
protected defaultLanguageModelPurpose: string;
|
|
55
|
+
iconClass: string;
|
|
56
|
+
locations: ChatAgentLocation[];
|
|
57
|
+
tags: String[];
|
|
58
|
+
protected languageModelRegistry: LanguageModelRegistry;
|
|
59
|
+
protected logger: ILogger;
|
|
60
|
+
protected recordingService: CommunicationRecordingService;
|
|
61
|
+
protected promptService: PromptService;
|
|
62
|
+
constructor(id: string, languageModelRequirements: LanguageModelRequirement[], defaultLanguageModelPurpose: string, iconClass?: string, locations?: ChatAgentLocation[], tags?: String[]);
|
|
63
|
+
invoke(request: ChatRequestModelImpl): Promise<void>;
|
|
64
|
+
protected handleError(request: ChatRequestModelImpl, error: Error): void;
|
|
65
|
+
protected getLanguageModelSelector(languageModelPurpose: string): LanguageModelRequirement;
|
|
66
|
+
protected getLanguageModel(languageModelPurpose: string): Promise<LanguageModel>;
|
|
67
|
+
protected selectLanguageModel(selector: LanguageModelRequirement): Promise<LanguageModel>;
|
|
68
|
+
protected abstract getSystemMessageDescription(): Promise<SystemMessageDescription | undefined>;
|
|
69
|
+
protected getMessages(model: ChatModel, includeResponseInProgress?: boolean): Promise<ChatMessage[]>;
|
|
70
|
+
/**
|
|
71
|
+
* @returns the list of tools used by this agent, or undefined if none is needed.
|
|
72
|
+
*/
|
|
73
|
+
protected getTools(request: ChatRequestModel): ToolRequest[] | undefined;
|
|
74
|
+
protected callLlm(languageModel: LanguageModel, messages: ChatMessage[], tools: ToolRequest[] | undefined, token: CancellationToken): Promise<LanguageModelResponse>;
|
|
75
|
+
protected abstract addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export declare abstract class AbstractTextToModelParsingChatAgent<T> extends AbstractChatAgent {
|
|
78
|
+
protected addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
79
|
+
protected abstract parseTextResponse(text: string): Promise<T>;
|
|
80
|
+
protected abstract createResponseContent(parsedModel: T, request: ChatRequestModelImpl): ChatResponseContent;
|
|
81
|
+
}
|
|
82
|
+
export declare abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
83
|
+
protected addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
84
|
+
private parse;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=chat-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agents.d.ts","sourceRoot":"","sources":["../../src/common/chat-agents.ts"],"names":[],"mappings":"AAqBA,OAAO,EACH,6BAA6B,EAE7B,aAAa,EACb,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,KAAK,EAGL,qBAAqB,EAErB,YAAY,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,OAAO,EAAW,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACH,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAKtB,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACnD;AACD,yBAAiB,wBAAwB,CAAC;IACtC,SAAgB,0BAA0B,CAAC,cAAc,EAAE,sBAAsB,GAAG,wBAAwB,CAK3G;CACJ;AAED;;;GAGG;AACH,oBAAY,iBAAiB;IACzB,KAAK,UAAU;IACf,QAAQ,aAAa;IAC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