@theia/ai-chat 1.46.0-next.241
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 +31 -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 +79 -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/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/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 +45 -0
- package/lib/common/chat-agent-service.d.ts.map +1 -0
- package/lib/common/chat-agent-service.js +78 -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 +108 -0
- package/lib/common/chat-agents.d.ts.map +1 -0
- package/lib/common/chat-agents.js +321 -0
- package/lib/common/chat-agents.js.map +1 -0
- 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/chat-model-util.d.ts +7 -0
- package/lib/common/chat-model-util.d.ts.map +1 -0
- package/lib/common/chat-model-util.js +50 -0
- package/lib/common/chat-model-util.js.map +1 -0
- package/lib/common/chat-model.d.ts +393 -0
- package/lib/common/chat-model.d.ts.map +1 -0
- package/lib/common/chat-model.js +612 -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 +329 -0
- package/lib/common/command-chat-agents.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 +12 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +30 -0
- package/lib/common/index.js.map +1 -0
- 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 +22 -0
- package/lib/common/orchestrator-chat-agent.d.ts.map +1 -0
- package/lib/common/orchestrator-chat-agent.js +167 -0
- package/lib/common/orchestrator-chat-agent.js.map +1 -0
- package/lib/common/parse-contents.d.ts +11 -0
- package/lib/common/parse-contents.d.ts.map +1 -0
- package/lib/common/parse-contents.js +67 -0
- package/lib/common/parse-contents.js.map +1 -0
- package/lib/common/parse-contents.spec.d.ts +9 -0
- package/lib/common/parse-contents.spec.d.ts.map +1 -0
- package/lib/common/parse-contents.spec.js +134 -0
- package/lib/common/parse-contents.spec.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/response-content-matcher.d.ts +63 -0
- package/lib/common/response-content-matcher.d.ts.map +1 -0
- package/lib/common/response-content-matcher.js +86 -0
- package/lib/common/response-content-matcher.js.map +1 -0
- package/lib/common/universal-chat-agent.d.ts +16 -0
- package/lib/common/universal-chat-agent.d.ts.map +1 -0
- package/lib/common/universal-chat-agent.js +109 -0
- package/lib/common/universal-chat-agent.js.map +1 -0
- package/package.json +54 -0
- package/src/browser/ai-chat-frontend-module.ts +98 -0
- package/src/browser/ai-chat-preferences.ts +32 -0
- package/src/browser/custom-agent-factory.ts +20 -0
- package/src/browser/custom-agent-frontend-application-contribution.ts +73 -0
- package/src/browser/frontend-chat-service.ts +66 -0
- package/src/common/chat-agent-service.ts +100 -0
- package/src/common/chat-agents-variable-contribution.ts +81 -0
- package/src/common/chat-agents.ts +392 -0
- package/src/common/chat-history-entry.ts +47 -0
- package/src/common/chat-model-util.ts +44 -0
- package/src/common/chat-model.ts +889 -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 +354 -0
- package/src/common/custom-chat-agent.ts +44 -0
- package/src/common/index.ts +26 -0
- package/src/common/o1-chat-agent.ts +51 -0
- package/src/common/orchestrator-chat-agent.ts +179 -0
- package/src/common/parse-contents.spec.ts +144 -0
- package/src/common/parse-contents.ts +93 -0
- package/src/common/parsed-chat-request.ts +112 -0
- package/src/common/response-content-matcher.ts +103 -0
- package/src/common/universal-chat-agent.ts +117 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CommunicationRecordingService, LanguageModel, LanguageModelRequirement, LanguageModelResponse, LanguageModelStreamResponse, PromptService, ResolvedPromptTemplate, ToolRequest } from '@theia/ai-core';
|
|
2
|
+
import { Agent, LanguageModelRegistry, LanguageModelStreamResponsePart, MessageActor } from '@theia/ai-core/lib/common';
|
|
3
|
+
import { CancellationToken, ContributionProvider, ILogger } from '@theia/core';
|
|
4
|
+
import { ChatAgentService } from './chat-agent-service';
|
|
5
|
+
import { ChatModel, ChatRequestModel, ChatRequestModelImpl, ChatResponseContent } from './chat-model';
|
|
6
|
+
import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
|
|
7
|
+
/**
|
|
8
|
+
* A conversation consists of a sequence of ChatMessages.
|
|
9
|
+
* Each ChatMessage is either a user message, AI message or a system message.
|
|
10
|
+
*
|
|
11
|
+
* For now we only support text based messages.
|
|
12
|
+
*/
|
|
13
|
+
export interface ChatMessage {
|
|
14
|
+
actor: MessageActor;
|
|
15
|
+
type: 'text';
|
|
16
|
+
query: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* System message content, enriched with function descriptions.
|
|
20
|
+
*/
|
|
21
|
+
export interface SystemMessageDescription {
|
|
22
|
+
text: string;
|
|
23
|
+
/** All functions references in the system message. */
|
|
24
|
+
functionDescriptions?: Map<string, ToolRequest>;
|
|
25
|
+
}
|
|
26
|
+
export declare namespace SystemMessageDescription {
|
|
27
|
+
function fromResolvedPromptTemplate(resolvedPrompt: ResolvedPromptTemplate): SystemMessageDescription;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The location from where an chat agent may be invoked.
|
|
31
|
+
* Based on the location, a different context may be available.
|
|
32
|
+
*/
|
|
33
|
+
export declare enum ChatAgentLocation {
|
|
34
|
+
Panel = "panel",
|
|
35
|
+
Terminal = "terminal",
|
|
36
|
+
Notebook = "notebook",
|
|
37
|
+
Editor = "editor"
|
|
38
|
+
}
|
|
39
|
+
export declare namespace ChatAgentLocation {
|
|
40
|
+
const ALL: ChatAgentLocation[];
|
|
41
|
+
function fromRaw(value: string): ChatAgentLocation;
|
|
42
|
+
}
|
|
43
|
+
export declare const ChatAgent: unique symbol;
|
|
44
|
+
/**
|
|
45
|
+
* A chat agent is a specialized agent with a common interface for its invocation.
|
|
46
|
+
*/
|
|
47
|
+
export interface ChatAgent extends Agent {
|
|
48
|
+
locations: ChatAgentLocation[];
|
|
49
|
+
iconClass?: string;
|
|
50
|
+
invoke(request: ChatRequestModelImpl, chatAgentService?: ChatAgentService): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare abstract class AbstractChatAgent {
|
|
53
|
+
id: string;
|
|
54
|
+
languageModelRequirements: LanguageModelRequirement[];
|
|
55
|
+
protected defaultLanguageModelPurpose: string;
|
|
56
|
+
iconClass: string;
|
|
57
|
+
locations: ChatAgentLocation[];
|
|
58
|
+
tags: string[];
|
|
59
|
+
defaultLogging: boolean;
|
|
60
|
+
protected languageModelRegistry: LanguageModelRegistry;
|
|
61
|
+
protected logger: ILogger;
|
|
62
|
+
protected recordingService: CommunicationRecordingService;
|
|
63
|
+
protected promptService: PromptService;
|
|
64
|
+
protected contentMatcherProviders: ContributionProvider<ResponseContentMatcherProvider>;
|
|
65
|
+
protected contentMatchers: ResponseContentMatcher[];
|
|
66
|
+
protected defaultContentFactory: DefaultResponseContentFactory;
|
|
67
|
+
constructor(id: string, languageModelRequirements: LanguageModelRequirement[], defaultLanguageModelPurpose: string, iconClass?: string, locations?: ChatAgentLocation[], tags?: string[], defaultLogging?: boolean);
|
|
68
|
+
init(): void;
|
|
69
|
+
protected initializeContentMatchers(): void;
|
|
70
|
+
invoke(request: ChatRequestModelImpl): Promise<void>;
|
|
71
|
+
protected parseContents(text: string, request: ChatRequestModelImpl): ChatResponseContent[];
|
|
72
|
+
protected handleError(request: ChatRequestModelImpl, error: Error): void;
|
|
73
|
+
protected getLanguageModelSelector(languageModelPurpose: string): LanguageModelRequirement;
|
|
74
|
+
protected getLanguageModel(languageModelPurpose: string): Promise<LanguageModel>;
|
|
75
|
+
protected selectLanguageModel(selector: LanguageModelRequirement): Promise<LanguageModel>;
|
|
76
|
+
protected abstract getSystemMessageDescription(): Promise<SystemMessageDescription | undefined>;
|
|
77
|
+
protected getMessages(model: ChatModel, includeResponseInProgress?: boolean): Promise<ChatMessage[]>;
|
|
78
|
+
/**
|
|
79
|
+
* @returns the list of tools used by this agent, or undefined if none is needed.
|
|
80
|
+
*/
|
|
81
|
+
protected getTools(request: ChatRequestModel): ToolRequest[] | undefined;
|
|
82
|
+
protected callLlm(languageModel: LanguageModel, messages: ChatMessage[], tools: ToolRequest[] | undefined, token: CancellationToken): Promise<LanguageModelResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* @returns the settings, such as `temperature`, to be used in all language model requests. Returns `undefined` by default.
|
|
85
|
+
*/
|
|
86
|
+
protected getLlmSettings(): {
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
} | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Invoked after the response by the LLM completed successfully.
|
|
91
|
+
*
|
|
92
|
+
* The default implementation sets the state of the response to `complete`.
|
|
93
|
+
* Subclasses may override this method to perform additional actions or keep the response open for processing further requests.
|
|
94
|
+
*/
|
|
95
|
+
protected onResponseComplete(request: ChatRequestModelImpl): Promise<void>;
|
|
96
|
+
protected abstract addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export declare abstract class AbstractTextToModelParsingChatAgent<T> extends AbstractChatAgent {
|
|
99
|
+
protected addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
100
|
+
protected abstract parseTextResponse(text: string): Promise<T>;
|
|
101
|
+
protected abstract createResponseContent(parsedModel: T, request: ChatRequestModelImpl): ChatResponseContent;
|
|
102
|
+
}
|
|
103
|
+
export declare abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
104
|
+
protected addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
105
|
+
protected addStreamResponse(languageModelResponse: LanguageModelStreamResponse, request: ChatRequestModelImpl): Promise<void>;
|
|
106
|
+
protected parse(token: LanguageModelStreamResponsePart, request: ChatRequestModelImpl): ChatResponseContent | ChatResponseContent[];
|
|
107
|
+
}
|
|
108
|
+
//# 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,2BAA2B,EAC3B,aAAa,EACb,sBAAsB,EACtB,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,KAAK,EAGL,qBAAqB,EACrB,+BAA+B,EAC/B,YAAY,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,oBAAoB,EAAE,OAAO,EAAW,MAAM,aAAa,CAAC;AAEjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACH,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAItB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAGnI;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,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|
|
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.AbstractStreamParsingChatAgent = exports.AbstractTextToModelParsingChatAgent = exports.AbstractChatAgent = exports.ChatAgent = exports.ChatAgentLocation = exports.SystemMessageDescription = void 0;
|
|
24
|
+
const tslib_1 = require("tslib");
|
|
25
|
+
const ai_core_1 = require("@theia/ai-core");
|
|
26
|
+
const common_1 = require("@theia/ai-core/lib/common");
|
|
27
|
+
const core_1 = require("@theia/core");
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const chat_model_1 = require("./chat-model");
|
|
30
|
+
const parse_contents_1 = require("./parse-contents");
|
|
31
|
+
const response_content_matcher_1 = require("./response-content-matcher");
|
|
32
|
+
const chat_history_entry_1 = require("./chat-history-entry");
|
|
33
|
+
var SystemMessageDescription;
|
|
34
|
+
(function (SystemMessageDescription) {
|
|
35
|
+
function fromResolvedPromptTemplate(resolvedPrompt) {
|
|
36
|
+
return {
|
|
37
|
+
text: resolvedPrompt.text,
|
|
38
|
+
functionDescriptions: resolvedPrompt.functionDescriptions
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
SystemMessageDescription.fromResolvedPromptTemplate = fromResolvedPromptTemplate;
|
|
42
|
+
})(SystemMessageDescription || (exports.SystemMessageDescription = SystemMessageDescription = {}));
|
|
43
|
+
/**
|
|
44
|
+
* The location from where an chat agent may be invoked.
|
|
45
|
+
* Based on the location, a different context may be available.
|
|
46
|
+
*/
|
|
47
|
+
var ChatAgentLocation;
|
|
48
|
+
(function (ChatAgentLocation) {
|
|
49
|
+
ChatAgentLocation["Panel"] = "panel";
|
|
50
|
+
ChatAgentLocation["Terminal"] = "terminal";
|
|
51
|
+
ChatAgentLocation["Notebook"] = "notebook";
|
|
52
|
+
ChatAgentLocation["Editor"] = "editor";
|
|
53
|
+
})(ChatAgentLocation || (exports.ChatAgentLocation = ChatAgentLocation = {}));
|
|
54
|
+
(function (ChatAgentLocation) {
|
|
55
|
+
ChatAgentLocation.ALL = [ChatAgentLocation.Panel, ChatAgentLocation.Terminal, ChatAgentLocation.Notebook, ChatAgentLocation.Editor];
|
|
56
|
+
function fromRaw(value) {
|
|
57
|
+
switch (value) {
|
|
58
|
+
case 'panel': return ChatAgentLocation.Panel;
|
|
59
|
+
case 'terminal': return ChatAgentLocation.Terminal;
|
|
60
|
+
case 'notebook': return ChatAgentLocation.Notebook;
|
|
61
|
+
case 'editor': return ChatAgentLocation.Editor;
|
|
62
|
+
}
|
|
63
|
+
return ChatAgentLocation.Panel;
|
|
64
|
+
}
|
|
65
|
+
ChatAgentLocation.fromRaw = fromRaw;
|
|
66
|
+
})(ChatAgentLocation || (exports.ChatAgentLocation = ChatAgentLocation = {}));
|
|
67
|
+
exports.ChatAgent = Symbol('ChatAgent');
|
|
68
|
+
let AbstractChatAgent = class AbstractChatAgent {
|
|
69
|
+
constructor(id, languageModelRequirements, defaultLanguageModelPurpose, iconClass = 'codicon codicon-copilot', locations = ChatAgentLocation.ALL, tags = ['Chat'], defaultLogging = true) {
|
|
70
|
+
this.id = id;
|
|
71
|
+
this.languageModelRequirements = languageModelRequirements;
|
|
72
|
+
this.defaultLanguageModelPurpose = defaultLanguageModelPurpose;
|
|
73
|
+
this.iconClass = iconClass;
|
|
74
|
+
this.locations = locations;
|
|
75
|
+
this.tags = tags;
|
|
76
|
+
this.defaultLogging = defaultLogging;
|
|
77
|
+
this.contentMatchers = [];
|
|
78
|
+
}
|
|
79
|
+
init() {
|
|
80
|
+
this.initializeContentMatchers();
|
|
81
|
+
}
|
|
82
|
+
initializeContentMatchers() {
|
|
83
|
+
const contributedContentMatchers = this.contentMatcherProviders.getContributions().flatMap(provider => provider.matchers);
|
|
84
|
+
this.contentMatchers.push(...contributedContentMatchers);
|
|
85
|
+
}
|
|
86
|
+
async invoke(request) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
try {
|
|
89
|
+
const languageModel = await this.getLanguageModel(this.defaultLanguageModelPurpose);
|
|
90
|
+
if (!languageModel) {
|
|
91
|
+
throw new Error('Couldn\'t find a matching language model. Please check your setup!');
|
|
92
|
+
}
|
|
93
|
+
const systemMessageDescription = await this.getSystemMessageDescription();
|
|
94
|
+
const messages = await this.getMessages(request.session);
|
|
95
|
+
if (this.defaultLogging) {
|
|
96
|
+
this.recordingService.recordRequest(chat_history_entry_1.ChatHistoryEntry.fromRequest(this.id, request, {
|
|
97
|
+
messages,
|
|
98
|
+
systemMessage: systemMessageDescription === null || systemMessageDescription === void 0 ? void 0 : systemMessageDescription.text
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
const tools = new Map();
|
|
102
|
+
if (systemMessageDescription) {
|
|
103
|
+
const systemMsg = {
|
|
104
|
+
actor: 'system',
|
|
105
|
+
type: 'text',
|
|
106
|
+
query: systemMessageDescription.text
|
|
107
|
+
};
|
|
108
|
+
// insert system message at the beginning of the request messages
|
|
109
|
+
messages.unshift(systemMsg);
|
|
110
|
+
(_a = systemMessageDescription.functionDescriptions) === null || _a === void 0 ? void 0 : _a.forEach((tool, id) => {
|
|
111
|
+
tools.set(id, tool);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
(_b = this.getTools(request)) === null || _b === void 0 ? void 0 : _b.forEach(tool => tools.set(tool.id, tool));
|
|
115
|
+
const cancellationToken = new core_1.CancellationTokenSource();
|
|
116
|
+
request.response.onDidChange(() => {
|
|
117
|
+
if (request.response.isCanceled) {
|
|
118
|
+
cancellationToken.cancel();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const languageModelResponse = await this.callLlm(languageModel, messages, tools.size > 0 ? Array.from(tools.values()) : undefined, cancellationToken.token);
|
|
122
|
+
await this.addContentsToResponse(languageModelResponse, request);
|
|
123
|
+
await this.onResponseComplete(request);
|
|
124
|
+
if (this.defaultLogging) {
|
|
125
|
+
this.recordingService.recordResponse(chat_history_entry_1.ChatHistoryEntry.fromResponse(this.id, request));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
this.handleError(request, e);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
parseContents(text, request) {
|
|
133
|
+
var _a;
|
|
134
|
+
return (0, parse_contents_1.parseContents)(text, request, this.contentMatchers, (_a = this.defaultContentFactory) === null || _a === void 0 ? void 0 : _a.create.bind(this.defaultContentFactory));
|
|
135
|
+
}
|
|
136
|
+
;
|
|
137
|
+
handleError(request, error) {
|
|
138
|
+
request.response.response.addContent(new chat_model_1.ErrorChatResponseContentImpl(error));
|
|
139
|
+
request.response.error(error);
|
|
140
|
+
}
|
|
141
|
+
getLanguageModelSelector(languageModelPurpose) {
|
|
142
|
+
return this.languageModelRequirements.find(req => req.purpose === languageModelPurpose);
|
|
143
|
+
}
|
|
144
|
+
async getLanguageModel(languageModelPurpose) {
|
|
145
|
+
return this.selectLanguageModel(this.getLanguageModelSelector(languageModelPurpose));
|
|
146
|
+
}
|
|
147
|
+
async selectLanguageModel(selector) {
|
|
148
|
+
const languageModel = await this.languageModelRegistry.selectLanguageModel({ agent: this.id, ...selector });
|
|
149
|
+
if (!languageModel) {
|
|
150
|
+
throw new Error('Couldn\'t find a language model. Please check your setup!');
|
|
151
|
+
}
|
|
152
|
+
return languageModel;
|
|
153
|
+
}
|
|
154
|
+
async getMessages(model, includeResponseInProgress = false) {
|
|
155
|
+
const requestMessages = model.getRequests().flatMap(request => {
|
|
156
|
+
const messages = [];
|
|
157
|
+
const text = request.message.parts.map(part => part.promptText).join('');
|
|
158
|
+
messages.push({
|
|
159
|
+
actor: 'user',
|
|
160
|
+
type: 'text',
|
|
161
|
+
query: text,
|
|
162
|
+
});
|
|
163
|
+
if (request.response.isComplete || includeResponseInProgress) {
|
|
164
|
+
messages.push({
|
|
165
|
+
actor: 'ai',
|
|
166
|
+
type: 'text',
|
|
167
|
+
query: request.response.response.asString(),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return messages;
|
|
171
|
+
});
|
|
172
|
+
return requestMessages;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @returns the list of tools used by this agent, or undefined if none is needed.
|
|
176
|
+
*/
|
|
177
|
+
getTools(request) {
|
|
178
|
+
return request.message.toolRequests.size > 0
|
|
179
|
+
? [...request.message.toolRequests.values()]
|
|
180
|
+
: undefined;
|
|
181
|
+
}
|
|
182
|
+
async callLlm(languageModel, messages, tools, token) {
|
|
183
|
+
const settings = this.getLlmSettings();
|
|
184
|
+
const languageModelResponse = languageModel.request({
|
|
185
|
+
messages,
|
|
186
|
+
tools,
|
|
187
|
+
settings,
|
|
188
|
+
}, token);
|
|
189
|
+
return languageModelResponse;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @returns the settings, such as `temperature`, to be used in all language model requests. Returns `undefined` by default.
|
|
193
|
+
*/
|
|
194
|
+
getLlmSettings() {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Invoked after the response by the LLM completed successfully.
|
|
199
|
+
*
|
|
200
|
+
* The default implementation sets the state of the response to `complete`.
|
|
201
|
+
* Subclasses may override this method to perform additional actions or keep the response open for processing further requests.
|
|
202
|
+
*/
|
|
203
|
+
async onResponseComplete(request) {
|
|
204
|
+
return request.response.complete();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.AbstractChatAgent = AbstractChatAgent;
|
|
208
|
+
tslib_1.__decorate([
|
|
209
|
+
(0, inversify_1.inject)(common_1.LanguageModelRegistry),
|
|
210
|
+
tslib_1.__metadata("design:type", Object)
|
|
211
|
+
], AbstractChatAgent.prototype, "languageModelRegistry", void 0);
|
|
212
|
+
tslib_1.__decorate([
|
|
213
|
+
(0, inversify_1.inject)(core_1.ILogger),
|
|
214
|
+
tslib_1.__metadata("design:type", Object)
|
|
215
|
+
], AbstractChatAgent.prototype, "logger", void 0);
|
|
216
|
+
tslib_1.__decorate([
|
|
217
|
+
(0, inversify_1.inject)(ai_core_1.CommunicationRecordingService),
|
|
218
|
+
tslib_1.__metadata("design:type", Object)
|
|
219
|
+
], AbstractChatAgent.prototype, "recordingService", void 0);
|
|
220
|
+
tslib_1.__decorate([
|
|
221
|
+
(0, inversify_1.inject)(ai_core_1.PromptService),
|
|
222
|
+
tslib_1.__metadata("design:type", Object)
|
|
223
|
+
], AbstractChatAgent.prototype, "promptService", void 0);
|
|
224
|
+
tslib_1.__decorate([
|
|
225
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
226
|
+
(0, inversify_1.named)(response_content_matcher_1.ResponseContentMatcherProvider),
|
|
227
|
+
tslib_1.__metadata("design:type", Object)
|
|
228
|
+
], AbstractChatAgent.prototype, "contentMatcherProviders", void 0);
|
|
229
|
+
tslib_1.__decorate([
|
|
230
|
+
(0, inversify_1.inject)(response_content_matcher_1.DefaultResponseContentFactory),
|
|
231
|
+
tslib_1.__metadata("design:type", response_content_matcher_1.DefaultResponseContentFactory)
|
|
232
|
+
], AbstractChatAgent.prototype, "defaultContentFactory", void 0);
|
|
233
|
+
tslib_1.__decorate([
|
|
234
|
+
(0, inversify_1.postConstruct)(),
|
|
235
|
+
tslib_1.__metadata("design:type", Function),
|
|
236
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
237
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
238
|
+
], AbstractChatAgent.prototype, "init", null);
|
|
239
|
+
exports.AbstractChatAgent = AbstractChatAgent = tslib_1.__decorate([
|
|
240
|
+
(0, inversify_1.injectable)(),
|
|
241
|
+
tslib_1.__param(0, (0, inversify_1.unmanaged)()),
|
|
242
|
+
tslib_1.__param(1, (0, inversify_1.unmanaged)()),
|
|
243
|
+
tslib_1.__param(2, (0, inversify_1.unmanaged)()),
|
|
244
|
+
tslib_1.__param(3, (0, inversify_1.unmanaged)()),
|
|
245
|
+
tslib_1.__param(4, (0, inversify_1.unmanaged)()),
|
|
246
|
+
tslib_1.__param(5, (0, inversify_1.unmanaged)()),
|
|
247
|
+
tslib_1.__param(6, (0, inversify_1.unmanaged)()),
|
|
248
|
+
tslib_1.__metadata("design:paramtypes", [String, Array, String, String, Array, Array, Boolean])
|
|
249
|
+
], AbstractChatAgent);
|
|
250
|
+
let AbstractTextToModelParsingChatAgent = class AbstractTextToModelParsingChatAgent extends AbstractChatAgent {
|
|
251
|
+
async addContentsToResponse(languageModelResponse, request) {
|
|
252
|
+
const responseAsText = await (0, ai_core_1.getTextOfResponse)(languageModelResponse);
|
|
253
|
+
const parsedCommand = await this.parseTextResponse(responseAsText);
|
|
254
|
+
const content = this.createResponseContent(parsedCommand, request);
|
|
255
|
+
request.response.response.addContent(content);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
exports.AbstractTextToModelParsingChatAgent = AbstractTextToModelParsingChatAgent;
|
|
259
|
+
exports.AbstractTextToModelParsingChatAgent = AbstractTextToModelParsingChatAgent = tslib_1.__decorate([
|
|
260
|
+
(0, inversify_1.injectable)()
|
|
261
|
+
], AbstractTextToModelParsingChatAgent);
|
|
262
|
+
let AbstractStreamParsingChatAgent = class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
263
|
+
async addContentsToResponse(languageModelResponse, request) {
|
|
264
|
+
if ((0, common_1.isLanguageModelTextResponse)(languageModelResponse)) {
|
|
265
|
+
const contents = this.parseContents(languageModelResponse.text, request);
|
|
266
|
+
request.response.response.addContents(contents);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if ((0, common_1.isLanguageModelStreamResponse)(languageModelResponse)) {
|
|
270
|
+
await this.addStreamResponse(languageModelResponse, request);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.logger.error('Received unknown response in agent. Return response as text');
|
|
274
|
+
request.response.response.addContent(new chat_model_1.MarkdownChatResponseContentImpl(JSON.stringify(languageModelResponse)));
|
|
275
|
+
}
|
|
276
|
+
async addStreamResponse(languageModelResponse, request) {
|
|
277
|
+
var _a;
|
|
278
|
+
for await (const token of languageModelResponse.stream) {
|
|
279
|
+
const newContents = this.parse(token, request);
|
|
280
|
+
if ((0, core_1.isArray)(newContents)) {
|
|
281
|
+
request.response.response.addContents(newContents);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
request.response.response.addContent(newContents);
|
|
285
|
+
}
|
|
286
|
+
const lastContent = request.response.response.content.pop();
|
|
287
|
+
if (lastContent === undefined) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const text = (_a = lastContent.asString) === null || _a === void 0 ? void 0 : _a.call(lastContent);
|
|
291
|
+
if (text === undefined) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const result = (0, parse_contents_1.findFirstMatch)(this.contentMatchers, text) ? this.parseContents(text, request) : [];
|
|
295
|
+
if (result.length > 0) {
|
|
296
|
+
request.response.response.addContents(result);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
request.response.response.addContent(lastContent);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
parse(token, request) {
|
|
304
|
+
const content = token.content;
|
|
305
|
+
// eslint-disable-next-line no-null/no-null
|
|
306
|
+
if (content !== undefined && content !== null) {
|
|
307
|
+
return this.defaultContentFactory.create(content, request);
|
|
308
|
+
}
|
|
309
|
+
const toolCalls = token.tool_calls;
|
|
310
|
+
if (toolCalls !== undefined) {
|
|
311
|
+
const toolCallContents = toolCalls.map(toolCall => { var _a, _b; return new chat_model_1.ToolCallChatResponseContentImpl(toolCall.id, (_a = toolCall.function) === null || _a === void 0 ? void 0 : _a.name, (_b = toolCall.function) === null || _b === void 0 ? void 0 : _b.arguments, toolCall.finished, toolCall.result); });
|
|
312
|
+
return toolCallContents;
|
|
313
|
+
}
|
|
314
|
+
return this.defaultContentFactory.create('', request);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
exports.AbstractStreamParsingChatAgent = AbstractStreamParsingChatAgent;
|
|
318
|
+
exports.AbstractStreamParsingChatAgent = AbstractStreamParsingChatAgent = tslib_1.__decorate([
|
|
319
|
+
(0, inversify_1.injectable)()
|
|
320
|
+
], AbstractStreamParsingChatAgent);
|
|
321
|
+
//# sourceMappingURL=chat-agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agents.js","sourceRoot":"","sources":["../../src/common/chat-agents.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,4CAUwB;AACx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AC,MAAM,CAAC,CAAC;YAClD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;IAES,KAAK,CAAC,KAAsC,EAAE,OAA6B;QACjF,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,2CAA2C;QAC3C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,gBAAgB,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,eAC9C,OAAA,IAAI,4CAA+B,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAA,QAAQ,CAAC,QAAQ,0CAAE,IAAI,EAAE,MAAA,QAAQ,CAAC,QAAQ,0CAAE,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAA,CAAC,CAAC;YACjJ,OAAO,gBAAgB,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CAEJ,CAAA;AAhEqB,wEAA8B;yCAA9B,8BAA8B;IADnD,IAAA,sBAAU,GAAE;GACS,8BAA8B,CAgEnD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommunicationRequestEntryParam, CommunicationResponseEntryParam } from '@theia/ai-core/lib/common/communication-recording-service';
|
|
2
|
+
import { ChatRequestModel } from './chat-model';
|
|
3
|
+
export declare namespace ChatHistoryEntry {
|
|
4
|
+
function fromRequest(agentId: string, request: ChatRequestModel, args?: Partial<CommunicationRequestEntryParam>): CommunicationRequestEntryParam;
|
|
5
|
+
function fromResponse(agentId: string, request: ChatRequestModel, args?: Partial<CommunicationResponseEntryParam>): CommunicationResponseEntryParam;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=chat-history-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-entry.d.ts","sourceRoot":"","sources":["../../src/common/chat-history-entry.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC;AAC5I,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,yBAAiB,gBAAgB,CAAC;IAC9B,SAAgB,WAAW,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EACzB,IAAI,GAAE,OAAO,CAAC,8BAA8B,CAAM,GACnD,8BAA8B,CAQhC;IACD,SAAgB,YAAY,CACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EACzB,IAAI,GAAE,OAAO,CAAC,+BAA+B,CAAM,GACpD,+BAA+B,CAQjC;CACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.ChatHistoryEntry = void 0;
|
|
19
|
+
var ChatHistoryEntry;
|
|
20
|
+
(function (ChatHistoryEntry) {
|
|
21
|
+
function fromRequest(agentId, request, args = {}) {
|
|
22
|
+
return {
|
|
23
|
+
agentId: agentId,
|
|
24
|
+
sessionId: request.session.id,
|
|
25
|
+
requestId: request.id,
|
|
26
|
+
request: request.request.text,
|
|
27
|
+
...args,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
ChatHistoryEntry.fromRequest = fromRequest;
|
|
31
|
+
function fromResponse(agentId, request, args = {}) {
|
|
32
|
+
return {
|
|
33
|
+
agentId: agentId,
|
|
34
|
+
sessionId: request.session.id,
|
|
35
|
+
requestId: request.id,
|
|
36
|
+
response: request.response.response.asString(),
|
|
37
|
+
...args,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
ChatHistoryEntry.fromResponse = fromResponse;
|
|
41
|
+
})(ChatHistoryEntry || (exports.ChatHistoryEntry = ChatHistoryEntry = {}));
|
|
42
|
+
//# sourceMappingURL=chat-history-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-entry.js","sourceRoot":"","sources":["../../src/common/chat-history-entry.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;;;AAKhF,IAAiB,gBAAgB,CA2BhC;AA3BD,WAAiB,gBAAgB;IAC7B,SAAgB,WAAW,CACvB,OAAe,EACf,OAAyB,EACzB,OAAgD,EAAE;QAElD,OAAO;YACH,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YAC7B,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;YAC7B,GAAG,IAAI;SACV,CAAC;IACN,CAAC;IAZe,4BAAW,cAY1B,CAAA;IACD,SAAgB,YAAY,CACxB,OAAe,EACf,OAAyB,EACzB,OAAiD,EAAE;QAEnD,OAAO;YACH,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YAC7B,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAC9C,GAAG,IAAI;SACV,CAAC;IACN,CAAC;IAZe,6BAAY,eAY3B,CAAA;AACL,CAAC,EA3BgB,gBAAgB,gCAAhB,gBAAgB,QA2BhC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChatProgressMessage, ChatRequestModel, ChatResponse, ChatResponseContent, ChatResponseModel, QuestionResponseContent } from './chat-model';
|
|
2
|
+
export declare function lastResponseContent(request: ChatRequestModel): ChatResponseContent | undefined;
|
|
3
|
+
export declare function lastContentOfResponse(response: ChatResponse | undefined): ChatResponseContent | undefined;
|
|
4
|
+
export declare function lastProgressMessage(request: ChatRequestModel): ChatProgressMessage | undefined;
|
|
5
|
+
export declare function lastProgressMessageOfResponse(response: ChatResponseModel | undefined): ChatProgressMessage | undefined;
|
|
6
|
+
export declare function unansweredQuestions(request: ChatRequestModel): QuestionResponseContent[];
|
|
7
|
+
//# sourceMappingURL=chat-model-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-model-util.d.ts","sourceRoot":"","sources":["../../src/common/chat-model-util.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEpJ,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,SAAS,CAE9F;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAAG,mBAAmB,GAAG,SAAS,CAGzG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,SAAS,CAE9F;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,mBAAmB,GAAG,SAAS,CAGtH;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,uBAAuB,EAAE,CAGxF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unansweredQuestions = exports.lastProgressMessageOfResponse = exports.lastProgressMessage = exports.lastContentOfResponse = exports.lastResponseContent = void 0;
|
|
4
|
+
// *****************************************************************************
|
|
5
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
6
|
+
//
|
|
7
|
+
// This program and the accompanying materials are made available under the
|
|
8
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
//
|
|
11
|
+
// This Source Code may also be made available under the following Secondary
|
|
12
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
+
// with the GNU Classpath Exception which is available at
|
|
15
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
16
|
+
//
|
|
17
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
18
|
+
// *****************************************************************************
|
|
19
|
+
const chat_model_1 = require("./chat-model");
|
|
20
|
+
function lastResponseContent(request) {
|
|
21
|
+
var _a;
|
|
22
|
+
return lastContentOfResponse((_a = request.response) === null || _a === void 0 ? void 0 : _a.response);
|
|
23
|
+
}
|
|
24
|
+
exports.lastResponseContent = lastResponseContent;
|
|
25
|
+
function lastContentOfResponse(response) {
|
|
26
|
+
const content = response === null || response === void 0 ? void 0 : response.content;
|
|
27
|
+
return content && content.length > 0 ? content[content.length - 1] : undefined;
|
|
28
|
+
}
|
|
29
|
+
exports.lastContentOfResponse = lastContentOfResponse;
|
|
30
|
+
function lastProgressMessage(request) {
|
|
31
|
+
return lastProgressMessageOfResponse(request.response);
|
|
32
|
+
}
|
|
33
|
+
exports.lastProgressMessage = lastProgressMessage;
|
|
34
|
+
function lastProgressMessageOfResponse(response) {
|
|
35
|
+
const progressMessages = response === null || response === void 0 ? void 0 : response.progressMessages;
|
|
36
|
+
return progressMessages && progressMessages.length > 0 ? progressMessages[progressMessages.length - 1] : undefined;
|
|
37
|
+
}
|
|
38
|
+
exports.lastProgressMessageOfResponse = lastProgressMessageOfResponse;
|
|
39
|
+
function unansweredQuestions(request) {
|
|
40
|
+
const response = request.response;
|
|
41
|
+
return unansweredQuestionsOfResponse(response);
|
|
42
|
+
}
|
|
43
|
+
exports.unansweredQuestions = unansweredQuestions;
|
|
44
|
+
function unansweredQuestionsOfResponse(response) {
|
|
45
|
+
if (!response || !response.response) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return response.response.content.filter((c) => chat_model_1.QuestionResponseContent.is(c) && c.selectedOption === undefined);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=chat-model-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-model-util.js","sourceRoot":"","sources":["../../src/common/chat-model-util.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;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