@theia/ai-chat 1.55.0-next.37 → 1.55.0-next.67
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/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +25 -2
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/custom-agent-factory.d.ts +4 -0
- package/lib/browser/custom-agent-factory.d.ts.map +1 -0
- package/lib/browser/custom-agent-factory.js +20 -0
- package/lib/browser/custom-agent-factory.js.map +1 -0
- package/lib/browser/custom-agent-frontend-application-contribution.d.ts +13 -0
- package/lib/browser/custom-agent-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/custom-agent-frontend-application-contribution.js +82 -0
- package/lib/browser/custom-agent-frontend-application-contribution.js.map +1 -0
- package/lib/common/chat-agent-service.d.ts +11 -0
- package/lib/common/chat-agent-service.d.ts.map +1 -1
- package/lib/common/chat-agent-service.js +3 -0
- package/lib/common/chat-agent-service.js.map +1 -1
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +9 -30
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-history-entry.d.ts +7 -0
- package/lib/common/chat-history-entry.d.ts.map +1 -0
- package/lib/common/chat-history-entry.js +42 -0
- package/lib/common/chat-history-entry.js.map +1 -0
- package/lib/common/custom-chat-agent.d.ts +14 -0
- package/lib/common/custom-chat-agent.d.ts.map +1 -0
- package/lib/common/custom-chat-agent.js +43 -0
- package/lib/common/custom-chat-agent.js.map +1 -0
- package/lib/common/index.d.ts +4 -3
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/o1-chat-agent.d.ts +13 -0
- package/lib/common/o1-chat-agent.d.ts.map +1 -0
- package/lib/common/o1-chat-agent.js +45 -0
- package/lib/common/o1-chat-agent.js.map +1 -0
- package/lib/common/orchestrator-chat-agent.d.ts.map +1 -1
- package/lib/common/orchestrator-chat-agent.js +13 -13
- package/lib/common/orchestrator-chat-agent.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/ai-chat-frontend-module.ts +30 -4
- package/src/browser/custom-agent-factory.ts +20 -0
- package/src/browser/custom-agent-frontend-application-contribution.ts +73 -0
- package/src/common/chat-agent-service.ts +15 -0
- package/src/common/chat-agents.ts +13 -31
- package/src/common/chat-history-entry.ts +47 -0
- package/src/common/custom-chat-agent.ts +44 -0
- package/src/common/index.ts +4 -3
- package/src/common/o1-chat-agent.ts +51 -0
- package/src/common/orchestrator-chat-agent.ts +14 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"o1-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/o1-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,SAAS,EACT,8BAA8B,EAC9B,wBAAwB,EAC3B,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExE,qBACa,WAAY,SAAQ,8BAA+B,YAAW,SAAS;IAEzE,IAAI,SAAgB;IACpB,WAAW,SAAsD;IACjE,eAAe,EAAE,cAAc,EAAE,CAAM;IAC9C,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAM;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;;cAalB,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;CAI/F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.O1ChatAgent = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const chat_agents_1 = require("./chat-agents");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
let O1ChatAgent = class O1ChatAgent extends chat_agents_1.AbstractStreamParsingChatAgent {
|
|
23
|
+
constructor() {
|
|
24
|
+
super('o1-preview', [{
|
|
25
|
+
purpose: 'chat',
|
|
26
|
+
identifier: 'openai/o1-preview',
|
|
27
|
+
}], 'chat');
|
|
28
|
+
this.name = 'O1-Preview';
|
|
29
|
+
this.description = 'An agent for interacting with ChatGPT o1-preview';
|
|
30
|
+
this.promptTemplates = [];
|
|
31
|
+
this.agentSpecificVariables = [];
|
|
32
|
+
this.variables = [];
|
|
33
|
+
this.functions = [];
|
|
34
|
+
}
|
|
35
|
+
async getSystemMessageDescription() {
|
|
36
|
+
// O1 currently does not support system prompts
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.O1ChatAgent = O1ChatAgent;
|
|
41
|
+
exports.O1ChatAgent = O1ChatAgent = tslib_1.__decorate([
|
|
42
|
+
(0, inversify_1.injectable)(),
|
|
43
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
44
|
+
], O1ChatAgent);
|
|
45
|
+
//# sourceMappingURL=o1-chat-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"o1-chat-agent.js","sourceRoot":"","sources":["../../src/common/o1-chat-agent.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,+CAIuB;AAEvB,4DAA0D;AAInD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,4CAA8B;IAS3D;QACI,KAAK,CACD,YAAY,EACZ,CAAC;gBACG,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,mBAAmB;aAClC,CAAC,EACF,MAAM,CACT,CAAC;QAfC,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,kDAAkD,CAAC;QACjE,oBAAe,GAAqB,EAAE,CAAC;QACrC,2BAAsB,GAA6B,EAAE,CAAC;QACtD,cAAS,GAAa,EAAE,CAAC;QACzB,cAAS,GAAa,EAAE,CAAC;IAWlC,CAAC;IAES,KAAK,CAAC,2BAA2B;QACvC,+CAA+C;QAC/C,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AAxBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,sBAAU,GAAE;;GACA,WAAW,CAwBvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/orchestrator-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAoC,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EACH,cAAc,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAwC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrator-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/orchestrator-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAoC,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EACH,cAAc,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAwC,MAAM,cAAc,CAAC;AAI1F,eAAO,MAAM,oBAAoB,EAAE,cAiCjC,CAAC;AAEH,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAGtD,qBACa,qBAAsB,SAAQ,8BAA+B,YAAW,SAAS;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAM;;IAkB/D,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAE9B,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;cAiBnD,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;cAKnE,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CA6DhI"}
|
|
@@ -23,6 +23,7 @@ const chat_agent_service_1 = require("./chat-agent-service");
|
|
|
23
23
|
const chat_agents_1 = require("./chat-agents");
|
|
24
24
|
const chat_model_1 = require("./chat-model");
|
|
25
25
|
const core_1 = require("@theia/core");
|
|
26
|
+
const chat_history_entry_1 = require("./chat-history-entry");
|
|
26
27
|
exports.orchestratorTemplate = {
|
|
27
28
|
id: 'orchestrator-system',
|
|
28
29
|
template: `# Instructions
|
|
@@ -59,7 +60,7 @@ You must only use the \`id\` attribute of the agent, never the name.
|
|
|
59
60
|
`
|
|
60
61
|
};
|
|
61
62
|
exports.OrchestratorChatAgentId = 'Orchestrator';
|
|
62
|
-
const
|
|
63
|
+
const OrchestratorRequestIdKey = 'orchestatorRequestIdKey';
|
|
63
64
|
let OrchestratorChatAgent = class OrchestratorChatAgent extends chat_agents_1.AbstractStreamParsingChatAgent {
|
|
64
65
|
constructor() {
|
|
65
66
|
super(exports.OrchestratorChatAgentId, [{
|
|
@@ -78,18 +79,18 @@ let OrchestratorChatAgent = class OrchestratorChatAgent extends chat_agents_1.Ab
|
|
|
78
79
|
this.agentSpecificVariables = [];
|
|
79
80
|
}
|
|
80
81
|
async invoke(request) {
|
|
82
|
+
var _a;
|
|
81
83
|
request.response.addProgressMessage({ content: 'Determining the most appropriate agent', status: 'inProgress' });
|
|
82
84
|
// We generate a dedicated ID for recording the orchestrator request/response, as we will forward the original request to another agent
|
|
83
|
-
const
|
|
84
|
-
request.addData(
|
|
85
|
-
const
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
85
|
+
const orchestratorRequestId = (0, core_1.generateUuid)();
|
|
86
|
+
request.addData(OrchestratorRequestIdKey, orchestratorRequestId);
|
|
87
|
+
const messages = await this.getMessages(request.session);
|
|
88
|
+
const systemMessage = (_a = (await this.getSystemMessageDescription())) === null || _a === void 0 ? void 0 : _a.text;
|
|
89
|
+
this.recordingService.recordRequest(chat_history_entry_1.ChatHistoryEntry.fromRequest(this.id, request, {
|
|
90
|
+
requestId: orchestratorRequestId,
|
|
91
|
+
messages,
|
|
92
|
+
systemMessage
|
|
93
|
+
}));
|
|
93
94
|
return super.invoke(request);
|
|
94
95
|
}
|
|
95
96
|
async getSystemMessageDescription() {
|
|
@@ -101,12 +102,11 @@ let OrchestratorChatAgent = class OrchestratorChatAgent extends chat_agents_1.Ab
|
|
|
101
102
|
let agentIds = [];
|
|
102
103
|
const responseText = await (0, ai_core_1.getTextOfResponse)(response);
|
|
103
104
|
// We use the previously generated, dedicated ID to log the orchestrator response before we forward the original request
|
|
104
|
-
const orchestratorRequestId = request.getDataByKey(
|
|
105
|
+
const orchestratorRequestId = request.getDataByKey(OrchestratorRequestIdKey);
|
|
105
106
|
if (typeof orchestratorRequestId === 'string') {
|
|
106
107
|
this.recordingService.recordResponse({
|
|
107
108
|
agentId: this.id,
|
|
108
109
|
sessionId: request.session.id,
|
|
109
|
-
timestamp: Date.now(),
|
|
110
110
|
requestId: orchestratorRequestId,
|
|
111
111
|
response: responseText,
|
|
112
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-chat-agent.js","sourceRoot":"","sources":["../../src/common/orchestrator-chat-agent.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,4CAAiH;AAIjH,4DAAkE;AAClE,6DAAwD;AACxD,+CAAoG;AACpG,6CAA0F;AAC1F,sCAA2C;
|
|
1
|
+
{"version":3,"file":"orchestrator-chat-agent.js","sourceRoot":"","sources":["../../src/common/orchestrator-chat-agent.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAA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|
-
"version": "1.55.0-next.
|
|
3
|
+
"version": "1.55.0-next.67+8664face6",
|
|
4
4
|
"description": "Theia - AI Chat Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.55.0-next.
|
|
7
|
-
"@theia/ai-history": "1.55.0-next.
|
|
8
|
-
"@theia/core": "1.55.0-next.
|
|
9
|
-
"@theia/filesystem": "1.55.0-next.
|
|
10
|
-
"@theia/workspace": "1.55.0-next.
|
|
6
|
+
"@theia/ai-core": "1.55.0-next.67+8664face6",
|
|
7
|
+
"@theia/ai-history": "1.55.0-next.67+8664face6",
|
|
8
|
+
"@theia/core": "1.55.0-next.67+8664face6",
|
|
9
|
+
"@theia/filesystem": "1.55.0-next.67+8664face6",
|
|
10
|
+
"@theia/workspace": "1.55.0-next.67+8664face6",
|
|
11
11
|
"minimatch": "^5.1.0",
|
|
12
12
|
"tslib": "^2.6.2"
|
|
13
13
|
},
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"watch": "theiaext watch"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@theia/ext-scripts": "1.
|
|
48
|
+
"@theia/ext-scripts": "1.55.0"
|
|
49
49
|
},
|
|
50
50
|
"nyc": {
|
|
51
51
|
"extends": "../../configs/nyc.json"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "8664face680c050b8d544a381645259b6821a634"
|
|
54
54
|
}
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { Agent, AIVariableContribution } from '@theia/ai-core/lib/common';
|
|
17
|
+
import { Agent, AgentService, AIVariableContribution } from '@theia/ai-core/lib/common';
|
|
18
18
|
import { bindContributionProvider } from '@theia/core';
|
|
19
|
-
import { PreferenceContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import { FrontendApplicationContribution, PreferenceContribution } from '@theia/core/lib/browser';
|
|
20
20
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
21
21
|
import {
|
|
22
22
|
ChatAgent,
|
|
@@ -27,13 +27,17 @@ import {
|
|
|
27
27
|
ChatService,
|
|
28
28
|
DefaultChatAgentId
|
|
29
29
|
} from '../common';
|
|
30
|
+
import { ChatAgentsVariableContribution } from '../common/chat-agents-variable-contribution';
|
|
30
31
|
import { CommandChatAgent } from '../common/command-chat-agents';
|
|
32
|
+
import { CustomChatAgent } from '../common/custom-chat-agent';
|
|
31
33
|
import { OrchestratorChatAgent, OrchestratorChatAgentId } from '../common/orchestrator-chat-agent';
|
|
34
|
+
import { DefaultResponseContentFactory, DefaultResponseContentMatcherProvider, ResponseContentMatcherProvider } from '../common/response-content-matcher';
|
|
32
35
|
import { UniversalChatAgent } from '../common/universal-chat-agent';
|
|
33
36
|
import { aiChatPreferences } from './ai-chat-preferences';
|
|
34
|
-
import {
|
|
37
|
+
import { AICustomAgentsFrontendApplicationContribution } from './custom-agent-frontend-application-contribution';
|
|
35
38
|
import { FrontendChatServiceImpl } from './frontend-chat-service';
|
|
36
|
-
import {
|
|
39
|
+
import { CustomAgentFactory } from './custom-agent-factory';
|
|
40
|
+
import { O1ChatAgent } from '../common/o1-chat-agent';
|
|
37
41
|
|
|
38
42
|
export default new ContainerModule(bind => {
|
|
39
43
|
bindContributionProvider(bind, Agent);
|
|
@@ -60,6 +64,10 @@ export default new ContainerModule(bind => {
|
|
|
60
64
|
bind(Agent).toService(OrchestratorChatAgent);
|
|
61
65
|
bind(ChatAgent).toService(OrchestratorChatAgent);
|
|
62
66
|
|
|
67
|
+
bind(O1ChatAgent).toSelf().inSingletonScope();
|
|
68
|
+
bind(Agent).toService(O1ChatAgent);
|
|
69
|
+
bind(ChatAgent).toService(O1ChatAgent);
|
|
70
|
+
|
|
63
71
|
bind(UniversalChatAgent).toSelf().inSingletonScope();
|
|
64
72
|
bind(Agent).toService(UniversalChatAgent);
|
|
65
73
|
bind(ChatAgent).toService(UniversalChatAgent);
|
|
@@ -69,4 +77,22 @@ export default new ContainerModule(bind => {
|
|
|
69
77
|
bind(ChatAgent).toService(CommandChatAgent);
|
|
70
78
|
|
|
71
79
|
bind(PreferenceContribution).toConstantValue({ schema: aiChatPreferences });
|
|
80
|
+
|
|
81
|
+
bind(CustomChatAgent).toSelf();
|
|
82
|
+
bind(CustomAgentFactory).toFactory<CustomChatAgent, [string, string, string, string, string]>(
|
|
83
|
+
ctx => (id: string, name: string, description: string, prompt: string, defaultLLM: string) => {
|
|
84
|
+
const agent = ctx.container.get<CustomChatAgent>(CustomChatAgent);
|
|
85
|
+
agent.id = id;
|
|
86
|
+
agent.name = name;
|
|
87
|
+
agent.description = description;
|
|
88
|
+
agent.prompt = prompt;
|
|
89
|
+
agent.languageModelRequirements = [{
|
|
90
|
+
purpose: 'chat',
|
|
91
|
+
identifier: defaultLLM,
|
|
92
|
+
}];
|
|
93
|
+
ctx.container.get<ChatAgentService>(ChatAgentService).registerChatAgent(agent);
|
|
94
|
+
ctx.container.get<AgentService>(AgentService).registerAgent(agent);
|
|
95
|
+
return agent;
|
|
96
|
+
});
|
|
97
|
+
bind(FrontendApplicationContribution).to(AICustomAgentsFrontendApplicationContribution).inSingletonScope();
|
|
72
98
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CustomChatAgent } from '../common';
|
|
18
|
+
|
|
19
|
+
export const CustomAgentFactory = Symbol('CustomAgentFactory');
|
|
20
|
+
export type CustomAgentFactory = (id: string, name: string, description: string, prompt: string, defaultLLM: string) => CustomChatAgent;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { AgentService, CustomAgentDescription, PromptCustomizationService } from '@theia/ai-core';
|
|
18
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import { ChatAgentService } from '../common';
|
|
21
|
+
import { CustomAgentFactory } from './custom-agent-factory';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class AICustomAgentsFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
25
|
+
@inject(CustomAgentFactory)
|
|
26
|
+
protected readonly customAgentFactory: CustomAgentFactory;
|
|
27
|
+
|
|
28
|
+
@inject(PromptCustomizationService)
|
|
29
|
+
protected readonly customizationService: PromptCustomizationService;
|
|
30
|
+
|
|
31
|
+
@inject(AgentService)
|
|
32
|
+
private readonly agentService: AgentService;
|
|
33
|
+
|
|
34
|
+
@inject(ChatAgentService)
|
|
35
|
+
private readonly chatAgentService: ChatAgentService;
|
|
36
|
+
|
|
37
|
+
private knownCustomAgents: Map<string, CustomAgentDescription> = new Map();
|
|
38
|
+
onStart(): void {
|
|
39
|
+
this.customizationService?.getCustomAgents().then(customAgents => {
|
|
40
|
+
customAgents.forEach(agent => {
|
|
41
|
+
this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
|
|
42
|
+
this.knownCustomAgents.set(agent.id, agent);
|
|
43
|
+
});
|
|
44
|
+
}).catch(e => {
|
|
45
|
+
console.error('Failed to load custom agents', e);
|
|
46
|
+
});
|
|
47
|
+
this.customizationService?.onDidChangeCustomAgents(() => {
|
|
48
|
+
this.customizationService?.getCustomAgents().then(customAgents => {
|
|
49
|
+
const customAgentsToAdd = customAgents.filter(agent =>
|
|
50
|
+
!this.knownCustomAgents.has(agent.id) || !CustomAgentDescription.equals(this.knownCustomAgents.get(agent.id)!, agent));
|
|
51
|
+
const customAgentIdsToRemove = [...this.knownCustomAgents.values()].filter(agent =>
|
|
52
|
+
!customAgents.find(a => CustomAgentDescription.equals(a, agent))).map(a => a.id);
|
|
53
|
+
|
|
54
|
+
// delete first so we don't have to deal with the case where we add and remove the same agentId
|
|
55
|
+
customAgentIdsToRemove.forEach(id => {
|
|
56
|
+
this.chatAgentService.unregisterChatAgent(id);
|
|
57
|
+
this.agentService.unregisterAgent(id);
|
|
58
|
+
this.knownCustomAgents.delete(id);
|
|
59
|
+
});
|
|
60
|
+
customAgentsToAdd
|
|
61
|
+
.forEach(agent => {
|
|
62
|
+
this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
|
|
63
|
+
this.knownCustomAgents.set(agent.id, agent);
|
|
64
|
+
});
|
|
65
|
+
}).catch(e => {
|
|
66
|
+
console.error('Failed to load custom agents', e);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onStop(): void {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -41,6 +41,18 @@ export interface ChatAgentService {
|
|
|
41
41
|
* Returns all agents, including disabled ones.
|
|
42
42
|
*/
|
|
43
43
|
getAllAgents(): ChatAgent[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Allows to register a chat agent programmatically.
|
|
47
|
+
* @param agent the agent to register
|
|
48
|
+
*/
|
|
49
|
+
registerChatAgent(agent: ChatAgent): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Allows to unregister a chat agent programmatically.
|
|
53
|
+
* @param agentId the agent id to unregister
|
|
54
|
+
*/
|
|
55
|
+
unregisterChatAgent(agentId: string): void;
|
|
44
56
|
}
|
|
45
57
|
@injectable()
|
|
46
58
|
export class ChatAgentServiceImpl implements ChatAgentService {
|
|
@@ -65,6 +77,9 @@ export class ChatAgentServiceImpl implements ChatAgentService {
|
|
|
65
77
|
registerChatAgent(agent: ChatAgent): void {
|
|
66
78
|
this._agents.push(agent);
|
|
67
79
|
}
|
|
80
|
+
unregisterChatAgent(agentId: string): void {
|
|
81
|
+
this._agents = this._agents.filter(a => a.id !== agentId);
|
|
82
|
+
}
|
|
68
83
|
|
|
69
84
|
getAgent(id: string): ChatAgent | undefined {
|
|
70
85
|
if (!this._agentIsEnabled(id)) {
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
} from './chat-model';
|
|
53
53
|
import { findFirstMatch, parseContents } from './parse-contents';
|
|
54
54
|
import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
|
|
55
|
+
import { ChatHistoryEntry } from './chat-history-entry';
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* A conversation consists of a sequence of ChatMessages.
|
|
@@ -152,19 +153,19 @@ export abstract class AbstractChatAgent {
|
|
|
152
153
|
if (!languageModel) {
|
|
153
154
|
throw new Error('Couldn\'t find a matching language model. Please check your setup!');
|
|
154
155
|
}
|
|
156
|
+
|
|
157
|
+
const systemMessageDescription = await this.getSystemMessageDescription();
|
|
155
158
|
const messages = await this.getMessages(request.session);
|
|
156
159
|
if (this.defaultLogging) {
|
|
157
|
-
this.recordingService.recordRequest(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
160
|
+
this.recordingService.recordRequest(
|
|
161
|
+
ChatHistoryEntry.fromRequest(
|
|
162
|
+
this.id, request, {
|
|
163
|
+
messages,
|
|
164
|
+
systemMessage: systemMessageDescription?.text
|
|
165
|
+
})
|
|
166
|
+
);
|
|
165
167
|
}
|
|
166
168
|
|
|
167
|
-
const systemMessageDescription = await this.getSystemMessageDescription();
|
|
168
169
|
const tools: Map<string, ToolRequest> = new Map();
|
|
169
170
|
if (systemMessageDescription) {
|
|
170
171
|
const systemMsg: ChatMessage = {
|
|
@@ -196,13 +197,7 @@ export abstract class AbstractChatAgent {
|
|
|
196
197
|
await this.addContentsToResponse(languageModelResponse, request);
|
|
197
198
|
request.response.complete();
|
|
198
199
|
if (this.defaultLogging) {
|
|
199
|
-
this.recordingService.recordResponse(
|
|
200
|
-
agentId: this.id,
|
|
201
|
-
sessionId: request.session.id,
|
|
202
|
-
timestamp: Date.now(),
|
|
203
|
-
requestId: request.response.requestId,
|
|
204
|
-
response: request.response.response.asString()
|
|
205
|
-
});
|
|
200
|
+
this.recordingService.recordResponse(ChatHistoryEntry.fromResponse(this.id, request));
|
|
206
201
|
}
|
|
207
202
|
} catch (e) {
|
|
208
203
|
this.handleError(request, e);
|
|
@@ -322,14 +317,7 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
|
322
317
|
request.response.response.addContents(contents);
|
|
323
318
|
request.response.complete();
|
|
324
319
|
if (this.defaultLogging) {
|
|
325
|
-
this.recordingService.recordResponse(
|
|
326
|
-
agentId: this.id,
|
|
327
|
-
sessionId: request.session.id,
|
|
328
|
-
timestamp: Date.now(),
|
|
329
|
-
requestId: request.response.requestId,
|
|
330
|
-
response: request.response.response.asString()
|
|
331
|
-
|
|
332
|
-
});
|
|
320
|
+
this.recordingService.recordResponse(ChatHistoryEntry.fromResponse(this.id, request));
|
|
333
321
|
}
|
|
334
322
|
return;
|
|
335
323
|
}
|
|
@@ -337,13 +325,7 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
|
337
325
|
await this.addStreamResponse(languageModelResponse, request);
|
|
338
326
|
request.response.complete();
|
|
339
327
|
if (this.defaultLogging) {
|
|
340
|
-
this.recordingService.recordResponse(
|
|
341
|
-
agentId: this.id,
|
|
342
|
-
sessionId: request.session.id,
|
|
343
|
-
timestamp: Date.now(),
|
|
344
|
-
requestId: request.response.requestId,
|
|
345
|
-
response: request.response.response.asString()
|
|
346
|
-
});
|
|
328
|
+
this.recordingService.recordResponse(ChatHistoryEntry.fromResponse(this.id, request));
|
|
347
329
|
}
|
|
348
330
|
return;
|
|
349
331
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CommunicationRequestEntryParam, CommunicationResponseEntryParam } from '@theia/ai-core/lib/common/communication-recording-service';
|
|
18
|
+
import { ChatRequestModel } from './chat-model';
|
|
19
|
+
|
|
20
|
+
export namespace ChatHistoryEntry {
|
|
21
|
+
export function fromRequest(
|
|
22
|
+
agentId: string,
|
|
23
|
+
request: ChatRequestModel,
|
|
24
|
+
args: Partial<CommunicationRequestEntryParam> = {}
|
|
25
|
+
): CommunicationRequestEntryParam {
|
|
26
|
+
return {
|
|
27
|
+
agentId: agentId,
|
|
28
|
+
sessionId: request.session.id,
|
|
29
|
+
requestId: request.id,
|
|
30
|
+
request: request.request.text,
|
|
31
|
+
...args,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function fromResponse(
|
|
35
|
+
agentId: string,
|
|
36
|
+
request: ChatRequestModel,
|
|
37
|
+
args: Partial<CommunicationResponseEntryParam> = {}
|
|
38
|
+
): CommunicationResponseEntryParam {
|
|
39
|
+
return {
|
|
40
|
+
agentId: agentId,
|
|
41
|
+
sessionId: request.session.id,
|
|
42
|
+
requestId: request.id,
|
|
43
|
+
response: request.response.response.asString(),
|
|
44
|
+
...args,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
|
|
18
|
+
import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
|
|
19
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class CustomChatAgent
|
|
23
|
+
extends AbstractStreamParsingChatAgent
|
|
24
|
+
implements ChatAgent {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
readonly variables: string[] = [];
|
|
28
|
+
readonly functions: string[] = [];
|
|
29
|
+
readonly promptTemplates: PromptTemplate[] = [];
|
|
30
|
+
readonly agentSpecificVariables: AgentSpecificVariables[] = [];
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
) {
|
|
34
|
+
super('CustomChatAgent', [{ purpose: 'chat' }], 'chat');
|
|
35
|
+
}
|
|
36
|
+
protected override async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
|
|
37
|
+
const resolvedPrompt = await this.promptService.getPrompt(`${this.name}_prompt`);
|
|
38
|
+
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set prompt(prompt: string) {
|
|
42
|
+
this.promptTemplates.push({ id: `${this.name}_prompt`, template: prompt });
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/common/index.ts
CHANGED
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
//
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
|
-
export * from './chat-agent-service';
|
|
17
16
|
export * from './chat-agents';
|
|
17
|
+
export * from './chat-agent-service';
|
|
18
18
|
export * from './chat-model';
|
|
19
|
-
export * from './parsed-chat-request';
|
|
20
19
|
export * from './chat-request-parser';
|
|
21
20
|
export * from './chat-service';
|
|
22
21
|
export * from './command-chat-agents';
|
|
23
|
-
export * from './
|
|
22
|
+
export * from './custom-chat-agent';
|
|
23
|
+
export * from './parsed-chat-request';
|
|
24
24
|
export * from './orchestrator-chat-agent';
|
|
25
|
+
export * from './universal-chat-agent';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
ChatAgent,
|
|
19
|
+
AbstractStreamParsingChatAgent,
|
|
20
|
+
SystemMessageDescription
|
|
21
|
+
} from './chat-agents';
|
|
22
|
+
|
|
23
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
24
|
+
import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
|
|
25
|
+
|
|
26
|
+
@injectable()
|
|
27
|
+
export class O1ChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
|
|
28
|
+
|
|
29
|
+
public name = 'O1-Preview';
|
|
30
|
+
public description = 'An agent for interacting with ChatGPT o1-preview';
|
|
31
|
+
public promptTemplates: PromptTemplate[] = [];
|
|
32
|
+
readonly agentSpecificVariables: AgentSpecificVariables[] = [];
|
|
33
|
+
readonly variables: string[] = [];
|
|
34
|
+
readonly functions: string[] = [];
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super(
|
|
38
|
+
'o1-preview',
|
|
39
|
+
[{
|
|
40
|
+
purpose: 'chat',
|
|
41
|
+
identifier: 'openai/o1-preview',
|
|
42
|
+
}],
|
|
43
|
+
'chat'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
|
|
48
|
+
// O1 currently does not support system prompts
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|