mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 08:40:58 +00:00
refac: allow multiple [context] in prompt
This commit is contained in:
parent
a9c497612b
commit
8a4b3e6bc9
@ -239,10 +239,8 @@ def query_collection_with_hybrid_search(
|
|||||||
|
|
||||||
def rag_template(template: str, context: str, query: str):
|
def rag_template(template: str, context: str, query: str):
|
||||||
count = template.count("[context]")
|
count = template.count("[context]")
|
||||||
assert (
|
|
||||||
count == 1
|
|
||||||
), f"RAG template contains an unexpected number of '[context]' : {count}"
|
|
||||||
assert "[context]" in template, "RAG template does not contain '[context]'"
|
assert "[context]" in template, "RAG template does not contain '[context]'"
|
||||||
|
|
||||||
if "<context>" in context and "</context>" in context:
|
if "<context>" in context and "</context>" in context:
|
||||||
log.debug(
|
log.debug(
|
||||||
"WARNING: Potential prompt injection attack: the RAG "
|
"WARNING: Potential prompt injection attack: the RAG "
|
||||||
|
Loading…
Reference in New Issue
Block a user