mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-08 11:58:34 +02:00
Fix Vespa limit
This commit is contained in:
parent
742a016175
commit
adb22273b6
@ -270,6 +270,10 @@ def _build_vespa_filters(
|
||||
return filter_str
|
||||
|
||||
|
||||
def _build_vespa_limit(num_to_retrieve: int, offset: int = 0) -> str:
|
||||
return f" limit {num_to_retrieve} offset {offset}"
|
||||
|
||||
|
||||
def _query_vespa(query_params: Mapping[str, str | int]) -> list[InferenceChunk]:
|
||||
if "query" in query_params and not cast(str, query_params["query"]).strip():
|
||||
raise ValueError(
|
||||
@ -388,6 +392,7 @@ class VespaIndex(DocumentIndex):
|
||||
VespaIndex.yql_base
|
||||
+ vespa_where_clauses
|
||||
+ '({grammar: "weakAnd"}userInput(@query))'
|
||||
+ _build_vespa_limit(num_to_retrieve)
|
||||
)
|
||||
|
||||
params: dict[str, str | int] = {
|
||||
@ -413,6 +418,7 @@ class VespaIndex(DocumentIndex):
|
||||
VespaIndex.yql_base
|
||||
+ vespa_where_clauses
|
||||
+ f"({{targetHits: {10 * num_to_retrieve}}}nearestNeighbor(embeddings, query_embedding))"
|
||||
+ _build_vespa_limit(num_to_retrieve)
|
||||
)
|
||||
|
||||
query_embedding = embed_query(query)
|
||||
@ -438,6 +444,7 @@ class VespaIndex(DocumentIndex):
|
||||
+ vespa_where_clauses
|
||||
+ f"{{targetHits: {10 * num_to_retrieve}}}nearestNeighbor(embeddings, query_embedding) or "
|
||||
+ '{grammar: "weakAnd"}userInput(@query)'
|
||||
+ _build_vespa_limit(num_to_retrieve)
|
||||
)
|
||||
|
||||
query_embedding = embed_query(query)
|
||||
|
@ -244,7 +244,7 @@ def stream_direct_qa(
|
||||
# types which can't be parsed). These chunks are useful to show in the
|
||||
# search results, but not for QA.
|
||||
filtered_ranked_chunks = [
|
||||
chunk for chunk in ranked_chunks if chunk.metadata.get(IGNORE_FOR_QA)
|
||||
chunk for chunk in ranked_chunks if not chunk.metadata.get(IGNORE_FOR_QA)
|
||||
]
|
||||
|
||||
chunk_offset = offset_count * NUM_GENERATIVE_AI_INPUT_DOCS
|
||||
|
Loading…
x
Reference in New Issue
Block a user