Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix: langchain sdk and add example
Utkarsh Dixitabb8c616119f
diff --git a/examples/langchain/.env.example b/examples/langchain/.env.examplenew file mode 100644index 000000000..ad0f7ed62--- /dev/null+++ b/examples/langchain/.env.example@@ -0,0 +1,2 @@+COMPOSIO_API_KEY=+OPENAI_API_KEY=\ No newline at end of filediff --git a/examples/langchain/package.json b/examples/langchain/package.jsonnew file mode 100644index 000000000..8fcc34640--- /dev/null+++ b/examples/langchain/package.json@@ -0,0 +1,23 @@+{+ "name": "langchain-example",+ "version": "1.0.0",+ "description": "",+ "main": "index.js",+ "scripts": {+ "start": "bun src/index.ts",+ "test": "echo \"Error: no test specified\" && exit 1"+ },+ "keywords": [],+ "author": "",+ "license": "ISC",+ "packageManager": "[email protected]",+ "dependencies": {+ "@composio/core": "workspace:*",+ "@composio/langchain-toolset": "workspace:*",+ "openai": "^4.94.0"+ },+ "devDependencies": {+ "@types/bun": "^1.2.9",+ "typescript": "^5.8.3"+ }+}diff --git a/examples/langchain/src/index.ts b/examples/langchain/src/index.tsnew file mode 100644index 000000000..dee744cd1--- /dev/null+++ b/examples/langchain/src/index.ts@@ -0,0 +1,14 @@+import { Composio } from "@composio/core"+import { LangchainToolset } from "@composio/langchain-toolset"+import process from "process"++const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+})++const toolset = new LangchainToolset()+toolset.setClient(composio)++const tools = await toolset.getTools()++console.log(tools)\ No newline at end of filediff --git a/examples/langchain/tsconfig.json b/examples/langchain/tsconfig.jsonnew file mode 100644index 000000000..ad82940d5--- /dev/null+++ b/examples/langchain/tsconfig.json@@ -0,0 +1,15 @@+{+ "compilerOptions": {+ "target": "ESNext",+ "module": "ESNext",+ "declaration": true,+ "declarationDir": "./dist",+ "outDir": "./dist",+ "rootDir": "./src",+ "strict": true,+ "esModuleInterop": true,+ "moduleResolution": "node",+ "skipLibCheck": true+ },+ "include": ["src"]+}diff --git a/examples/openai/package.json b/examples/openai/package.jsonindex 5be7723a5..5ae2d045b 100644--- a/examples/openai/package.json+++ b/examples/openai/package.json@@ -13,6 +13,7 @@"packageManager": "[email protected]","dependencies": {"@composio/core": "workspace:*",+ "@composio/langchain-toolset": "workspace:*","openai": "^4.94.0"},"devDependencies": {diff --git a/packages/core/src/composio.ts b/packages/core/src/composio.tsindex 63f0e4e7a..38ad1fdf0 100644--- a/packages/core/src/composio.ts+++ b/packages/core/src/composio.ts@@ -17,7 +17,7 @@ import { checkForLatestVersionFromNPM } from "./utils/version";import { OpenAIToolset } from "./toolset/OpenAIToolset";-export type ComposioConfig<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> = {+export type ComposioConfig<TToolset extends BaseComposioToolset<any, any>> = {apiKey?: string;baseURL?: string;allowTracking?: boolean;@@ -32,7 +32,7 @@ export type ComposioConfig<TToolset extends BaseComposioToolset<any, any> = Open* This is the core class for Composio.* It is used to initialize the Composio SDK and provide a global configuration.*/-export class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> {+export class Composio<TToolset extends BaseComposioToolset<any, any>> {private readonly DEFAULT_USER_ID = "default";readonly FILE_NAME = "core/composio.ts";diff --git a/packages/core/src/toolset/BaseToolset.ts b/packages/core/src/toolset/BaseToolset.tsindex 53963ca86..f30f604e2 100644--- a/packages/core/src/toolset/BaseToolset.ts+++ b/packages/core/src/toolset/BaseToolset.ts@@ -16,6 +16,8 @@ import type { Composio } from "../composio";export abstract class BaseComposioToolset<TToolCollection, TTool> implements Toolset<TTool, TToolCollection> {protected client: Composio<this> | undefined;abstract FILE_NAME: string;++ protected DEFAULT_ENTITY_ID = "default";/*** Set the client for the toolset. This is automatically done by the Composio class.diff --git a/packages/toolsets/cloudflare/src/index.ts b/packages/toolsets/cloudflare/src/index.tsindex 062d971b9..d9c89f7fc 100644--- a/packages/toolsets/cloudflare/src/index.ts+++ b/packages/toolsets/cloudflare/src/index.ts@@ -18,7 +18,6 @@ export class CloudflareToolset extends BaseComposioToolset<AiToolCollection, AiTreadonly FILE_NAME: string = "toolsets/cloudflare/src/index.ts";static FRAMEWORK_NAME = "cloudflare";- private DEFAULT_ENTITY_ID = "default";/*** Abstract method to wrap a tool in the toolset.diff --git a/packages/toolsets/langchain/src/index.ts b/packages/toolsets/langchain/src/index.tsindex f45b9e9c7..cf194c2fe 100644--- a/packages/toolsets/langchain/src/index.ts+++ b/packages/toolsets/langchain/src/index.ts@@ -16,7 +16,6 @@ import { DynamicStructuredTool } from "@langchain/core/tools";export class LangchainToolset extends BaseComposioToolset<Array<DynamicStructuredTool>, DynamicStructuredTool> {static FRAMEWORK_NAME = "langchain";- private DEFAULT_ENTITY_ID = "default";readonly FILE_NAME: string = "toolsets/langchain/src/index.ts";/**diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e8b866de7..678fc976f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -12,11 +12,33 @@ importers:specifier: ^2.5.0version: 2.5.0+ examples/langchain:+ dependencies:+ '@composio/core':+ specifier: workspace:*+ version: link:../../packages/core+ '@composio/langchain-toolset':+ specifier: workspace:*+ version: link:../../packages/toolsets/langchain+ openai:+ specifier: ^4.94.0+ version: 4.94.0([email protected])+ devDependencies:+ '@types/bun':+ specifier: ^1.2.9+ version: 1.2.9+ typescript:+ specifier: ^5.8.3+ version: 5.8.3+examples/openai:dependencies:'@composio/core':specifier: workspace:*version: link:../../packages/core+ '@composio/langchain-toolset':+ specifier: workspace:*+ version: link:../../packages/toolsets/langchainopenai:specifier: ^4.94.0version: 4.94.0([email protected])diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 29acc3c8d..5c64f4ba2 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -1,3 +1,4 @@packages:- - 'packages/**'+ - 'packages/core'+ - 'packages/toolsets/*'- 'examples/*'\ No newline at end of file