Update a tool with provided parameters (name, func, tags) Args: id (str): ID of the tool name (str): Name of the tool func (callable): Function to wrap in a tool tags (List[str]): Tags for the tool return_char_limit (int):
(
self,
id: str,
description: Optional[str] = None,
func: Optional[Callable] = None,
tags: Optional[List[str]] = None,
return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
)
| 1590 | return Tool(**response.json()) |
| 1591 | |
| 1592 | def update_tool( |
| 1593 | self, |
| 1594 | id: str, |
| 1595 | description: Optional[str] = None, |
| 1596 | func: Optional[Callable] = None, |
| 1597 | tags: Optional[List[str]] = None, |
| 1598 | return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT, |
| 1599 | ) -> Tool: |
| 1600 | """ |
| 1601 | Update a tool with provided parameters (name, func, tags) |
| 1602 | |
| 1603 | Args: |
| 1604 | id (str): ID of the tool |
| 1605 | name (str): Name of the tool |
| 1606 | func (callable): Function to wrap in a tool |
| 1607 | tags (List[str]): Tags for the tool |
| 1608 | return_char_limit (int): The character limit for the tool's return value. Defaults to FUNCTION_RETURN_CHAR_LIMIT. |
| 1609 | |
| 1610 | Returns: |
| 1611 | tool (Tool): Updated tool |
| 1612 | """ |
| 1613 | if func: |
| 1614 | source_code = parse_source_code(func) |
| 1615 | else: |
| 1616 | source_code = None |
| 1617 | |
| 1618 | source_type = "python" |
| 1619 | |
| 1620 | request = ToolUpdate( |
| 1621 | description=description, |
| 1622 | source_type=source_type, |
| 1623 | source_code=source_code, |
| 1624 | tags=tags, |
| 1625 | return_char_limit=return_char_limit, |
| 1626 | ) |
| 1627 | response = requests.patch(f"{self.base_url}/{self.api_prefix}/tools/{id}", json=request.model_dump(), headers=self.headers) |
| 1628 | if response.status_code != 200: |
| 1629 | raise ValueError(f"Failed to update tool: {response.text}") |
| 1630 | return Tool(**response.json()) |
| 1631 | |
| 1632 | def list_tools(self, after: Optional[str] = None, limit: Optional[int] = 50) -> List[Tool]: |
| 1633 | """ |
nothing calls this directly
no test coverage detected