Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | """ |
| 2 | Langchain demo. |
| 3 | """ |
| 4 | |
| 5 | from composio_langchain import LangchainProvider |
| 6 | from langchain.agents import create_agent |
| 7 | from langchain_openai import ChatOpenAI |
| 8 | |
| 9 | from composio import Composio |
| 10 | |
| 11 | openai_client = ChatOpenAI(model="gpt-5") |
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | composio = Composio(provider=LangchainProvider()) |
| 16 | |
| 17 | # Get All the tools |
| 18 | tools = composio.tools.get(user_id="default", toolkits=["GITHUB"]) |
| 19 | |
| 20 | # Define task |
| 21 | task = "Star a repo composiohq/composio on GitHub" |
| 22 | |
| 23 | # Define agent |
| 24 | agent = create_agent( |
| 25 | model=openai_client, tools=tools, system_prompt="intelligent composio agent" |
| 26 | ) |
| 27 | |
| 28 | # Execute task |
| 29 | result = agent.invoke({"messages": [{"role": "user", "content": task}]}) |
| 30 | |
| 31 | print(result) |
| 32 | |
| 33 | |
| 34 | if __name__ == "__main__": |
| 35 | main() |