check point

This commit is contained in:
vuongps38770
2025-12-25 18:06:29 +07:00
commit 31de8b0d84
34 changed files with 3209 additions and 0 deletions

100
README.md Normal file
View File

@@ -0,0 +1,100 @@
# GAME GENERATOR
## 🚀 TỐI ƯU API CALLS
| Trước | Sau |
|-------|-----|
| Analyzer: 1 call | Analyzer: 1 call |
| Generate: N calls (1 per game) | Generate: **1 call** (tất cả games) |
| Validator: N calls | Validator: **0 call** (Python) |
| **Tổng: N+1 calls** | **Tổng: 1-2 calls** |
---
## 📁 Cấu trúc
```
gen_using_graph/
├── api.py # FastAPI server
├── requirements.txt
└── src/
├── core.py # Core engine (tối ưu API calls)
├── game_registry.py # Auto-load games
├── validator.py # Hallucination check (không dùng API)
└── games/ # Game definitions
├── _template.py # Template
├── quiz.py # Quiz game
└── fill_blank.py # Fill-blank game
```
---
## 🔌 API ENDPOINTS
### Generate games
```bash
POST /generate
{
"text": "Văn bản...",
"enabled_games": ["quiz", "fill_blank"],
"run_analyzer": true,
"run_validator": true,
"max_items": 3
}
# Response includes:
# "api_calls": 2 <-- Số lần gọi LLM
```
### Xem games
```bash
GET /games
```
### Bật/Tắt game
```bash
POST /games/quiz/activate
POST /games/quiz/deactivate
```
### Reload
```bash
POST /reload
```
---
## 🎮 THÊM GAME MỚI
1. Copy `src/games/_template.py``src/games/new_game.py`
2. Sửa nội dung
3. Gọi `POST /reload`
---
## ✅ BẬT/TẮT GAME
```python
# Trong file game
GAME_CONFIG = {
"active": True, # Bật
"active": False, # Tắt
}
```
Hoặc qua API:
```bash
curl -X POST http://localhost:8000/games/quiz/deactivate
```
---
## 🚀 Chạy
```bash
pip install -r requirements.txt
export GOOGLE_API_KEY=your_key
uvicorn api:app --port 8000
```