scai
Version:
> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.
23 lines (22 loc) • 740 B
JavaScript
export async function generateEmbedding(text) {
try {
const res = await fetch('http://localhost:11434/api/embeddings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'mistral', // or 'llama3' — whatever works best
prompt: text,
}),
});
if (!res.ok) {
console.error('❌ Failed to generate embedding:', await res.text());
return null;
}
const data = await res.json();
return data.embedding;
}
catch (err) {
console.error('❌ Embedding error:', err instanceof Error ? err.message : err);
return null;
}
}