feat: Claude client + Voyage AI embed helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
This commit is contained in:
2026-07-11 16:10:26 +08:00
co-authored by Claude Sonnet 4.6
parent 0e53d5c771
commit ebaa98d9f4
6 changed files with 101 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
export async function embedText(text: string): Promise<number[]> {
if (!process.env.VOYAGE_API_KEY) throw new Error('VOYAGE_API_KEY is not set')
const res = await fetch('https://api.voyageai.com/v1/embeddings', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.VOYAGE_API_KEY}`,
},
body: JSON.stringify({ input: [text], model: 'voyage-3-lite' }),
})
if (!res.ok) throw new Error(`Voyage embed failed: ${res.status}`)
const json = await res.json() as { data: Array<{ embedding: number[] }> }
return json.data[0].embedding
}