-
Notifications
You must be signed in to change notification settings - Fork 548
fix: samples js change port make it work & change model better results #433
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @codeusb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the JavaScript samples for the Coder Agent by updating the underlying AI model to Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the AI model and server port for the coder agent sample, and includes several code formatting improvements for consistency. My review identifies a bug where the agent's URL is hardcoded, which could cause issues when a custom port is used. I've suggested a refactoring to fix this by dynamically constructing the URL. I've also included a couple of minor suggestions to improve code cleanliness.
| const coderAgentCard: AgentCard = { | ||
| name: 'Coder Agent', | ||
| description: | ||
| 'An agent that generates code based on natural language instructions and streams file outputs.', | ||
| url: 'http://localhost:41242/', // Adjusted port and base URL | ||
| provider: { | ||
| organization: 'A2A Samples', | ||
| url: 'https://example.com/a2a-samples', | ||
| }, | ||
| version: '0.0.2', // Incremented version | ||
| capabilities: { | ||
| streaming: true, // Agent streams artifact updates | ||
| pushNotifications: false, | ||
| stateTransitionHistory: true, | ||
| }, | ||
| securitySchemes: undefined, | ||
| security: undefined, | ||
| defaultInputModes: ['text'], | ||
| defaultOutputModes: ['text', 'file'], // 'file' implies artifacts | ||
| skills: [ | ||
| { | ||
| id: 'code_generation', | ||
| name: 'Code Generation', | ||
| description: | ||
| 'Generates code snippets or complete files based on user requests, streaming the results.', | ||
| tags: ['code', 'development', 'programming'], | ||
| examples: [ | ||
| 'Write a python function to calculate fibonacci numbers.', | ||
| 'Create an HTML file with a basic button that alerts "Hello!" when clicked.', | ||
| ], | ||
| inputModes: ['text'], | ||
| outputModes: ['text', 'file'], | ||
| name: "Coder Agent", | ||
| description: | ||
| "An agent that generates code based on natural language instructions and streams file outputs.", | ||
| url: "http://localhost:41241/", // Adjusted port and base URL | ||
| provider: { | ||
| organization: "A2A Samples", | ||
| url: "https://example.com/a2a-samples", | ||
| }, | ||
| ], | ||
| supportsAuthenticatedExtendedCard: false, | ||
| version: "0.0.2", // Incremented version | ||
| capabilities: { | ||
| streaming: true, // Agent streams artifact updates | ||
| pushNotifications: false, | ||
| stateTransitionHistory: true, | ||
| }, | ||
| securitySchemes: undefined, | ||
| security: undefined, | ||
| defaultInputModes: ["text"], | ||
| defaultOutputModes: ["text", "file"], // 'file' implies artifacts | ||
| skills: [ | ||
| { | ||
| id: "code_generation", | ||
| name: "Code Generation", | ||
| description: | ||
| "Generates code snippets or complete files based on user requests, streaming the results.", | ||
| tags: ["code", "development", "programming"], | ||
| examples: [ | ||
| "Write a python function to calculate fibonacci numbers.", | ||
| 'Create an HTML file with a basic button that alerts "Hello!" when clicked.', | ||
| ], | ||
| inputModes: ["text"], | ||
| outputModes: ["text", "file"], | ||
| }, | ||
| ], | ||
| supportsAuthenticatedExtendedCard: false, | ||
| }; | ||
|
|
||
| async function main() { | ||
| // 1. Create TaskStore | ||
| const taskStore: TaskStore = new InMemoryTaskStore(); | ||
|
|
||
| // 2. Create AgentExecutor | ||
| const agentExecutor: AgentExecutor = new CoderAgentExecutor(); | ||
|
|
||
| // 3. Create DefaultRequestHandler | ||
| const requestHandler = new DefaultRequestHandler( | ||
| coderAgentCard, | ||
| taskStore, | ||
| agentExecutor | ||
| ); | ||
|
|
||
| // 4. Create and setup A2AExpressApp | ||
| const appBuilder = new A2AExpressApp(requestHandler); | ||
| const expressApp = appBuilder.setupRoutes(express(), ''); | ||
|
|
||
| // 5. Start the server | ||
| const PORT = process.env.CODER_AGENT_PORT || 41242; // Different port for coder agent | ||
| expressApp.listen(PORT, () => { | ||
| console.log(`[CoderAgent] Server using new framework started on http://localhost:${PORT}`); | ||
| console.log(`[CoderAgent] Agent Card: http://localhost:${PORT}/.well-known/agent-card.json`); | ||
| console.log('[CoderAgent] Press Ctrl+C to stop the server'); | ||
| }); | ||
| // 1. Create TaskStore | ||
| const taskStore: TaskStore = new InMemoryTaskStore(); | ||
|
|
||
| // 2. Create AgentExecutor | ||
| const agentExecutor: AgentExecutor = new CoderAgentExecutor(); | ||
|
|
||
| // 3. Create DefaultRequestHandler | ||
| const requestHandler = new DefaultRequestHandler( | ||
| coderAgentCard, | ||
| taskStore, | ||
| agentExecutor | ||
| ); | ||
|
|
||
| // 4. Create and setup A2AExpressApp | ||
| const appBuilder = new A2AExpressApp(requestHandler); | ||
| const expressApp = appBuilder.setupRoutes(express(), ""); | ||
|
|
||
| // 5. Start the server | ||
| const PORT = process.env.CODER_AGENT_PORT || 41241; // Different port for coder agent | ||
| expressApp.listen(PORT, () => { | ||
| console.log( | ||
| `[CoderAgent] Server using new framework started on http://localhost:${PORT}` | ||
| ); | ||
| console.log( | ||
| `[CoderAgent] Agent Card: http://localhost:${PORT}/.well-known/agent-card.json` | ||
| ); | ||
| console.log("[CoderAgent] Press Ctrl+C to stop the server"); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coderAgentCard has a hardcoded url, but the server port can be configured via an environment variable. This can lead to the agent advertising an incorrect URL if a custom port is used. To resolve this, I recommend moving the coderAgentCard definition inside the main function to dynamically construct the URL with the correct port.
async function main() {
const PORT = process.env.CODER_AGENT_PORT || 41241;
const coderAgentCard: AgentCard = {
name: "Coder Agent",
description:
"An agent that generates code based on natural language instructions and streams file outputs.",
url: `http://localhost:${PORT}/`, // Use dynamic port
provider: {
organization: "A2A Samples",
url: "https://example.com/a2a-samples",
},
version: "0.0.2", // Incremented version
capabilities: {
streaming: true, // Agent streams artifact updates
pushNotifications: false,
stateTransitionHistory: true,
},
securitySchemes: undefined,
security: undefined,
defaultInputModes: ["text"],
defaultOutputModes: ["text", "file"], // 'file' implies artifacts
skills: [
{
id: "code_generation",
name: "Code Generation",
description:
"Generates code snippets or complete files based on user requests, streaming the results.",
tags: ["code", "development", "programming"],
examples: [
"Write a python function to calculate fibonacci numbers.",
'Create an HTML file with a basic button that alerts "Hello!" when clicked.',
],
inputModes: ["text"],
outputModes: ["text", "file"],
},
],
supportsAuthenticatedExtendedCard: false,
};
// 1. Create TaskStore
const taskStore: TaskStore = new InMemoryTaskStore();
// 2. Create AgentExecutor
const agentExecutor: AgentExecutor = new CoderAgentExecutor();
// 3. Create DefaultRequestHandler
const requestHandler = new DefaultRequestHandler(
coderAgentCard,
taskStore,
agentExecutor
);
// 4. Create and setup A2AExpressApp
const appBuilder = new A2AExpressApp(requestHandler);
const expressApp = appBuilder.setupRoutes(express(), "");
// 5. Start the server
expressApp.listen(PORT, () => {
console.log(
`[CoderAgent] Server using new framework started on http://localhost:${PORT}`
);
console.log(
`[CoderAgent] Agent Card: http://localhost:${PORT}/.well-known/agent-card.json`
);
console.log("[CoderAgent] Press Ctrl+C to stop the server");
});
}| generatedFiles.length > 0 | ||
| ? `Generated files: ${generatedFiles.join( | ||
| ", " | ||
| )} ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.[Fixes #<issue_number_goes_here> 🦕
](fix: samples js change port make it work & change model better results)