MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / create_tool

Method create_tool

methods/letta/client/client.py:1532–1560  ·  view source on GitHub ↗

Create a tool. This stores the source code of function on the server, so that the server can execute the function and generate an OpenAI JSON schemas for it when using with an agent. Args: func (callable): The function to create a tool for. name: (str): Name

(
        self,
        func: Callable,
        tags: Optional[List[str]] = None,
        return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
    )

Source from the content-addressed store, hash-verified

1530 return [Tool(**tool) for tool in response.json()]
1531
1532 def create_tool(
1533 self,
1534 func: Callable,
1535 tags: Optional[List[str]] = None,
1536 return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
1537 ) -> Tool:
1538 """
1539 Create a tool. This stores the source code of function on the server, so that the server can execute the function and generate an OpenAI JSON schemas for it when using with an agent.
1540
1541 Args:
1542 func (callable): The function to create a tool for.
1543 name: (str): Name of the tool (must be unique per-user.)
1544 tags (Optional[List[str]], optional): Tags for the tool. Defaults to None.
1545 return_char_limit (int): The character limit for the tool's return value. Defaults to FUNCTION_RETURN_CHAR_LIMIT.
1546
1547 Returns:
1548 tool (Tool): The created tool.
1549 """
1550 source_code = parse_source_code(func)
1551 source_type = "python"
1552
1553 # call server function
1554 request = ToolCreate(source_type=source_type, source_code=source_code, return_char_limit=return_char_limit)
1555 if tags:
1556 request.tags = tags
1557 response = requests.post(f"{self.base_url}/{self.api_prefix}/tools", json=request.model_dump(), headers=self.headers)
1558 if response.status_code != 200:
1559 raise ValueError(f"Failed to create tool: {response.text}")
1560 return Tool(**response.json())
1561
1562 def create_or_update_tool(
1563 self,

Callers 1

create_toolMethod · 0.45

Calls 6

parse_source_codeFunction · 0.90
ToolCreateClass · 0.90
ToolClass · 0.90
postMethod · 0.80
model_dumpMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected