Include chunk score in query response and don't attempt to initialize colpali store if it is disabled (#52)

This commit is contained in:
LukeZekes 2025-03-11 14:53:42 -05:00 committed by GitHub
parent 38683df0f3
commit 39d7bc7bfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 16 deletions

View File

@ -4,6 +4,7 @@ from pydantic_settings import BaseSettings
from functools import lru_cache from functools import lru_cache
import tomli import tomli
from dotenv import load_dotenv from dotenv import load_dotenv
from collections import ChainMap
class Settings(BaseSettings): class Settings(BaseSettings):
@ -275,18 +276,17 @@ def get_settings() -> Settings:
"ENABLE_COLPALI": config["databridge"]["enable_colpali"], "ENABLE_COLPALI": config["databridge"]["enable_colpali"],
} }
settings_dict = {} settings_dict = dict(ChainMap(
settings_dict.update( api_config,
**api_config, auth_config,
**auth_config, completion_config,
**completion_config, database_config,
**database_config, embedding_config,
**embedding_config, parser_config,
**parser_config, reranker_config,
**reranker_config, storage_config,
**storage_config, vector_store_config,
**vector_store_config, rules_config,
**rules_config, databridge_config,
**databridge_config, ))
)
return Settings(**settings_dict) return Settings(**settings_dict)

View File

@ -7,6 +7,7 @@ class ChunkSource(BaseModel):
document_id: str document_id: str
chunk_number: int chunk_number: int
score: Optional[float] = None
class CompletionResponse(BaseModel): class CompletionResponse(BaseModel):

View File

@ -63,7 +63,8 @@ class DocumentService:
self.colpali_embedding_model = colpali_embedding_model self.colpali_embedding_model = colpali_embedding_model
self.colpali_vector_store = colpali_vector_store self.colpali_vector_store = colpali_vector_store
colpali_vector_store.initialize() if colpali_vector_store:
colpali_vector_store.initialize()
# Cache-related data structures # Cache-related data structures
# Maps cache name to active cache object # Maps cache name to active cache object
@ -243,7 +244,7 @@ class DocumentService:
# Collect sources information # Collect sources information
sources = [ sources = [
ChunkSource(document_id=chunk.document_id, chunk_number=chunk.chunk_number) ChunkSource(document_id=chunk.document_id, chunk_number=chunk.chunk_number, score=chunk.score)
for chunk in chunks for chunk in chunks
] ]

View File

@ -64,6 +64,7 @@ class ChunkSource(BaseModel):
document_id: str = Field(..., description="ID of the source document") document_id: str = Field(..., description="ID of the source document")
chunk_number: int = Field(..., description="Chunk number within the document") chunk_number: int = Field(..., description="Chunk number within the document")
score: Optional[float] = Field(None, description="Relevance score")
class CompletionResponse(BaseModel): class CompletionResponse(BaseModel):