Skip to content

Commit 3d50d23

Browse files
committed
rebase on top of 15146
1 parent 0b496e8 commit 3d50d23

File tree

11 files changed

+97
-59
lines changed

11 files changed

+97
-59
lines changed

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ai-chat-ui/src/browser/ai-chat-ui-frontend-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import {
3333
HorizontalLayoutPartRenderer,
3434
InsertCodeAtCursorButtonAction,
3535
MarkdownPartRenderer,
36-
TextPartRenderer,
3736
ToolCallPartRenderer,
37+
ThinkingPartRenderer,
3838
} from './chat-response-renderer';
3939
import {
4040
GitHubSelectionResolver,
@@ -80,14 +80,14 @@ export default new ContainerModule((bind, _unbind, _isBound, rebind) => {
8080

8181
bind(ContextVariablePicker).toSelf().inSingletonScope();
8282

83-
bind(ChatResponsePartRenderer).to(TextPartRenderer).inSingletonScope();
8483
bind(ChatResponsePartRenderer).to(HorizontalLayoutPartRenderer).inSingletonScope();
8584
bind(ChatResponsePartRenderer).to(ErrorPartRenderer).inSingletonScope();
8685
bind(ChatResponsePartRenderer).to(MarkdownPartRenderer).inSingletonScope();
8786
bind(ChatResponsePartRenderer).to(CodePartRenderer).inSingletonScope();
8887
bind(ChatResponsePartRenderer).to(CommandPartRenderer).inSingletonScope();
8988
bind(ChatResponsePartRenderer).to(ToolCallPartRenderer).inSingletonScope();
9089
bind(ChatResponsePartRenderer).to(ErrorPartRenderer).inSingletonScope();
90+
bind(ChatResponsePartRenderer).to(ThinkingPartRenderer).inSingletonScope();
9191
bind(ChatResponsePartRenderer).to(QuestionPartRenderer).inSingletonScope();
9292
[CommandContribution, MenuContribution].forEach(serviceIdentifier =>
9393
bind(serviceIdentifier).to(ChatViewMenuContribution).inSingletonScope()

packages/ai-chat-ui/src/browser/chat-response-renderer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ export * from './horizontal-layout-part-renderer';
2121
export * from './markdown-part-renderer';
2222
export * from './text-part-renderer';
2323
export * from './toolcall-part-renderer';
24+
export * from './thinking-part-renderer';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// *****************************************************************************
2+
// Copyright (C) 2024 EclipseSource GmbH.
3+
//
4+
// This program and the accompanying materials are made available under the
5+
// terms of the Eclipse Public License v. 2.0 which is available at
6+
// http://www.eclipse.org/legal/epl-2.0.
7+
//
8+
// This Source Code may also be made available under the following Secondary
9+
// Licenses when the conditions for such availability set forth in the Eclipse
10+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
// with the GNU Classpath Exception which is available at
12+
// https://www.gnu.org/software/classpath/license.html.
13+
//
14+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15+
// *****************************************************************************
16+
17+
import { ChatResponsePartRenderer } from '../chat-response-part-renderer';
18+
import { injectable } from '@theia/core/shared/inversify';
19+
import { ChatResponseContent, ThinkingChatResponseContent } from '@theia/ai-chat/lib/common';
20+
import { ReactNode } from '@theia/core/shared/react';
21+
import { nls } from '@theia/core/lib/common/nls';
22+
import * as React from '@theia/core/shared/react';
23+
24+
@injectable()
25+
export class ThinkingPartRenderer implements ChatResponsePartRenderer<ThinkingChatResponseContent> {
26+
27+
canHandle(response: ChatResponseContent): number {
28+
if (ThinkingChatResponseContent.is(response)) {
29+
return 10;
30+
}
31+
return -1;
32+
}
33+
34+
render(response: ThinkingChatResponseContent): ReactNode {
35+
return (
36+
<div className='theia-thinking'>
37+
<details>
38+
<summary>{nls.localize('theia/ai/chat-ui/thinking-part-renderer/thinking', 'Thinking')}</summary>
39+
<pre>{response.content}</pre>
40+
<pre>{response.signature}</pre>
41+
</details>
42+
</div>
43+
);
44+
}
45+
}

packages/ai-chat/src/common/chat-agents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export abstract class AbstractChatAgent implements ChatAgent {
316316
sessionId: request.session.id,
317317
requestId: request.id,
318318
response: request.response.response.content.flatMap(c =>
319-
({ type: 'text', actor: 'ai', query: c.asDisplayString?.() ?? c.asString?.() ?? JSON.stringify(c) }))
319+
c.toLanguageModelMessage?.() ?? ({ type: 'text', actor: 'ai', text: c.asDisplayString?.() ?? c.asString?.() ?? JSON.stringify(c) }))
320320
}
321321
);
322322
return request.response.complete();

packages/ai-code-completion/src/browser/code-completion-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
143143
agentId: this.id,
144144
sessionId,
145145
requestId,
146-
response: [{ actor: 'ai', query: completionText, type: 'text' }]
146+
response: [{ actor: 'ai', text: completionText, type: 'text' }]
147147
});
148148

149149
const postProcessedCompletionText = this.postProcessor.postProcess(completionText);

packages/ai-core/src/common/communication-recording-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// *****************************************************************************
1616

1717
import { Event } from '@theia/core';
18-
import { LanguageModelRequestMessage } from './language-model';
18+
import { LanguageModelMessage } from './language-model';
1919

2020
export type CommunicationHistory = CommunicationHistoryEntry[];
2121

@@ -27,8 +27,8 @@ export interface CommunicationHistoryEntryBase {
2727
}
2828

2929
export interface CommunicationHistoryEntry extends CommunicationHistoryEntryBase {
30-
request?: LanguageModelRequestMessage[];
31-
response?: LanguageModelRequestMessage[];
30+
request?: LanguageModelMessage[];
31+
response?: LanguageModelMessage[];
3232
responseTime?: number;
3333
}
3434

packages/ai-history/src/common/communication-recording-service.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,47 @@ import { ILogger } from '@theia/core';
1717
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
1818
import { DefaultCommunicationRecordingService } from './communication-recording-service';
1919
import { expect } from 'chai';
20-
import { LanguageModelRequestMessage } from '@theia/ai-core';
20+
import { TextMessage } from '@theia/ai-core';
2121

2222
describe('DefaultCommunicationRecordingService', () => {
2323

2424
it('records history', () => {
2525
const service = new DefaultCommunicationRecordingService();
2626
(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', query: 'dummy request' }] });
27+
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', text: 'dummy request' }] });
2828

2929
const history1 = service.getHistory('agent');
30-
expect((history1[0].request?.[0] as LanguageModelRequestMessage).query).to.eq('dummy request');
30+
expect((history1[0].request?.[0] as TextMessage).text).to.eq('dummy request');
3131

32-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', query: 'dummy response' }] });
32+
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', text: 'dummy response' }] });
3333
const history2 = service.getHistory('agent');
34-
expect((history2[0].request?.[0] as LanguageModelRequestMessage).query).to.eq('dummy request');
35-
expect((history2[0].response?.[0] as LanguageModelRequestMessage).query).to.eq('dummy response');
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');
3636
});
3737

3838
it('returns session history', () => {
3939
const service = new DefaultCommunicationRecordingService();
4040
(service as unknown as { logger: ILogger }).logger = new MockLogger();
4141
// some requests and responses for session 1
42-
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', query: 'session 1 request 1' }] });
43-
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', query: 'session 1 response 1' }] });
44-
service.recordRequest({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 100, request: [{ type: 'text', actor: 'user', query: 'session 1 request 2' }] });
45-
service.recordResponse({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 200, response: [{ type: 'text', actor: 'ai', query: 'session 1 response 2' }] });
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' }] });
4646
// some requests and responses for session 2
47-
service.recordRequest({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 100, request: [{ type: 'text', actor: 'user', query: 'different session request' }] });
48-
service.recordResponse({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 200, response: [{ type: 'text', actor: 'ai', query: 'different session request' }] });
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' }] });
4949

5050
const history1 = service.getSessionHistory('1');
5151
expect(history1.length).to.eq(2);
52-
expect((history1[0].request?.[0] as LanguageModelRequestMessage).query).to.eq('session 1 request 1');
53-
expect((history1[0].response?.[0] as LanguageModelRequestMessage).query).to.eq('session 1 response 1');
54-
expect((history1[1].request?.[0] as LanguageModelRequestMessage).query).to.eq('session 1 request 2');
55-
expect((history1[1].response?.[0] as LanguageModelRequestMessage).query).to.eq('session 1 response 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');
5656

5757
const history2 = service.getSessionHistory('2');
5858
expect(history2.length).to.eq(1);
59-
expect((history2[0].request?.[0] as LanguageModelRequestMessage).query).to.eq('different session request');
60-
expect((history2[0].response?.[0] as LanguageModelRequestMessage).query).to.eq('different session request');
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');
6161
});
6262

6363
});

packages/ai-ide/src/browser/ai-configuration/agent-configuration-widget.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,12 @@ export class AIAgentConfigurationWidget extends ReactWidget {
135135
const functions = Array.from(new Set([...parsedPromptParts.functions, ...agent.functions]));
136136

137137
return <div key={agent.id} style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
138-
<div className='settings-section-title settings-section-category-title' style={{ paddingLeft: 0, paddingBottom: 10 }}>{this.renderAgentName(agent)}</div>
138+
<div className='settings-section-title settings-section-category-title' style={{ paddingLeft: 0, paddingBottom: 10 }}>
139+
{this.renderAgentName(agent)}
140+
<pre style={{ fontSize: 'small', margin: 0 }}>
141+
Id: {agent.id}
142+
</pre>
143+
</div>
139144
<div style={{ paddingBottom: 10 }}>{agent.description}</div>
140145
<div style={{ paddingBottom: 10 }}>
141146
<label>

packages/ai-ide/src/browser/architect-agent.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,4 @@ export class ArchitectAgent extends AbstractStreamParsingChatAgent {
3939
override functions = [GET_WORKSPACE_FILE_LIST_FUNCTION_ID, FILE_CONTENT_FUNCTION_ID];
4040
protected override systemPromptId: string | undefined = architectPromptTemplate.id;
4141

42-
protected override getLlmSettings(): { [key: string]: unknown; } | undefined {
43-
const parentSettings = super.getLlmSettings() ?? {};
44-
const currentSettings = {
45-
max_tokens: 12238,
46-
temperature: 1,
47-
thinking: {
48-
type: 'enabled',
49-
budget_tokens: 8192
50-
}
51-
};
52-
return { ...parentSettings, ...currentSettings };
53-
}
54-
5542
}

0 commit comments

Comments
 (0)