Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ Key points about Zerodha:
|
|
26 |
|
27 |
Always prioritize user safety, ethical investing practices, and transparent communication. Never provide information that could mislead users or bring disrepute to Zerodha."""
|
28 |
|
29 |
-
# Guardrail functions
|
30 |
def sanitize_input(input_text):
|
31 |
sanitized = re.sub(r'[<>&\']', '', input_text)
|
32 |
return sanitized
|
@@ -57,7 +57,7 @@ def check_response_content(response):
|
|
57 |
return not any(re.search(pattern, response, re.IGNORECASE) for pattern in unauthorized_patterns)
|
58 |
|
59 |
def check_confidence(response):
|
60 |
-
uncertain_phrases = [
|
61 |
return not any(phrase in response for phrase in uncertain_phrases)
|
62 |
|
63 |
def generate_response(prompt):
|
@@ -75,7 +75,7 @@ def post_process_response(response):
|
|
75 |
|
76 |
return response
|
77 |
|
78 |
-
# CrewAI and AutoGen setup
|
79 |
communication_expert_crew = CrewAgent(
|
80 |
role='Communication Expert',
|
81 |
goal='Interpret and rephrase user queries with empathy and respect',
|
@@ -128,7 +128,7 @@ user_proxy = autogen.UserProxyAgent(
|
|
128 |
max_consecutive_auto_reply=1
|
129 |
)
|
130 |
|
131 |
-
# Main function
|
132 |
async def zerodha_support(message, history):
|
133 |
sanitized_message = sanitize_input(message)
|
134 |
|
|
|
26 |
|
27 |
Always prioritize user safety, ethical investing practices, and transparent communication. Never provide information that could mislead users or bring disrepute to Zerodha."""
|
28 |
|
29 |
+
# Guardrail functions
|
30 |
def sanitize_input(input_text):
|
31 |
sanitized = re.sub(r'[<>&\']', '', input_text)
|
32 |
return sanitized
|
|
|
57 |
return not any(re.search(pattern, response, re.IGNORECASE) for pattern in unauthorized_patterns)
|
58 |
|
59 |
def check_confidence(response):
|
60 |
+
uncertain_phrases = ["I'm not sure", "It's possible", "I don't have enough information"]
|
61 |
return not any(phrase in response for phrase in uncertain_phrases)
|
62 |
|
63 |
def generate_response(prompt):
|
|
|
75 |
|
76 |
return response
|
77 |
|
78 |
+
# CrewAI and AutoGen setup
|
79 |
communication_expert_crew = CrewAgent(
|
80 |
role='Communication Expert',
|
81 |
goal='Interpret and rephrase user queries with empathy and respect',
|
|
|
128 |
max_consecutive_auto_reply=1
|
129 |
)
|
130 |
|
131 |
+
# Main function
|
132 |
async def zerodha_support(message, history):
|
133 |
sanitized_message = sanitize_input(message)
|
134 |
|