Access to Composio from my Python app
Hey team,
I need your help. I am able to connect to Jira through the Composio UI. I can trigger all sort of actions sucessfully. Unfortunately, I still cannot connect to composio from my Python app. I am always getting a connection error. Here is my code — could you please let me know what I might be missing? I have the same issue when I am trying to use GoogleDocs. Thanks a lot in advance!
Code:
from composio_langchain import ComposioToolSet
from llm.LLM import LLM
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain import hub
from langchain.memory import ConversationBufferMemory
from storage.System_Messages import get_system_messages
class JiraAgent:
def init(self):
prompt = hub.pull("hwchase17/openai-functions-agent") llm = LLM().get_model() composio_toolset = ComposioToolSet(api_key="...") tools = composio_toolset.get_tools(actions=['JIRA_CREATE_ISSUE', 'JIRA_GET_PROJECT']) memory = ConversationBufferMemory(memory_key="chat_history")
integration = composio_toolset.get_integration(id="...")
connection_request = composio_toolset.initiate_connection( integration_id=integration.id, connected_account_params={ "Base64_Encode"...", "your-domain": "..." }, entity_id="sam-openai", )
print(connection_request.redirectUrl) print(connection_request.connectedAccountId)
system_message = get_system_messages()["jira_agent"] agent = create_openai_functions_agent(llm, tools, prompt+system_message) self.agent = AgentExecutor(agent=agent, tools=tools, verbose=True, checkpointer=memory) def run(self, prompt): return self.agent.invoke({"input": prompt})
prompt = hub.pull("hwchase17/openai-functions-agent") llm = LLM().get_model() composio_toolset = ComposioToolSet(api_key="...") tools = composio_toolset.get_tools(actions=['JIRA_CREATE_ISSUE', 'JIRA_GET_PROJECT']) memory = ConversationBufferMemory(memory_key="chat_history")
integration = composio_toolset.get_integration(id="...")
connection_request = composio_toolset.initiate_connection( integration_id=integration.id, connected_account_params={ "Base64_Encode"...", "your-domain": "..." }, entity_id="sam-openai", )
print(connection_request.redirectUrl) print(connection_request.connectedAccountId)
system_message = get_system_messages()["jira_agent"] agent = create_openai_functions_agent(llm, tools, prompt+system_message) self.agent = AgentExecutor(agent=agent, tools=tools, verbose=True, checkpointer=memory) def run(self, prompt): return self.agent.invoke({"input": prompt})
5 Replies
genetic-orange•4w ago
hey @Valentin.g - can you share the error logs? that will give us better visibility into the issue you are facing.
correct-apricotOP•4w ago
This is the error: composio.client.exceptions.NoItemsFound: Could not find a connection with app='jira',connected_account_id=
None
and entity=default
correct-apricotOP•4w ago
This is my integration in composio
genetic-orange•4w ago
you will need to specify the entity_id when initializing the composio toolset. here's how you do it:
composio_toolset = ComposioToolSet(api_key="...", entity_id="sam-openai")
correct-apricotOP•4w ago
Thanks a lot! It works!