@theia/ai-chat 1.55.0-next.37 → 1.55.0-next.67

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.
Files changed (48) hide show
  1. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
  2. package/lib/browser/ai-chat-frontend-module.js +25 -2
  3. package/lib/browser/ai-chat-frontend-module.js.map +1 -1
  4. package/lib/browser/custom-agent-factory.d.ts +4 -0
  5. package/lib/browser/custom-agent-factory.d.ts.map +1 -0
  6. package/lib/browser/custom-agent-factory.js +20 -0
  7. package/lib/browser/custom-agent-factory.js.map +1 -0
  8. package/lib/browser/custom-agent-frontend-application-contribution.d.ts +13 -0
  9. package/lib/browser/custom-agent-frontend-application-contribution.d.ts.map +1 -0
  10. package/lib/browser/custom-agent-frontend-application-contribution.js +82 -0
  11. package/lib/browser/custom-agent-frontend-application-contribution.js.map +1 -0
  12. package/lib/common/chat-agent-service.d.ts +11 -0
  13. package/lib/common/chat-agent-service.d.ts.map +1 -1
  14. package/lib/common/chat-agent-service.js +3 -0
  15. package/lib/common/chat-agent-service.js.map +1 -1
  16. package/lib/common/chat-agents.d.ts.map +1 -1
  17. package/lib/common/chat-agents.js +9 -30
  18. package/lib/common/chat-agents.js.map +1 -1
  19. package/lib/common/chat-history-entry.d.ts +7 -0
  20. package/lib/common/chat-history-entry.d.ts.map +1 -0
  21. package/lib/common/chat-history-entry.js +42 -0
  22. package/lib/common/chat-history-entry.js.map +1 -0
  23. package/lib/common/custom-chat-agent.d.ts +14 -0
  24. package/lib/common/custom-chat-agent.d.ts.map +1 -0
  25. package/lib/common/custom-chat-agent.js +43 -0
  26. package/lib/common/custom-chat-agent.js.map +1 -0
  27. package/lib/common/index.d.ts +4 -3
  28. package/lib/common/index.d.ts.map +1 -1
  29. package/lib/common/index.js +4 -3
  30. package/lib/common/index.js.map +1 -1
  31. package/lib/common/o1-chat-agent.d.ts +13 -0
  32. package/lib/common/o1-chat-agent.d.ts.map +1 -0
  33. package/lib/common/o1-chat-agent.js +45 -0
  34. package/lib/common/o1-chat-agent.js.map +1 -0
  35. package/lib/common/orchestrator-chat-agent.d.ts.map +1 -1
  36. package/lib/common/orchestrator-chat-agent.js +13 -13
  37. package/lib/common/orchestrator-chat-agent.js.map +1 -1
  38. package/package.json +8 -8
  39. package/src/browser/ai-chat-frontend-module.ts +30 -4
  40. package/src/browser/custom-agent-factory.ts +20 -0
  41. package/src/browser/custom-agent-frontend-application-contribution.ts +73 -0
  42. package/src/common/chat-agent-service.ts +15 -0
  43. package/src/common/chat-agents.ts +13 -31
  44. package/src/common/chat-history-entry.ts +47 -0
  45. package/src/common/custom-chat-agent.ts +44 -0
  46. package/src/common/index.ts +4 -3
  47. package/src/common/o1-chat-agent.ts +51 -0
  48. package/src/common/orchestrator-chat-agent.ts +14 -13
@@ -23,6 +23,7 @@ import { ChatAgentService } from './chat-agent-service';
23
23
  import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
24
24
  import { ChatRequestModelImpl, InformationalChatResponseContentImpl } from './chat-model';
25
25
  import { generateUuid } from '@theia/core';
26
+ import { ChatHistoryEntry } from './chat-history-entry';
26
27
 
27
28
  export const orchestratorTemplate: PromptTemplate = {
28
29
  id: 'orchestrator-system',
@@ -60,7 +61,7 @@ You must only use the \`id\` attribute of the agent, never the name.
60
61
  `};
61
62
 
62
63
  export const OrchestratorChatAgentId = 'Orchestrator';
63
- const OrchestatorRequestIdKey = 'orchestatorRequestIdKey';
64
+ const OrchestratorRequestIdKey = 'orchestatorRequestIdKey';
64
65
 
65
66
  @injectable()
66
67
  export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
@@ -93,16 +94,17 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent implem
93
94
  override async invoke(request: ChatRequestModelImpl): Promise<void> {
94
95
  request.response.addProgressMessage({ content: 'Determining the most appropriate agent', status: 'inProgress' });
95
96
  // We generate a dedicated ID for recording the orchestrator request/response, as we will forward the original request to another agent
96
- const orchestartorRequestId = generateUuid();
97
- request.addData(OrchestatorRequestIdKey, orchestartorRequestId);
98
- const userPrompt = request.request.text;
99
- this.recordingService.recordRequest({
100
- agentId: this.id,
101
- sessionId: request.session.id,
102
- timestamp: Date.now(),
103
- requestId: orchestartorRequestId,
104
- request: userPrompt,
105
- });
97
+ const orchestratorRequestId = generateUuid();
98
+ request.addData(OrchestratorRequestIdKey, orchestratorRequestId);
99
+ const messages = await this.getMessages(request.session);
100
+ const systemMessage = (await this.getSystemMessageDescription())?.text;
101
+ this.recordingService.recordRequest(
102
+ ChatHistoryEntry.fromRequest(this.id, request, {
103
+ requestId: orchestratorRequestId,
104
+ messages,
105
+ systemMessage
106
+ })
107
+ );
106
108
  return super.invoke(request);
107
109
  }
108
110
 
@@ -115,12 +117,11 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent implem
115
117
  let agentIds: string[] = [];
116
118
  const responseText = await getTextOfResponse(response);
117
119
  // We use the previously generated, dedicated ID to log the orchestrator response before we forward the original request
118
- const orchestratorRequestId = request.getDataByKey(OrchestatorRequestIdKey);
120
+ const orchestratorRequestId = request.getDataByKey(OrchestratorRequestIdKey);
119
121
  if (typeof orchestratorRequestId === 'string') {
120
122
  this.recordingService.recordResponse({
121
123
  agentId: this.id,
122
124
  sessionId: request.session.id,
123
- timestamp: Date.now(),
124
125
  requestId: orchestratorRequestId,
125
126
  response: responseText,
126
127
  });