feat(knowledgebase): replace litellm-pgvector connector with memory-retrieval
Per docs/research/langchain-pgvector-vs-litellm-pgvector.md (issue #25): the vendored litellm-pgvector connector (793 lines, Prisma migrations, a fragile git-context build) is replaced by a ~90-line FastAPI service (services/memory-retrieval/) wrapping langchain_postgres.PGVector directly against pgvector-db. Same gateway boundary — it still calls litellm for embeddings, nothing talks to Postgres or the model directly except this service. - New services/memory-retrieval/ (main.py, Dockerfile, requirements.txt): POST /ingest, POST /query, GET /health. - docker-compose.yml: litellm-pgvector service replaced by memory-retrieval; pgvector-db and embedding-server untouched. - litellm-config.yaml: vector_store_registry block removed (no langchain_postgres provider exists to register against; callers query memory-retrieval directly instead of an in-band file_search tool call — that mechanism was never confirmed working per issue #24 anyway). - scripts/ingest-memory.sh rewritten for the new /ingest endpoint (same per-line chunking, no dedup). - .env vars renamed: LITELLM_PGVECTOR_API_KEY/LITELLM_PGVECTOR_EMBEDDING_KEY -> MEMORY_RETRIEVAL_API_KEY/MEMORY_RETRIEVAL_EMBEDDING_KEY. - vendor/litellm-pgvector/ removed entirely. - docs/memory-knowledgebase.md updated for the new setup/query flow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Vendored
-60
@@ -1,60 +0,0 @@
|
||||
from typing import Dict, Optional
|
||||
from pydantic import BaseModel
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class DatabaseFieldConfig(BaseModel):
|
||||
"""Configuration for database field mappings"""
|
||||
id_field: str = "id"
|
||||
content_field: str = "content"
|
||||
metadata_field: str = "metadata"
|
||||
embedding_field: str = "embedding"
|
||||
vector_store_id_field: str = "vector_store_id"
|
||||
created_at_field: str = "created_at"
|
||||
|
||||
|
||||
class EmbeddingConfig(BaseModel):
|
||||
"""Configuration for embedding generation via LiteLLM proxy"""
|
||||
model: str = "text-embedding-ada-002"
|
||||
base_url: str = "http://localhost:4000" # LiteLLM proxy URL
|
||||
api_key: str = "sk-1234" # LiteLLM proxy API key
|
||||
dimensions: int = 1536
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
# Database configuration
|
||||
database_url: str = "postgresql://username:password@localhost:5432/vectordb?schema=public"
|
||||
|
||||
# API configuration
|
||||
server_api_key: str = "your-api-key-here"
|
||||
port: int = 8000
|
||||
host: str = "0.0.0.0"
|
||||
|
||||
# Database field mappings
|
||||
db_fields: DatabaseFieldConfig = DatabaseFieldConfig()
|
||||
|
||||
# Embedding configuration
|
||||
embedding: EmbeddingConfig = EmbeddingConfig()
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
env_nested_delimiter = "__"
|
||||
case_sensitive = False
|
||||
|
||||
# Allow environment variables like:
|
||||
# DB_FIELDS__ID_FIELD=custom_id
|
||||
# EMBEDDING__MODEL=text-embedding-3-small
|
||||
# EMBEDDING__API_BASE=https://api.openai.com/v1
|
||||
|
||||
@property
|
||||
def table_names(self) -> Dict[str, str]:
|
||||
"""Get table names"""
|
||||
return {
|
||||
"vector_stores": "vector_stores",
|
||||
"embeddings": "embeddings"
|
||||
}
|
||||
|
||||
|
||||
# Global settings instance
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user