396e005686
- POST /embed: batch text → vector (max 100) - KV cache: sha256(model+text), content-addressable, no expiry - Dashscope text-embedding-v3 upstream (1024 dims) - Bearer token auth - Health endpoint Deployed: https://embed.shazhou.workers.dev
11 lines
420 B
TypeScript
11 lines
420 B
TypeScript
/**
|
|
* SHA-256 hash using Web Crypto API (available in Workers runtime).
|
|
*/
|
|
export async function createHash(input: string): Promise<string> {
|
|
const encoder = new TextEncoder();
|
|
const data = encoder.encode(input);
|
|
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
}
|