Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent prompt ids #14162

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/ai-chat/src/common/command-chat-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {
generateUuid,
} from '@theia/core';

export const commandChatAgentSystemPromptTemplate: PromptTemplate = {
id: 'command-chat-agent-system-prompt-template',
export const commandTemplate: PromptTemplate = {
id: 'command-system',
template: `# System Prompt

You are a service that helps users find commands to execute in an IDE.
Expand Down Expand Up @@ -267,15 +267,15 @@ export class CommandChatAgent extends AbstractTextToModelParsingChatAgent<Parsed
this.description = 'This agent is aware of all commands that the user can execute within the Theia IDE, the tool that the user is currently working with. \
Based on the user request, it can find the right command and then let the user execute it.';
this.variables = [];
this.promptTemplates = [commandChatAgentSystemPromptTemplate];
this.promptTemplates = [commandTemplate];
}

protected async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
const knownCommands: string[] = [];
for (const command of this.commandRegistry.getAllCommands()) {
knownCommands.push(`${command.id}: ${command.label}`);
}
const systemPrompt = await this.promptService.getPrompt('command-chat-agent-system-prompt-template', {
const systemPrompt = await this.promptService.getPrompt(commandTemplate.id, {
'command-ids': knownCommands.join('\n')
});
if (systemPrompt === undefined) {
Expand Down
8 changes: 4 additions & 4 deletions packages/ai-chat/src/common/orchestrator-chat-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { ChatAgentService } from './chat-agent-service';
import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
import { ChatRequestModelImpl, InformationalChatResponseContentImpl } from './chat-model';

export const delegateTemplate: PromptTemplate = {
id: 'default-delegate-template',
export const orchestratorTemplate: PromptTemplate = {
id: 'orchestrator-system',
template: `# Instructions

Your task is to identify which Chat Agent(s) should best reply a given user's message.
Expand Down Expand Up @@ -76,7 +76,7 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent implem
this.description = 'This agent analyzes the user request against the description of all available chat agents and selects the best fitting agent to answer the request \
(by using AI).The user\'s request will be directly delegated to the selected agent without further confirmation.';
this.variables = ['chatAgents'];
this.promptTemplates = [delegateTemplate];
this.promptTemplates = [orchestratorTemplate];
this.fallBackChatAgentId = 'Universal';
}

Expand All @@ -89,7 +89,7 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent implem
}

protected async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
const resolvedPrompt = await this.promptService.getPrompt(delegateTemplate.id);
const resolvedPrompt = await this.promptService.getPrompt(orchestratorTemplate.id);
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ai-chat/src/common/universal-chat-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
import { injectable } from '@theia/core/shared/inversify';
import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';

export const defaultTemplate: PromptTemplate = {
id: 'default-template',
export const universalTemplate: PromptTemplate = {
id: 'universal-system',
template: `# Instructions

You are an AI assistant integrated into the Theia IDE, specifically designed to help software developers by
Expand Down Expand Up @@ -93,11 +93,11 @@ export class UniversalChatAgent extends AbstractStreamParsingChatAgent implement
+ 'questions the user might ask. The universal agent currently does not have any context by default, i.e. it cannot '
+ 'access the current user context or the workspace.';
this.variables = [];
this.promptTemplates = [defaultTemplate];
this.promptTemplates = [universalTemplate];
}

protected override async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
const resolvedPrompt = await this.promptService.getPrompt(defaultTemplate.id);
const resolvedPrompt = await this.promptService.getPrompt(universalTemplate.id);
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ai-terminal/src/browser/ai-terminal-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AiTerminalAgent implements Agent {
variables = [];
promptTemplates = [
{
id: 'ai-terminal:system-prompt',
id: 'terminal-system',
name: 'AI Terminal System Prompt',
description: 'Prompt for the AI Terminal Assistant',
template: `
Expand Down Expand Up @@ -89,7 +89,7 @@ nothing to commit, working tree clean
`
},
{
id: 'ai-terminal:user-prompt',
id: 'terminal-user',
name: 'AI Terminal User Prompt',
description: 'Prompt that contains the user request',
template: `
Expand Down Expand Up @@ -139,8 +139,8 @@ recent-terminal-contents:
recentTerminalContents
};

const systemPrompt = await this.promptService.getPrompt('ai-terminal:system-prompt', parameters).then(p => p?.text);
const userPrompt = await this.promptService.getPrompt('ai-terminal:user-prompt', parameters).then(p => p?.text);
const systemPrompt = await this.promptService.getPrompt('terminal-system', parameters).then(p => p?.text);
const userPrompt = await this.promptService.getPrompt('terminal-user', parameters).then(p => p?.text);
if (!systemPrompt || !userPrompt) {
this.logger.error('The prompt service didn\'t return prompts for the AI Terminal Agent.');
return [];
Expand Down
6 changes: 3 additions & 3 deletions packages/ai-workspace-agent/src/browser/workspace-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from '@theia/ai-chat/lib/common';
import { PromptTemplate, ToolInvocationRegistry } from '@theia/ai-core';
import { inject, injectable } from '@theia/core/shared/inversify';
import { template } from '../common/template';
import { workspaceTemplate } from '../common/template';

@injectable()
export class WorkspaceAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
Expand All @@ -37,12 +37,12 @@ export class WorkspaceAgent extends AbstractStreamParsingChatAgent implements Ch
this.description = 'This agent can access the users workspace, it can get a list of all available files and retrieve their content. \
It can therefore answer questions about the current project, project files and source code in the workspace, such as how to build the project, \
where to put source code, where to find specific code or configurations, etc.';
this.promptTemplates = [template];
this.promptTemplates = [workspaceTemplate];
this.variables = [];
}

protected override async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
const resolvedPrompt = await this.promptService.getPrompt(template.id);
const resolvedPrompt = await this.promptService.getPrompt(workspaceTemplate.id);
return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
}
}
4 changes: 2 additions & 2 deletions packages/ai-workspace-agent/src/common/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import { PromptTemplate } from '@theia/ai-core/lib/common';
import { GET_WORKSPACE_FILE_LIST_FUNCTION_ID, FILE_CONTENT_FUNCTION_ID } from './functions';

export const template = <PromptTemplate>{
id: 'workspace-prompt',
export const workspaceTemplate = <PromptTemplate>{
id: 'workspace-system',
template: `# Instructions

You are an AI assistant integrated into the Theia IDE, specifically designed to help software developers by
Expand Down
Loading