feat: Add query mode 'bypass' to bypass knowledge retrieval and directly use LLM
This commit is contained in:
@@ -22,7 +22,7 @@ class QueryRequest(BaseModel):
|
||||
description="The query text",
|
||||
)
|
||||
|
||||
mode: Literal["local", "global", "hybrid", "naive", "mix"] = Field(
|
||||
mode: Literal["local", "global", "hybrid", "naive", "mix", "bypass"] = Field(
|
||||
default="hybrid",
|
||||
description="Query mode",
|
||||
)
|
||||
|
@@ -36,7 +36,7 @@ T = TypeVar("T")
|
||||
class QueryParam:
|
||||
"""Configuration parameters for query execution in LightRAG."""
|
||||
|
||||
mode: Literal["local", "global", "hybrid", "naive", "mix"] = "global"
|
||||
mode: Literal["local", "global", "hybrid", "naive", "mix", "bypass"] = "global"
|
||||
"""Specifies the retrieval mode:
|
||||
- "local": Focuses on context-dependent information.
|
||||
- "global": Utilizes global knowledge.
|
||||
|
@@ -1381,6 +1381,14 @@ class LightRAG:
|
||||
hashing_kv=self.llm_response_cache, # Directly use llm_response_cache
|
||||
system_prompt=system_prompt,
|
||||
)
|
||||
elif param.mode == "bypass":
|
||||
# Bypass mode: directly use LLM without knowledge retrieval
|
||||
use_llm_func = param.model_func or global_config["llm_model_func"]
|
||||
response = await use_llm_func(
|
||||
query.strip(),
|
||||
system_prompt=system_prompt,
|
||||
history_messages=param.conversation_history,
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unknown mode {param.mode}")
|
||||
await self._query_done()
|
||||
|
Reference in New Issue
Block a user