Fix CF-271: Add fallback text search to archive_search
When LiteLLM embedding service is unavailable, archive_search now gracefully falls back to PostgreSQL text search (ILIKE) instead of returning an error. Also adds dotenv support for proper credential loading. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
// Embeddings via LiteLLM API
|
||||
|
||||
const LLM_API_URL = process.env.LLM_API_URL || 'https://api.agiliton.cloud/llm';
|
||||
const LLM_API_KEY = process.env.LLM_API_KEY || '';
|
||||
|
||||
interface EmbeddingResponse {
|
||||
data: Array<{
|
||||
embedding: number[];
|
||||
@@ -19,8 +16,13 @@ interface EmbeddingResponse {
|
||||
* Generate embedding for text using LiteLLM API
|
||||
*/
|
||||
export async function getEmbedding(text: string): Promise<number[] | null> {
|
||||
// Read env vars at runtime (after dotenv.config() in index.ts)
|
||||
const LLM_API_URL = process.env.LLM_API_URL || 'https://api.agiliton.cloud/llm';
|
||||
const LLM_API_KEY = process.env.LLM_API_KEY || '';
|
||||
|
||||
if (!LLM_API_KEY) {
|
||||
console.error('LLM_API_KEY not set, skipping embedding');
|
||||
console.error('LLM_API_KEY not set, skipping embedding (check .env file)');
|
||||
console.error('LLM_API_URL:', LLM_API_URL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user