@devries-cameron20 / composio Mirror · read-only / commits / cf94e1465
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 23, 04:15 UTC

fix: langchain sdk and add example

Utkarsh Dixit committed Apr 21, 2025 at 19:05 UTC cf94e1465152fbfc34870153b7c26e56e5bead87
11 files changed +84 -6
examples/langchain/.env.example new
+2
@@ -0,0 +1,2 @@
1 +COMPOSIO_API_KEY=
2 +OPENAI_API_KEY=
\ No newline at end of file
examples/langchain/package.json new
+23
@@ -0,0 +1,23 @@
1 +{
2 + "name": "langchain-example",
3 + "version": "1.0.0",
4 + "description": "",
5 + "main": "index.js",
6 + "scripts": {
7 + "start": "bun src/index.ts",
8 + "test": "echo \"Error: no test specified\" && exit 1"
9 + },
10 + "keywords": [],
11 + "author": "",
12 + "license": "ISC",
13 + "packageManager": "pnpm@10.8.0",
14 + "dependencies": {
15 + "@composio/core": "workspace:*",
16 + "@composio/langchain-toolset": "workspace:*",
17 + "openai": "^4.94.0"
18 + },
19 + "devDependencies": {
20 + "@types/bun": "^1.2.9",
21 + "typescript": "^5.8.3"
22 + }
23 +}
examples/langchain/src/index.ts new
+14
@@ -0,0 +1,14 @@
1 +import { Composio } from "@composio/core"
2 +import { LangchainToolset } from "@composio/langchain-toolset"
3 +import process from "process"
4 +
5 +const composio = new Composio({
6 + apiKey: process.env.COMPOSIO_API_KEY,
7 +})
8 +
9 +const toolset = new LangchainToolset()
10 +toolset.setClient(composio)
11 +
12 +const tools = await toolset.getTools()
13 +
14 +console.log(tools)
\ No newline at end of file
examples/langchain/tsconfig.json new
+15
@@ -0,0 +1,15 @@
1 +{
2 + "compilerOptions": {
3 + "target": "ESNext",
4 + "module": "ESNext",
5 + "declaration": true,
6 + "declarationDir": "./dist",
7 + "outDir": "./dist",
8 + "rootDir": "./src",
9 + "strict": true,
10 + "esModuleInterop": true,
11 + "moduleResolution": "node",
12 + "skipLibCheck": true
13 + },
14 + "include": ["src"]
15 +}
examples/openai/package.json
+1
@@ -13,6 +13,7 @@
13 "packageManager": "pnpm@10.8.0",
14 "dependencies": {
15 "@composio/core": "workspace:*",
16 + "@composio/langchain-toolset": "workspace:*",
17 "openai": "^4.94.0"
18 },
19 "devDependencies": {
packages/core/src/composio.ts
+2 -2
@@ -17,7 +17,7 @@ import { checkForLatestVersionFromNPM } from "./utils/version";
17 import { OpenAIToolset } from "./toolset/OpenAIToolset";
18
19
20 -export type ComposioConfig<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> = {
20 +export type ComposioConfig<TToolset extends BaseComposioToolset<any, any>> = {
21 apiKey?: string;
22 baseURL?: string;
23 allowTracking?: boolean;
@@ -32,7 +32,7 @@ export type ComposioConfig<TToolset extends BaseComposioToolset<any, any> = Open
32 * This is the core class for Composio.
33 * It is used to initialize the Composio SDK and provide a global configuration.
34 */
35 -export class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> {
35 +export class Composio<TToolset extends BaseComposioToolset<any, any>> {
36
37 private readonly DEFAULT_USER_ID = "default";
38 readonly FILE_NAME = "core/composio.ts";
packages/core/src/toolset/BaseToolset.ts
+2
@@ -16,6 +16,8 @@ import type { Composio } from "../composio";
16 export abstract class BaseComposioToolset<TToolCollection, TTool> implements Toolset<TTool, TToolCollection> {
17 protected client: Composio<this> | undefined;
18 abstract FILE_NAME: string;
19 +
20 + protected DEFAULT_ENTITY_ID = "default";
21
22 /**
23 * Set the client for the toolset. This is automatically done by the Composio class.
packages/toolsets/cloudflare/src/index.ts
-1
@@ -7,7 +7,6 @@ export class CloudflareToolset extends BaseComposioToolset<AiToolCollection, AiT
7 readonly FILE_NAME: string = "toolsets/cloudflare/src/index.ts";
8
9 static FRAMEWORK_NAME = "cloudflare";
10 - private DEFAULT_ENTITY_ID = "default";
10
11 /**
12 * Abstract method to wrap a tool in the toolset.
packages/toolsets/langchain/src/index.ts
+1 -2
@@ -1,11 +1,10 @@
1 -import { BaseComposioToolset, jsonSchemaToModel, Tool, ToolListParams } from "@composio/core";
1 +import { BaseComposioToolset, Composio, jsonSchemaToModel, Tool, ToolListParams } from "@composio/core";
2 import { DynamicStructuredTool } from "@langchain/core/tools";
3
4
5
6 export class LangchainToolset extends BaseComposioToolset<Array<DynamicStructuredTool>, DynamicStructuredTool> {
7 static FRAMEWORK_NAME = "langchain";
8 - private DEFAULT_ENTITY_ID = "default";
8 readonly FILE_NAME: string = "toolsets/langchain/src/index.ts";
9
10 /**
pnpm-lock.yaml
+22
@@ -12,11 +12,33 @@ importers:
12 specifier: ^2.5.0
13 version: 2.5.0
14
15 + examples/langchain:
16 + dependencies:
17 + '@composio/core':
18 + specifier: workspace:*
19 + version: link:../../packages/core
20 + '@composio/langchain-toolset':
21 + specifier: workspace:*
22 + version: link:../../packages/toolsets/langchain
23 + openai:
24 + specifier: ^4.94.0
25 + version: 4.94.0(zod@3.24.2)
26 + devDependencies:
27 + '@types/bun':
28 + specifier: ^1.2.9
29 + version: 1.2.9
30 + typescript:
31 + specifier: ^5.8.3
32 + version: 5.8.3
33 +
34 examples/openai:
35 dependencies:
36 '@composio/core':
37 specifier: workspace:*
38 version: link:../../packages/core
39 + '@composio/langchain-toolset':
40 + specifier: workspace:*
41 + version: link:../../packages/toolsets/langchain
42 openai:
43 specifier: ^4.94.0
44 version: 4.94.0(zod@3.24.2)
pnpm-workspace.yaml
+2 -1
@@ -1,3 +1,4 @@
1 packages:
2 - - 'packages/**'
2 + - 'packages/core'
3 + - 'packages/toolsets/*'
4 - 'examples/*'
\ No newline at end of file