From e6796561ad7f47c05492d61f0ddb89a5c22e8120 Mon Sep 17 00:00:00 2001 From: Ismail Pelaseyed Date: Wed, 31 May 2023 13:43:50 +0200 Subject: [PATCH] Add `Typescript` support --- package.json | 3 ++- src/superagent.d.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/superagent.d.ts diff --git a/package.json b/package.json index af2aae4..be73d8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "superagentai-js", - "version": "0.0.5", + "version": "0.0.6", + "types": "src/superagent.d.ts", "description": "Superagent.sh Javascript SDK", "main": "src/superagent.js", "type": "module", diff --git a/src/superagent.d.ts b/src/superagent.d.ts new file mode 100644 index 0000000..3d6ee3e --- /dev/null +++ b/src/superagent.d.ts @@ -0,0 +1,53 @@ +declare module 'superagentSDK' { + type Method = "GET" | "POST" | "DELETE"; + + interface Prompt { + name?: string | null; + input_variables?: string[]; + template?: string | null; + } + + interface Document { + name: string; + url: string; + type: string; + authorization?: string | null; + } + + interface Agent { + name: string; + llm: string; + type?: string; + has_memory: boolean; + } + + interface Prediction { + id: string; + input: string; + has_streaming: boolean; + } + + export default class SuperagentSDK { + constructor(authToken: string); + private _request(method: Method, endpoint: string, data?: any): Promise; + prompts(): { + delete(id: string): Promise; + get(id: string): Promise; + list(): Promise; + create(prompt: Prompt): Promise; + }; + documents(): { + delete(id: string): Promise; + list(): Promise; + get(id: string): Promise; + create(document: Document): Promise; + }; + agents(): { + delete(id: string): Promise; + list(): Promise; + get(id: string): Promise; + create(agent: Agent): Promise; + predict(prediction: Prediction): Promise; + }; + } +}