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",
|
description="The query text",
|
||||||
)
|
)
|
||||||
|
|
||||||
mode: Literal["local", "global", "hybrid", "naive", "mix"] = Field(
|
mode: Literal["local", "global", "hybrid", "naive", "mix", "bypass"] = Field(
|
||||||
default="hybrid",
|
default="hybrid",
|
||||||
description="Query mode",
|
description="Query mode",
|
||||||
)
|
)
|
||||||
|
@@ -36,7 +36,7 @@ T = TypeVar("T")
|
|||||||
class QueryParam:
|
class QueryParam:
|
||||||
"""Configuration parameters for query execution in LightRAG."""
|
"""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:
|
"""Specifies the retrieval mode:
|
||||||
- "local": Focuses on context-dependent information.
|
- "local": Focuses on context-dependent information.
|
||||||
- "global": Utilizes global knowledge.
|
- "global": Utilizes global knowledge.
|
||||||
|
@@ -1381,6 +1381,14 @@ class LightRAG:
|
|||||||
hashing_kv=self.llm_response_cache, # Directly use llm_response_cache
|
hashing_kv=self.llm_response_cache, # Directly use llm_response_cache
|
||||||
system_prompt=system_prompt,
|
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:
|
else:
|
||||||
raise ValueError(f"Unknown mode {param.mode}")
|
raise ValueError(f"Unknown mode {param.mode}")
|
||||||
await self._query_done()
|
await self._query_done()
|
||||||
|
@@ -65,8 +65,9 @@ export type LightragDocumentsScanProgress = {
|
|||||||
* - "global": Utilizes global knowledge.
|
* - "global": Utilizes global knowledge.
|
||||||
* - "hybrid": Combines local and global retrieval methods.
|
* - "hybrid": Combines local and global retrieval methods.
|
||||||
* - "mix": Integrates knowledge graph and vector retrieval.
|
* - "mix": Integrates knowledge graph and vector retrieval.
|
||||||
|
* - "bypass": Bypasses knowledge retrieval and directly uses the LLM.
|
||||||
*/
|
*/
|
||||||
export type QueryMode = 'naive' | 'local' | 'global' | 'hybrid' | 'mix'
|
export type QueryMode = 'naive' | 'local' | 'global' | 'hybrid' | 'mix' | 'bypass'
|
||||||
|
|
||||||
export type Message = {
|
export type Message = {
|
||||||
role: 'user' | 'assistant' | 'system'
|
role: 'user' | 'assistant' | 'system'
|
||||||
|
@@ -55,6 +55,7 @@ export default function QuerySettings() {
|
|||||||
<SelectItem value="global">{t('retrievePanel.querySettings.queryModeOptions.global')}</SelectItem>
|
<SelectItem value="global">{t('retrievePanel.querySettings.queryModeOptions.global')}</SelectItem>
|
||||||
<SelectItem value="hybrid">{t('retrievePanel.querySettings.queryModeOptions.hybrid')}</SelectItem>
|
<SelectItem value="hybrid">{t('retrievePanel.querySettings.queryModeOptions.hybrid')}</SelectItem>
|
||||||
<SelectItem value="mix">{t('retrievePanel.querySettings.queryModeOptions.mix')}</SelectItem>
|
<SelectItem value="mix">{t('retrievePanel.querySettings.queryModeOptions.mix')}</SelectItem>
|
||||||
|
<SelectItem value="bypass">{t('retrievePanel.querySettings.queryModeOptions.bypass')}</SelectItem>
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
@@ -302,7 +302,8 @@
|
|||||||
"local": "محلي",
|
"local": "محلي",
|
||||||
"global": "عالمي",
|
"global": "عالمي",
|
||||||
"hybrid": "مختلط",
|
"hybrid": "مختلط",
|
||||||
"mix": "مزيج"
|
"mix": "مزيج",
|
||||||
|
"bypass": "تجاوز"
|
||||||
},
|
},
|
||||||
"responseFormat": "تنسيق الرد",
|
"responseFormat": "تنسيق الرد",
|
||||||
"responseFormatTooltip": "يحدد تنسيق الرد. أمثلة:\n• فقرات متعددة\n• فقرة واحدة\n• نقاط نقطية",
|
"responseFormatTooltip": "يحدد تنسيق الرد. أمثلة:\n• فقرات متعددة\n• فقرة واحدة\n• نقاط نقطية",
|
||||||
|
@@ -301,7 +301,8 @@
|
|||||||
"local": "Local",
|
"local": "Local",
|
||||||
"global": "Global",
|
"global": "Global",
|
||||||
"hybrid": "Hybrid",
|
"hybrid": "Hybrid",
|
||||||
"mix": "Mix"
|
"mix": "Mix",
|
||||||
|
"bypass": "Bypass"
|
||||||
},
|
},
|
||||||
"responseFormat": "Response Format",
|
"responseFormat": "Response Format",
|
||||||
"responseFormatTooltip": "Defines the response format. Examples:\n• Multiple Paragraphs\n• Single Paragraph\n• Bullet Points",
|
"responseFormatTooltip": "Defines the response format. Examples:\n• Multiple Paragraphs\n• Single Paragraph\n• Bullet Points",
|
||||||
|
@@ -302,7 +302,8 @@
|
|||||||
"local": "Local",
|
"local": "Local",
|
||||||
"global": "Global",
|
"global": "Global",
|
||||||
"hybrid": "Hybride",
|
"hybrid": "Hybride",
|
||||||
"mix": "Mixte"
|
"mix": "Mixte",
|
||||||
|
"bypass": "Bypass"
|
||||||
},
|
},
|
||||||
"responseFormat": "Format de réponse",
|
"responseFormat": "Format de réponse",
|
||||||
"responseFormatTooltip": "Définit le format de la réponse. Exemples :\n• Plusieurs paragraphes\n• Paragraphe unique\n• Points à puces",
|
"responseFormatTooltip": "Définit le format de la réponse. Exemples :\n• Plusieurs paragraphes\n• Paragraphe unique\n• Points à puces",
|
||||||
|
@@ -302,7 +302,8 @@
|
|||||||
"local": "Local",
|
"local": "Local",
|
||||||
"global": "Global",
|
"global": "Global",
|
||||||
"hybrid": "Hybrid",
|
"hybrid": "Hybrid",
|
||||||
"mix": "Mix"
|
"mix": "Mix",
|
||||||
|
"bypass": "Bypass"
|
||||||
},
|
},
|
||||||
"responseFormat": "响应格式",
|
"responseFormat": "响应格式",
|
||||||
"responseFormatTooltip": "定义响应格式。例如:\n• 多段落\n• 单段落\n• 要点",
|
"responseFormatTooltip": "定义响应格式。例如:\n• 多段落\n• 单段落\n• 要点",
|
||||||
|
Reference in New Issue
Block a user