Skip to content

Commit

Permalink
Consitently name agents and add tags
Browse files Browse the repository at this point in the history
fixed #14180

Signed-off-by: Jonas Helming <[email protected]>
  • Loading branch information
JonasHelming committed Sep 16, 2024
1 parent 1364191 commit 3b49e05
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/ai-chat/src/common/chat-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export abstract class AbstractChatAgent {
public languageModelRequirements: LanguageModelRequirement[],
protected defaultLanguageModelPurpose: string,
public iconClass: string = 'codicon codicon-copilot',
public locations: ChatAgentLocation[] = ChatAgentLocation.ALL) {
public locations: ChatAgentLocation[] = ChatAgentLocation.ALL,
public tags: String[] = ['Chat']) {
}

async invoke(request: ChatRequestModelImpl): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-chat/src/common/command-chat-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class CommandChatAgent extends AbstractTextToModelParsingChatAgent<Parsed
purpose: 'command',
identifier: 'openai/gpt-4o',
}], 'command');
this.name = 'Command Chat Agent';
this.name = 'Command';
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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export class AIAgentConfigurationWidget extends ReactWidget {
<div className='configuration-agents-list preferences-tree-widget theia-TreeContainer' style={{ width: '25%' }}>
<ul>
{this.agentService.getAllAgents().map(agent =>
<li key={agent.id} className='theia-TreeNode theia-CompositeTreeNode theia-ExpandableTreeNode' onClick={() => this.setActiveAgent(agent)}>{agent.name}</li>
<li key={agent.id} className='theia-TreeNode theia-CompositeTreeNode theia-ExpandableTreeNode' onClick={() => this.setActiveAgent(agent)}>
{this.renderAgentName(agent)}
</li>
)}
</ul>
</div>
Expand All @@ -83,6 +85,12 @@ export class AIAgentConfigurationWidget extends ReactWidget {
</div>;
}

private renderAgentName(agent: Agent): string {
// Check if the agent has tags, and join them with a comma separator if they exist
const tagsSuffix = agent.tags?.length ? ` (${agent.tags.join(', ')})` : '';
return `${agent.name}${tagsSuffix}`;
}

private renderAgentDetails(): React.ReactNode {
const agent = this.aiConfigurationSelectionService.getActiveAgent();
if (!agent) {
Expand All @@ -92,7 +100,7 @@ export class AIAgentConfigurationWidget extends ReactWidget {
const enabled = this.agentService.isEnabled(agent.id);

return <div key={agent.id} style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
<div className='settings-section-title settings-section-category-title' style={{ paddingLeft: 0, paddingBottom: 10 }}>{agent.name}</div>
<div className='settings-section-title settings-section-category-title' style={{ paddingLeft: 0, paddingBottom: 10 }}>{this.renderAgentName(agent)}</div>
<div style={{ paddingBottom: 10 }}>{agent.description}</div>
<div style={{ paddingBottom: 10 }}>
<label>
Expand Down
11 changes: 9 additions & 2 deletions packages/ai-core/src/common/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export const Agent = Symbol('Agent');
* They can also declare their used prompt templates, which makes them configurable for the user.
*/
export interface Agent {
/** Used to identify an agent, e.g. when it is requesting language models, etc. */
/**
* Used to identify an agent, e.g. when it is requesting language models, etc.
*
* @note This parameter might be removed in favor of `name`. Therefore, it is recommended to set `id` to the same value as `name` for now.
*/
readonly id: string;

/** Human-readable name shown to users to identify the agent. */
/** Human-readable name shown to users to identify the agent. Must be unique. Use short names without "Agent" or "Chat" (see `tags` for adding further properties).*/
readonly name: string;

/** A markdown description of its functionality and its privacy-relevant requirements, including function call handlers that access some data autonomously. */
Expand All @@ -45,4 +49,7 @@ export interface Agent {

/** Required language models. This includes the purpose and optional language model selector arguments. See #47. */
readonly languageModelRequirements: LanguageModelRequirement[];

/** A list of tags to filter agents and to display capabilities in the UI */
readonly tags?: String[];
}

0 comments on commit 3b49e05

Please sign in to comment.