Spaces:
Sleeping
Sleeping
Update pipeline.py
Browse files- pipeline.py +3 -3
pipeline.py
CHANGED
@@ -67,7 +67,7 @@ def classify_query(query: str) -> str:
|
|
67 |
classification = class_result.get("text", "").strip()
|
68 |
return classification if classification != "OutOfScope" else "OutOfScope"
|
69 |
|
70 |
-
# Function to moderate text using Mistral moderation API (
|
71 |
def moderate_text(query: str) -> str:
|
72 |
try:
|
73 |
# Use Pydantic AI to validate the text
|
@@ -165,8 +165,8 @@ async def merge_responses(kb_answer: str, web_answer: str) -> str:
|
|
165 |
|
166 |
# Orchestrate the entire workflow
|
167 |
async def run_async_pipeline(query: str) -> str:
|
168 |
-
# Moderate the query for harmful content (
|
169 |
-
moderated_query =
|
170 |
if moderated_query == "OutOfScope":
|
171 |
return "Sorry, this query contains harmful or inappropriate content."
|
172 |
|
|
|
67 |
classification = class_result.get("text", "").strip()
|
68 |
return classification if classification != "OutOfScope" else "OutOfScope"
|
69 |
|
70 |
+
# Function to moderate text using Mistral moderation API (synchronous version)
|
71 |
def moderate_text(query: str) -> str:
|
72 |
try:
|
73 |
# Use Pydantic AI to validate the text
|
|
|
165 |
|
166 |
# Orchestrate the entire workflow
|
167 |
async def run_async_pipeline(query: str) -> str:
|
168 |
+
# Moderate the query for harmful content (sync)
|
169 |
+
moderated_query = moderate_text(query)
|
170 |
if moderated_query == "OutOfScope":
|
171 |
return "Sorry, this query contains harmful or inappropriate content."
|
172 |
|