25 lines
887 B
TypeScript
25 lines
887 B
TypeScript
const EMBEDDING_BASE_URL = Deno.env.get("EMBEDDING_BASE_URL");
|
|
|
|
async function post(path: string, body: any): any {
|
|
const req = await fetch(`${EMBEDDING_BASE_URL}${path}`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
}).catch(() => null);
|
|
return await req.json().catch(() => null);
|
|
}
|
|
|
|
export async function embedText(text: string): Promise<Array<number> | null> {
|
|
const data = await post("/embed/search/text", { text });
|
|
return data?.result ?? null;
|
|
}
|
|
|
|
// export async function embedClipText(text: string): Array<number> | null {
|
|
// const data = await post("/embed/clip/text", { text });
|
|
// return data?.result ?? null;
|
|
// }
|
|
|
|
// export async function embedClipImage(url: string): Array<number> | null {
|
|
// const data = await post("/embed/clip/url?image=true", { url });
|
|
// return data?.result ?? null;
|
|
// }
|