Spaces:
Sleeping
Sleeping
add tool for review and account recovery
Browse files
app.py
CHANGED
|
@@ -33,6 +33,141 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def analyze_user_review_tool(review: str) -> str:
|
| 38 |
+
"""
|
| 39 |
+
AI Agent for User Review and Feedback Analysis
|
| 40 |
+
|
| 41 |
+
This AI agent processes and classifies user reviews for "Superstar Teen Patti" into:
|
| 42 |
+
|
| 43 |
+
1. **Bug Reports** - Issues with crashes, errors, or malfunctions.
|
| 44 |
+
2. **Feature Requests** - Suggestions for new features or improvements.
|
| 45 |
+
3. **Support Queries** - Questions about game mechanics or troubleshooting help.
|
| 46 |
+
4. **Negative Feedback** - Strong dissatisfaction with the game experience.
|
| 47 |
+
5. **General Feedback** - Neutral or mixed sentiment without specific issues.
|
| 48 |
+
6. **Real Cash Queries** - Questions about playing with real money or any transaction - related issues that related to real money and related to a financial service or application.
|
| 49 |
+
7. **Transaction Issues** - Complaints about delayed, missing, or failed purchases.
|
| 50 |
+
Example Responses:
|
| 51 |
+
------------------
|
| 52 |
+
- **Bug Report**: "The game crashes frequently."
|
| 53 |
+
*AI Response*: "We're sorry for the issue. Our team is investigating. Could you share more details?"
|
| 54 |
+
|
| 55 |
+
- **Feature Request**: "Can you add a new tournament mode?"
|
| 56 |
+
*AI Response*: "Great idea! We love hearing suggestions. We'll consider it for future updates."
|
| 57 |
+
|
| 58 |
+
- **Support Query**: "How do I earn free chips?"
|
| 59 |
+
*AI Response*: "You can earn free chips through daily rewards, lucky draws, and events!"
|
| 60 |
+
|
| 61 |
+
- **Negative Feedback**: "This game is the worst!"
|
| 62 |
+
*AI Response*: "We're sorry to hear that. Let us know how we can improve your experience."
|
| 63 |
+
|
| 64 |
+
- **General Feedback**: "I've been playing for a while."
|
| 65 |
+
*AI Response*: "Thanks for being a part of Superstar Teen Patti! Let us know if you have any suggestions."
|
| 66 |
+
|
| 67 |
+
- **Real Cash Queries**: "Can I win real money in this game?"
|
| 68 |
+
*AI Response*: "Superstar Teen Patti is an entertainment-based game and does not support real money gambling. It’s meant for fun and enjoyment only."
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
review: A user review or feedback string.
|
| 72 |
+
Returns:
|
| 73 |
+
A categorized response string.
|
| 74 |
+
"""
|
| 75 |
+
review_lower = review.lower()
|
| 76 |
+
|
| 77 |
+
# Keyword-based detection
|
| 78 |
+
categories = {
|
| 79 |
+
"Bug Report": ["bug", "issue", "crash", "error", "not working", "broken", "glitch", "lag"],
|
| 80 |
+
"Feature Request": ["feature", "add", "request", "update", "improve", "new mode", "tournament"],
|
| 81 |
+
"Support Query": [
|
| 82 |
+
"help", "support", "can't", "cannot", "how to", "unable", "stuck", "problem",
|
| 83 |
+
"assist", "assistance", "guide", "guidance", "trouble", "fix", "solution",
|
| 84 |
+
"need help", "failure", "error", "stopped working", "explain", "why"
|
| 85 |
+
],
|
| 86 |
+
"Negative Feedback": ["bad", "terrible", "worst", "hate", "disappointed", "frustrated", "not happy", "poor", "waste", "boring"],
|
| 87 |
+
"Neutral Feedback": ["okay", "fine", "decent", "average", "not bad", "meh"],
|
| 88 |
+
"Real Cash Query": ["withdraw", "cash", "money", "deposit", "payout", "real cash", "bank", "payment", "win real money", "amount lost"],
|
| 89 |
+
"Transaction Issues": ["purchase", "bought", "paid", "transaction", "chips not credited", "waiting for chips", "payment issue", "google pay", "order id", "proof of purchase"],
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
category_priority = [
|
| 93 |
+
"Transaction Issues",
|
| 94 |
+
"Real Cash Query",
|
| 95 |
+
"Bug Report",
|
| 96 |
+
"Support Query",
|
| 97 |
+
"Negative Feedback",
|
| 98 |
+
"Feature Request",
|
| 99 |
+
"Neutral Feedback",
|
| 100 |
+
]
|
| 101 |
+
|
| 102 |
+
detected_categories = {}
|
| 103 |
+
# Check for keyword matches
|
| 104 |
+
for category, keywords in categories.items():
|
| 105 |
+
match_count = sum(1 for word in keywords if word in review_lower)
|
| 106 |
+
if match_count > 0:
|
| 107 |
+
detected_categories[category] = match_count
|
| 108 |
+
|
| 109 |
+
# Assign category based on priority
|
| 110 |
+
if detected_categories:
|
| 111 |
+
category = sorted(detected_categories, key=lambda c: category_priority.index(c))[0]
|
| 112 |
+
else:
|
| 113 |
+
category = "General Feedback"
|
| 114 |
+
|
| 115 |
+
# Predefined responses
|
| 116 |
+
responses = {
|
| 117 |
+
"Transaction Issues": "We understand how frustrating this can be. If your purchased chips have not been credited yet, please ensure you've provided the necessary transaction details, such as the purchase confirmation email or order ID. Our team will review your case and assist you as soon as possible. Thank you for your patience!",
|
| 118 |
+
"Real Cash Query": "Superstar Teen Patti is an entertainment-based game and does not support real money gambling or withdrawals. It's meant for fun and enjoyment only.",
|
| 119 |
+
"Bug Report": "We're sorry you're experiencing issues. Our team is investigating this problem. Could you provide more details so we can resolve it faster?",
|
| 120 |
+
"Support Query": "It looks like you need assistance! Please check our help center or reach out to our support team for immediate help.",
|
| 121 |
+
"Negative Feedback": "We're truly sorry for your experience. Your feedback is important to us, and we're always looking to improve. Please let us know how we can make things better.",
|
| 122 |
+
"Feature Request": "Thanks for your suggestion! We love hearing new ideas. We'll consider this in our upcoming updates.",
|
| 123 |
+
"Neutral Feedback": "Thank you for sharing your thoughts! Your feedback helps us improve the experience for everyone.",
|
| 124 |
+
"General Feedback": "Thank you for playing Superstar Teen Patti! We appreciate your feedback and hope you enjoy the game."
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
return f"Review Category: {category}\n{responses[category]}"
|
| 128 |
+
|
| 129 |
+
@tool
|
| 130 |
+
def account_recovery_tool(username: str = None, email: str = None) -> str:
|
| 131 |
+
"""
|
| 132 |
+
A tool to help users recover their accounts by verifying their username or email.
|
| 133 |
+
|
| 134 |
+
This tool assists users who have forgotten their account details. If the user provides a username, it will check if an associated email exists and send a recovery link. If the user provides an email, it will check for a matching account and return the associated username along with a recovery link.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
username: string optional The username provided by the user. If given, the tool will attempt to find the associated email and send a recovery link.
|
| 138 |
+
email: string optional The email provided by the user. If given, the tool will check for a matching username and send a recovery link.
|
| 139 |
+
|
| 140 |
+
Returns:
|
| 141 |
+
str: A message indicating the recovery status:
|
| 142 |
+
- The associated email will receive a reset link if a valid username is provided.
|
| 143 |
+
- If a valid email is provided, the associated username will be revealed, and a reset link will be sent.
|
| 144 |
+
- If neither is found, a request for a correct email or username is prompted.
|
| 145 |
+
"""
|
| 146 |
+
|
| 147 |
+
# Dummy user data for validation (in real-world use a database) at list 15
|
| 148 |
+
user_database = {
|
| 149 |
+
"user1": "user1@example.com",
|
| 150 |
+
"user2": "user2@example.com",
|
| 151 |
+
"john_doe": "john.doe@example.com",
|
| 152 |
+
"jane_doe": "jane.doe@example.com",
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
if username:
|
| 156 |
+
# Check if the username exists in the database
|
| 157 |
+
if username in user_database:
|
| 158 |
+
return f" Account found for username '{username}'. A password reset link has been sent to {user_database[username]}."
|
| 159 |
+
else:
|
| 160 |
+
return "No account found with that username. Please try again or provide your email for verification."
|
| 161 |
+
|
| 162 |
+
elif email:
|
| 163 |
+
# Search for the email in the database
|
| 164 |
+
for user, user_email in user_database.items():
|
| 165 |
+
if user_email == email:
|
| 166 |
+
return f" Account found for email '{email}'. Your associated username is '{user}'. A password reset link has been sent to your email."
|
| 167 |
+
return "No account found with that email. Please check and try again."
|
| 168 |
+
|
| 169 |
+
else:
|
| 170 |
+
return "Please provide either a username or an email to recover your account."
|
| 171 |
|
| 172 |
final_answer = FinalAnswerTool()
|
| 173 |
|