Add Ollama embedding support and improve prayer system with public/private visibility
- Add Ollama fallback support in vector search with Azure OpenAI as primary - Enhance prayer system with public/private visibility options and language filtering - Update OG image to use new biblical-guide-og-image.png - Improve prayer request management with better categorization - Remove deprecated ingest_json_pgvector.py script 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,32 @@ export interface BibleVerse {
|
||||
}
|
||||
|
||||
export async function getEmbedding(text: string): Promise<number[]> {
|
||||
// Try Ollama first (for local embeddings)
|
||||
if (process.env.OLLAMA_API_URL && process.env.OLLAMA_EMBED_MODEL) {
|
||||
try {
|
||||
const response = await fetch(`${process.env.OLLAMA_API_URL}/api/embeddings`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: process.env.OLLAMA_EMBED_MODEL,
|
||||
prompt: text,
|
||||
}),
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
return data.embedding
|
||||
} else {
|
||||
console.warn(`Ollama embedding failed: ${response.status}, falling back to Azure`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Ollama embedding error, falling back to Azure:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to Azure OpenAI
|
||||
const response = await fetch(
|
||||
`${process.env.AZURE_OPENAI_ENDPOINT}/openai/deployments/${process.env.AZURE_OPENAI_EMBED_DEPLOYMENT}/embeddings?api-version=${process.env.AZURE_OPENAI_API_VERSION}`,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user