From d0e7437ada94e1b2ec62e7a55f21442659381a9e Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Thu, 2 Jan 2025 00:55:44 +0000 Subject: [PATCH] chore(base): add an integration test for `Supabase.ai` --- crates/base/test_cases/supabase-ai/index.ts | 18 ++++++++++++++++++ crates/base/tests/integration_tests.rs | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 crates/base/test_cases/supabase-ai/index.ts diff --git a/crates/base/test_cases/supabase-ai/index.ts b/crates/base/test_cases/supabase-ai/index.ts new file mode 100644 index 00000000..1c1d8f11 --- /dev/null +++ b/crates/base/test_cases/supabase-ai/index.ts @@ -0,0 +1,18 @@ +const session = new Supabase.ai.Session('gte-small'); + +export default { + async fetch() { + // Generate embedding + const embedding = await session.run("meow", { + mean_pool: true, + normalize: true + }); + + return new Response( + null, + { + status: embedding instanceof Array ? 200 : 500 + } + ); + } +} \ No newline at end of file diff --git a/crates/base/tests/integration_tests.rs b/crates/base/tests/integration_tests.rs index b49bfdae..5edc2b33 100644 --- a/crates/base/tests/integration_tests.rs +++ b/crates/base/tests/integration_tests.rs @@ -2856,6 +2856,26 @@ async fn test_tmp_fs_should_not_be_available_in_import_stmt() { ); } +#[tokio::test] +#[serial] +async fn test_supabase_ai_gte() { + let tb = TestBedBuilder::new("./test_cases/main") + .with_per_worker_policy(None) + .build() + .await; + + let resp = tb + .request(|b| { + b.uri("/supabase-ai") + .body(Body::empty()) + .context("can't make request") + }) + .await + .unwrap(); + + assert_eq!(resp.status().as_u16(), StatusCode::OK); +} + // -- sb_ai: ORT @huggingface/transformers async fn test_ort_transformers_js(script_path: &str) { fn visit_json(value: &mut serde_json::Value) {