Spaces:
Sleeping
Sleeping
Jonathan Bejarano
commited on
Commit
·
47ded99
1
Parent(s):
77e482a
update diagrams
Browse files
README.md
CHANGED
|
@@ -20,6 +20,22 @@ An interactive geography game where you try to guess the country I'm thinking of
|
|
| 20 |
|
| 21 |
Built with [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
## Features
|
| 24 |
|
| 25 |
- 🎯 20 Questions gameplay format
|
|
|
|
| 20 |
|
| 21 |
Built with [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
| 22 |
|
| 23 |
+
## Architecture
|
| 24 |
+
|
| 25 |
+
The application follows a modular architecture with clear separation between the UI, game logic, and AI inference:
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
|
| 30 |
+
### Key Components:
|
| 31 |
+
|
| 32 |
+
- **Gradio ChatInterface**: Provides the web-based chat UI
|
| 33 |
+
- **Game Logic**: Manages the 20-questions game flow and state
|
| 34 |
+
- **Country Selector**: Randomly selects countries and fetches facts
|
| 35 |
+
- **Response Cleaner**: Processes and formats AI model responses
|
| 36 |
+
- **Dual Mode Support**: Seamlessly switches between local and cloud inference
|
| 37 |
+
- **Facts Fetcher**: Enriches game data with real country information
|
| 38 |
+
|
| 39 |
## Features
|
| 40 |
|
| 41 |
- 🎯 20 Questions gameplay format
|
arch.dot
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```dot
|
| 2 |
+
digraph WorldGeographyArchitecture {
|
| 3 |
+
rankdir=TB;
|
| 4 |
+
node [shape=box, style=rounded];
|
| 5 |
+
|
| 6 |
+
// User Interface Layer
|
| 7 |
+
subgraph cluster_ui {
|
| 8 |
+
label="User Interface Layer";
|
| 9 |
+
style=filled;
|
| 10 |
+
color=lightblue;
|
| 11 |
+
gradio [label="Gradio ChatInterface"];
|
| 12 |
+
oauth [label="HF OAuth\n(Cloud Mode)"];
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
// Application Layer
|
| 16 |
+
subgraph cluster_app {
|
| 17 |
+
label="Application Layer";
|
| 18 |
+
style=filled;
|
| 19 |
+
color=lightgreen;
|
| 20 |
+
|
| 21 |
+
app [label="app.py\nMain Application"];
|
| 22 |
+
game_logic [label="Game Logic\n• Question tracking\n• Response formatting\n• Session management"];
|
| 23 |
+
response_cleaner [label="Response Cleaner\n• JSON parsing\n• Artifact removal\n• Text formatting"];
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// Data Layer
|
| 27 |
+
subgraph cluster_data {
|
| 28 |
+
label="Data Layer";
|
| 29 |
+
style=filled;
|
| 30 |
+
color=lightyellow;
|
| 31 |
+
|
| 32 |
+
countries_db [label="Countries Database\n(COUNTRIES list)"];
|
| 33 |
+
country_selector [label="Country Selector\n• Random selection\n• Session initialization"];
|
| 34 |
+
facts_fetcher [label="Facts Fetcher\n• Web scraping\n• HTML parsing"];
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
// External Services
|
| 38 |
+
subgraph cluster_external {
|
| 39 |
+
label="External Services";
|
| 40 |
+
style=filled;
|
| 41 |
+
color=lightcoral;
|
| 42 |
+
|
| 43 |
+
hf_api [label="HuggingFace\nInference API"];
|
| 44 |
+
local_model [label="Local Model Server\n(LM Studio/Ollama)"];
|
| 45 |
+
travel_guide [label="Kids World Travel Guide\nWebsite"];
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// Environment
|
| 49 |
+
env_vars [label=".env Configuration\n• BASE_URL\n• TOKEN\n• MODEL_NAME", shape=ellipse, style=dashed];
|
| 50 |
+
|
| 51 |
+
// User flow
|
| 52 |
+
user [label="User", shape=ellipse];
|
| 53 |
+
|
| 54 |
+
// Connections
|
| 55 |
+
user -> gradio [label="Interact"];
|
| 56 |
+
gradio -> oauth [label="Authenticate\n(Cloud Mode)"];
|
| 57 |
+
gradio -> app [label="Send Message"];
|
| 58 |
+
|
| 59 |
+
app -> game_logic [label="Process Question"];
|
| 60 |
+
app -> country_selector [label="Initialize Game"];
|
| 61 |
+
app -> response_cleaner [label="Clean Response"];
|
| 62 |
+
|
| 63 |
+
country_selector -> countries_db [label="Select Country"];
|
| 64 |
+
country_selector -> facts_fetcher [label="Fetch Facts"];
|
| 65 |
+
facts_fetcher -> travel_guide [label="Scrape Data"];
|
| 66 |
+
|
| 67 |
+
game_logic -> hf_api [label="Cloud Mode"];
|
| 68 |
+
game_logic -> local_model [label="Local Mode"];
|
| 69 |
+
|
| 70 |
+
env_vars -> app [label="Configure", style=dashed];
|
| 71 |
+
|
| 72 |
+
response_cleaner -> gradio [label="Formatted Response"];
|
| 73 |
+
gradio -> user [label="Display"];
|
| 74 |
+
|
| 75 |
+
// Styling
|
| 76 |
+
user [fillcolor=lightsteelblue, style=filled];
|
| 77 |
+
env_vars [fillcolor=lavender, style="filled,dashed"];
|
| 78 |
+
}
|
| 79 |
+
```
|