vuongps38770 7c41ddaa82 init
2026-01-13 09:33:10 +07:00
2026-01-13 09:33:10 +07:00
2026-01-13 09:33:10 +07:00
2026-01-13 09:33:10 +07:00
2025-12-25 18:08:22 +07:00
2025-12-25 18:06:29 +07:00
2026-01-13 09:33:10 +07:00
2025-12-25 18:06:29 +07:00
2025-12-25 18:06:29 +07:00
2025-12-25 18:06:29 +07:00
2025-12-25 18:06:29 +07:00

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

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

GET /games

Bật/Tắt game

POST /games/quiz/activate
POST /games/quiz/deactivate

Reload

POST /reload

🎮 THÊM GAME MỚI

  1. Copy src/games/_template.pysrc/games/new_game.py
  2. Sửa nội dung
  3. Gọi POST /reload

BẬT/TẮT GAME

# Trong file game
GAME_CONFIG = {
    "active": True,   # Bật
    "active": False,  # Tắt
}

Hoặc qua API:

curl -X POST http://localhost:8000/games/quiz/deactivate

🚀 Chạy

pip install -r requirements.txt
export GOOGLE_API_KEY=your_key
uvicorn api:app --port 8000
Description
No description provided
Readme 151 KiB
Languages
Python 99.8%
Dockerfile 0.2%