diff --git a/lightrag/api/routers/query_routes.py b/lightrag/api/routers/query_routes.py
index 600e680e..6fe86f79 100644
--- a/lightrag/api/routers/query_routes.py
+++ b/lightrag/api/routers/query_routes.py
@@ -78,6 +78,11 @@ class QueryRequest(BaseModel):
description="Number of complete conversation turns (user-assistant pairs) to consider in the response context.",
)
+ user_prompt: Optional[str] = Field(
+ default=None,
+ description="User-provided prompt for the query. If provided, this will be used instead of the default value from prompt template.",
+ )
+
@field_validator("query", mode="after")
@classmethod
def query_strip_after(cls, query: str) -> str:
diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts
index 5adeb8be..55046e15 100644
--- a/lightrag_webui/src/api/lightrag.ts
+++ b/lightrag_webui/src/api/lightrag.ts
@@ -101,6 +101,8 @@ export type QueryRequest = {
conversation_history?: Message[]
/** Number of complete conversation turns (user-assistant pairs) to consider in the response context. */
history_turns?: number
+ /** User-provided prompt for the query. If provided, this will be used instead of the default value from prompt template. */
+ user_prompt?: string
}
export type QueryResponse = {
diff --git a/lightrag_webui/src/components/retrieval/QuerySettings.tsx b/lightrag_webui/src/components/retrieval/QuerySettings.tsx
index b51ddc75..735a4190 100644
--- a/lightrag_webui/src/components/retrieval/QuerySettings.tsx
+++ b/lightrag_webui/src/components/retrieval/QuerySettings.tsx
@@ -3,6 +3,7 @@ import { QueryMode, QueryRequest } from '@/api/lightrag'
// Removed unused import for Text component
import Checkbox from '@/components/ui/Checkbox'
import NumberInput from '@/components/ui/NumberInput'
+import Input from '@/components/ui/Input'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'
import {
Select,
@@ -241,6 +242,31 @@ export default function QuerySettings() {
>
+ {/* User Prompt */}
+ <>
+
+
+
+
+
+
+