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

feat: add support for custom agents #14301

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix issues found by review:
- fix prompt key of custom agent
- improve ui
- add example entry for a new custom agent file
eneufeld committed Oct 16, 2024
commit 9a6fffa59ea210488a653a95d751397ddf0e3fec
2 changes: 1 addition & 1 deletion packages/ai-chat/src/common/custom-chat-agent.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,6 @@ export class CustomChatAgent
}

set prompt(prompt: string) {
this.promptTemplates.push({ id: `${this.name}_system`, template: prompt });
this.promptTemplates.push({ id: `${this.name}_prompt`, template: prompt });
}
}
Original file line number Diff line number Diff line change
@@ -101,7 +101,9 @@ export class AIAgentConfigurationWidget extends ReactWidget {
</li>
)}
</ul>
<button style={{ marginLeft: 0 }} className='theia-button main' onClick={() => this.addCustomAgent()}>Add Custom Agent</button>
<div className='configuration-agents-add'>
<button style={{ marginLeft: 0 }} className='theia-button main' onClick={() => this.addCustomAgent()}>Add Custom Agent</button>
</div>
Comment on lines +105 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are already custom agents then this should be called "Edit Custom Agents" as it does no longer add one

</div>
<div className='configuration-agent-panel preferences-editor-widget'>
{this.renderAgentDetails()}
Original file line number Diff line number Diff line change
@@ -26,6 +26,11 @@ import { AgentService } from '../common/agent-service';
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
import { load } from 'js-yaml';

const templateEntry = `-id: my_agent
name: My Agent
description: This is an example agent. Please adapt the properties to fit your needs.
prompt: You are an example agent. Be nice and helpful to the user.`;

@injectable()
export class FrontendPromptCustomizationServiceImpl implements PromptCustomizationService {

@@ -224,7 +229,7 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
async openCustomAgentYaml(): Promise<void> {
const customAgentYamlUri = (await this.getTemplatesDirectoryURI()).resolve('customAgents.yml');
if (! await this.fileService.exists(customAgentYamlUri)) {
await this.fileService.createFile(customAgentYamlUri);
await this.fileService.createFile(customAgentYamlUri, BinaryBuffer.fromString(templateEntry));
}
const openHandler = await this.openerService.getOpener(customAgentYamlUri);
openHandler.open(customAgentYamlUri);
5 changes: 5 additions & 0 deletions packages/ai-core/src/browser/style/index.css
Original file line number Diff line number Diff line change
@@ -88,3 +88,8 @@
border-radius: calc(var(--theia-ui-padding) * 2 / 3);
background: hsla(0, 0%, 68%, 0.31);
}

.configuration-agents-add {
margin-top: 3em;
margin-left: 0;
}
Loading