From 8a4b3e6bc9cbd71d62cd8cadb65e104f3f305b45 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 13 Sep 2024 01:06:51 -0400 Subject: [PATCH] refac: allow multiple [context] in prompt --- backend/open_webui/apps/rag/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/open_webui/apps/rag/utils.py b/backend/open_webui/apps/rag/utils.py index 22f34c6a9..efa22841d 100644 --- a/backend/open_webui/apps/rag/utils.py +++ b/backend/open_webui/apps/rag/utils.py @@ -239,10 +239,8 @@ def query_collection_with_hybrid_search( def rag_template(template: str, context: str, query: str): 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]'" + if "" in context and "" in context: log.debug( "WARNING: Potential prompt injection attack: the RAG "