-
Notifications
You must be signed in to change notification settings - Fork 0
Rest api #21
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
Conversation
Modifies the agent to track which tools are used during a query. The used tools are returned as part of the API response and displayed in the chat UI. This allows users to see which tools the agent utilized to formulate its response.
Removes the text-transform style that forced tool tags to be capitalized. This allows tool tags to be displayed as they are defined, improving consistency.
Implements API endpoints for listing and toggling tools, allowing users to enable or disable tools dynamically. Introduces the ability to enable or disable individual tools within the agent's chat functionality. This allows for greater control over the agent's capabilities and resources.
Enhances the agent's tool management by adding try-except blocks to the enable_tool and disable_tool methods, preventing exceptions from halting execution. Refactors the API to correctly iterate through tool information. Modifies the chat logic to properly define tools when sending them to the language model and ensures unique tool entries. Enhances the UI by adding a tools section with toggle functionality, allowing users to enable or disable tools.
Improves the clarity and detail of tool descriptions for better user understanding. Refactors the UI to include a toggle all tools feature and displays tool configuration as active/total. Adds a new test suite to validate UI tools configuration functionality.
Improves the descriptions of the google_search, list_files, read_file, and write_file tools to provide more context and detail about their functionality, security measures, and usage. This enhances understanding and usability. Updates base_dir and relative paths descriptions in file tools.
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.
Pull Request Overview
This PR enhances tool lifecycle management, extends API routes for tool operations, refines tool metadata, and integrates tool toggling in the UI.
- Introduces
enable_tool,disable_tool, andget_toolsinAgent/Chat - Adds
/toolsand/tools/toggleendpoints with corresponding Pydantic models - Updates UI (
chat.ts,index.html,styles.css) to display, toggle, and style tools - Expands tool descriptions and parameter schemas for
write_file,read_file,list_files,google_search, andgithub_search
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/llm/chat.py | Tool state methods, filtering disabled tools, debug prints |
| src/api/routes.py & models.py | New list/toggle tool endpoints and models |
| src/ui/chat.ts, index.html, styles.css | UI elements and styling for tools panel |
| src/tools/*.py | Detailed tool descriptions and parameter updates |
| src/agent.py | Agent wrappers for tool operations |
| tests/ | Updated tests for tool metadata and QueryResponse.used_tools |
Comments suppressed due to low confidence (1)
src/api/routes.py:24
- No tests currently cover the new
/toolsand/tools/toggleendpoints. Please add pytest AsyncClient tests to verify the listing and toggling behavior, including error cases.
@router.get("/tools", response_model=ToolsListResponse)
| // Update the tools configuration text to show active/total format | ||
| const toolsLabelSpan = this.toolsHeader.querySelector('.tools-label span'); | ||
| if (toolsLabelSpan) { | ||
| toolsLabelSpan.textContent = `Tools Configuration [${enabledCount}/${totalCount}]`; |
Copilot
AI
Jun 23, 2025
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 UI uses square brackets around the tools count ([x/y]) while tests and other displays use angle brackets (<x/y>). To maintain consistency, consider switching to angle brackets or updating tests to match this format.
| toolsLabelSpan.textContent = `Tools Configuration [${enabledCount}/${totalCount}]`; | |
| toolsLabelSpan.textContent = `Tools Configuration <${enabledCount}/${totalCount}>`; |
|
|
||
| def _set_tool_state(self, tool_name: str, active = True) -> None: | ||
| for tool in self.tools: | ||
| print(f"Checking tool: {tool.name} against {tool_name} ") |
Copilot
AI
Jun 23, 2025
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.
[nitpick] This debug print may clutter logs in production. Consider removing it or gating it behind a verbose/debug flag.
| print(f"Checking tool: {tool.name} against {tool_name} ") | |
| if is_debug(): | |
| print(f"Checking tool: {tool.name} against {tool_name} ") |
|
|
||
| const data = await response.json(); | ||
| return data.response || 'Sorry, I couldn\'t process your request.'; | ||
| console.log('API Response Data:', data); // Debug log |
Copilot
AI
Jun 23, 2025
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.
[nitpick] Remove or disable this debug console.log in production builds to avoid leaking potentially sensitive response payloads.
| console.log('API Response Data:', data); // Debug log | |
| if (process.env.NODE_ENV !== 'production') { | |
| console.log('API Response Data:', data); // Debug log | |
| } |
| tool.disable() | ||
| if active: | ||
| tool.enable() |
Copilot
AI
Jun 23, 2025
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 disable-then-enable pattern is redundant when activating a tool. Consider simplifying to if active: tool.enable() else: tool.disable() for clarity.
| tool.disable() | |
| if active: | |
| tool.enable() | |
| if active: | |
| tool.enable() | |
| else: | |
| tool.disable() |
| def enable_tool(self, tool_name: str) -> None: | ||
| try: | ||
| self.chat.enable_tool(tool_name) | ||
| except Exception as e: | ||
| return False | ||
| return True | ||
|
|
||
| def disable_tool(self, tool_name: str) -> None: |
Copilot
AI
Jun 23, 2025
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 return type should be annotated as -> bool to reflect that this method returns True/False, improving type clarity.
| def enable_tool(self, tool_name: str) -> None: | |
| try: | |
| self.chat.enable_tool(tool_name) | |
| except Exception as e: | |
| return False | |
| return True | |
| def disable_tool(self, tool_name: str) -> None: | |
| def enable_tool(self, tool_name: str) -> bool: | |
| try: | |
| self.chat.enable_tool(tool_name) | |
| except Exception as e: | |
| return False | |
| return True | |
| def disable_tool(self, tool_name: str) -> bool: |
This pull request introduces significant enhancements to tool management and API functionality, along with updates to tool descriptions and UI integration. The changes improve the modularity and usability of tools, refine API responses, and enhance the user interface to display tool information effectively.
Tool Management Enhancements:
enable_tool,disable_tool, andget_toolsto theAgentclass for managing tool states and retrieving tool information.Chatclass to ensure tools are unique, track their enabled state, and dynamically filter enabled tools during query processing. [1] [2]enableanddisablemethods in theToolclass to manage tool activation state.Query Processing Improvements:
process_querymethod inAgentto return a list of tools used during query execution. [1] [2]process_tool_callsmethod inChatto track and return the names of tools used during tool calls. [1] [2]API Updates:
/tools) and toggling tool states (/tools/toggle) inapi/routes.py. [1] [2]R1)ToolInfo,ToolsListResponse,ToolToggleRequest,ToolToggleResponse) to support tool-related API responses.Tool Description and Parameter Updates:
github_search,google_search,list_files,read_file, andwrite_fileto provide more detailed and user-friendly information. [1] [2] [3] [4] [5]UI Changes:
usedToolsproperty to theMessageinterface and integrated tool-related UI elements (toolsHeader,toolsList) into theChatAppclass inchat.ts. [1] [2]