feat: Add orm for Tools and clean up Tool logic (#1935)
This commit is contained in:
@@ -5,7 +5,6 @@ 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
|
||||
|
||||
"""
|
||||
Setup here.
|
||||
@@ -49,10 +48,7 @@ def main():
|
||||
from composio_langchain import Action
|
||||
|
||||
# Add the composio tool
|
||||
tool = Tool.get_composio_tool(action=Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER)
|
||||
|
||||
# create tool
|
||||
client.add_tool(tool)
|
||||
tool = client.load_composio_tool(action=Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER)
|
||||
|
||||
persona = f"""
|
||||
My name is Letta.
|
||||
|
||||
@@ -2,8 +2,9 @@ import json
|
||||
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
|
||||
|
||||
"""
|
||||
This example show how you can add CrewAI tools .
|
||||
@@ -21,14 +22,14 @@ def main():
|
||||
|
||||
crewai_tool = ScrapeWebsiteTool(website_url="https://www.example.com")
|
||||
|
||||
example_website_scrape_tool = Tool.from_crewai(crewai_tool)
|
||||
tool_name = example_website_scrape_tool.name
|
||||
|
||||
# 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"))
|
||||
|
||||
# create tool
|
||||
client.add_tool(example_website_scrape_tool)
|
||||
example_website_scrape_tool = client.load_crewai_tool(crewai_tool)
|
||||
tool_name = example_website_scrape_tool.name
|
||||
|
||||
# Confirm that the tool is in
|
||||
tools = client.list_tools()
|
||||
|
||||
@@ -5,7 +5,6 @@ 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
|
||||
|
||||
"""
|
||||
This example show how you can add LangChain tools .
|
||||
@@ -26,25 +25,22 @@ def main():
|
||||
api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=500)
|
||||
langchain_tool = WikipediaQueryRun(api_wrapper=api_wrapper)
|
||||
|
||||
# Translate to memGPT Tool
|
||||
# Note the additional_imports_module_attr_map
|
||||
# We need to pass in a map of all the additional imports necessary to run this tool
|
||||
# Because an object of type WikipediaAPIWrapper is passed into WikipediaQueryRun to initialize langchain_tool,
|
||||
# We need to also import WikipediaAPIWrapper
|
||||
# The map is a mapping of the module name to the attribute name
|
||||
# langchain_community.utilities.WikipediaAPIWrapper
|
||||
wikipedia_query_tool = Tool.from_langchain(
|
||||
langchain_tool, additional_imports_module_attr_map={"langchain_community.utilities": "WikipediaAPIWrapper"}
|
||||
)
|
||||
tool_name = wikipedia_query_tool.name
|
||||
|
||||
# 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"))
|
||||
|
||||
# create tool
|
||||
client.add_tool(wikipedia_query_tool)
|
||||
# Note the additional_imports_module_attr_map
|
||||
# We need to pass in a map of all the additional imports necessary to run this tool
|
||||
# Because an object of type WikipediaAPIWrapper is passed into WikipediaQueryRun to initialize langchain_tool,
|
||||
# We need to also import WikipediaAPIWrapper
|
||||
# The map is a mapping of the module name to the attribute name
|
||||
# langchain_community.utilities.WikipediaAPIWrapper
|
||||
wikipedia_query_tool = client.load_langchain_tool(
|
||||
langchain_tool, additional_imports_module_attr_map={"langchain_community.utilities": "WikipediaAPIWrapper"}
|
||||
)
|
||||
tool_name = wikipedia_query_tool.name
|
||||
|
||||
# Confirm that the tool is in
|
||||
tools = client.list_tools()
|
||||
|
||||
Reference in New Issue
Block a user