Public
Edited
Jun 4
Insert cell
flowchart TD
Start(["User Types Message"]) --> Router{"Router LLM GPT-3.5-turbo"}
Router -- "Availability/Prices/Bookings" --> SQL["SQL Tool"]
Router -- "Hotel Info/Amenities/Policies" --> Vector["Vector Tool"]
Router -- "Book a room" --> Booking["Booking Tool"]
Router -- "General Chat/Pleasantries" --> Chat["Chat Tool"]
%% SQL Tool Flow
SQL --> SQLPrompt["LLM: Natural Language to SQL"]
SQLPrompt --> Database[("MySQL Database - bookings, rooms")]
Database --> SQLExplain["LLM: SQL Results to Explanation"]
SQLExplain --> SQLResponse["SQL Response"]
%% Vector Tool Flow
Vector --> QueryProcessing["LLM: Query Enhancement and Context Integration"]
QueryProcessing --> VectorSearch["Pinecone Vector Search - similarity_search_with_score"]
VectorSearch --> VectorStore[("Vector Database - Hotel Documentation")]
VectorStore --> PythonProcessing["Python Processing - Filtering, Deduplication, Boosting"]
PythonProcessing --> VectorLLM["LLM: Retrieved Documents to Answer"]
VectorLLM --> VectorResponse["Vector Response"]
%% Booking Flow
Booking --> BookingUI["Show Booking Form"]
BookingUI --> BookingComplete{"Booking Completed?"}
BookingComplete -- "Yes" --> ConflictCheck["Check Room Availability and Date Conflicts"]
ConflictCheck --> BookingNumberGen["Generate Booking Number BKG-YYYYMMDD-XXXX"]
BookingNumberGen --> BookingDB["Store Booking in MySQL with Generated Number"]
BookingComplete -- "No" --> FormActive["Form Stays Active - User can manually close"]
%% Post-Booking Flow
BookingDB --> EmailSend["Send Confirmation Email - Booking details to guest"]
BookingDB --> FollowUpCreation["Create Follow-up Message - Hardcoded Template"]
FollowUpCreation --> FollowUpQuestion["Send Follow-up Question - Would you like activity recommendations?"]
FollowUpQuestion --> AwaitingResponse["Set awaiting_activity_consent = True"]
%% Follow-up Response Flow
AwaitingResponse --> UserResponse(["User Responds to Follow-up"])
UserResponse --> IntentClassification["LLM: Intent Classification - POSITIVE/NEGATIVE/UNCLEAR"]
IntentClassification --> FollowUpIntent{"User Wants Activities?"}
FollowUpIntent -- "Yes POSITIVE" --> LoadFacts["Load hotel_facts.txt - Activity information"]
FollowUpIntent -- "No NEGATIVE" --> FollowUpDecline["No problem response"]
FollowUpIntent -- "Unclear" --> FollowUpClarify["Clarification request"]
LoadFacts --> FollowUpLLM["LLM: Facts to Activity Suggestions with strict prompt rules"]
FollowUpLLM --> ActivityResponse["Activity Suggestions Response"]
%% Reset Follow-up State
FollowUpDecline --> ResetState["Reset awaiting_activity_consent = False"]
ActivityResponse --> ResetState
FollowUpClarify --> ResetState
%% Chat Tool Flow
Chat --> StaticFiles["Load hotel_facts.txt"]
StaticFiles --> ChatLLM["LLM: Facts to Friendly Response"]
ChatLLM --> ChatResponse["Chat Response"]
%% Memory Integration
SQLResponse --> Memory["Save to Conversation Memory - ConversationSummaryMemory"]
VectorResponse --> Memory
ChatResponse --> Memory
ActivityResponse --> Memory
FollowUpDecline --> Memory
FollowUpClarify --> Memory
%% UI Display
Memory --> Display["Display in Chat UI - Chat Bubbles, Forms, Confirmations"]
%% Session State Management
SessionState["Session State - booking_mode, chat_history, memory, awaiting_activity_consent, latest_booking_info"] -.-> Router
SessionState -.-> BookingUI
SessionState -.-> Display
SessionState -.-> AwaitingResponse
SessionState -.-> IntentClassification

%% Class Assignments
Start:::user
UserResponse:::user
Router:::router
FollowUpIntent:::router
BookingComplete:::router
IntentClassification:::llm
SQL:::tools
Vector:::tools
Booking:::tools
Chat:::tools
VectorSearch:::tools
SQLPrompt:::llm
QueryProcessing:::llm
SQLExplain:::llm
VectorLLM:::llm
FollowUpLLM:::llm
ChatLLM:::llm
Database:::data
VectorStore:::data
StaticFiles:::data
LoadFacts:::data
BookingDB:::data
ConflictCheck:::data
Memory:::memory
Display:::ui
SessionState:::state
BookingUI:::ui
FormActive:::ui
PythonProcessing:::tools
BookingNumberGen:::tools
FollowUpCreation:::tools
AwaitingResponse:::state
ResetState:::state
SQLResponse:::response
VectorResponse:::response
ChatResponse:::response
ActivityResponse:::response
FollowUpDecline:::response
FollowUpClarify:::response
EmailSend:::response
FollowUpQuestion:::response

classDef user fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff
classDef router fill:#e74c3c,stroke:#c0392b,stroke-width:3px,color:#fff
classDef tools fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#fff
classDef llm fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff
classDef data fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px,color:#fff
classDef memory fill:#f1c40f,stroke:#d4ac0d,stroke-width:2px,color:#000
classDef ui fill:#2ecc71,stroke:#27ae60,stroke-width:2px,color:#fff
classDef state fill:#34495e,stroke:#2c3e50,stroke-width:1px,color:#fff
classDef response fill:#16a085,stroke:#138d75,stroke-width:2px,color:#fff
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more