Skip to content

Commit

Permalink
fix: modify composio example (#1885)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Zhou <[email protected]>
  • Loading branch information
mattzh72 and Matt Zhou authored Oct 15, 2024
1 parent 1b4773a commit 1e501cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/composio_tool_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import uuid

from letta import create_client
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import ChatMemory
from letta.schemas.tool import Tool

Expand All @@ -10,6 +12,8 @@
"""
# Create a `LocalClient` (you can also use a `RESTClient`, see the letta_rest_client.py example)
client = create_client()
client.set_default_llm_config(LLMConfig.default_config("gpt-4o-mini"))
client.set_default_embedding_config(EmbeddingConfig.default_config(provider="openai"))

# Generate uuid for agent name for this example
namespace = uuid.NAMESPACE_DNS
Expand Down Expand Up @@ -59,18 +63,18 @@ def main():
"""

# Create an agent
agent_state = client.create_agent(name=agent_uuid, memory=ChatMemory(human="My name is Matt.", persona=persona), tools=[tool.name])
print(f"Created agent: {agent_state.name} with ID {str(agent_state.id)}")
agent = client.create_agent(name=agent_uuid, memory=ChatMemory(human="My name is Matt.", persona=persona), tools=[tool.name])
print(f"Created agent: {agent.name} with ID {str(agent.id)}")

# Send a message to the agent
send_message_response = client.user_message(agent_id=agent_state.id, message="Star a repo composio with owner composiohq on GitHub")
send_message_response = client.user_message(agent_id=agent.id, message="Star a repo composio with owner composiohq on GitHub")
for message in send_message_response.messages:
response_json = json.dumps(message.model_dump(), indent=4)
print(f"{response_json}\n")

# Delete agent
client.delete_agent(agent_id=agent_state.id)
print(f"Deleted agent: {agent_state.name} with ID {str(agent_state.id)}")
client.delete_agent(agent_id=agent.id)
print(f"Deleted agent: {agent.name} with ID {str(agent.id)}")


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions letta/schemas/llm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class LLMConfig(BaseModel):
"koboldcpp",
"vllm",
"hugging-face",
"mistral",
] = Field(..., description="The endpoint type for the model.")
model_endpoint: Optional[str] = Field(None, description="The endpoint for the model.")
model_wrapper: Optional[str] = Field(None, description="The wrapper for the model.")
Expand Down

0 comments on commit 1e501cb

Please sign in to comment.