Using Composio With Groq

Composio enables your Groq based assistants to connect with many tools!

Goal: Star a repository on GitHub with natural language & Groq

Install Packages & Connect a Tool

These commands prepare your environment for seamless interaction between Groq and GitHub.

$pip install composio-langchain
>pip install langchain-groq
>
>#Connect your GitHub so agents can use it
>composio add github
>
>#Check all different apps which you can connect with
>composio apps
1

Import Base Packages

1# Initialise imports
2from langchain.agents import AgentExecutor
3from langchain import hub
4from langchain_groq import ChatGroq
5from langgraph.prebuilt import create_react_agent
6
7llm = ChatGroq(model="mixtral-8x7b-32768", temperature=0)
8
9prompt = hub.pull("hwchase17/react")
2

Fetch all GitHub Langchain Tools via Composio

1# Import from composio_langchain
2from composio_langchain import ComposioToolSet, Action, App
3
4# Get All the tools
5
6composio_toolset = ComposioToolSet()
7tools = composio_toolset.get_tools(apps=[App.GITHUB])
3

Execute the Agent

Create an agent, set up an executor, and invoke tasks to perform GitHub API calls using Composio.

1task = "Star a repo composiohq/composio on GitHub"
2
3agent = create_react_agent(llm, tools)
4agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
5
6# Execute using agent_executor
7inputs = {"messages": [("user", task)]}
8agent_executor.invoke(input=inputs)
4

Check Response

Executing Agents
$> Entering new AgentExecutor chain...
>
>Invoking: `github_star_repo` with `{'owner': 'composiohq', 'repo': 'docs'}`
>
>{'connectedAccountId': 'ade8c167-836b-404b-bb47-fb8550203417', 'input': {'owner': 'composiohq', 'repo': 'docs'}}
>{'execution_details': {'executed': True}, 'response_data': ''}I have successfully starred the repository composiohq/composio on GitHub.

Use Specific Actions

Filter Specific Action
$# To restrict agents from using all the actions, filter specific actions
>tools = composio_toolset.get_tools(apps=[App.GITHUB])

Use Specific Apps

Filter Specific App
$# To restrict agents from using all tools, filter specific tools
>tools = composio_toolset.get_tools(actions=[Action.GITHUB_CREATE_ISSUE])
Built with