@theia/ai-chat 1.60.0-next.47 → 1.60.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/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +4 -0
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/file-chat-variable-contribution.d.ts +1 -1
- package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
- package/lib/browser/file-chat-variable-contribution.js +4 -3
- package/lib/browser/file-chat-variable-contribution.js.map +1 -1
- package/lib/common/chat-agents.d.ts +8 -19
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +59 -35
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-model.d.ts +41 -4
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +89 -1
- package/lib/common/chat-model.js.map +1 -1
- package/lib/common/chat-request-parser.spec.js +10 -2
- package/lib/common/chat-request-parser.spec.js.map +1 -1
- package/lib/common/chat-service.d.ts +20 -4
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +52 -5
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-session-naming-service.d.ts +26 -0
- package/lib/common/chat-session-naming-service.d.ts.map +1 -0
- package/lib/common/chat-session-naming-service.js +132 -0
- package/lib/common/chat-session-naming-service.js.map +1 -0
- package/package.json +11 -11
- package/src/browser/ai-chat-frontend-module.ts +5 -0
- package/src/browser/file-chat-variable-contribution.ts +5 -3
- package/src/common/chat-agents.ts +85 -69
- package/src/common/chat-model.ts +115 -5
- package/src/common/chat-request-parser.spec.ts +10 -2
- package/src/common/chat-service.ts +63 -5
- package/src/common/chat-session-naming-service.ts +135 -0
- package/lib/common/chat-history-entry.d.ts +0 -7
- package/lib/common/chat-history-entry.d.ts.map +0 -1
- package/lib/common/chat-history-entry.js +0 -42
- package/lib/common/chat-history-entry.js.map +0 -1
- package/src/common/chat-history-entry.ts +0 -47
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-service.js","sourceRoot":"","sources":["../../src/common/chat-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,8JAA8J;;;;AAE9J,4CAA2G;AAC3G,sCAA6D;AAC7D,4DAA4E;AAE5E,6DAAwD;AACxD,+CAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"chat-service.js","sourceRoot":"","sources":["../../src/common/chat-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,8JAA8J;;;;AAE9J,4CAA2G;AAC3G,sCAA6D;AAC7D,4DAA4E;AAE5E,6DAAwD;AACxD,+CAAiF;AACjF,6CASsB;AACtB,+DAA0D;AAC1D,+DAAsF;AACtF,+EAAyE;AAgCzE,SAAgB,2BAA2B,CAAC,GAAY;IACpD,2CAA2C;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,CAAC;AACnG,CAAC;AAHD,kEAGC;AAOD,SAAgB,qBAAqB,CAAC,GAAY;IAC9C,2CAA2C;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK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, LanguageModelRequirement, PromptService, PromptTemplate } from '@theia/ai-core';
|
|
2
|
+
import { ChatSession } from './chat-service';
|
|
3
|
+
export declare class ChatSessionNamingService {
|
|
4
|
+
protected agentService: AgentService;
|
|
5
|
+
generateChatSessionName(chatSession: ChatSession, otherNames: string[]): Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ChatSessionNamingAgent implements Agent {
|
|
8
|
+
static ID: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
variables: never[];
|
|
13
|
+
promptTemplates: PromptTemplate[];
|
|
14
|
+
languageModelRequirements: LanguageModelRequirement[];
|
|
15
|
+
agentSpecificVariables: {
|
|
16
|
+
name: string;
|
|
17
|
+
usedInPrompt: boolean;
|
|
18
|
+
description: string;
|
|
19
|
+
}[];
|
|
20
|
+
functions: never[];
|
|
21
|
+
protected readonly lmRegistry: LanguageModelRegistry;
|
|
22
|
+
protected recordingService: CommunicationRecordingService;
|
|
23
|
+
protected promptService: PromptService;
|
|
24
|
+
generateChatSessionName(chatSession: ChatSession, otherNames: string[]): Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=chat-session-naming-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-session-naming-service.d.ts","sourceRoot":"","sources":["../../src/common/chat-session-naming-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,EACL,YAAY,EACZ,6BAA6B,EAE7B,qBAAqB,EAErB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAiB7C,qBACa,wBAAwB;IACX,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrD,uBAAuB,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAO7G;AAED,qBACa,sBAAuB,YAAW,KAAK;IAChD,MAAM,CAAC,EAAE,SAA+B;IACxC,EAAE,SAA6B;IAC/B,IAAI,SAAyB;IAC7B,WAAW,SAA6C;IACxD,SAAS,UAAM;IACf,eAAe,EAAE,cAAc,EAAE,CAAgC;IACjE,yBAAyB,EAAE,wBAAwB,EAAE,CAGlD;IACH,sBAAsB;;;;QAGpB;IACF,SAAS,UAAM;IAGf,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAGrD,SAAS,CAAC,gBAAgB,EAAE,6BAA6B,CAAC;IAG1D,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAEjC,uBAAuB,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAkDjG"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 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
|
+
var ChatSessionNamingAgent_1;
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.ChatSessionNamingAgent = exports.ChatSessionNamingService = void 0;
|
|
20
|
+
const tslib_1 = require("tslib");
|
|
21
|
+
const ai_core_1 = require("@theia/ai-core");
|
|
22
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
|
+
const core_1 = require("@theia/core");
|
|
24
|
+
const CHAT_SESSION_NAMING_PROMPT = {
|
|
25
|
+
id: 'chat-session-naming-prompt',
|
|
26
|
+
template: '{{!-- Made improvements or adaptations to this prompt template? We\'d love for you to share it with the community! Contribute back here: ' +
|
|
27
|
+
'https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}\n\n' +
|
|
28
|
+
'Provide a short and descriptive name for the given AI chat conversation of an AI-powered tool based on the conversation below.\n\n' +
|
|
29
|
+
'The purpose of the name is for users to recognize the chat conversation easily in a list of conversations. ' +
|
|
30
|
+
'Use the same language for the chat conversation name as used in the provided conversation, if in doubt default to English. ' +
|
|
31
|
+
'Start the chat conversation name with an upper-case letter. ' +
|
|
32
|
+
'Below we also provide the already existing other conversation names, make sure your suggestion for a name is unique with respect to the existing ones.\n\n' +
|
|
33
|
+
'IMPORTANT: Your answer MUST ONLY CONTAIN THE PROPOSED NAME and must not be preceded or succeeded with any other text.' +
|
|
34
|
+
'\n\nOther session names:\n{{listOfSessionNames}}' +
|
|
35
|
+
'\n\nConversation:\n{{conversation}}',
|
|
36
|
+
};
|
|
37
|
+
let ChatSessionNamingService = class ChatSessionNamingService {
|
|
38
|
+
async generateChatSessionName(chatSession, otherNames) {
|
|
39
|
+
const chatSessionNamingAgent = this.agentService.getAgents().find(agent => ChatSessionNamingAgent.ID === agent.id);
|
|
40
|
+
if (!(chatSessionNamingAgent instanceof ChatSessionNamingAgent)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return chatSessionNamingAgent.generateChatSessionName(chatSession, otherNames);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.ChatSessionNamingService = ChatSessionNamingService;
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, inversify_1.inject)(ai_core_1.AgentService),
|
|
49
|
+
tslib_1.__metadata("design:type", Object)
|
|
50
|
+
], ChatSessionNamingService.prototype, "agentService", void 0);
|
|
51
|
+
exports.ChatSessionNamingService = ChatSessionNamingService = tslib_1.__decorate([
|
|
52
|
+
(0, inversify_1.injectable)()
|
|
53
|
+
], ChatSessionNamingService);
|
|
54
|
+
let ChatSessionNamingAgent = ChatSessionNamingAgent_1 = class ChatSessionNamingAgent {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.id = ChatSessionNamingAgent_1.ID;
|
|
57
|
+
this.name = 'Chat Session Naming';
|
|
58
|
+
this.description = 'Agent for generating chat session names';
|
|
59
|
+
this.variables = [];
|
|
60
|
+
this.promptTemplates = [CHAT_SESSION_NAMING_PROMPT];
|
|
61
|
+
this.languageModelRequirements = [{
|
|
62
|
+
purpose: 'chat-session-naming',
|
|
63
|
+
identifier: 'openai/gpt-4o-mini',
|
|
64
|
+
}];
|
|
65
|
+
this.agentSpecificVariables = [
|
|
66
|
+
{ name: 'conversation', usedInPrompt: true, description: 'The content of the chat conversation.' },
|
|
67
|
+
{ name: 'listOfSessionNames', usedInPrompt: true, description: 'The list of existing session names.' }
|
|
68
|
+
];
|
|
69
|
+
this.functions = [];
|
|
70
|
+
}
|
|
71
|
+
async generateChatSessionName(chatSession, otherNames) {
|
|
72
|
+
const lm = await this.lmRegistry.selectLanguageModel({ agent: this.id, ...this.languageModelRequirements[0] });
|
|
73
|
+
if (!lm) {
|
|
74
|
+
throw new Error('No language model found for chat session naming');
|
|
75
|
+
}
|
|
76
|
+
if (chatSession.model.getRequests().length < 1) {
|
|
77
|
+
throw new Error('No chat request available to generate chat session name');
|
|
78
|
+
}
|
|
79
|
+
const conversation = chatSession.model.getRequests()
|
|
80
|
+
.map(req => `<user>${req.request.text}</user>` +
|
|
81
|
+
(req.response.response ? `<assistant>${req.response.response.asString()}</assistant>` : ''))
|
|
82
|
+
.join('\n\n');
|
|
83
|
+
const listOfSessionNames = otherNames.map(name => name).join(', ');
|
|
84
|
+
const prompt = await this.promptService.getPrompt(CHAT_SESSION_NAMING_PROMPT.id, { conversation, listOfSessionNames });
|
|
85
|
+
const message = prompt === null || prompt === void 0 ? void 0 : prompt.text;
|
|
86
|
+
if (!message) {
|
|
87
|
+
throw new Error('Unable to create prompt message for generating chat session name');
|
|
88
|
+
}
|
|
89
|
+
const request = {
|
|
90
|
+
messages: [{
|
|
91
|
+
actor: 'user',
|
|
92
|
+
text: message,
|
|
93
|
+
type: 'text'
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
const sessionId = (0, core_1.generateUuid)();
|
|
97
|
+
const requestId = (0, core_1.generateUuid)();
|
|
98
|
+
this.recordingService.recordRequest({
|
|
99
|
+
agentId: this.id,
|
|
100
|
+
sessionId,
|
|
101
|
+
requestId,
|
|
102
|
+
...request
|
|
103
|
+
});
|
|
104
|
+
const result = await lm.request(request);
|
|
105
|
+
const response = await (0, ai_core_1.getTextOfResponse)(result);
|
|
106
|
+
this.recordingService.recordResponse({
|
|
107
|
+
agentId: this.id,
|
|
108
|
+
sessionId,
|
|
109
|
+
requestId,
|
|
110
|
+
response: [{ actor: 'ai', text: response, type: 'text' }]
|
|
111
|
+
});
|
|
112
|
+
return response.replace(/\s+/g, ' ').substring(0, 100);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.ChatSessionNamingAgent = ChatSessionNamingAgent;
|
|
116
|
+
ChatSessionNamingAgent.ID = 'chat-session-naming-agent';
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, inversify_1.inject)(ai_core_1.LanguageModelRegistry),
|
|
119
|
+
tslib_1.__metadata("design:type", Object)
|
|
120
|
+
], ChatSessionNamingAgent.prototype, "lmRegistry", void 0);
|
|
121
|
+
tslib_1.__decorate([
|
|
122
|
+
(0, inversify_1.inject)(ai_core_1.CommunicationRecordingService),
|
|
123
|
+
tslib_1.__metadata("design:type", Object)
|
|
124
|
+
], ChatSessionNamingAgent.prototype, "recordingService", void 0);
|
|
125
|
+
tslib_1.__decorate([
|
|
126
|
+
(0, inversify_1.inject)(ai_core_1.PromptService),
|
|
127
|
+
tslib_1.__metadata("design:type", Object)
|
|
128
|
+
], ChatSessionNamingAgent.prototype, "promptService", void 0);
|
|
129
|
+
exports.ChatSessionNamingAgent = ChatSessionNamingAgent = ChatSessionNamingAgent_1 = tslib_1.__decorate([
|
|
130
|
+
(0, inversify_1.injectable)()
|
|
131
|
+
], ChatSessionNamingAgent);
|
|
132
|
+
//# sourceMappingURL=chat-session-naming-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-session-naming-service.js","sourceRoot":"","sources":["../../src/common/chat-session-naming-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;;;;;AAEhF,4CAUwB;AACxB,4DAAkE;AAElE,sCAA2C;AAE3C,MAAM,0BAA0B,GAAG;IAC/B,EAAE,EAAE,4BAA4B;IAChC,QAAQ,EAAE,2IAA2I;QACjJ,uGAAuG;QACvG,oIAAoI;QACpI,6GAA6G;QAC7G,6HAA6H;QAC7H,8DAA8D;QAC9D,4JAA4J;QAC5J,uHAAuH;QACvH,kDAAkD;QAClD,qCAAqC;CAC5C,CAAC;AAGK,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEjC,KAAK,CAAC,uBAAuB,CAAC,WAAwB,EAAE,UAAoB;QACxE,MAAM,sBAAsB,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;QACnH,IAAI,CAAC,CAAC,sBAAsB,YAAY,sBAAsB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AAS;YACT,GAAG,OAAO;SACb,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAiB,EAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC;YACjC,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,SAAS;YACT,SAAS;YACT,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SAC5D,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;;AA1EQ,wDAAsB;AACxB,yBAAE,GAAG,2BAA2B,AAA9B,CAA+B;AAiBrB;IADlB,IAAA,kBAAM,EAAC,+BAAqB,CAAC;;0DACuB;AAG3C;IADT,IAAA,kBAAM,EAAC,uCAA6B,CAAC;;gEACoB;AAGhD;IADT,IAAA,kBAAM,EAAC,uBAAa,CAAC;;6DACiB;iCAxB9B,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CA4ElC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-chat",
|
|
3
|
-
"version": "1.60.0
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"description": "Theia - AI Chat Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.60.0
|
|
7
|
-
"@theia/ai-history": "1.60.0
|
|
8
|
-
"@theia/core": "1.60.0
|
|
9
|
-
"@theia/editor": "1.60.0
|
|
10
|
-
"@theia/file-search": "1.60.0
|
|
11
|
-
"@theia/filesystem": "1.60.0
|
|
12
|
-
"@theia/monaco": "1.60.0
|
|
6
|
+
"@theia/ai-core": "1.60.0",
|
|
7
|
+
"@theia/ai-history": "1.60.0",
|
|
8
|
+
"@theia/core": "1.60.0",
|
|
9
|
+
"@theia/editor": "1.60.0",
|
|
10
|
+
"@theia/file-search": "1.60.0",
|
|
11
|
+
"@theia/filesystem": "1.60.0",
|
|
12
|
+
"@theia/monaco": "1.60.0",
|
|
13
13
|
"@theia/monaco-editor-core": "1.96.302",
|
|
14
|
-
"@theia/workspace": "1.60.0
|
|
14
|
+
"@theia/workspace": "1.60.0",
|
|
15
15
|
"minimatch": "^5.1.0",
|
|
16
16
|
"tslib": "^2.6.2"
|
|
17
17
|
},
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"watch": "theiaext watch"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@theia/ext-scripts": "1.
|
|
52
|
+
"@theia/ext-scripts": "1.60.0"
|
|
53
53
|
},
|
|
54
54
|
"nyc": {
|
|
55
55
|
"extends": "../../configs/nyc.json"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "193fa55d7e26aa9dc8acba3ae3b99b0182f3603f"
|
|
58
58
|
}
|
|
@@ -45,6 +45,7 @@ import { FileChatVariableContribution } from './file-chat-variable-contribution'
|
|
|
45
45
|
import { ContextSummaryVariableContribution } from '../common/context-summary-variable';
|
|
46
46
|
import { ContextDetailsVariableContribution } from '../common/context-details-variable';
|
|
47
47
|
import { ChangeSetVariableContribution } from './change-set-variable';
|
|
48
|
+
import { ChatSessionNamingAgent, ChatSessionNamingService } from '../common/chat-session-naming-service';
|
|
48
49
|
|
|
49
50
|
export default new ContainerModule(bind => {
|
|
50
51
|
bindContributionProvider(bind, Agent);
|
|
@@ -56,6 +57,10 @@ export default new ContainerModule(bind => {
|
|
|
56
57
|
bind(ChatAgentService).toService(ChatAgentServiceImpl);
|
|
57
58
|
bind(PinChatAgent).toConstantValue(true);
|
|
58
59
|
|
|
60
|
+
bind(ChatSessionNamingService).toSelf().inSingletonScope();
|
|
61
|
+
bind(ChatSessionNamingAgent).toSelf().inSingletonScope();
|
|
62
|
+
bind(Agent).toService(ChatSessionNamingAgent);
|
|
63
|
+
|
|
59
64
|
bindContributionProvider(bind, ResponseContentMatcherProvider);
|
|
60
65
|
bind(DefaultResponseContentMatcherProvider).toSelf().inSingletonScope();
|
|
61
66
|
bind(ResponseContentMatcherProvider).toService(DefaultResponseContentMatcherProvider);
|
|
@@ -69,10 +69,11 @@ export class FileChatVariableContribution implements FrontendVariableContributio
|
|
|
69
69
|
|
|
70
70
|
protected async provideArgumentCompletionItems(
|
|
71
71
|
model: monaco.editor.ITextModel,
|
|
72
|
-
position: monaco.Position
|
|
72
|
+
position: monaco.Position,
|
|
73
|
+
matchString?: string
|
|
73
74
|
): Promise<monaco.languages.CompletionItem[] | undefined> {
|
|
74
75
|
const lineContent = model.getLineContent(position.lineNumber);
|
|
75
|
-
const indexOfVariableTrigger = lineContent.lastIndexOf(PromptText.VARIABLE_CHAR, position.column - 1);
|
|
76
|
+
const indexOfVariableTrigger = lineContent.lastIndexOf(matchString ?? PromptText.VARIABLE_CHAR, position.column - 1);
|
|
76
77
|
|
|
77
78
|
// check if there is a variable trigger and no space typed between the variable trigger and the cursor
|
|
78
79
|
if (indexOfVariableTrigger === -1 || lineContent.substring(indexOfVariableTrigger).includes(' ')) {
|
|
@@ -86,7 +87,8 @@ export class FileChatVariableContribution implements FrontendVariableContributio
|
|
|
86
87
|
const typedWord = lineContent.substring(triggerCharIndex + 1, position.column - 1);
|
|
87
88
|
const range = new monaco.Range(position.lineNumber, triggerCharIndex + 2, position.lineNumber, position.column);
|
|
88
89
|
const picks = await this.quickFileSelectService.getPicks(typedWord, CancellationToken.None);
|
|
89
|
-
const
|
|
90
|
+
const matchVariableChar = lineContent[triggerCharIndex] === (matchString ? matchString : PromptText.VARIABLE_CHAR);
|
|
91
|
+
const prefix = matchVariableChar ? FILE_VARIABLE.name + PromptText.VARIABLE_SEPARATOR_CHAR : '';
|
|
90
92
|
|
|
91
93
|
return Promise.all(
|
|
92
94
|
picks
|
|
@@ -24,13 +24,19 @@ import {
|
|
|
24
24
|
AIVariableContext,
|
|
25
25
|
CommunicationRecordingService,
|
|
26
26
|
getTextOfResponse,
|
|
27
|
+
isTextResponsePart,
|
|
28
|
+
isThinkingResponsePart,
|
|
29
|
+
isToolCallResponsePart,
|
|
27
30
|
LanguageModel,
|
|
31
|
+
LanguageModelMessage,
|
|
28
32
|
LanguageModelRequirement,
|
|
29
33
|
LanguageModelResponse,
|
|
34
|
+
LanguageModelService,
|
|
30
35
|
LanguageModelStreamResponse,
|
|
31
36
|
PromptService,
|
|
32
37
|
PromptTemplate,
|
|
33
38
|
ResolvedPromptTemplate,
|
|
39
|
+
TextMessage,
|
|
34
40
|
ToolCall,
|
|
35
41
|
ToolRequest,
|
|
36
42
|
} from '@theia/ai-core';
|
|
@@ -39,10 +45,9 @@ import {
|
|
|
39
45
|
isLanguageModelStreamResponse,
|
|
40
46
|
isLanguageModelTextResponse,
|
|
41
47
|
LanguageModelRegistry,
|
|
42
|
-
LanguageModelStreamResponsePart
|
|
43
|
-
MessageActor,
|
|
48
|
+
LanguageModelStreamResponsePart
|
|
44
49
|
} from '@theia/ai-core/lib/common';
|
|
45
|
-
import {
|
|
50
|
+
import { ContributionProvider, ILogger, isArray } from '@theia/core';
|
|
46
51
|
import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify';
|
|
47
52
|
import { ChatAgentService } from './chat-agent-service';
|
|
48
53
|
import {
|
|
@@ -52,24 +57,12 @@ import {
|
|
|
52
57
|
ErrorChatResponseContentImpl,
|
|
53
58
|
MarkdownChatResponseContentImpl,
|
|
54
59
|
ToolCallChatResponseContentImpl,
|
|
55
|
-
ChatRequestModel
|
|
60
|
+
ChatRequestModel,
|
|
61
|
+
ThinkingChatResponseContentImpl
|
|
56
62
|
} from './chat-model';
|
|
57
63
|
import { findFirstMatch, parseContents } from './parse-contents';
|
|
58
64
|
import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
|
|
59
|
-
import {
|
|
60
|
-
import { ChatToolRequestService } from './chat-tool-request-service';
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A conversation consists of a sequence of ChatMessages.
|
|
64
|
-
* Each ChatMessage is either a user message, AI message or a system message.
|
|
65
|
-
*
|
|
66
|
-
* For now we only support text based messages.
|
|
67
|
-
*/
|
|
68
|
-
export interface ChatMessage {
|
|
69
|
-
actor: MessageActor;
|
|
70
|
-
type: 'text';
|
|
71
|
-
query: string;
|
|
72
|
-
}
|
|
65
|
+
import { ChatToolRequest, ChatToolRequestService } from './chat-tool-request-service';
|
|
73
66
|
|
|
74
67
|
/**
|
|
75
68
|
* System message content, enriched with function descriptions.
|
|
@@ -138,8 +131,8 @@ export interface ChatAgent extends Agent {
|
|
|
138
131
|
export abstract class AbstractChatAgent implements ChatAgent {
|
|
139
132
|
@inject(LanguageModelRegistry) protected languageModelRegistry: LanguageModelRegistry;
|
|
140
133
|
@inject(ILogger) protected logger: ILogger;
|
|
141
|
-
@inject(CommunicationRecordingService) protected recordingService: CommunicationRecordingService;
|
|
142
134
|
@inject(ChatToolRequestService) protected chatToolRequestService: ChatToolRequestService;
|
|
135
|
+
@inject(LanguageModelService) protected languageModelService: LanguageModelService;
|
|
143
136
|
@inject(PromptService) protected promptService: PromptService;
|
|
144
137
|
|
|
145
138
|
@inject(ContributionProvider) @named(ResponseContentMatcherProvider)
|
|
@@ -148,6 +141,9 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
148
141
|
@inject(DefaultResponseContentFactory)
|
|
149
142
|
protected defaultContentFactory: DefaultResponseContentFactory;
|
|
150
143
|
|
|
144
|
+
@inject(CommunicationRecordingService)
|
|
145
|
+
protected recordingService: CommunicationRecordingService;
|
|
146
|
+
|
|
151
147
|
readonly abstract id: string;
|
|
152
148
|
readonly abstract name: string;
|
|
153
149
|
readonly abstract languageModelRequirements: LanguageModelRequirement[];
|
|
@@ -160,7 +156,6 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
160
156
|
agentSpecificVariables: AgentSpecificVariables[] = [];
|
|
161
157
|
functions: string[] = [];
|
|
162
158
|
protected readonly abstract defaultLanguageModelPurpose: string;
|
|
163
|
-
protected defaultLogging: boolean = true;
|
|
164
159
|
protected systemPromptId: string | undefined = undefined;
|
|
165
160
|
protected additionalToolRequests: ToolRequest[] = [];
|
|
166
161
|
protected contentMatchers: ResponseContentMatcher[] = [];
|
|
@@ -183,21 +178,12 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
183
178
|
}
|
|
184
179
|
const systemMessageDescription = await this.getSystemMessageDescription({ model: request.session, request } satisfies ChatSessionContext);
|
|
185
180
|
const messages = await this.getMessages(request.session);
|
|
186
|
-
if (this.defaultLogging) {
|
|
187
|
-
this.recordingService.recordRequest(
|
|
188
|
-
ChatHistoryEntry.fromRequest(
|
|
189
|
-
this.id, request, {
|
|
190
|
-
messages,
|
|
191
|
-
systemMessage: systemMessageDescription?.text
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
181
|
|
|
196
182
|
if (systemMessageDescription) {
|
|
197
|
-
const systemMsg:
|
|
183
|
+
const systemMsg: LanguageModelMessage = {
|
|
198
184
|
actor: 'system',
|
|
199
185
|
type: 'text',
|
|
200
|
-
|
|
186
|
+
text: systemMessageDescription.text
|
|
201
187
|
};
|
|
202
188
|
// insert system message at the beginning of the request messages
|
|
203
189
|
messages.unshift(systemMsg);
|
|
@@ -209,18 +195,11 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
209
195
|
...this.chatToolRequestService.toChatToolRequests(systemMessageToolRequests ? Array.from(systemMessageToolRequests) : [], request),
|
|
210
196
|
...this.chatToolRequestService.toChatToolRequests(this.additionalToolRequests, request)
|
|
211
197
|
];
|
|
198
|
+
const languageModelResponse = await this.sendLlmRequest(request, messages, tools, languageModel);
|
|
212
199
|
|
|
213
|
-
const languageModelResponse = await this.callLlm(
|
|
214
|
-
languageModel,
|
|
215
|
-
messages,
|
|
216
|
-
tools.length > 0 ? tools : undefined,
|
|
217
|
-
request.response.cancellationToken
|
|
218
|
-
);
|
|
219
200
|
await this.addContentsToResponse(languageModelResponse, request);
|
|
220
201
|
await this.onResponseComplete(request);
|
|
221
|
-
|
|
222
|
-
this.recordingService.recordResponse(ChatHistoryEntry.fromResponse(this.id, request));
|
|
223
|
-
}
|
|
202
|
+
|
|
224
203
|
} catch (e) {
|
|
225
204
|
this.handleError(request, e);
|
|
226
205
|
}
|
|
@@ -266,21 +245,28 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
266
245
|
|
|
267
246
|
protected async getMessages(
|
|
268
247
|
model: ChatModel, includeResponseInProgress = false
|
|
269
|
-
): Promise<
|
|
248
|
+
): Promise<LanguageModelMessage[]> {
|
|
270
249
|
const requestMessages = model.getRequests().flatMap(request => {
|
|
271
|
-
const messages:
|
|
250
|
+
const messages: LanguageModelMessage[] = [];
|
|
272
251
|
const text = request.message.parts.map(part => part.promptText).join('');
|
|
273
252
|
messages.push({
|
|
274
253
|
actor: 'user',
|
|
275
254
|
type: 'text',
|
|
276
|
-
|
|
255
|
+
text: text,
|
|
277
256
|
});
|
|
278
257
|
if (request.response.isComplete || includeResponseInProgress) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
258
|
+
const responseMessages: LanguageModelMessage[] = request.response.response.content.flatMap(c => {
|
|
259
|
+
if (ChatResponseContent.hasToLanguageModelMessage(c)) {
|
|
260
|
+
return c.toLanguageModelMessage();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
actor: 'ai',
|
|
265
|
+
type: 'text',
|
|
266
|
+
text: c.asString?.() ?? c.asDisplayString?.() ?? '',
|
|
267
|
+
} as TextMessage;
|
|
283
268
|
});
|
|
269
|
+
messages.push(...responseMessages);
|
|
284
270
|
}
|
|
285
271
|
return messages;
|
|
286
272
|
});
|
|
@@ -288,19 +274,33 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
288
274
|
return requestMessages;
|
|
289
275
|
}
|
|
290
276
|
|
|
291
|
-
protected async
|
|
292
|
-
|
|
293
|
-
messages:
|
|
294
|
-
|
|
295
|
-
|
|
277
|
+
protected async sendLlmRequest(
|
|
278
|
+
request: MutableChatRequestModel,
|
|
279
|
+
messages: LanguageModelMessage[],
|
|
280
|
+
toolRequests: ChatToolRequest[],
|
|
281
|
+
languageModel: LanguageModel
|
|
296
282
|
): Promise<LanguageModelResponse> {
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
283
|
+
const agentSettings = this.getLlmSettings();
|
|
284
|
+
const settings = { ...agentSettings, ...request.session.settings };
|
|
285
|
+
const tools = toolRequests.length > 0 ? toolRequests : undefined;
|
|
286
|
+
this.recordingService.recordRequest({
|
|
287
|
+
agentId: this.id,
|
|
288
|
+
sessionId: request.session.id,
|
|
289
|
+
requestId: request.id,
|
|
290
|
+
request: messages
|
|
291
|
+
});
|
|
292
|
+
return this.languageModelService.sendRequest(
|
|
293
|
+
languageModel,
|
|
294
|
+
{
|
|
295
|
+
messages,
|
|
296
|
+
tools,
|
|
297
|
+
settings,
|
|
298
|
+
agentId: this.id,
|
|
299
|
+
sessionId: request.session.id,
|
|
300
|
+
requestId: request.id,
|
|
301
|
+
cancellationToken: request.response.cancellationToken
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
/**
|
|
@@ -317,6 +317,15 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
317
317
|
* Subclasses may override this method to perform additional actions or keep the response open for processing further requests.
|
|
318
318
|
*/
|
|
319
319
|
protected async onResponseComplete(request: MutableChatRequestModel): Promise<void> {
|
|
320
|
+
this.recordingService.recordResponse(
|
|
321
|
+
{
|
|
322
|
+
agentId: this.id,
|
|
323
|
+
sessionId: request.session.id,
|
|
324
|
+
requestId: request.id,
|
|
325
|
+
response: request.response.response.content.flatMap(c =>
|
|
326
|
+
c.toLanguageModelMessage?.() ?? ({ type: 'text', actor: 'ai', text: c.asDisplayString?.() ?? c.asString?.() ?? JSON.stringify(c) }))
|
|
327
|
+
}
|
|
328
|
+
);
|
|
320
329
|
return request.response.complete();
|
|
321
330
|
}
|
|
322
331
|
|
|
@@ -407,17 +416,24 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
|
407
416
|
}
|
|
408
417
|
|
|
409
418
|
protected parse(token: LanguageModelStreamResponsePart, request: MutableChatRequestModel): ChatResponseContent | ChatResponseContent[] {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
if (isTextResponsePart(token)) {
|
|
420
|
+
const content = token.content;
|
|
421
|
+
// eslint-disable-next-line no-null/no-null
|
|
422
|
+
if (content !== undefined && content !== null) {
|
|
423
|
+
return this.defaultContentFactory.create(content, request);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (isToolCallResponsePart(token)) {
|
|
427
|
+
const toolCalls = token.tool_calls;
|
|
428
|
+
if (toolCalls !== undefined) {
|
|
429
|
+
const toolCallContents = toolCalls.map(toolCall =>
|
|
430
|
+
this.createToolCallResponseContent(toolCall)
|
|
431
|
+
);
|
|
432
|
+
return toolCallContents;
|
|
433
|
+
}
|
|
414
434
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const toolCallContents = toolCalls.map(toolCall =>
|
|
418
|
-
this.createToolCallResponseContent(toolCall)
|
|
419
|
-
);
|
|
420
|
-
return toolCallContents;
|
|
435
|
+
if (isThinkingResponsePart(token)) {
|
|
436
|
+
return new ThinkingChatResponseContentImpl(token.thought, token.signature);
|
|
421
437
|
}
|
|
422
438
|
return this.defaultContentFactory.create('', request);
|
|
423
439
|
}
|