mirror of
https://github.com/james-m-jordan/morphik-core.git
synced 2025-05-09 19:32:38 +00:00
Include chunk score in query response and don't attempt to initialize colpali store if it is disabled (#52)
This commit is contained in:
parent
38683df0f3
commit
39d7bc7bfd
@ -4,6 +4,7 @@ from pydantic_settings import BaseSettings
|
||||
from functools import lru_cache
|
||||
import tomli
|
||||
from dotenv import load_dotenv
|
||||
from collections import ChainMap
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
@ -275,18 +276,17 @@ def get_settings() -> Settings:
|
||||
"ENABLE_COLPALI": config["databridge"]["enable_colpali"],
|
||||
}
|
||||
|
||||
settings_dict = {}
|
||||
settings_dict.update(
|
||||
**api_config,
|
||||
**auth_config,
|
||||
**completion_config,
|
||||
**database_config,
|
||||
**embedding_config,
|
||||
**parser_config,
|
||||
**reranker_config,
|
||||
**storage_config,
|
||||
**vector_store_config,
|
||||
**rules_config,
|
||||
**databridge_config,
|
||||
)
|
||||
settings_dict = dict(ChainMap(
|
||||
api_config,
|
||||
auth_config,
|
||||
completion_config,
|
||||
database_config,
|
||||
embedding_config,
|
||||
parser_config,
|
||||
reranker_config,
|
||||
storage_config,
|
||||
vector_store_config,
|
||||
rules_config,
|
||||
databridge_config,
|
||||
))
|
||||
return Settings(**settings_dict)
|
||||
|
@ -7,6 +7,7 @@ class ChunkSource(BaseModel):
|
||||
|
||||
document_id: str
|
||||
chunk_number: int
|
||||
score: Optional[float] = None
|
||||
|
||||
|
||||
class CompletionResponse(BaseModel):
|
||||
|
@ -63,7 +63,8 @@ class DocumentService:
|
||||
self.colpali_embedding_model = colpali_embedding_model
|
||||
self.colpali_vector_store = colpali_vector_store
|
||||
|
||||
colpali_vector_store.initialize()
|
||||
if colpali_vector_store:
|
||||
colpali_vector_store.initialize()
|
||||
|
||||
# Cache-related data structures
|
||||
# Maps cache name to active cache object
|
||||
@ -243,7 +244,7 @@ class DocumentService:
|
||||
|
||||
# Collect sources information
|
||||
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
|
||||
]
|
||||
|
||||
|
@ -64,6 +64,7 @@ class ChunkSource(BaseModel):
|
||||
|
||||
document_id: str = Field(..., description="ID of the source document")
|
||||
chunk_number: int = Field(..., description="Chunk number within the document")
|
||||
score: Optional[float] = Field(None, description="Relevance score")
|
||||
|
||||
|
||||
class CompletionResponse(BaseModel):
|
||||
|
Loading…
x
Reference in New Issue
Block a user