-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add human readable result when there is not LLM studio working
- Loading branch information
1 parent
3552221
commit 85891d2
Showing
4 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from typing import Any | ||
from typing_extensions import TypedDict | ||
from app.models.event_model import Event | ||
|
||
class Answer(TypedDict): | ||
events: list[Event] | ||
weather: str | ||
pois: list[dict[str, Any]] | ||
unesco_sites: list[str] | ||
hotels_motels: list[str] | ||
historic_places: list[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import datetime | ||
|
||
from app.models.event_model import Event | ||
|
||
def generate_ai_style_response(events: list[Event], weather: str) -> str: | ||
# Sort events by priority and pinned status | ||
sorted_events = sorted(events, key=lambda x: (-x.pinned, -x.priority, x.date or datetime.max)) | ||
|
||
# Start the response with the weather | ||
response = f"The weather for the day is expected to be: {weather}.\n\n" | ||
|
||
# Check if there are any events | ||
if not sorted_events: | ||
response += "It seems like there are no events scheduled for now. Maybe take the opportunity to relax or explore something spontaneous!" | ||
else: | ||
response += "Here are some events you might enjoy:\n" | ||
for event in sorted_events: | ||
event_date = ( | ||
f" on {event.date.strftime('%A, %B %d at %I:%M %p')}" if event.date else "" | ||
) | ||
description = "" | ||
|
||
if event.description: | ||
description = f" - {description}" | ||
|
||
response += f"- **{event.name}** at {event.location}{event_date}{description}\n" | ||
return response.strip() |