mirror of
				https://github.com/microsoft/autogen.git
				synced 2025-10-31 17:59:50 +00:00 
			
		
		
		
	 fe96f7de24
			
		
	
	
		fe96f7de24
		
			
		
	
	
	
	
		
			
			* fix import issue related to agentchat update #4245 * update uv lock file * fix db auto_upgrade logic issue. * im prove msg rendering issue * Support termination condition combination. Closes #4325 * fix db instantiation bug * update yarn.lock, closes #4260 #4262 * remove deps for now with vulnerabilities found by dependabot #4262 * update db tests * add ability to load sessions from db .. * format updates, add format checks to ags * format check fixes * linting and ruff check fixes * make tests for ags non-parrallel to avoid db race conditions. * format updates * fix concurrency issue * minor ui tweaks, move run start to websocket * lint fixes * update uv.lock * Update python/packages/autogen-studio/autogenstudio/datamodel/types.py Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> * Update python/packages/autogen-studio/autogenstudio/teammanager.py Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> * reuse user proxy from agentchat * ui tweaks --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> Co-authored-by: Hussein Mozannar <hmozannar@microsoft.com>
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # api/routes/tools.py
 | |
| from typing import Dict
 | |
| 
 | |
| from fastapi import APIRouter, Depends, HTTPException
 | |
| 
 | |
| from ...datamodel import Tool
 | |
| from ..deps import get_db
 | |
| 
 | |
| router = APIRouter()
 | |
| 
 | |
| 
 | |
| @router.get("/")
 | |
| async def list_tools(user_id: str, db=Depends(get_db)) -> Dict:
 | |
|     """List all tools for a user"""
 | |
|     response = db.get(Tool, filters={"user_id": user_id})
 | |
|     return {"status": True, "data": response.data}
 | |
| 
 | |
| 
 | |
| @router.get("/{tool_id}")
 | |
| async def get_tool(tool_id: int, user_id: str, db=Depends(get_db)) -> Dict:
 | |
|     """Get a specific tool"""
 | |
|     response = db.get(Tool, filters={"id": tool_id, "user_id": user_id})
 | |
|     if not response.status or not response.data:
 | |
|         raise HTTPException(status_code=404, detail="Tool not found")
 | |
|     return {"status": True, "data": response.data[0]}
 | |
| 
 | |
| 
 | |
| @router.post("/")
 | |
| async def create_tool(tool: Tool, db=Depends(get_db)) -> Dict:
 | |
|     """Create a new tool"""
 | |
|     response = db.upsert(tool)
 | |
|     if not response.status:
 | |
|         raise HTTPException(status_code=400, detail=response.message)
 | |
|     return {"status": True, "data": response.data}
 | |
| 
 | |
| 
 | |
| @router.delete("/{tool_id}")
 | |
| async def delete_tool(tool_id: int, user_id: str, db=Depends(get_db)) -> Dict:
 | |
|     """Delete a tool"""
 | |
|     db.delete(filters={"id": tool_id, "user_id": user_id}, model_class=Tool)
 | |
|     return {"status": True, "message": "Tool deleted successfully"}
 |