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
|
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)
|
||||||
|
@ -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):
|
||||||
|
@ -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
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user