@theia/ai-chat 1.68.0-next.0 → 1.68.0-next.23
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/chat-session-store-impl.d.ts +3 -0
- package/lib/browser/chat-session-store-impl.d.ts.map +1 -1
- package/lib/browser/chat-session-store-impl.js +46 -7
- package/lib/browser/chat-session-store-impl.js.map +1 -1
- package/lib/browser/chat-session-store-impl.spec.d.ts +2 -0
- package/lib/browser/chat-session-store-impl.spec.d.ts.map +1 -0
- package/lib/browser/chat-session-store-impl.spec.js +383 -0
- package/lib/browser/chat-session-store-impl.spec.js.map +1 -0
- package/lib/browser/task-context-service.d.ts +1 -1
- package/lib/browser/task-context-service.d.ts.map +1 -1
- package/lib/browser/task-context-service.js +3 -2
- package/lib/browser/task-context-service.js.map +1 -1
- package/lib/common/ai-chat-preferences.d.ts +1 -0
- package/lib/common/ai-chat-preferences.d.ts.map +1 -1
- package/lib/common/ai-chat-preferences.js +10 -1
- package/lib/common/ai-chat-preferences.js.map +1 -1
- package/lib/common/chat-agents.d.ts +6 -1
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +17 -5
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-model-serialization.d.ts +2 -0
- package/lib/common/chat-model-serialization.d.ts.map +1 -1
- package/lib/common/chat-model-serialization.js.map +1 -1
- package/lib/common/chat-model.d.ts +13 -0
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +17 -0
- package/lib/common/chat-model.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/chat-session-store-impl.spec.ts +491 -0
- package/src/browser/chat-session-store-impl.ts +49 -7
- package/src/browser/task-context-service.ts +4 -3
- package/src/common/ai-chat-preferences.ts +10 -0
- package/src/common/chat-agents.ts +31 -3
- package/src/common/chat-model-serialization.ts +2 -0
- package/src/common/chat-model.ts +28 -0
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
AIVariableContext,
|
|
25
25
|
AIVariableResolutionRequest,
|
|
26
26
|
getTextOfResponse,
|
|
27
|
+
isCustomizedPromptFragment,
|
|
27
28
|
isLanguageModelStreamResponsePart,
|
|
28
29
|
isTextResponsePart,
|
|
29
30
|
isThinkingResponsePart,
|
|
@@ -76,12 +77,22 @@ export interface SystemMessageDescription {
|
|
|
76
77
|
text: string;
|
|
77
78
|
/** All functions references in the system message. */
|
|
78
79
|
functionDescriptions?: Map<string, ToolRequest>;
|
|
80
|
+
/** The prompt variant ID used */
|
|
81
|
+
promptVariantId?: string;
|
|
82
|
+
/** Whether the prompt variant is customized */
|
|
83
|
+
isPromptVariantEdited?: boolean;
|
|
79
84
|
}
|
|
80
85
|
export namespace SystemMessageDescription {
|
|
81
|
-
export function fromResolvedPromptFragment(
|
|
86
|
+
export function fromResolvedPromptFragment(
|
|
87
|
+
resolvedPrompt: ResolvedPromptFragment,
|
|
88
|
+
promptVariantId?: string,
|
|
89
|
+
isPromptVariantEdited?: boolean
|
|
90
|
+
): SystemMessageDescription {
|
|
82
91
|
return {
|
|
83
92
|
text: resolvedPrompt.text,
|
|
84
|
-
functionDescriptions: resolvedPrompt.functionDescriptions
|
|
93
|
+
functionDescriptions: resolvedPrompt.functionDescriptions,
|
|
94
|
+
promptVariantId,
|
|
95
|
+
isPromptVariantEdited
|
|
85
96
|
};
|
|
86
97
|
}
|
|
87
98
|
}
|
|
@@ -192,6 +203,14 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
192
203
|
throw new Error(nls.localize('theia/ai/chat/couldNotFindMatchingLM', 'Couldn\'t find a matching language model. Please check your setup!'));
|
|
193
204
|
}
|
|
194
205
|
const systemMessageDescription = await this.getSystemMessageDescription({ model: request.session, request } satisfies ChatSessionContext);
|
|
206
|
+
|
|
207
|
+
if (systemMessageDescription?.promptVariantId) {
|
|
208
|
+
request.response.setPromptVariantInfo(
|
|
209
|
+
systemMessageDescription.promptVariantId,
|
|
210
|
+
systemMessageDescription.isPromptVariantEdited ?? false
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
195
214
|
const messages = await this.getMessages(request.session);
|
|
196
215
|
|
|
197
216
|
if (systemMessageDescription) {
|
|
@@ -255,8 +274,17 @@ export abstract class AbstractChatAgent implements ChatAgent {
|
|
|
255
274
|
if (this.systemPromptId === undefined) {
|
|
256
275
|
return undefined;
|
|
257
276
|
}
|
|
277
|
+
|
|
278
|
+
const effectiveVariantId = this.promptService.getEffectiveVariantId(this.systemPromptId) ?? this.systemPromptId;
|
|
279
|
+
const isEdited = this.isPromptVariantCustomized(effectiveVariantId);
|
|
280
|
+
|
|
258
281
|
const resolvedPrompt = await this.promptService.getResolvedPromptFragment(this.systemPromptId, undefined, context);
|
|
259
|
-
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptFragment(resolvedPrompt) : undefined;
|
|
282
|
+
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptFragment(resolvedPrompt, effectiveVariantId, isEdited) : undefined;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
protected isPromptVariantCustomized(fragmentId: string): boolean {
|
|
286
|
+
const fragment = this.promptService.getRawPromptFragment(fragmentId);
|
|
287
|
+
return fragment ? isCustomizedPromptFragment(fragment) : false;
|
|
260
288
|
}
|
|
261
289
|
|
|
262
290
|
protected async getMessages(
|
package/src/common/chat-model.ts
CHANGED
|
@@ -743,6 +743,14 @@ export interface ChatResponseModel {
|
|
|
743
743
|
* This can be used to store and retrieve such data.
|
|
744
744
|
*/
|
|
745
745
|
readonly data: { [key: string]: unknown };
|
|
746
|
+
/**
|
|
747
|
+
* The ID of the prompt variant used to generate this response
|
|
748
|
+
*/
|
|
749
|
+
readonly promptVariantId?: string;
|
|
750
|
+
/**
|
|
751
|
+
* Indicates whether the prompt variant was customized/edited
|
|
752
|
+
*/
|
|
753
|
+
readonly isPromptVariantEdited?: boolean;
|
|
746
754
|
toSerializable(): SerializableChatResponseData;
|
|
747
755
|
}
|
|
748
756
|
|
|
@@ -2331,6 +2339,8 @@ export class MutableChatResponseModel implements ChatResponseModel {
|
|
|
2331
2339
|
protected _isError: boolean;
|
|
2332
2340
|
protected _errorObject: Error | undefined;
|
|
2333
2341
|
protected _cancellationToken: CancellationTokenSource;
|
|
2342
|
+
protected _promptVariantId?: string;
|
|
2343
|
+
protected _isPromptVariantEdited?: boolean;
|
|
2334
2344
|
|
|
2335
2345
|
constructor(
|
|
2336
2346
|
requestId: string,
|
|
@@ -2372,6 +2382,8 @@ export class MutableChatResponseModel implements ChatResponseModel {
|
|
|
2372
2382
|
this._isWaitingForInput = false;
|
|
2373
2383
|
// TODO: Restore progressMessages?
|
|
2374
2384
|
this._progressMessages = [];
|
|
2385
|
+
this._promptVariantId = data.promptVariantId;
|
|
2386
|
+
this._isPromptVariantEdited = data.isPromptVariantEdited ?? false;
|
|
2375
2387
|
|
|
2376
2388
|
if (data.errorMessage) {
|
|
2377
2389
|
this._errorObject = new Error(data.errorMessage);
|
|
@@ -2443,6 +2455,20 @@ export class MutableChatResponseModel implements ChatResponseModel {
|
|
|
2443
2455
|
return this._agentId;
|
|
2444
2456
|
}
|
|
2445
2457
|
|
|
2458
|
+
get promptVariantId(): string | undefined {
|
|
2459
|
+
return this._promptVariantId;
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
get isPromptVariantEdited(): boolean {
|
|
2463
|
+
return this._isPromptVariantEdited ?? false;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
setPromptVariantInfo(variantId: string | undefined, isEdited: boolean): void {
|
|
2467
|
+
this._promptVariantId = variantId;
|
|
2468
|
+
this._isPromptVariantEdited = isEdited;
|
|
2469
|
+
this._onDidChangeEmitter.fire();
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2446
2472
|
overrideAgentId(agentId: string): void {
|
|
2447
2473
|
this._agentId = agentId;
|
|
2448
2474
|
}
|
|
@@ -2508,6 +2534,8 @@ export class MutableChatResponseModel implements ChatResponseModel {
|
|
|
2508
2534
|
isComplete: this.isComplete,
|
|
2509
2535
|
isError: this.isError,
|
|
2510
2536
|
errorMessage: this.errorObject?.message,
|
|
2537
|
+
promptVariantId: this._promptVariantId,
|
|
2538
|
+
isPromptVariantEdited: this._isPromptVariantEdited,
|
|
2511
2539
|
content: this.response.content.map(c => {
|
|
2512
2540
|
const serialized = c.toSerializable?.();
|
|
2513
2541
|
if (!serialized) {
|