INNER CODE UNIT · TypeScript
truncatedText
winstonkoh87/Athena-Public · supabase/functions/sync-athena/index.ts:30
const truncatedText = text.slice(0, 32000); // Truncate to ~8000 tokens
const response = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models/text-embedding-004:embedContent?key=${GOOGLE_API_KEY}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "models/text-embedding-004",
content: { parts: [{ text: truncatedText }] },
}),
}
);
if (!response.ok) {
throw new Error(`Embedding API error: ${response.statusText}`);
}