@theia/ai-history 1.61.0 → 1.62.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-history-contribution.d.ts +9 -1
- package/lib/browser/ai-history-contribution.d.ts.map +1 -1
- package/lib/browser/ai-history-contribution.js +102 -4
- package/lib/browser/ai-history-contribution.js.map +1 -1
- package/lib/browser/ai-history-exchange-card.d.ts +11 -0
- package/lib/browser/ai-history-exchange-card.d.ts.map +1 -0
- package/lib/browser/ai-history-exchange-card.js +132 -0
- package/lib/browser/ai-history-exchange-card.js.map +1 -0
- package/lib/browser/ai-history-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-history-frontend-module.js +0 -4
- package/lib/browser/ai-history-frontend-module.js.map +1 -1
- package/lib/browser/ai-history-widget.d.ts +17 -5
- package/lib/browser/ai-history-widget.d.ts.map +1 -1
- package/lib/browser/ai-history-widget.js +50 -30
- package/lib/browser/ai-history-widget.js.map +1 -1
- package/lib/common/index.d.ts +0 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -4
- package/lib/common/index.js.map +1 -1
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +9 -8
- package/src/browser/ai-history-contribution.ts +107 -3
- package/src/browser/ai-history-exchange-card.tsx +243 -0
- package/src/browser/ai-history-frontend-module.ts +0 -5
- package/src/browser/ai-history-widget.tsx +74 -31
- package/src/browser/style/ai-history.css +145 -60
- package/src/common/index.ts +0 -1
- package/src/package.spec.ts +28 -0
- package/lib/browser/ai-history-communication-card.d.ts +0 -8
- package/lib/browser/ai-history-communication-card.d.ts.map +0 -1
- package/lib/browser/ai-history-communication-card.js +0 -71
- package/lib/browser/ai-history-communication-card.js.map +0 -1
- package/lib/common/communication-recording-service.d.ts +0 -18
- package/lib/common/communication-recording-service.d.ts.map +0 -1
- package/lib/common/communication-recording-service.js +0 -74
- package/lib/common/communication-recording-service.js.map +0 -1
- package/lib/common/communication-recording-service.spec.d.ts +0 -2
- package/lib/common/communication-recording-service.spec.d.ts.map +0 -1
- package/lib/common/communication-recording-service.spec.js +0 -43
- package/lib/common/communication-recording-service.spec.js.map +0 -1
- package/src/browser/ai-history-communication-card.tsx +0 -103
- package/src/common/communication-recording-service.spec.ts +0 -63
- package/src/common/communication-recording-service.ts +0 -97
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":";;;;AAuBA,sCAAsD;AACtD,4DAAyE;AAGlE,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAA1C;QAKO,8BAAyB,GAAG,IAAI,cAAO,EAA6B,CAAC;QACtE,uBAAkB,GAAqC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC;QAE3F,+BAA0B,GAAG,IAAI,cAAO,EAA8B,CAAC;QACxE,wBAAmB,GAAsC,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;QAE9F,8BAAyB,GAAG,IAAI,cAAO,EAAQ,CAAC;QACjD,uBAAkB,GAAgB,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC;QAEtE,YAAO,GAAsC,IAAI,GAAG,EAAE,CAAC;IAuDrE,CAAC;IArDG,UAAU,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,iBAAiB,CAAC,SAAiB;QAC/B,OAAO,KAAK,CAAC,IAAI,CACb,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CACxB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACtB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,C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ACnE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC9D,IAAI,YAAY,EAAE,CAAC;gBACf,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,cAAc,CAAC,SAAS,CAAC,CAAC;gBACzF,IAAI,CAAC,eAAe,EAAE,CAAC;oBACnB,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAC;gBAC1D,CAAC;gBACD,eAAe,CAAC,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC;gBACnD,eAAe,CAAC,YAAY,GAAG,cAAc,CAAC,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;gBACpF,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACzD,CAAC;QACL,CAAC;IACL,CAAC;IAED,YAAY;QACR,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AArEY,oFAAoC;AAGnC;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,4BAA4B,CAAC;;oEAC3B;+CAHjB,oCAAoC;IADhD,IAAA,sBAAU,GAAE;GACA,oCAAoC,CAqEhD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.spec.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
|
|
4
|
-
const communication_recording_service_1 = require("./communication-recording-service");
|
|
5
|
-
const chai_1 = require("chai");
|
|
6
|
-
describe('DefaultCommunicationRecordingService', () => {
|
|
7
|
-
it('records history', () => {
|
|
8
|
-
var _a, _b, _c;
|
|
9
|
-
const service = new communication_recording_service_1.DefaultCommunicationRecordingService();
|
|
10
|
-
service.logger = new mock_logger_1.MockLogger();
|
|
11
|
-
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'dummy request' }] });
|
|
12
|
-
const history1 = service.getHistory('agent');
|
|
13
|
-
(0, chai_1.expect)(((_a = history1[0].request) === null || _a === void 0 ? void 0 : _a[0]).text).to.eq('dummy request');
|
|
14
|
-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'dummy response' }] });
|
|
15
|
-
const history2 = service.getHistory('agent');
|
|
16
|
-
(0, chai_1.expect)(((_b = history2[0].request) === null || _b === void 0 ? void 0 : _b[0]).text).to.eq('dummy request');
|
|
17
|
-
(0, chai_1.expect)(((_c = history2[0].response) === null || _c === void 0 ? void 0 : _c[0]).text).to.eq('dummy response');
|
|
18
|
-
});
|
|
19
|
-
it('returns session history', () => {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f;
|
|
21
|
-
const service = new communication_recording_service_1.DefaultCommunicationRecordingService();
|
|
22
|
-
service.logger = new mock_logger_1.MockLogger();
|
|
23
|
-
// some requests and responses for session 1
|
|
24
|
-
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'session 1 request 1' }] });
|
|
25
|
-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'session 1 response 1' }] });
|
|
26
|
-
service.recordRequest({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'session 1 request 2' }] });
|
|
27
|
-
service.recordResponse({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'session 1 response 2' }] });
|
|
28
|
-
// some requests and responses for session 2
|
|
29
|
-
service.recordRequest({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'different session request' }] });
|
|
30
|
-
service.recordResponse({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'different session request' }] });
|
|
31
|
-
const history1 = service.getSessionHistory('1');
|
|
32
|
-
(0, chai_1.expect)(history1.length).to.eq(2);
|
|
33
|
-
(0, chai_1.expect)(((_a = history1[0].request) === null || _a === void 0 ? void 0 : _a[0]).text).to.eq('session 1 request 1');
|
|
34
|
-
(0, chai_1.expect)(((_b = history1[0].response) === null || _b === void 0 ? void 0 : _b[0]).text).to.eq('session 1 response 1');
|
|
35
|
-
(0, chai_1.expect)(((_c = history1[1].request) === null || _c === void 0 ? void 0 : _c[0]).text).to.eq('session 1 request 2');
|
|
36
|
-
(0, chai_1.expect)(((_d = history1[1].response) === null || _d === void 0 ? void 0 : _d[0]).text).to.eq('session 1 response 2');
|
|
37
|
-
const history2 = service.getSessionHistory('2');
|
|
38
|
-
(0, chai_1.expect)(history2.length).to.eq(1);
|
|
39
|
-
(0, chai_1.expect)(((_e = history2[0].request) === null || _e === void 0 ? void 0 : _e[0]).text).to.eq('different session request');
|
|
40
|
-
(0, chai_1.expect)(((_f = history2[0].response) === null || _f === void 0 ? void 0 : _f[0]).text).to.eq('different session request');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=communication-recording-service.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.spec.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.spec.ts"],"names":[],"mappings":";;AAgBA,yEAAqE;AACrE,uFAA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O,0CAAG,CAAC,CAAiB,CAAA,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;QACpF,IAAA,aAAM,EAAC,CAAC,MAAA,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,0CAAG,CAAC,CAAiB,CAAA,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC;QAEtF,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAChD,IAAA,aAAM,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACjC,IAAA,aAAM,EAAC,CAAC,MAAA,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,0CAAG,CAAC,CAAiB,CAAA,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC;QAC1F,IAAA,aAAM,EAAC,CAAC,MAAA,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,0CAAG,CAAC,CAAiB,CAAA,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
import { CommunicationHistoryEntry } from '@theia/ai-core';
|
|
17
|
-
import { nls } from '@theia/core';
|
|
18
|
-
import * as React from '@theia/core/shared/react';
|
|
19
|
-
|
|
20
|
-
export interface CommunicationCardProps {
|
|
21
|
-
entry: CommunicationHistoryEntry;
|
|
22
|
-
}
|
|
23
|
-
// Format JSON with error handling
|
|
24
|
-
const formatJson = (data: unknown): React.ReactNode => {
|
|
25
|
-
try {
|
|
26
|
-
return JSON.stringify(data, undefined, 2).split(/(?:\\r)?\\n/).flatMap((stringChunk, i) => [stringChunk, <br key={stringChunk + i}/>]);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Error formatting JSON:', error);
|
|
29
|
-
return 'Error formatting data';
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Format the timestamp for better readability
|
|
34
|
-
const formatTimestamp = (timestamp: number): string =>
|
|
35
|
-
new Date(timestamp).toLocaleString(undefined, {
|
|
36
|
-
year: 'numeric',
|
|
37
|
-
month: 'short',
|
|
38
|
-
day: 'numeric',
|
|
39
|
-
hour: '2-digit',
|
|
40
|
-
minute: '2-digit',
|
|
41
|
-
second: '2-digit'
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export const CommunicationCard: React.FC<CommunicationCardProps> = ({ entry }) => (
|
|
45
|
-
<div className='theia-card' role="article" aria-label={`Communication log for request ${entry.requestId}`}>
|
|
46
|
-
<div className='theia-card-meta'>
|
|
47
|
-
<span className='theia-card-request-id'>{nls.localize('theia/ai/history/communication-card/requestId', 'Request ID')}: {entry.requestId}</span>
|
|
48
|
-
<span className='theia-card-session-id'>{nls.localize('theia/ai/history/communication-card/sessionId', 'Session ID')}: {entry.sessionId}</span>
|
|
49
|
-
</div>
|
|
50
|
-
<div className='theia-card-content'>
|
|
51
|
-
{entry.request && (
|
|
52
|
-
<div className='theia-card-request'>
|
|
53
|
-
<h2>{nls.localize('theia/ai/history/communication-card/request', 'Request')}</h2>
|
|
54
|
-
<details key={`request-${entry.requestId}`}>
|
|
55
|
-
<summary>
|
|
56
|
-
<h3>{nls.localize('theia/ai/history/communication-card/request/summary', 'Request')} {entry.requestId}</h3>
|
|
57
|
-
</summary>
|
|
58
|
-
<div className='theia-card-request-messages'>
|
|
59
|
-
<h4>{nls.localize('theia/ai/history/communication-card/request/messages', 'Messages')}</h4>
|
|
60
|
-
<ul className='theia-card-request-messages-list'>
|
|
61
|
-
{entry.request.map((message, index) => (
|
|
62
|
-
<li key={`message-${entry.requestId}-${index}`} className="message-item">
|
|
63
|
-
<pre className="message-content">{formatJson(message)}</pre>
|
|
64
|
-
</li>
|
|
65
|
-
))}
|
|
66
|
-
</ul>
|
|
67
|
-
</div>
|
|
68
|
-
</details>
|
|
69
|
-
</div>
|
|
70
|
-
)}
|
|
71
|
-
{entry.response && (
|
|
72
|
-
<div className='theia-card-response'>
|
|
73
|
-
<h2>{nls.localize('theia/ai/history/communication-card/response', 'Response')}</h2>
|
|
74
|
-
<details key={`response-${entry.requestId}`}>
|
|
75
|
-
<summary>
|
|
76
|
-
<h3>{nls.localize('theia/ai/history/communication-card/response/summary', 'Response')} {entry.requestId}</h3>
|
|
77
|
-
</summary>
|
|
78
|
-
<div className='theia-card-response-messages'>
|
|
79
|
-
<h4>{nls.localize('theia/ai/history/communication-card/response/messages', 'Messages')}</h4>
|
|
80
|
-
<ul className='theia-card-response-messages-list'>
|
|
81
|
-
{entry.response.map((message, index) => (
|
|
82
|
-
<li key={`message-${entry.requestId}-${index}`} className="message-item">
|
|
83
|
-
<pre className="message-content">{formatJson(message)}</pre>
|
|
84
|
-
</li>
|
|
85
|
-
))}
|
|
86
|
-
</ul>
|
|
87
|
-
</div>
|
|
88
|
-
</details>
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
<div className='theia-card-meta'>
|
|
93
|
-
<span className='theia-card-timestamp'>
|
|
94
|
-
{nls.localize('theia/ai/history/communication-card/timestamp', 'Timestamp')}: {formatTimestamp(entry.timestamp)}
|
|
95
|
-
</span>
|
|
96
|
-
{entry.responseTime !== undefined && (
|
|
97
|
-
<span className='theia-card-response-time'>
|
|
98
|
-
{nls.localize('theia/ai/history/communication-card/responseTime', 'Response Time')}: {entry.responseTime}ms
|
|
99
|
-
</span>
|
|
100
|
-
)}
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
import { ILogger } from '@theia/core';
|
|
17
|
-
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
|
|
18
|
-
import { DefaultCommunicationRecordingService } from './communication-recording-service';
|
|
19
|
-
import { expect } from 'chai';
|
|
20
|
-
import { TextMessage } from '@theia/ai-core';
|
|
21
|
-
|
|
22
|
-
describe('DefaultCommunicationRecordingService', () => {
|
|
23
|
-
|
|
24
|
-
it('records history', () => {
|
|
25
|
-
const service = new DefaultCommunicationRecordingService();
|
|
26
|
-
(service as unknown as { logger: ILogger }).logger = new MockLogger();
|
|
27
|
-
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'dummy request' }] });
|
|
28
|
-
|
|
29
|
-
const history1 = service.getHistory('agent');
|
|
30
|
-
expect((history1[0].request?.[0] as TextMessage).text).to.eq('dummy request');
|
|
31
|
-
|
|
32
|
-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'dummy response' }] });
|
|
33
|
-
const history2 = service.getHistory('agent');
|
|
34
|
-
expect((history2[0].request?.[0] as TextMessage).text).to.eq('dummy request');
|
|
35
|
-
expect((history2[0].response?.[0] as TextMessage).text).to.eq('dummy response');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('returns session history', () => {
|
|
39
|
-
const service = new DefaultCommunicationRecordingService();
|
|
40
|
-
(service as unknown as { logger: ILogger }).logger = new MockLogger();
|
|
41
|
-
// some requests and responses for session 1
|
|
42
|
-
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'session 1 request 1' }] });
|
|
43
|
-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'session 1 response 1' }] });
|
|
44
|
-
service.recordRequest({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'session 1 request 2' }] });
|
|
45
|
-
service.recordResponse({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'session 1 response 2' }] });
|
|
46
|
-
// some requests and responses for session 2
|
|
47
|
-
service.recordRequest({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'different session request' }] });
|
|
48
|
-
service.recordResponse({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'different session request' }] });
|
|
49
|
-
|
|
50
|
-
const history1 = service.getSessionHistory('1');
|
|
51
|
-
expect(history1.length).to.eq(2);
|
|
52
|
-
expect((history1[0].request?.[0] as TextMessage).text).to.eq('session 1 request 1');
|
|
53
|
-
expect((history1[0].response?.[0] as TextMessage).text).to.eq('session 1 response 1');
|
|
54
|
-
expect((history1[1].request?.[0] as TextMessage).text).to.eq('session 1 request 2');
|
|
55
|
-
expect((history1[1].response?.[0] as TextMessage).text).to.eq('session 1 response 2');
|
|
56
|
-
|
|
57
|
-
const history2 = service.getSessionHistory('2');
|
|
58
|
-
expect(history2.length).to.eq(1);
|
|
59
|
-
expect((history2[0].request?.[0] as TextMessage).text).to.eq('different session request');
|
|
60
|
-
expect((history2[0].response?.[0] as TextMessage).text).to.eq('different session request');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
import {
|
|
17
|
-
CommunicationHistory,
|
|
18
|
-
CommunicationRecordingService,
|
|
19
|
-
CommunicationRequestEntry,
|
|
20
|
-
CommunicationRequestEntryParam,
|
|
21
|
-
CommunicationResponseEntry,
|
|
22
|
-
CommunicationResponseEntryParam,
|
|
23
|
-
} from '@theia/ai-core';
|
|
24
|
-
import { Emitter, Event, ILogger } from '@theia/core';
|
|
25
|
-
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
26
|
-
|
|
27
|
-
@injectable()
|
|
28
|
-
export class DefaultCommunicationRecordingService implements CommunicationRecordingService {
|
|
29
|
-
|
|
30
|
-
@inject(ILogger) @named('llm-communication-recorder')
|
|
31
|
-
protected logger: ILogger;
|
|
32
|
-
|
|
33
|
-
protected onDidRecordRequestEmitter = new Emitter<CommunicationRequestEntry>();
|
|
34
|
-
readonly onDidRecordRequest: Event<CommunicationRequestEntry> = this.onDidRecordRequestEmitter.event;
|
|
35
|
-
|
|
36
|
-
protected onDidRecordResponseEmitter = new Emitter<CommunicationResponseEntry>();
|
|
37
|
-
readonly onDidRecordResponse: Event<CommunicationResponseEntry> = this.onDidRecordResponseEmitter.event;
|
|
38
|
-
|
|
39
|
-
protected onStructuralChangeEmitter = new Emitter<void>();
|
|
40
|
-
readonly onStructuralChange: Event<void> = this.onStructuralChangeEmitter.event;
|
|
41
|
-
|
|
42
|
-
protected history: Map<string, CommunicationHistory> = new Map();
|
|
43
|
-
|
|
44
|
-
getHistory(agentId: string): CommunicationHistory {
|
|
45
|
-
return this.history.get(agentId) || [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getSessionHistory(sessionId: string): CommunicationHistory {
|
|
49
|
-
return Array.from(
|
|
50
|
-
this.history.values()
|
|
51
|
-
).reduce((acc, current) =>
|
|
52
|
-
acc.concat(current.filter(entry => entry.sessionId === sessionId)), []
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
recordRequest(requestEntry: CommunicationRequestEntryParam): void {
|
|
57
|
-
this.logger.debug('Recording request:', requestEntry.request);
|
|
58
|
-
const completedEntry = { timestamp: Date.now(), ...requestEntry };
|
|
59
|
-
if (!this.history.has(requestEntry.agentId)) {
|
|
60
|
-
this.history.set(requestEntry.agentId, [completedEntry]);
|
|
61
|
-
} else {
|
|
62
|
-
const agentHistory = this.history.get(requestEntry.agentId)!;
|
|
63
|
-
const existingEntryIndex = agentHistory.findIndex(e => e.requestId === requestEntry.requestId);
|
|
64
|
-
if (existingEntryIndex !== -1) {
|
|
65
|
-
agentHistory[existingEntryIndex] = {
|
|
66
|
-
...agentHistory[existingEntryIndex],
|
|
67
|
-
...completedEntry
|
|
68
|
-
};
|
|
69
|
-
} else {
|
|
70
|
-
agentHistory.push(completedEntry);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
this.onDidRecordRequestEmitter.fire(completedEntry);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
recordResponse(responseEntry: CommunicationResponseEntryParam): void {
|
|
77
|
-
this.logger.debug('Recording response:', responseEntry.response);
|
|
78
|
-
const completedEntry = { timestamp: Date.now(), ...responseEntry };
|
|
79
|
-
if (this.history.has(completedEntry.agentId)) {
|
|
80
|
-
const agentHistory = this.history.get(completedEntry.agentId);
|
|
81
|
-
if (agentHistory) {
|
|
82
|
-
const matchingRequest = agentHistory.find(e => e.requestId === completedEntry.requestId);
|
|
83
|
-
if (!matchingRequest) {
|
|
84
|
-
throw Error('No matching request found for response');
|
|
85
|
-
}
|
|
86
|
-
matchingRequest.response = completedEntry.response;
|
|
87
|
-
matchingRequest.responseTime = completedEntry.timestamp - matchingRequest.timestamp;
|
|
88
|
-
this.onDidRecordResponseEmitter.fire(completedEntry);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
clearHistory(): void {
|
|
94
|
-
this.history.clear();
|
|
95
|
-
this.onStructuralChangeEmitter.fire(undefined);
|
|
96
|
-
}
|
|
97
|
-
}
|