mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-01 16:24:44 +00:00
Feature: Configuring search modes for RAG - Address review
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
This commit is contained in:
parent
2060fdba7f
commit
6a2a0836c5
11 changed files with 11 additions and 13 deletions
2
docs/_static/llama-stack-spec.html
vendored
2
docs/_static/llama-stack-spec.html
vendored
|
@ -11611,7 +11611,7 @@
|
||||||
},
|
},
|
||||||
"mode": {
|
"mode": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Search mode for retrieval—either \"vector\" or \"keyword\"."
|
"description": "Search mode for retrieval—either \"vector\" or \"keyword\". Default \"vector\"."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|
2
docs/_static/llama-stack-spec.yaml
vendored
2
docs/_static/llama-stack-spec.yaml
vendored
|
@ -8089,7 +8089,7 @@ components:
|
||||||
mode:
|
mode:
|
||||||
type: string
|
type: string
|
||||||
description: >-
|
description: >-
|
||||||
Search mode for retrieval—either "vector" or "keyword".
|
Search mode for retrieval—either "vector" or "keyword". Default "vector".
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- query_generator_config
|
- query_generator_config
|
||||||
|
|
|
@ -76,7 +76,7 @@ class RAGQueryConfig(BaseModel):
|
||||||
:param chunk_template: Template for formatting each retrieved chunk in the context.
|
:param chunk_template: Template for formatting each retrieved chunk in the context.
|
||||||
Available placeholders: {index} (1-based chunk ordinal), {chunk.content} (chunk content string), {metadata} (chunk metadata dict).
|
Available placeholders: {index} (1-based chunk ordinal), {chunk.content} (chunk content string), {metadata} (chunk metadata dict).
|
||||||
Default: "Result {index}\\nContent: {chunk.content}\\nMetadata: {metadata}\\n"
|
Default: "Result {index}\\nContent: {chunk.content}\\nMetadata: {metadata}\\n"
|
||||||
:param mode: Search mode for retrieval—either "vector" or "keyword".
|
:param mode: Search mode for retrieval—either "vector" or "keyword". Default "vector".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This config defines how a query is generated using the messages
|
# This config defines how a query is generated using the messages
|
||||||
|
|
|
@ -118,7 +118,7 @@ class FaissIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -203,8 +203,6 @@ class SQLiteVecIndex(EmbeddingIndex):
|
||||||
"""
|
"""
|
||||||
Performs vector-based search using a virtual table for vector similarity.
|
Performs vector-based search using a virtual table for vector similarity.
|
||||||
"""
|
"""
|
||||||
if embedding is None:
|
|
||||||
raise ValueError("embedding is required for vector search.")
|
|
||||||
|
|
||||||
def _execute_query():
|
def _execute_query():
|
||||||
connection = _create_sqlite_connection(self.db_path)
|
connection = _create_sqlite_connection(self.db_path)
|
||||||
|
@ -243,7 +241,7 @@ class SQLiteVecIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ChromaIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -88,7 +88,7 @@ class MilvusIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -122,7 +122,7 @@ class PGVectorIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -97,7 +97,7 @@ class QdrantIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -86,7 +86,7 @@ class WeaviateIndex(EmbeddingIndex):
|
||||||
|
|
||||||
async def query_keyword(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
query_string: str | None,
|
query_string: str,
|
||||||
k: int,
|
k: int,
|
||||||
score_threshold: float,
|
score_threshold: float,
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
|
|
|
@ -181,7 +181,7 @@ class EmbeddingIndex(ABC):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def query_keyword(self, query_string: str | None, k: int, score_threshold: float) -> QueryChunksResponse:
|
async def query_keyword(self, query_string: str, k: int, score_threshold: float) -> QueryChunksResponse:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue