From ef0b7b2ea15266f00bd28202a32fd8a4e3a4f856 Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Mon, 15 Apr 2024 06:52:11 +1000 Subject: [PATCH 1/2] feat: add Edge Runtime global types --- src/edge-runtime.d.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/edge-runtime.d.ts diff --git a/src/edge-runtime.d.ts b/src/edge-runtime.d.ts new file mode 100644 index 0000000..0c1aa02 --- /dev/null +++ b/src/edge-runtime.d.ts @@ -0,0 +1,21 @@ +interface ModelOptions { + mean_pool?: boolean + normalize?: boolean + stream?: boolean + timeout?: number +} + +interface Session { + run(prompt: string, modelOptions?: ModelOptions): unknown +} + +declare var Session: { + prototype: Session + new (modelName: string, sessionOptions?: unknown): Session +} + +declare var Supabase: { + readonly ai: { + readonly Session: typeof Session + } +} From bc12abc13c9634083401ccf2e9840863608d4154 Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Mon, 15 Apr 2024 09:39:53 +1000 Subject: [PATCH 2/2] chore: add typedocs for model options --- src/edge-runtime.d.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/edge-runtime.d.ts b/src/edge-runtime.d.ts index 0c1aa02..740937a 100644 --- a/src/edge-runtime.d.ts +++ b/src/edge-runtime.d.ts @@ -1,20 +1,44 @@ interface ModelOptions { + /** + * Pool embeddings by taking their mean. Applies only for `gte-small` model + */ mean_pool?: boolean + + /** + * Normalize the embeddings result. Applies only for `gte-small` model + */ normalize?: boolean + + /** + * Stream response from model. Applies only for LLMs like `mistral` (default: false) + */ stream?: boolean + + /** + * Automatically abort the request to the model after specified time (in seconds). Applies only for LLMs like `mistral` (default: 60) + */ timeout?: number } interface Session { + /** + * Execute the given prompt in model session + */ run(prompt: string, modelOptions?: ModelOptions): unknown } declare var Session: { prototype: Session - new (modelName: string, sessionOptions?: unknown): Session + /** + * Create a new model session using given model + */ + new (model: string, sessionOptions?: unknown): Session } declare var Supabase: { + /** + * Provides AI related APIs + */ readonly ai: { readonly Session: typeof Session }