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
Remove unwanted generics
haxzie committed
Apr 17, 2025 at 17:08 UTC
5e2cea9518ebe892fcc97fa676284fe1a2202658
3 files changed
+10
-8
examples/openai/src/index.ts
+2
@@ -16,6 +16,8 @@ const composio = new Composio({
16
// these tools are automatically typed and wrapped with the OpenAI Toolset
17
const tool = await composio.getTool("HACKERNEWS_GET_USER");
18
19
+await composio.toolset.getTool("HACKERNEWS_GET_USER");
20
+
21
22
const task = "Fetch the details of the user 'haxzie'";
23
packages/core/src/composio.ts
+5
-5
@@ -16,7 +16,7 @@ import { IS_DEVELOPMENT_OR_CI } from "./utils/constants";
16
import { checkForLatestVersionFromNPM } from "./utils/version";
17
18
19
-export type ComposioConfig<TToolCollection, TTool, TToolset extends BaseComposioToolset<TToolCollection, TTool>> = {
19
+export type ComposioConfig<TToolset extends BaseComposioToolset<any, any>> = {
20
apiKey?: string;
21
baseURL?: string;
22
allowTracking?: boolean;
@@ -31,7 +31,7 @@ export type ComposioConfig<TToolCollection, TTool, TToolset extends BaseComposio
31
* This is the core class for Composio.
32
* It is used to initialize the Composio SDK and provide a global configuration.
33
*/
34
-export class Composio<TToolCollection, TTool, TToolset extends BaseComposioToolset<TToolCollection, TTool>> {
34
+export class Composio<TToolset extends BaseComposioToolset<any, any>> {
35
36
private readonly DEFAULT_USER_ID = "default";
37
readonly FILE_NAME = "core/composio.ts";
@@ -46,7 +46,7 @@ export class Composio<TToolCollection, TTool, TToolset extends BaseComposioTools
46
* The configuration for the Composio SDK.
47
* @type {ComposioConfig<TTool, TToolset>}
48
*/
49
- private config: ComposioConfig<TToolCollection, TTool, TToolset>;
49
+ private config: ComposioConfig<TToolset>;
50
51
private telemetry: Telemetry<InstrumentedInstance> | undefined;
52
@@ -76,7 +76,7 @@ export class Composio<TToolCollection, TTool, TToolset extends BaseComposioTools
76
* @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.
77
* @param {TS} config.toolset The toolset to use for this Composio instance.
78
*/
79
- constructor(config: ComposioConfig<TToolCollection, TTool, TToolset>) {
79
+ constructor(config: ComposioConfig<TToolset>) {
80
81
const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(
82
config?.baseURL,
@@ -116,7 +116,7 @@ export class Composio<TToolCollection, TTool, TToolset extends BaseComposioTools
116
/**
117
* Set the default toolset, if not provided by the user.
118
*/
119
- this.toolset = config.toolset ?? new ComposioToolset() as unknown as TToolset;
119
+ this.toolset = (config.toolset ?? new ComposioToolset()) as TToolset;
120
this.toolset.setClient(this);
121
122
/**
packages/core/src/toolset/BaseToolset.ts
+3
-3
@@ -13,15 +13,15 @@ import { Composio } from "../composio";
13
* eg:
14
* class YourToolSet extends BaseComposioToolset<CustomToolCollection, CustomTool> {}
15
*/
16
-export abstract class BaseComposioToolset<TToolCollection, TTool = BaseTool> implements Toolset<TTool, TToolCollection> {
17
- protected client: Composio<TToolCollection, TTool, this> | undefined;
16
+export abstract class BaseComposioToolset<TToolCollection, TTool> implements Toolset<TTool, TToolCollection> {
17
+ protected client: Composio<this> | undefined;
18
abstract FILE_NAME: string;
19
20
/**
21
* Set the client for the toolset. This is automatically done by the Composio class.
22
* @param client - The Composio client.
23
*/
24
- setClient(client: Composio<TToolCollection, TTool, this>): void {
24
+ setClient(client: Composio<this>): void {
25
this.client = client;
26
}
27