Spaces:
Runtime error
Runtime error
Update backend/classes/rag_application.py
Browse files
backend/classes/rag_application.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
import json
|
| 3 |
import time
|
|
|
|
| 4 |
from promptquality import Models
|
| 5 |
from backend.classes.embedding_model import EmbeddingModel
|
| 6 |
from backend.classes.vector_database.milvus_vector_database import MilvusVectorDatabase
|
|
@@ -188,6 +189,7 @@ class RAGApplication:
|
|
| 188 |
# pii_flag["company"] = protect_response["metric_results"]["deutsche_bank_company_pii_0"]["value"]>0.1
|
| 189 |
redacted_result = self.get_redacted_result(result, pii_flag)
|
| 190 |
result = redacted_result.replace("<pii>", "<tag>").replace("</pii>", "</tag>")
|
|
|
|
| 191 |
|
| 192 |
if hallucination_detection:
|
| 193 |
context_adherence_score = protect_response["metric_results"]["context_adherence_luna"]["value"]
|
|
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
import json
|
| 3 |
import time
|
| 4 |
+
import re
|
| 5 |
from promptquality import Models
|
| 6 |
from backend.classes.embedding_model import EmbeddingModel
|
| 7 |
from backend.classes.vector_database.milvus_vector_database import MilvusVectorDatabase
|
|
|
|
| 189 |
# pii_flag["company"] = protect_response["metric_results"]["deutsche_bank_company_pii_0"]["value"]>0.1
|
| 190 |
redacted_result = self.get_redacted_result(result, pii_flag)
|
| 191 |
result = redacted_result.replace("<pii>", "<tag>").replace("</pii>", "</tag>")
|
| 192 |
+
redacted_result = re.sub(r'<pii>(.*?)</pii>', r'<pii>REDACTED</pii>', redacted_result)
|
| 193 |
|
| 194 |
if hallucination_detection:
|
| 195 |
context_adherence_score = protect_response["metric_results"]["context_adherence_luna"]["value"]
|