Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add (dummy) create tool route (#1139)
Charles Packer3f998148ceb8
diff --git a/memgpt/server/rest_api/tools/index.py b/memgpt/server/rest_api/tools/index.pyindex 8d08e6a31..a45781efa 100644--- a/memgpt/server/rest_api/tools/index.py+++ b/memgpt/server/rest_api/tools/index.py@@ -1,6 +1,6 @@import uuidfrom functools import partial-from typing import List+from typing import List, Optional, Literalfrom fastapi import APIRouter, Depends, Bodyfrom pydantic import BaseModel, Field@@ -17,6 +17,17 @@ class ListToolsResponse(BaseModel):tools: List[ToolModel] = Field(..., description="List of tools (functions).")+class CreateToolRequest(BaseModel):+ name: str = Field(..., description="The name of the function.")+ source_code: str = Field(..., description="The source code of the function.")+ source_type: Optional[Literal["python"]] = Field(None, description="The type of the source code.")+ tags: Optional[List[str]] = Field(None, description="Metadata tags.")+++class CreateToolResponse(BaseModel):+ tool: ToolModel = Field(..., description="Information about the newly created tool.")++def setup_tools_index_router(server: SyncServer, interface: QueuingInterface, password: str):get_current_user_with_server = partial(partial(get_current_user, server), password)@@ -32,4 +43,18 @@ def setup_tools_index_router(server: SyncServer, interface: QueuingInterface, patools = server.ms.list_tools(user_id=user_id)return ListToolsResponse(tools=tools)+ @router.post("/tools", tags=["tools"], response_model=ListToolsResponse)+ async def create_tool(+ request: CreateToolRequest = Body(...),+ user_id: uuid.UUID = Depends(get_current_user_with_server),+ ):+ """+ Create a new tool (dummy route)+ """+ return ToolModel(+ name="dummy_tool",+ json_schema={},+ tags=[],+ )+return router