Skip to content

feat: LUMINA AI — web chatbot hợp nhất, tự chọn model, đăng nhập Google - #1

Merged
baoduy3108 merged 1 commit into
mainfrom
claude/ai-model-web-search-fv05v2
Jul 6, 2026
Merged

baoduy3108 merged 1 commit into
mainfrom
claude/ai-model-web-search-fv05v2

Conversation

@baoduy3108

@baoduy3108 baoduy3108 commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Description

Thêm thư mục lumina-ai/ — một web chatbot AI độc lập (không đụng đến code spec-kit hiện có), gọi tên LUMINA AI:

  • Auto-Router "bù trừ": người dùng không chọn model — hệ thống tự phân tích câu hỏi và chọn chế độ phù hợp (⚡ nhanh / ✨ cân bằng / 🧠 tư duy sâu / 🔍 tìm kiếm web / 🌌 đỉnh cao tùy chọn), dựa trên Claude API (Opus 4.8 / Sonnet 5 / Haiku 4.5 / Fable 5 tùy chọn).
  • Web search tích hợp qua server tool của Claude, trả trích dẫn nguồn.
  • Độ bền kiểu ChatGPT: circuit breaker + fallback chain (Claude → Gemini → OpenAI nếu có key), cache, rate limit theo người dùng.
  • Đăng nhập Google bắt buộc (Google Identity Services + JWT cookie), lịch sử hội thoại lưu SQLite theo tài khoản.
  • Giao diện chat kiểu GLM (HTML/CSS/JS thuần, không cần build step): dark mode, streaming SSE thật, khối "đang tư duy", trạng thái tìm kiếm, nguồn trích dẫn.
  • Deploy: render.yaml (1-click Render, free tier, hỗ trợ SSE) + Dockerfile; README tiếng Việt đầy đủ 3 bước (lấy API key Claude, tạo Google Client ID, deploy).

Testing

  • Cài đặt pip install -r requirements.txt thành công trong venv sạch
  • pytest tests/ — 10/10 test pass (router intent detection, memory trimming, cache TTL, circuit breaker, rate limiter)
  • Chạy uvicorn app.main:app thật, kiểm tra bằng curl: /health, /api/config, đăng nhập DEV, /api/conversations, chat SSE (báo lỗi rõ ràng khi thiếu ANTHROPIC_API_KEY, đúng như thiết kế)
  • Mở giao diện bằng Chromium (Playwright) — xác nhận màn đăng nhập và màn chat render đúng, router gắn badge chế độ chính xác
  • Chưa test gọi Claude API thật (môi trường phát triển không có ANTHROPIC_API_KEY của chủ repo) — cần điền key thật sau khi merge để kiểm tra đầu-cuối

AI Disclosure

  • Tôi đã sử dụng AI hỗ trợ (mô tả bên dưới)

Toàn bộ code trong lumina-ai/ được viết bởi Claude (Claude Code), dựa trên khung kiến trúc mẫu do chủ repo cung cấp (Router/Circuit Breaker/Cache/Memory/Rate limiter kiểu "Unified AI Core"), viết lại theo Claude API hiện hành và mở rộng thêm auto-router, đăng nhập Google, giao diện chat.


Generated by Claude Code

… web search

Xây dựng từ khung mẫu "Unified AI Core" (Router + Circuit Breaker + Cache +
Memory + Rate limiter + Metrics), viết lại theo Claude API hiện hành:

- Auto-Router "bù trừ": tự chọn chế độ theo câu lệnh (⚡ Haiku 4.5 /
  ✨ Sonnet 5 / 🧠 Opus 4.8 effort cao / 🔍 Opus 4.8 + web search /
  🌌 Fable 5 tùy chọn) — người dùng không cần chọn model
- Claude engine: SDK anthropic chính thức, adaptive thinking, server tools
  web_search_20260209 + web_fetch_20260209, streaming SSE thật, pause_turn,
  refusal + server-side fallbacks cho Fable 5
- Fallback chain claude → gemini → openai với circuit breaker
- Đăng nhập Google bắt buộc (GIS + JWT cookie), lịch sử chat SQLite theo user,
  rate limit token-bucket theo user
- Frontend chat kiểu GLM (HTML/CSS/JS thuần): dark mode, markdown, khối tư duy,
  trạng thái tìm kiếm, trích dẫn nguồn
- Deploy: render.yaml (1-click Render) + Dockerfile; README tiếng Việt đầy đủ
- 10 unit tests (router/memory/cache/breaker/ratelimit) — pass

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
@baoduy3108
baoduy3108 merged commit 967c7e3 into main Jul 6, 2026
baoduy3108 pushed a commit that referenced this pull request Jul 27, 2026
#1 BẢN ĐỒ QUYẾT ĐỊNH: bộ não xuất ```lumina-decision (JSON cây lựa chọn) →
   frontend render cây bấm mở từng nhánh: hệ quả / được / mất-rủi ro / tối ưu
   cho ai + nhánh con (đệ quy). Directive + renderDecisionsIn + CSS.
#2 TRÍ NHỚ DỰ ÁN: cột projects.memory (ALTER) + set_project_memory + PUT nhận
   memory; chat trong project chèn "TRÍ NHỚ DỰ ÁN" vào system prompt (tách khỏi
   chuyện cá nhân). Editor trong Dashboard project.
github#7 FEEDBACK: bảng feedback + POST /api/feedback + feedback_summary; nút 👍/👎
   dưới mỗi câu trả lời (👎 hỏi note). Đo độ hữu dụng theo hành vi thật.
github#10 BRAIN MAP: khuyến khích bộ não dùng Mermaid mindmap cho "bản đồ tri thức/tư
    duy" (tái dùng overlay zoom sẵn có).
Test project-memory + feedback + (goals cũ). E2E trình duyệt: decision map render
3 nhánh (có nhánh con) mở được. 227 test xanh. README.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
baoduy3108 pushed a commit that referenced this pull request Aug 2, 2026
#1 — LUMINA thành API dùng được từ app/script ngoài:
- db.api_keys (lưu HASH sha256, prefix hiển thị) + create/list/delete + user_by_api_key.
- auth.require_api_key: 'Authorization: Bearer lum_…'.
- POST /v1/chat/completions — TƯƠNG THÍCH OpenAI (trỏ SDK OpenAI vào <host>/v1,
  model 'lumina'): định tuyến qua bộ não nhiều tầng, KHÔNG lộ model thật, stream &
  non-stream, tôn trọng hạn mức gói. Quản lý key: POST/GET/DELETE /api/keys.
- Frontend: modal 🔑 API (tạo/sao chép/thu hồi key + ví dụ curl).

#2 — thêm ~30 bộ não phụ MIỄN PHÍ:
- config.OPENROUTER_MODELS (~31 model free: Llama/Qwen/Gemma/DeepSeek/Mistral/Phi…).
- orchestrator đăng ký mỗi model thành engine openrouter-N (như LOCAL_MODELS cho
  Ollama), chèn vào chuỗi free → nay 52 engine, 51 bộ não free (chỉ chạy khi có
  OPENROUTER_API_KEY; engine chết thì fallback tự nhảy). OpenRouterEngine nhận model/name.

324 test pass (API key lifecycle + /v1 + đếm engine).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants