Spaces:
Sleeping
Sleeping
Shageenderan Sapai commited on
Commit ·
b7b7ad3
1
Parent(s): 5c0f374
Small fix for fetch alerts
Browse files
app/__pycache__/assistants.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/assistants.cpython-312.pyc and b/app/__pycache__/assistants.cpython-312.pyc differ
|
|
|
app/__pycache__/flows.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/flows.cpython-312.pyc and b/app/__pycache__/flows.cpython-312.pyc differ
|
|
|
app/__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/main.cpython-312.pyc and b/app/__pycache__/main.cpython-312.pyc differ
|
|
|
app/__pycache__/user.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/user.cpython-312.pyc and b/app/__pycache__/user.cpython-312.pyc differ
|
|
|
app/__pycache__/utils.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/utils.cpython-312.pyc and b/app/__pycache__/utils.cpython-312.pyc differ
|
|
|
app/main.py
CHANGED
|
@@ -294,11 +294,7 @@ class AssistantItem(BaseModel):
|
|
| 294 |
class ChangeDateItem(BaseModel):
|
| 295 |
user_id: str
|
| 296 |
date: str
|
| 297 |
-
|
| 298 |
-
class UpsellGGItem(BaseModel):
|
| 299 |
-
user_id: str
|
| 300 |
-
day: int
|
| 301 |
-
date: str
|
| 302 |
|
| 303 |
class BookingItem(BaseModel):
|
| 304 |
booking_id: str
|
|
@@ -822,12 +818,12 @@ async def create_user(
|
|
| 822 |
@app.post("/fetch_daily_alert")
|
| 823 |
@catch_endpoint_error
|
| 824 |
async def fetch_daily_alert(
|
| 825 |
-
request:
|
| 826 |
api_key: str = Depends(get_api_key) # Change Security to Depends
|
| 827 |
):
|
| 828 |
logger.info(f"Upselling GG for day: {request.day}", extra={"user_id": request.user_id, "endpoint": "/upsell_gg"})
|
| 829 |
user = get_user(request.user_id)
|
| 830 |
-
response = user.get_alerts(request.
|
| 831 |
return {"response": response}
|
| 832 |
|
| 833 |
@app.post("/chat")
|
|
|
|
| 294 |
class ChangeDateItem(BaseModel):
|
| 295 |
user_id: str
|
| 296 |
date: str
|
| 297 |
+
day: Optional[int] = None,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
class BookingItem(BaseModel):
|
| 300 |
booking_id: str
|
|
|
|
| 818 |
@app.post("/fetch_daily_alert")
|
| 819 |
@catch_endpoint_error
|
| 820 |
async def fetch_daily_alert(
|
| 821 |
+
request: ChangeDateItem,
|
| 822 |
api_key: str = Depends(get_api_key) # Change Security to Depends
|
| 823 |
):
|
| 824 |
logger.info(f"Upselling GG for day: {request.day}", extra={"user_id": request.user_id, "endpoint": "/upsell_gg"})
|
| 825 |
user = get_user(request.user_id)
|
| 826 |
+
response = user.get_alerts(request.date, request.day)
|
| 827 |
return {"response": response}
|
| 828 |
|
| 829 |
@app.post("/chat")
|
app/user.py
CHANGED
|
@@ -620,10 +620,10 @@ class User:
|
|
| 620 |
self.conversations.intro_done = True
|
| 621 |
|
| 622 |
@catch_error
|
| 623 |
-
def get_alerts(self,
|
| 624 |
-
#
|
| 625 |
-
|
| 626 |
-
|
| 627 |
if day == 2 or day == 5:
|
| 628 |
# upsell the GG
|
| 629 |
growth_guide = get_growth_guide(self.user_id)
|
|
@@ -703,12 +703,15 @@ class User:
|
|
| 703 |
timestamp = pd.Timestamp.now().replace(hour=19, minute=0, second=0, microsecond=0).strftime("%d-%m-%Y %a %H:%M:%S")
|
| 704 |
else:
|
| 705 |
return []
|
|
|
|
|
|
|
| 706 |
|
| 707 |
response, run = self.conversations._run_current_thread(prompt, hidden=True)
|
| 708 |
message = run.metadata.get("message", "No message")
|
| 709 |
logger.info(f"Message: {message}", extra={"user_id": self.user_id, "endpoint": "upsell_gg"})
|
| 710 |
|
| 711 |
-
|
|
|
|
| 712 |
return [response]
|
| 713 |
|
| 714 |
@catch_error
|
|
|
|
| 620 |
self.conversations.intro_done = True
|
| 621 |
|
| 622 |
@catch_error
|
| 623 |
+
def get_alerts(self, date, day=None):
|
| 624 |
+
# responses = []
|
| 625 |
+
if day is None:
|
| 626 |
+
day = self.cumulative_plan_day
|
| 627 |
if day == 2 or day == 5:
|
| 628 |
# upsell the GG
|
| 629 |
growth_guide = get_growth_guide(self.user_id)
|
|
|
|
| 703 |
timestamp = pd.Timestamp.now().replace(hour=19, minute=0, second=0, microsecond=0).strftime("%d-%m-%Y %a %H:%M:%S")
|
| 704 |
else:
|
| 705 |
return []
|
| 706 |
+
else:
|
| 707 |
+
return []
|
| 708 |
|
| 709 |
response, run = self.conversations._run_current_thread(prompt, hidden=True)
|
| 710 |
message = run.metadata.get("message", "No message")
|
| 711 |
logger.info(f"Message: {message}", extra={"user_id": self.user_id, "endpoint": "upsell_gg"})
|
| 712 |
|
| 713 |
+
# make timestamp ISO
|
| 714 |
+
response['timestamp'] = pd.to_datetime(timestamp).isoformat()
|
| 715 |
return [response]
|
| 716 |
|
| 717 |
@catch_error
|