Merge pull request #1546 from danielaskdd/user-prompt
Browse filesThis view is limited to 50 files because it contains too many changes. Β
See raw diff
- lightrag/api/routers/query_routes.py +5 -0
- lightrag/api/webui/assets/{_basePickBy-Dv6p6ahL.js β _basePickBy--_O36kXE.js} +0 -0
- lightrag/api/webui/assets/{_baseUniq-D7fwxRvj.js β _baseUniq-D81M49Y6.js} +0 -0
- lightrag/api/webui/assets/{architectureDiagram-IEHRJDOE-Di0P3qFY.js β architectureDiagram-IEHRJDOE-Ba9Io2eo.js} +0 -0
- lightrag/api/webui/assets/{blockDiagram-JOT3LUYC-CCZHFr5P.js β blockDiagram-JOT3LUYC-Ca9NC-96.js} +0 -0
- lightrag/api/webui/assets/{c4Diagram-VJAJSXHY-DYwH7GIZ.js β c4Diagram-VJAJSXHY-DhTcycAT.js} +0 -0
- lightrag/api/webui/assets/{chunk-4BMEZGHF-WR_wp-oy.js β chunk-4BMEZGHF-M5QBFtoC.js} +0 -0
- lightrag/api/webui/assets/{chunk-A2AXSNBT-dlp4DAcZ.js β chunk-A2AXSNBT-CTXPIZDs.js} +0 -0
- lightrag/api/webui/assets/{chunk-AEK57VVT-DwVcIy50.js β chunk-AEK57VVT-BRJnVklE.js} +0 -0
- lightrag/api/webui/assets/{chunk-D6G4REZN-StK6Rbr_.js β chunk-D6G4REZN-CO4Tk6j6.js} +0 -0
- lightrag/api/webui/assets/{chunk-RZ5BOZE2-DacnBdPn.js β chunk-RZ5BOZE2-vCqEaZEa.js} +0 -0
- lightrag/api/webui/assets/{chunk-XZIHB7SX-BLR4huZX.js β chunk-XZIHB7SX-BjHVUYBP.js} +0 -0
- lightrag/api/webui/assets/{classDiagram-GIVACNV2-DHdZrgr6.js β classDiagram-GIVACNV2-DUFHlr92.js} +0 -0
- lightrag/api/webui/assets/{classDiagram-v2-COTLJTTW-DHdZrgr6.js β classDiagram-v2-COTLJTTW-DUFHlr92.js} +0 -0
- lightrag/api/webui/assets/{clone-bPboWGu0.js β clone-BHIBWXu-.js} +0 -0
- lightrag/api/webui/assets/{dagre-OKDRZEBW-D3I5ukn6.js β dagre-OKDRZEBW-hl_RTy2g.js} +0 -0
- lightrag/api/webui/assets/{diagram-SSKATNLV-BRpwtBhC.js β diagram-SSKATNLV-prPjpZ5y.js} +0 -0
- lightrag/api/webui/assets/{diagram-VNBRO52H-BUxc2-2Y.js β diagram-VNBRO52H-CpzL1-Is.js} +0 -0
- lightrag/api/webui/assets/{erDiagram-Q7BY3M3F-CVZJK2_D.js β erDiagram-Q7BY3M3F-CAraTg_G.js} +0 -0
- lightrag/api/webui/assets/{feature-documents-wtbEF8SC.js β feature-documents-BKQZIcI6.js} +0 -0
- lightrag/api/webui/assets/{feature-graph-n9v7_77L.js β feature-graph-D6-O-kXP.js} +0 -0
- lightrag/api/webui/assets/feature-retrieval-BWPImNx0.js +0 -0
- lightrag/api/webui/assets/feature-retrieval-wTZcnY1B.js +0 -0
- lightrag/api/webui/assets/{flowDiagram-4HSFHLVR-B06tP2Lf.js β flowDiagram-4HSFHLVR-DC7cFb2q.js} +0 -0
- lightrag/api/webui/assets/{ganttDiagram-APWFNJXF-CQRvmtrS.js β ganttDiagram-APWFNJXF-CkKq4NOY.js} +0 -0
- lightrag/api/webui/assets/{gitGraphDiagram-7IBYFJ6S-NQXP3Qqt.js β gitGraphDiagram-7IBYFJ6S-C7t9VG9x.js} +0 -0
- lightrag/api/webui/assets/{graph-oZBbEMHh.js β graph-CmqUPRtj.js} +0 -0
- lightrag/api/webui/assets/{index-CvkPVz55.js β index-m6I92ZpT.js} +0 -0
- lightrag/api/webui/assets/{infoDiagram-PH2N3AL5-WiBZxbTM.js β infoDiagram-PH2N3AL5-C4VRyMR4.js} +0 -0
- lightrag/api/webui/assets/{journeyDiagram-U35MCT3I-BXGb0-DG.js β journeyDiagram-U35MCT3I-YPalBptu.js} +0 -0
- lightrag/api/webui/assets/{kanban-definition-NDS4AKOZ-B5O_e_gP.js β kanban-definition-NDS4AKOZ-DDoftzBy.js} +0 -0
- lightrag/api/webui/assets/{layout-BojIpu1o.js β layout-Klo12PD4.js} +0 -0
- lightrag/api/webui/assets/{mermaid-vendor-DJG80fdk.js β mermaid-vendor-SwnP6Sr8.js} +0 -0
- lightrag/api/webui/assets/{mindmap-definition-ALO5MXBD-TRtI_0iN.js β mindmap-definition-ALO5MXBD-DGAXVsL1.js} +0 -0
- lightrag/api/webui/assets/{pieDiagram-IB7DONF6-COfHI39o.js β pieDiagram-IB7DONF6-B0cIkycz.js} +0 -0
- lightrag/api/webui/assets/{quadrantDiagram-7GDLP6J5-BYCgdChU.js β quadrantDiagram-7GDLP6J5-zmngfYyO.js} +0 -0
- lightrag/api/webui/assets/{radar-MK3ICKWK-BuDReZWo.js β radar-MK3ICKWK-CihkADAx.js} +0 -0
- lightrag/api/webui/assets/{requirementDiagram-KVF5MWMF-D3nMJW_g.js β requirementDiagram-KVF5MWMF-A4JwVpFF.js} +0 -0
- lightrag/api/webui/assets/{sankeyDiagram-QLVOVGJD-B6O7zLhx.js β sankeyDiagram-QLVOVGJD-DkTUSo82.js} +0 -0
- lightrag/api/webui/assets/{sequenceDiagram-X6HHIX6F-BNKLY7TW.js β sequenceDiagram-X6HHIX6F-hDfAwQVw.js} +0 -0
- lightrag/api/webui/assets/{stateDiagram-DGXRK772-DVQpiu6y.js β stateDiagram-DGXRK772-CcL234E-.js} +0 -0
- lightrag/api/webui/assets/{stateDiagram-v2-YXO3MK2T-BHWn8Hav.js β stateDiagram-v2-YXO3MK2T-BnpIGSVY.js} +0 -0
- lightrag/api/webui/assets/{timeline-definition-BDJGKUSR-CAeS47FD.js β timeline-definition-BDJGKUSR-CFveliQS.js} +0 -0
- lightrag/api/webui/assets/{xychartDiagram-VJFVF3MP-DfkirVzk.js β xychartDiagram-VJFVF3MP-5OclOI0o.js} +0 -0
- lightrag/api/webui/index.html +0 -0
- lightrag/base.py +5 -0
- lightrag/operate.py +16 -0
- lightrag/prompt.py +9 -2
- lightrag_webui/src/api/lightrag.ts +2 -0
- lightrag_webui/src/components/retrieval/QuerySettings.tsx +27 -1
lightrag/api/routers/query_routes.py
CHANGED
@@ -78,6 +78,11 @@ class QueryRequest(BaseModel):
|
|
78 |
description="Number of complete conversation turns (user-assistant pairs) to consider in the response context.",
|
79 |
)
|
80 |
|
|
|
|
|
|
|
|
|
|
|
81 |
@field_validator("query", mode="after")
|
82 |
@classmethod
|
83 |
def query_strip_after(cls, query: str) -> str:
|
|
|
78 |
description="Number of complete conversation turns (user-assistant pairs) to consider in the response context.",
|
79 |
)
|
80 |
|
81 |
+
user_prompt: Optional[str] = Field(
|
82 |
+
default=None,
|
83 |
+
description="User-provided prompt for the query. If provided, this will be used instead of the default value from prompt template.",
|
84 |
+
)
|
85 |
+
|
86 |
@field_validator("query", mode="after")
|
87 |
@classmethod
|
88 |
def query_strip_after(cls, query: str) -> str:
|
lightrag/api/webui/assets/{_basePickBy-Dv6p6ahL.js β _basePickBy--_O36kXE.js}
RENAMED
Binary files a/lightrag/api/webui/assets/_basePickBy-Dv6p6ahL.js and b/lightrag/api/webui/assets/_basePickBy--_O36kXE.js differ
|
|
lightrag/api/webui/assets/{_baseUniq-D7fwxRvj.js β _baseUniq-D81M49Y6.js}
RENAMED
Binary files a/lightrag/api/webui/assets/_baseUniq-D7fwxRvj.js and b/lightrag/api/webui/assets/_baseUniq-D81M49Y6.js differ
|
|
lightrag/api/webui/assets/{architectureDiagram-IEHRJDOE-Di0P3qFY.js β architectureDiagram-IEHRJDOE-Ba9Io2eo.js}
RENAMED
Binary files a/lightrag/api/webui/assets/architectureDiagram-IEHRJDOE-Di0P3qFY.js and b/lightrag/api/webui/assets/architectureDiagram-IEHRJDOE-Ba9Io2eo.js differ
|
|
lightrag/api/webui/assets/{blockDiagram-JOT3LUYC-CCZHFr5P.js β blockDiagram-JOT3LUYC-Ca9NC-96.js}
RENAMED
Binary files a/lightrag/api/webui/assets/blockDiagram-JOT3LUYC-CCZHFr5P.js and b/lightrag/api/webui/assets/blockDiagram-JOT3LUYC-Ca9NC-96.js differ
|
|
lightrag/api/webui/assets/{c4Diagram-VJAJSXHY-DYwH7GIZ.js β c4Diagram-VJAJSXHY-DhTcycAT.js}
RENAMED
Binary files a/lightrag/api/webui/assets/c4Diagram-VJAJSXHY-DYwH7GIZ.js and b/lightrag/api/webui/assets/c4Diagram-VJAJSXHY-DhTcycAT.js differ
|
|
lightrag/api/webui/assets/{chunk-4BMEZGHF-WR_wp-oy.js β chunk-4BMEZGHF-M5QBFtoC.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-4BMEZGHF-WR_wp-oy.js and b/lightrag/api/webui/assets/chunk-4BMEZGHF-M5QBFtoC.js differ
|
|
lightrag/api/webui/assets/{chunk-A2AXSNBT-dlp4DAcZ.js β chunk-A2AXSNBT-CTXPIZDs.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-A2AXSNBT-dlp4DAcZ.js and b/lightrag/api/webui/assets/chunk-A2AXSNBT-CTXPIZDs.js differ
|
|
lightrag/api/webui/assets/{chunk-AEK57VVT-DwVcIy50.js β chunk-AEK57VVT-BRJnVklE.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-AEK57VVT-DwVcIy50.js and b/lightrag/api/webui/assets/chunk-AEK57VVT-BRJnVklE.js differ
|
|
lightrag/api/webui/assets/{chunk-D6G4REZN-StK6Rbr_.js β chunk-D6G4REZN-CO4Tk6j6.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-D6G4REZN-StK6Rbr_.js and b/lightrag/api/webui/assets/chunk-D6G4REZN-CO4Tk6j6.js differ
|
|
lightrag/api/webui/assets/{chunk-RZ5BOZE2-DacnBdPn.js β chunk-RZ5BOZE2-vCqEaZEa.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-RZ5BOZE2-DacnBdPn.js and b/lightrag/api/webui/assets/chunk-RZ5BOZE2-vCqEaZEa.js differ
|
|
lightrag/api/webui/assets/{chunk-XZIHB7SX-BLR4huZX.js β chunk-XZIHB7SX-BjHVUYBP.js}
RENAMED
Binary files a/lightrag/api/webui/assets/chunk-XZIHB7SX-BLR4huZX.js and b/lightrag/api/webui/assets/chunk-XZIHB7SX-BjHVUYBP.js differ
|
|
lightrag/api/webui/assets/{classDiagram-GIVACNV2-DHdZrgr6.js β classDiagram-GIVACNV2-DUFHlr92.js}
RENAMED
Binary files a/lightrag/api/webui/assets/classDiagram-GIVACNV2-DHdZrgr6.js and b/lightrag/api/webui/assets/classDiagram-GIVACNV2-DUFHlr92.js differ
|
|
lightrag/api/webui/assets/{classDiagram-v2-COTLJTTW-DHdZrgr6.js β classDiagram-v2-COTLJTTW-DUFHlr92.js}
RENAMED
Binary files a/lightrag/api/webui/assets/classDiagram-v2-COTLJTTW-DHdZrgr6.js and b/lightrag/api/webui/assets/classDiagram-v2-COTLJTTW-DUFHlr92.js differ
|
|
lightrag/api/webui/assets/{clone-bPboWGu0.js β clone-BHIBWXu-.js}
RENAMED
Binary files a/lightrag/api/webui/assets/clone-bPboWGu0.js and b/lightrag/api/webui/assets/clone-BHIBWXu-.js differ
|
|
lightrag/api/webui/assets/{dagre-OKDRZEBW-D3I5ukn6.js β dagre-OKDRZEBW-hl_RTy2g.js}
RENAMED
Binary files a/lightrag/api/webui/assets/dagre-OKDRZEBW-D3I5ukn6.js and b/lightrag/api/webui/assets/dagre-OKDRZEBW-hl_RTy2g.js differ
|
|
lightrag/api/webui/assets/{diagram-SSKATNLV-BRpwtBhC.js β diagram-SSKATNLV-prPjpZ5y.js}
RENAMED
Binary files a/lightrag/api/webui/assets/diagram-SSKATNLV-BRpwtBhC.js and b/lightrag/api/webui/assets/diagram-SSKATNLV-prPjpZ5y.js differ
|
|
lightrag/api/webui/assets/{diagram-VNBRO52H-BUxc2-2Y.js β diagram-VNBRO52H-CpzL1-Is.js}
RENAMED
Binary files a/lightrag/api/webui/assets/diagram-VNBRO52H-BUxc2-2Y.js and b/lightrag/api/webui/assets/diagram-VNBRO52H-CpzL1-Is.js differ
|
|
lightrag/api/webui/assets/{erDiagram-Q7BY3M3F-CVZJK2_D.js β erDiagram-Q7BY3M3F-CAraTg_G.js}
RENAMED
Binary files a/lightrag/api/webui/assets/erDiagram-Q7BY3M3F-CVZJK2_D.js and b/lightrag/api/webui/assets/erDiagram-Q7BY3M3F-CAraTg_G.js differ
|
|
lightrag/api/webui/assets/{feature-documents-wtbEF8SC.js β feature-documents-BKQZIcI6.js}
RENAMED
Binary files a/lightrag/api/webui/assets/feature-documents-wtbEF8SC.js and b/lightrag/api/webui/assets/feature-documents-BKQZIcI6.js differ
|
|
lightrag/api/webui/assets/{feature-graph-n9v7_77L.js β feature-graph-D6-O-kXP.js}
RENAMED
Binary files a/lightrag/api/webui/assets/feature-graph-n9v7_77L.js and b/lightrag/api/webui/assets/feature-graph-D6-O-kXP.js differ
|
|
lightrag/api/webui/assets/feature-retrieval-BWPImNx0.js
DELETED
Binary file (200 kB)
|
|
lightrag/api/webui/assets/feature-retrieval-wTZcnY1B.js
ADDED
Binary file (200 kB). View file
|
|
lightrag/api/webui/assets/{flowDiagram-4HSFHLVR-B06tP2Lf.js β flowDiagram-4HSFHLVR-DC7cFb2q.js}
RENAMED
Binary files a/lightrag/api/webui/assets/flowDiagram-4HSFHLVR-B06tP2Lf.js and b/lightrag/api/webui/assets/flowDiagram-4HSFHLVR-DC7cFb2q.js differ
|
|
lightrag/api/webui/assets/{ganttDiagram-APWFNJXF-CQRvmtrS.js β ganttDiagram-APWFNJXF-CkKq4NOY.js}
RENAMED
Binary files a/lightrag/api/webui/assets/ganttDiagram-APWFNJXF-CQRvmtrS.js and b/lightrag/api/webui/assets/ganttDiagram-APWFNJXF-CkKq4NOY.js differ
|
|
lightrag/api/webui/assets/{gitGraphDiagram-7IBYFJ6S-NQXP3Qqt.js β gitGraphDiagram-7IBYFJ6S-C7t9VG9x.js}
RENAMED
Binary files a/lightrag/api/webui/assets/gitGraphDiagram-7IBYFJ6S-NQXP3Qqt.js and b/lightrag/api/webui/assets/gitGraphDiagram-7IBYFJ6S-C7t9VG9x.js differ
|
|
lightrag/api/webui/assets/{graph-oZBbEMHh.js β graph-CmqUPRtj.js}
RENAMED
Binary files a/lightrag/api/webui/assets/graph-oZBbEMHh.js and b/lightrag/api/webui/assets/graph-CmqUPRtj.js differ
|
|
lightrag/api/webui/assets/{index-CvkPVz55.js β index-m6I92ZpT.js}
RENAMED
Binary files a/lightrag/api/webui/assets/index-CvkPVz55.js and b/lightrag/api/webui/assets/index-m6I92ZpT.js differ
|
|
lightrag/api/webui/assets/{infoDiagram-PH2N3AL5-WiBZxbTM.js β infoDiagram-PH2N3AL5-C4VRyMR4.js}
RENAMED
Binary files a/lightrag/api/webui/assets/infoDiagram-PH2N3AL5-WiBZxbTM.js and b/lightrag/api/webui/assets/infoDiagram-PH2N3AL5-C4VRyMR4.js differ
|
|
lightrag/api/webui/assets/{journeyDiagram-U35MCT3I-BXGb0-DG.js β journeyDiagram-U35MCT3I-YPalBptu.js}
RENAMED
Binary files a/lightrag/api/webui/assets/journeyDiagram-U35MCT3I-BXGb0-DG.js and b/lightrag/api/webui/assets/journeyDiagram-U35MCT3I-YPalBptu.js differ
|
|
lightrag/api/webui/assets/{kanban-definition-NDS4AKOZ-B5O_e_gP.js β kanban-definition-NDS4AKOZ-DDoftzBy.js}
RENAMED
Binary files a/lightrag/api/webui/assets/kanban-definition-NDS4AKOZ-B5O_e_gP.js and b/lightrag/api/webui/assets/kanban-definition-NDS4AKOZ-DDoftzBy.js differ
|
|
lightrag/api/webui/assets/{layout-BojIpu1o.js β layout-Klo12PD4.js}
RENAMED
Binary files a/lightrag/api/webui/assets/layout-BojIpu1o.js and b/lightrag/api/webui/assets/layout-Klo12PD4.js differ
|
|
lightrag/api/webui/assets/{mermaid-vendor-DJG80fdk.js β mermaid-vendor-SwnP6Sr8.js}
RENAMED
Binary files a/lightrag/api/webui/assets/mermaid-vendor-DJG80fdk.js and b/lightrag/api/webui/assets/mermaid-vendor-SwnP6Sr8.js differ
|
|
lightrag/api/webui/assets/{mindmap-definition-ALO5MXBD-TRtI_0iN.js β mindmap-definition-ALO5MXBD-DGAXVsL1.js}
RENAMED
Binary files a/lightrag/api/webui/assets/mindmap-definition-ALO5MXBD-TRtI_0iN.js and b/lightrag/api/webui/assets/mindmap-definition-ALO5MXBD-DGAXVsL1.js differ
|
|
lightrag/api/webui/assets/{pieDiagram-IB7DONF6-COfHI39o.js β pieDiagram-IB7DONF6-B0cIkycz.js}
RENAMED
Binary files a/lightrag/api/webui/assets/pieDiagram-IB7DONF6-COfHI39o.js and b/lightrag/api/webui/assets/pieDiagram-IB7DONF6-B0cIkycz.js differ
|
|
lightrag/api/webui/assets/{quadrantDiagram-7GDLP6J5-BYCgdChU.js β quadrantDiagram-7GDLP6J5-zmngfYyO.js}
RENAMED
Binary files a/lightrag/api/webui/assets/quadrantDiagram-7GDLP6J5-BYCgdChU.js and b/lightrag/api/webui/assets/quadrantDiagram-7GDLP6J5-zmngfYyO.js differ
|
|
lightrag/api/webui/assets/{radar-MK3ICKWK-BuDReZWo.js β radar-MK3ICKWK-CihkADAx.js}
RENAMED
Binary files a/lightrag/api/webui/assets/radar-MK3ICKWK-BuDReZWo.js and b/lightrag/api/webui/assets/radar-MK3ICKWK-CihkADAx.js differ
|
|
lightrag/api/webui/assets/{requirementDiagram-KVF5MWMF-D3nMJW_g.js β requirementDiagram-KVF5MWMF-A4JwVpFF.js}
RENAMED
Binary files a/lightrag/api/webui/assets/requirementDiagram-KVF5MWMF-D3nMJW_g.js and b/lightrag/api/webui/assets/requirementDiagram-KVF5MWMF-A4JwVpFF.js differ
|
|
lightrag/api/webui/assets/{sankeyDiagram-QLVOVGJD-B6O7zLhx.js β sankeyDiagram-QLVOVGJD-DkTUSo82.js}
RENAMED
Binary files a/lightrag/api/webui/assets/sankeyDiagram-QLVOVGJD-B6O7zLhx.js and b/lightrag/api/webui/assets/sankeyDiagram-QLVOVGJD-DkTUSo82.js differ
|
|
lightrag/api/webui/assets/{sequenceDiagram-X6HHIX6F-BNKLY7TW.js β sequenceDiagram-X6HHIX6F-hDfAwQVw.js}
RENAMED
Binary files a/lightrag/api/webui/assets/sequenceDiagram-X6HHIX6F-BNKLY7TW.js and b/lightrag/api/webui/assets/sequenceDiagram-X6HHIX6F-hDfAwQVw.js differ
|
|
lightrag/api/webui/assets/{stateDiagram-DGXRK772-DVQpiu6y.js β stateDiagram-DGXRK772-CcL234E-.js}
RENAMED
Binary files a/lightrag/api/webui/assets/stateDiagram-DGXRK772-DVQpiu6y.js and b/lightrag/api/webui/assets/stateDiagram-DGXRK772-CcL234E-.js differ
|
|
lightrag/api/webui/assets/{stateDiagram-v2-YXO3MK2T-BHWn8Hav.js β stateDiagram-v2-YXO3MK2T-BnpIGSVY.js}
RENAMED
Binary files a/lightrag/api/webui/assets/stateDiagram-v2-YXO3MK2T-BHWn8Hav.js and b/lightrag/api/webui/assets/stateDiagram-v2-YXO3MK2T-BnpIGSVY.js differ
|
|
lightrag/api/webui/assets/{timeline-definition-BDJGKUSR-CAeS47FD.js β timeline-definition-BDJGKUSR-CFveliQS.js}
RENAMED
Binary files a/lightrag/api/webui/assets/timeline-definition-BDJGKUSR-CAeS47FD.js and b/lightrag/api/webui/assets/timeline-definition-BDJGKUSR-CFveliQS.js differ
|
|
lightrag/api/webui/assets/{xychartDiagram-VJFVF3MP-DfkirVzk.js β xychartDiagram-VJFVF3MP-5OclOI0o.js}
RENAMED
Binary files a/lightrag/api/webui/assets/xychartDiagram-VJFVF3MP-DfkirVzk.js and b/lightrag/api/webui/assets/xychartDiagram-VJFVF3MP-5OclOI0o.js differ
|
|
lightrag/api/webui/index.html
CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
|
|
lightrag/base.py
CHANGED
@@ -93,6 +93,11 @@ class QueryParam:
|
|
93 |
This allows using different models for different query modes.
|
94 |
"""
|
95 |
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
@dataclass
|
98 |
class StorageNameSpace(ABC):
|
|
|
93 |
This allows using different models for different query modes.
|
94 |
"""
|
95 |
|
96 |
+
user_prompt: str | None = None
|
97 |
+
"""User-provided prompt for the query.
|
98 |
+
If proivded, this will be use instead of the default vaulue from prompt template.
|
99 |
+
"""
|
100 |
+
|
101 |
|
102 |
@dataclass
|
103 |
class StorageNameSpace(ABC):
|
lightrag/operate.py
CHANGED
@@ -925,11 +925,18 @@ async def kg_query(
|
|
925 |
query_param.conversation_history, query_param.history_turns
|
926 |
)
|
927 |
|
|
|
|
|
|
|
|
|
|
|
|
|
928 |
sys_prompt_temp = system_prompt if system_prompt else PROMPTS["rag_response"]
|
929 |
sys_prompt = sys_prompt_temp.format(
|
930 |
context_data=context,
|
931 |
response_type=query_param.response_type,
|
932 |
history=history_context,
|
|
|
933 |
)
|
934 |
|
935 |
if query_param.only_need_prompt:
|
@@ -1907,11 +1914,18 @@ async def naive_query(
|
|
1907 |
query_param.conversation_history, query_param.history_turns
|
1908 |
)
|
1909 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1910 |
sys_prompt_temp = system_prompt if system_prompt else PROMPTS["naive_rag_response"]
|
1911 |
sys_prompt = sys_prompt_temp.format(
|
1912 |
content_data=text_units_str,
|
1913 |
response_type=query_param.response_type,
|
1914 |
history=history_context,
|
|
|
1915 |
)
|
1916 |
|
1917 |
if query_param.only_need_prompt:
|
@@ -1957,6 +1971,7 @@ async def naive_query(
|
|
1957 |
return response
|
1958 |
|
1959 |
|
|
|
1960 |
async def kg_query_with_keywords(
|
1961 |
query: str,
|
1962 |
knowledge_graph_inst: BaseGraphStorage,
|
@@ -2079,6 +2094,7 @@ async def kg_query_with_keywords(
|
|
2079 |
return response
|
2080 |
|
2081 |
|
|
|
2082 |
async def query_with_keywords(
|
2083 |
query: str,
|
2084 |
prompt: str,
|
|
|
925 |
query_param.conversation_history, query_param.history_turns
|
926 |
)
|
927 |
|
928 |
+
# Build system prompt
|
929 |
+
user_prompt = (
|
930 |
+
query_param.user_prompt
|
931 |
+
if query_param.user_prompt
|
932 |
+
else PROMPTS["DEFAULT_USER_PROMPT"]
|
933 |
+
)
|
934 |
sys_prompt_temp = system_prompt if system_prompt else PROMPTS["rag_response"]
|
935 |
sys_prompt = sys_prompt_temp.format(
|
936 |
context_data=context,
|
937 |
response_type=query_param.response_type,
|
938 |
history=history_context,
|
939 |
+
user_prompt=user_prompt,
|
940 |
)
|
941 |
|
942 |
if query_param.only_need_prompt:
|
|
|
1914 |
query_param.conversation_history, query_param.history_turns
|
1915 |
)
|
1916 |
|
1917 |
+
# Build system prompt
|
1918 |
+
user_prompt = (
|
1919 |
+
query_param.user_prompt
|
1920 |
+
if query_param.user_prompt
|
1921 |
+
else PROMPTS["DEFAULT_USER_PROMPT"]
|
1922 |
+
)
|
1923 |
sys_prompt_temp = system_prompt if system_prompt else PROMPTS["naive_rag_response"]
|
1924 |
sys_prompt = sys_prompt_temp.format(
|
1925 |
content_data=text_units_str,
|
1926 |
response_type=query_param.response_type,
|
1927 |
history=history_context,
|
1928 |
+
user_prompt=user_prompt,
|
1929 |
)
|
1930 |
|
1931 |
if query_param.only_need_prompt:
|
|
|
1971 |
return response
|
1972 |
|
1973 |
|
1974 |
+
# TODO: Deprecated, use user_prompt in QueryParam instead
|
1975 |
async def kg_query_with_keywords(
|
1976 |
query: str,
|
1977 |
knowledge_graph_inst: BaseGraphStorage,
|
|
|
2094 |
return response
|
2095 |
|
2096 |
|
2097 |
+
# TODO: Deprecated, use user_prompt in QueryParam instead
|
2098 |
async def query_with_keywords(
|
2099 |
query: str,
|
2100 |
prompt: str,
|
lightrag/prompt.py
CHANGED
@@ -12,6 +12,8 @@ PROMPTS["DEFAULT_COMPLETION_DELIMITER"] = "<|COMPLETE|>"
|
|
12 |
|
13 |
PROMPTS["DEFAULT_ENTITY_TYPES"] = ["organization", "person", "geo", "event", "category"]
|
14 |
|
|
|
|
|
15 |
PROMPTS["entity_extraction"] = """---Goal---
|
16 |
Given a text document that is potentially relevant to this activity and a list of entity types, identify all entities of those types from the text and all relationships among the identified entities.
|
17 |
Use {language} as output language.
|
@@ -224,7 +226,10 @@ When handling relationships with timestamps:
|
|
224 |
- Ensure the response maintains continuity with the conversation history.
|
225 |
- List up to 5 most important reference sources at the end under "References" section. Clearly indicating whether each source is from Knowledge Graph (KG) or Vector Data (DC), and include the file path if available, in the following format: [KG/DC] file_path
|
226 |
- If you don't know the answer, just say so.
|
227 |
-
- Do not make anything up. Do not include information not provided by the Knowledge Base.
|
|
|
|
|
|
|
228 |
|
229 |
PROMPTS["keywords_extraction"] = """---Role---
|
230 |
|
@@ -322,8 +327,10 @@ When handling content with timestamps:
|
|
322 |
- Ensure the response maintains continuity with the conversation history.
|
323 |
- List up to 5 most important reference sources at the end under "References" section. Clearly indicating each source from Document Chunks(DC), and include the file path if available, in the following format: [DC] file_path
|
324 |
- If you don't know the answer, just say so.
|
325 |
-
- Do not include information not provided by the Document Chunks.
|
|
|
326 |
|
|
|
327 |
|
328 |
PROMPTS[
|
329 |
"similarity_check"
|
|
|
12 |
|
13 |
PROMPTS["DEFAULT_ENTITY_TYPES"] = ["organization", "person", "geo", "event", "category"]
|
14 |
|
15 |
+
PROMPTS["DEFAULT_USER_PROMPT"] = "n/a"
|
16 |
+
|
17 |
PROMPTS["entity_extraction"] = """---Goal---
|
18 |
Given a text document that is potentially relevant to this activity and a list of entity types, identify all entities of those types from the text and all relationships among the identified entities.
|
19 |
Use {language} as output language.
|
|
|
226 |
- Ensure the response maintains continuity with the conversation history.
|
227 |
- List up to 5 most important reference sources at the end under "References" section. Clearly indicating whether each source is from Knowledge Graph (KG) or Vector Data (DC), and include the file path if available, in the following format: [KG/DC] file_path
|
228 |
- If you don't know the answer, just say so.
|
229 |
+
- Do not make anything up. Do not include information not provided by the Knowledge Base.
|
230 |
+
- Addtional user prompt: {user_prompt}
|
231 |
+
|
232 |
+
Response:"""
|
233 |
|
234 |
PROMPTS["keywords_extraction"] = """---Role---
|
235 |
|
|
|
327 |
- Ensure the response maintains continuity with the conversation history.
|
328 |
- List up to 5 most important reference sources at the end under "References" section. Clearly indicating each source from Document Chunks(DC), and include the file path if available, in the following format: [DC] file_path
|
329 |
- If you don't know the answer, just say so.
|
330 |
+
- Do not include information not provided by the Document Chunks.
|
331 |
+
- Addtional user prompt: {user_prompt}
|
332 |
|
333 |
+
Response:"""
|
334 |
|
335 |
PROMPTS[
|
336 |
"similarity_check"
|
lightrag_webui/src/api/lightrag.ts
CHANGED
@@ -101,6 +101,8 @@ export type QueryRequest = {
|
|
101 |
conversation_history?: Message[]
|
102 |
/** Number of complete conversation turns (user-assistant pairs) to consider in the response context. */
|
103 |
history_turns?: number
|
|
|
|
|
104 |
}
|
105 |
|
106 |
export type QueryResponse = {
|
|
|
101 |
conversation_history?: Message[]
|
102 |
/** Number of complete conversation turns (user-assistant pairs) to consider in the response context. */
|
103 |
history_turns?: number
|
104 |
+
/** User-provided prompt for the query. If provided, this will be used instead of the default value from prompt template. */
|
105 |
+
user_prompt?: string
|
106 |
}
|
107 |
|
108 |
export type QueryResponse = {
|
lightrag_webui/src/components/retrieval/QuerySettings.tsx
CHANGED
@@ -3,6 +3,7 @@ import { QueryMode, QueryRequest } from '@/api/lightrag'
|
|
3 |
// Removed unused import for Text component
|
4 |
import Checkbox from '@/components/ui/Checkbox'
|
5 |
import NumberInput from '@/components/ui/NumberInput'
|
|
|
6 |
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'
|
7 |
import {
|
8 |
Select,
|
@@ -28,7 +29,7 @@ export default function QuerySettings() {
|
|
28 |
<Card className="flex shrink-0 flex-col min-w-[220px]">
|
29 |
<CardHeader className="px-4 pt-4 pb-2">
|
30 |
<CardTitle>{t('retrievePanel.querySettings.parametersTitle')}</CardTitle>
|
31 |
-
<CardDescription>{t('retrievePanel.querySettings.parametersDescription')}</CardDescription>
|
32 |
</CardHeader>
|
33 |
<CardContent className="m-0 flex grow flex-col p-0 text-xs">
|
34 |
<div className="relative size-full">
|
@@ -241,6 +242,31 @@ export default function QuerySettings() {
|
|
241 |
</div>
|
242 |
</>
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
{/* Toggle Options */}
|
245 |
<>
|
246 |
<div className="flex items-center gap-2">
|
|
|
3 |
// Removed unused import for Text component
|
4 |
import Checkbox from '@/components/ui/Checkbox'
|
5 |
import NumberInput from '@/components/ui/NumberInput'
|
6 |
+
import Input from '@/components/ui/Input'
|
7 |
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'
|
8 |
import {
|
9 |
Select,
|
|
|
29 |
<Card className="flex shrink-0 flex-col min-w-[220px]">
|
30 |
<CardHeader className="px-4 pt-4 pb-2">
|
31 |
<CardTitle>{t('retrievePanel.querySettings.parametersTitle')}</CardTitle>
|
32 |
+
<CardDescription className="sr-only">{t('retrievePanel.querySettings.parametersDescription')}</CardDescription>
|
33 |
</CardHeader>
|
34 |
<CardContent className="m-0 flex grow flex-col p-0 text-xs">
|
35 |
<div className="relative size-full">
|
|
|
242 |
</div>
|
243 |
</>
|
244 |
|
245 |
+
{/* User Prompt */}
|
246 |
+
<>
|
247 |
+
<TooltipProvider>
|
248 |
+
<Tooltip>
|
249 |
+
<TooltipTrigger asChild>
|
250 |
+
<label htmlFor="user_prompt" className="ml-1 cursor-help">
|
251 |
+
{t('retrievePanel.querySettings.userPrompt')}
|
252 |
+
</label>
|
253 |
+
</TooltipTrigger>
|
254 |
+
<TooltipContent side="left">
|
255 |
+
<p>{t('retrievePanel.querySettings.userPromptTooltip')}</p>
|
256 |
+
</TooltipContent>
|
257 |
+
</Tooltip>
|
258 |
+
</TooltipProvider>
|
259 |
+
<div>
|
260 |
+
<Input
|
261 |
+
id="user_prompt"
|
262 |
+
value={querySettings.user_prompt}
|
263 |
+
onChange={(e) => handleChange('user_prompt', e.target.value)}
|
264 |
+
placeholder={t('retrievePanel.querySettings.userPromptPlaceholder')}
|
265 |
+
className="h-9"
|
266 |
+
/>
|
267 |
+
</div>
|
268 |
+
</>
|
269 |
+
|
270 |
{/* Toggle Options */}
|
271 |
<>
|
272 |
<div className="flex items-center gap-2">
|