-
Notifications
You must be signed in to change notification settings - Fork 296
Dev/add playground #226
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?
Dev/add playground #226
Conversation
XinyueDu
commented
Oct 31, 2025
Summary of ChangesHello @XinyueDu, 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 introduces a new 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
|
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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 introduces a new playground application, which serves as an excellent interactive demo for the MCP server's chart generation capabilities. The implementation using React, Vite, and Ant Design is solid. My review includes suggestions to fix an incorrect command in the documentation, improve the robustness of unique ID generation in both the React components and the MCP client, enhance type safety, and ensure documentation consistency.
| const userMessage: Message = { | ||
| id: Date.now().toString(), | ||
| role: 'user', | ||
| content: text, | ||
| status: 'success', | ||
| }; | ||
|
|
||
| // 添加用户消息和加载中的助手消息 | ||
| const loadingMessageId = (Date.now() + 1).toString(); |
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.
Using Date.now() to generate ids for messages is not robust. If handleSend is called multiple times within the same millisecond, it could result in duplicate keys for React components, leading to unpredictable UI behavior and potential bugs. It's better to use a more reliable method for generating unique IDs, such as crypto.randomUUID().
| const userMessage: Message = { | |
| id: Date.now().toString(), | |
| role: 'user', | |
| content: text, | |
| status: 'success', | |
| }; | |
| // 添加用户消息和加载中的助手消息 | |
| const loadingMessageId = (Date.now() + 1).toString(); | |
| const userMessage: Message = { | |
| id: crypto.randomUUID(), | |
| role: 'user', | |
| content: text, | |
| status: 'success', | |
| }; | |
| // 添加用户消息和加载中的助手消息 | |
| const loadingMessageId = crypto.randomUUID(); |
| await this.connect(); | ||
| } | ||
|
|
||
| const requestId = Date.now(); |
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.
Using Date.now() for requestId is not guaranteed to be unique. If callTool or listTools are called in rapid succession within the same millisecond, it could lead to request ID collisions. This would cause responses to be routed to the wrong caller, leading to incorrect behavior. A simple incrementing counter would be a more robust solution for generating unique request IDs within the client's session.
You should add a private requestIdCounter = 0; field to the MCPClient class and then use it here. The same applies to the listTools method.
| const requestId = Date.now(); | |
| const requestId = this.requestIdCounter++; |
| await this.connect(); | ||
| } | ||
|
|
||
| const requestId = Date.now(); |
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.
playground/README.md
Outdated
| ### 1. Install Dependencies | ||
|
|
||
| ```bash | ||
| cd demo |
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.
playground/src/llmService.ts
Outdated
| export class LLMService { | ||
| private client: OpenAI; | ||
| private mcpClient: MCPClient; | ||
| private conversationHistory: Array<{ role: string; content: string }> = []; |
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 type for conversationHistory is Array<{ role: string; content: string }>, which is too generic. The role property has a specific set of allowed values (e.g., 'system', 'user', 'assistant'). Using a more specific type would improve type safety and code clarity, aligning it with the OpenAI API's expectations.
| private conversationHistory: Array<{ role: string; content: string }> = []; | |
| private conversationHistory: Array<{ role: 'system' | 'user' | 'assistant'; content: string }> = []; |