@devries-cameron20 / composio Mirror · read-only / commits / 27ffc703c
Fork 0

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 22, 09:30 UTC

docs: Update LangChain provider page with create_agent pattern

Use create_agent/createAgent + invoke() pattern. Standardize to Steps pattern, persistent language tabs, API key callout, and consistent email task. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmithamallesh committed Feb 17, 2026 at 15:20 UTC 27ffc703c733853fe1ba26ff5f29a84908d85992
1 file changed +44 -50
docs/content/docs/providers/langchain.mdx
+44 -50
@@ -1,14 +1,16 @@
1 ---
2 title: LangChain
3 description: Build an agent with LangChain and enable it to use 800+ tools with Composio.
4 -keywords: [langgraph]
4 +keywords: [langchain]
5 ---
6
7 -The LangChain Provider transforms Composio tools into a format compatible with LangChain's function calling capabilities.
7 +The LangChain provider transforms Composio tools into LangChain's [StructuredTool](https://python.langchain.com/docs/how_to/custom_tools/) format with built-in execution.
8
9 -## Setup
9 +<Steps>
10 +<Step>
11 +**Install**
12
11 -<Tabs items={["Python", "TypeScript"]}>
13 +<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
14 <Tab value="Python">
15 ```bash
16 pip install composio composio_langchain langchain langchain_openai
@@ -16,43 +18,54 @@ pip install composio composio_langchain langchain langchain_openai
18 </Tab>
19 <Tab value="TypeScript">
20 ```bash
19 -npm install @composio/core @composio/langchain @langchain/openai @langchain/langgraph @langchain/core
21 +npm install @composio/core @composio/langchain langchain @langchain/openai
22 ```
23 </Tab>
24 </Tabs>
25 +</Step>
26
24 -## Usage
27 +<Step>
28 +**Configure API Keys**
29
26 -<Tabs items={["Python", "TypeScript"]}>
30 +<Callout type="info">
31 +Set `COMPOSIO_API_KEY` with your API key from [Settings](https://platform.composio.dev/?next_page=/settings) and `OPENAI_API_KEY` with your [OpenAI API key](https://platform.openai.com/api-keys).
32 +</Callout>
33 +
34 +```txt title=".env"
35 +COMPOSIO_API_KEY=xxxxxxxxx
36 +OPENAI_API_KEY=xxxxxxxxx
37 +```
38 +</Step>
39 +
40 +<Step>
41 +**Create session and run**
42 +
43 +<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
44 <Tab value="Python">
45 ```python
46 from composio import Composio
47 from composio_langchain import LangchainProvider
31 -from langchain import hub # type: ignore
32 -from langchain.agents import AgentExecutor, create_openai_functions_agent
48 +from langchain.agents import create_agent
49 from langchain_openai import ChatOpenAI
50
35 -prompt = hub.pull("hwchase17/openai-functions-agent")
36 -openai_client = ChatOpenAI(model="gpt-5")
37 -
51 composio = Composio(provider=LangchainProvider())
52 +llm = ChatOpenAI(model="gpt-5.2")
53
54 # Create a session for your user
55 session = composio.create(user_id="user_123")
56 tools = session.tools()
57
44 -agent = create_openai_functions_agent(openai_client, tools, prompt)
45 -agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
58 +agent = create_agent(tools=tools, model=llm)
59 +result = agent.invoke({"messages": [("user", "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'")]})
60
47 -agent_executor.invoke({"input": "Star the composiohq/composio repository on GitHub"})
61 +print(result["messages"][-1].content)
62 ```
63 </Tab>
64 <Tab value="TypeScript">
65 ```typescript
66 +// @noErrors
67 import { ChatOpenAI } from '@langchain/openai';
53 -import { HumanMessage, AIMessage } from '@langchain/core/messages';
54 -import { ToolNode } from '@langchain/langgraph/prebuilt';
55 -import { StateGraph, MessagesAnnotation } from '@langchain/langgraph';
68 +import { createAgent } from 'langchain';
69 import { Composio } from '@composio/core';
70 import { LangchainProvider } from '@composio/langchain';
71
@@ -64,39 +77,20 @@ const composio = new Composio({
77 const session = await composio.create("user_123");
78 const tools = await session.tools();
79
67 -const toolNode = new ToolNode(tools);
68 -
69 -const model = new ChatOpenAI({
70 - model: 'gpt-4o-mini',
71 - temperature: 0,
72 -}).bindTools(tools);
73 -
74 -function shouldContinue({ messages }: typeof MessagesAnnotation.State) {
75 - const lastMessage = messages[messages.length - 1] as AIMessage;
76 - if (lastMessage.tool_calls?.length) {
77 - return 'tools';
78 - }
79 - return '__end__';
80 -}
81 -
82 -async function callModel(state: typeof MessagesAnnotation.State) {
83 - const response = await model.invoke(state.messages);
84 - return { messages: [response] };
85 -}
86 -
87 -const workflow = new StateGraph(MessagesAnnotation)
88 - .addNode('agent', callModel)
89 - .addEdge('__start__', 'agent')
90 - .addNode('tools', toolNode)
91 - .addEdge('tools', 'agent')
92 - .addConditionalEdges('agent', shouldContinue);
93 -
94 -const app = workflow.compile();
95 -
96 -const finalState = await app.invoke({
97 - messages: [new HumanMessage('Star the composiohq/composio repository on GitHub')],
80 +const model = new ChatOpenAI({ model: 'gpt-5.2' });
81 +
82 +const agent = createAgent({
83 + model,
84 + tools,
85 +});
86 +
87 +const result = await agent.invoke({
88 + messages: [{ role: "user", content: "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'" }],
89 });
99 -console.log(finalState.messages[finalState.messages.length - 1].content);
90 +
91 +console.log(result.messages[result.messages.length - 1].content);
92 ```
93 </Tab>
94 </Tabs>
95 +</Step>
96 +</Steps>