You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to run the follow starter code from the "Execute tools" screen in Composio for Gmail action "FETCH EMAILS"
This line here: tools = composio_toolset.get_tools(actions=['GMAIL_FETCH_EMAILS']) returns the following type list
[{'type': 'function', 'function': {'name': 'GMAIL_FETCH_EMAILS', 'description': 'Action To Fetch All Emails From Gmail.', 'parameters': {'properties': {'user_id': {'default': 'me', 'description': "The user's email address or 'me' for the authenticated user. Please provide a value of type string.", 'title': 'User Id', 'type': 'string'}, 'max_results': {'default': 10, 'description': 'Maximum number of messages to return. Please provide a value of type integer.', 'maximum': 500, 'minimum': 1, 'title': 'Max Results', 'type': 'integer'}, 'page_token': {'default': '', 'description': 'Page token to retrieve a specific page of results in the list. The page token is returned in the response of this action if there are more results to be fetched. If not provided, the first page of results is returned. Please provide a value of type string.', 'title': 'Page Token', 'type': 'string'}, 'query': {'default': '', 'description': 'Only return messages matching the specified query. Please provide a value of type string.', 'title': 'Query', 'type': 'string'}, 'label_ids': {'description': "Filter messages by their label IDs. Labels identify the status or category of messages. Some of the in-built labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. The 'label_ids' for custom labels can be found in the response of the 'listLabels' action. Note: The label_ids is a list of label IDs to filter the messages by.", 'items': {'type': 'string'}, 'title': 'Label Ids', 'type': 'array'}, 'include_spam_trash': {'default': False, 'description': 'Include messages from SPAM and TRASH in the results. Please provide a value of type boolean.', 'title': 'Include Spam Trash', 'type': 'boolean'}}, 'title': 'FetchEmailsRequest', 'type': 'object'}}}]
This is the tool that is to be passed into the OpenAI client to create the agent. However, I seem to be getting an error with the format of the output:
Traceback (most recent call last): File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/composio_gmail.py", line 24, in <module> agent = create_openai_functions_agent(llm, tools, prompt) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain/agents/openai_functions_agent/base.py", line 360, in create_openai_functions_agent llm_with_tools = llm.bind(functions=[convert_to_openai_function(t) for t in tools]) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain/agents/openai_functions_agent/base.py", line 360, in <listcomp> llm_with_tools = llm.bind(functions=[convert_to_openai_function(t) for t in tools]) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain_core/utils/function_calling.py", line 434, in convert_to_openai_function raise ValueError(msg) ValueError: Unsupported function
I have tried reformatting the tool in several ways, though it should be taken care of by the convert_to_openai_function. I was able to reformat it by manually constructing the tool and have it accepted but now receiving this error when trying to run the agent_executor:
Traceback (most recent call last): File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/composio_gmail.py", line 70, in <module> agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain_core/load/serializable.py", line 125, in __init__ super().__init__(*args, **kwargs) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/pydantic/main.py", line 214, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/pydantic/_internal/_validators.py", line 45, in sequence_validator v_list = validator(input_value) TypeError: Can't instantiate abstract class BaseTool with abstract method _run
Any thoughts here what I could be missing?
The text was updated successfully, but these errors were encountered:
Hey, sorry about this. If possible could you share the code that you using to execute the above? Will help us debug your issue further. Here is an example of a working snippet of code!
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain import hub
from langchain_openai import ChatOpenAI
from composio_langchain import ComposioToolSet
llm = ChatOpenAI()
prompt = hub.pull("hwchase17/openai-functions-agent")
composio_toolset = ComposioToolSet(api_key="<your api key>")
tools = composio_toolset.get_tools(actions=['GMAIL_FETCH_EMAILS'])
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
task = "Get the latest email from the inbox"
result = agent_executor.invoke({"input": task})
print(result)
Trying to run the follow starter code from the "Execute tools" screen in Composio for Gmail action "FETCH EMAILS"
This line here:
tools = composio_toolset.get_tools(actions=['GMAIL_FETCH_EMAILS'])
returns the following typelist
[{'type': 'function', 'function': {'name': 'GMAIL_FETCH_EMAILS', 'description': 'Action To Fetch All Emails From Gmail.', 'parameters': {'properties': {'user_id': {'default': 'me', 'description': "The user's email address or 'me' for the authenticated user. Please provide a value of type string.", 'title': 'User Id', 'type': 'string'}, 'max_results': {'default': 10, 'description': 'Maximum number of messages to return. Please provide a value of type integer.', 'maximum': 500, 'minimum': 1, 'title': 'Max Results', 'type': 'integer'}, 'page_token': {'default': '', 'description': 'Page token to retrieve a specific page of results in the list. The page token is returned in the response of this action if there are more results to be fetched. If not provided, the first page of results is returned. Please provide a value of type string.', 'title': 'Page Token', 'type': 'string'}, 'query': {'default': '', 'description': 'Only return messages matching the specified query. Please provide a value of type string.', 'title': 'Query', 'type': 'string'}, 'label_ids': {'description': "Filter messages by their label IDs. Labels identify the status or category of messages. Some of the in-built labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. The 'label_ids' for custom labels can be found in the response of the 'listLabels' action. Note: The label_ids is a list of label IDs to filter the messages by.", 'items': {'type': 'string'}, 'title': 'Label Ids', 'type': 'array'}, 'include_spam_trash': {'default': False, 'description': 'Include messages from SPAM and TRASH in the results. Please provide a value of type boolean.', 'title': 'Include Spam Trash', 'type': 'boolean'}}, 'title': 'FetchEmailsRequest', 'type': 'object'}}}]
This is the tool that is to be passed into the OpenAI client to create the agent. However, I seem to be getting an error with the format of the output:
Traceback (most recent call last): File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/composio_gmail.py", line 24, in <module> agent = create_openai_functions_agent(llm, tools, prompt) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain/agents/openai_functions_agent/base.py", line 360, in create_openai_functions_agent llm_with_tools = llm.bind(functions=[convert_to_openai_function(t) for t in tools]) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain/agents/openai_functions_agent/base.py", line 360, in <listcomp> llm_with_tools = llm.bind(functions=[convert_to_openai_function(t) for t in tools]) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain_core/utils/function_calling.py", line 434, in convert_to_openai_function raise ValueError(msg) ValueError: Unsupported function
I have tried reformatting the tool in several ways, though it should be taken care of by the
convert_to_openai_function
. I was able to reformat it by manually constructing the tool and have it accepted but now receiving this error when trying to run the agent_executor:Traceback (most recent call last): File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/composio_gmail.py", line 70, in <module> agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/langchain_core/load/serializable.py", line 125, in __init__ super().__init__(*args, **kwargs) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/pydantic/main.py", line 214, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) File "/Users/melissa.herrera/Documents/VSCode/composio_integrations/.venv/lib/python3.9/site-packages/pydantic/_internal/_validators.py", line 45, in sequence_validator v_list = validator(input_value) TypeError: Can't instantiate abstract class BaseTool with abstract method _run
Any thoughts here what I could be missing?
The text was updated successfully, but these errors were encountered: