Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: Fix composio bugs (#884)
Matthew Zhou85dee1785b12
diff --git a/letta/local_llm/utils.py b/letta/local_llm/utils.pyindex f5d541740..21be45c5c 100644--- a/letta/local_llm/utils.py+++ b/letta/local_llm/utils.py@@ -11,8 +11,11 @@ import letta.local_llm.llm_chat_completion_wrappers.configurable_wrapper as confimport letta.local_llm.llm_chat_completion_wrappers.dolphin as dolphinimport letta.local_llm.llm_chat_completion_wrappers.llama3 as llama3import letta.local_llm.llm_chat_completion_wrappers.zephyr as zephyr+from letta.log import get_loggerfrom letta.schemas.openai.chat_completion_request import Tool, ToolCall+logger = get_logger(__name__)+def post_json_auth_request(uri, json_payload, auth_type, auth_key):"""Send a POST request with a JSON payload and optional authentication"""@@ -126,8 +129,11 @@ def num_tokens_from_functions(functions: List[dict], model: str = "gpt-4"):function_tokens += 2if isinstance(v["items"], dict) and "type" in v["items"]:function_tokens += len(encoding.encode(v["items"]["type"]))+ elif field == "default":+ function_tokens += 2+ function_tokens += len(encoding.encode(str(v["default"])))else:- warnings.warn(f"num_tokens_from_functions: Unsupported field {field} in function {function}")+ logger.warning(f"num_tokens_from_functions: Unsupported field {field} in function {function}")function_tokens += 11num_tokens += function_tokensdiff --git a/letta/services/tool_manager.py b/letta/services/tool_manager.pyindex 27188f932..211b3e33f 100644--- a/letta/services/tool_manager.py+++ b/letta/services/tool_manager.py@@ -58,11 +58,15 @@ class ToolManager:@enforce_typesdef create_or_update_composio_tool(self, tool_create: ToolCreate, actor: PydanticUser) -> PydanticTool:- return self.create_or_update_tool(PydanticTool(tool_type=ToolType.EXTERNAL_COMPOSIO, **tool_create.model_dump()), actor)+ return self.create_or_update_tool(+ PydanticTool(tool_type=ToolType.EXTERNAL_COMPOSIO, name=tool_create.json_schema["name"], **tool_create.model_dump()), actor+ )@enforce_typesdef create_or_update_langchain_tool(self, tool_create: ToolCreate, actor: PydanticUser) -> PydanticTool:- return self.create_or_update_tool(PydanticTool(tool_type=ToolType.EXTERNAL_LANGCHAIN, **tool_create.model_dump()), actor)+ return self.create_or_update_tool(+ PydanticTool(tool_type=ToolType.EXTERNAL_LANGCHAIN, name=tool_create.json_schema["name"], **tool_create.model_dump()), actor+ )@enforce_typesdef create_tool(self, pydantic_tool: PydanticTool, actor: PydanticUser) -> PydanticTool: