Marco310 commited on
Commit
9092b29
·
1 Parent(s): 63e03d8

Release v1.0.0: Hybrid AI Architecture, Modern UI Overhaul, and Performance Optimizations

Browse files

# 🚀 Major Features: Hybrid AI Architecture
- **Dual-Brain System**: Implemented "Primary Brain" (GPT-4o/Gemini) for complex reasoning and "Acceleration Layer" (Groq/Llama-3) for fast tool execution.
- **Model Allowlist**: Integrated `MODEL_OPTIONS` in `config.py` with tiered selection (Efficiency vs. Flagship).
- **Fast Mode**: Added toggle to offload heavy tasks (Scout/Navigator) to Groq/Llama-3-70B, reducing costs and latency.

# 🎨 UI/UX: Modern Redesign & Workflow
- **Settings Modal Revamp**:
- Redesigned with a "Purple/Gradient" theme for a professional look.
- Split configuration into "Services", "Primary Brain", and "Acceleration" tabs.
- Implemented **Passive Validation**: API keys are validated instantly on blur (Zero-cost check).
- Dynamic visibility: Automatically hides redundant keys based on provider selection.
- **Dashboard Layout**:
- Vertical control bar in the header for better space utilization.
- Repositioned "Stop & Back" button to the right column for better accessibility.
- Enforced white-card styling (`live-report-wrapper`) for Full Reports in Step 3

Files changed (1) hide show
  1. services/validator.py +73 -0
services/validator.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # services/validator.py
2
+ import googlemaps
3
+ import requests
4
+ from google import genai
5
+ from openai import OpenAI
6
+
7
+
8
+ class APIValidator:
9
+
10
+ # 1. Google Maps (ID Only = Free)
11
+ @staticmethod
12
+ def test_google_maps(api_key: str) -> str:
13
+ if not api_key: return "⚠️ Please enter a key first."
14
+ try:
15
+ gmaps = googlemaps.Client(key=api_key)
16
+ # 使用 Taipei 101 ID 測試,只請求 ID 欄位 = 免費 Essentials SKU
17
+ gmaps.place(place_id='ChIJH56c2rarQjQRphD9gvC8BhI', fields=['place_id'])
18
+ return "✅ Google Maps Key is Valid!"
19
+ except Exception as e:
20
+ err = str(e)
21
+ if "REQUEST_DENIED" in err: return "❌ Invalid Key"
22
+ return f"❌ Error: {err.split(':')[0]}"
23
+
24
+ # 2. OpenWeather (原本就是 call API 才會驗證,無法避開,但極便宜)
25
+ @staticmethod
26
+ def test_openweather(api_key: str) -> str:
27
+ if not api_key: return "⚠️ Please enter a key first."
28
+ try:
29
+ # 隨便查個座標
30
+ url = f"https://api.openweathermap.org/data/2.5/weather?lat=25&lon=121&appid={api_key}"
31
+ resp = requests.get(url, timeout=5)
32
+ if resp.status_code == 200: return "✅ OpenWeather Key is Valid!"
33
+ if resp.status_code == 401: return "❌ Invalid Key"
34
+ return f"❌ Error: {resp.status_code}"
35
+ except:
36
+ return "❌ Connection Failed"
37
+
38
+ # 3. LLM (List Models = Free)
39
+ @staticmethod
40
+ def test_llm(provider: str, api_key: str, model_id: str = None) -> str:
41
+ if not api_key: return "⚠️ Please enter a key first."
42
+
43
+ try:
44
+ if provider == "Gemini":
45
+ # Google GenAI: 列出模型是免費的管理操作
46
+ client = genai.Client(api_key=api_key)
47
+ # 試著抓取第一個模型就好,不用全部列出來
48
+ client.models.list()
49
+ return "✅ Gemini Key is Valid!"
50
+
51
+ elif provider == "OpenAI":
52
+ # OpenAI: 列出模型是免費的
53
+ client = OpenAI(api_key=api_key)
54
+ client.models.list()
55
+ return "✅ OpenAI Key is Valid!"
56
+
57
+ elif provider == "Groq":
58
+ # Groq: 相容 OpenAI 介面,列出模型也是免費的
59
+ client = OpenAI(
60
+ api_key=api_key,
61
+ base_url="https://api.groq.com/openai/v1"
62
+ )
63
+ client.models.list()
64
+ return "✅ Groq Key is Valid!"
65
+
66
+ else:
67
+ return "⚠️ Unknown Provider"
68
+
69
+ except Exception as e:
70
+ err = str(e).lower()
71
+ if "401" in err or "invalid_api_key" in err: return "❌ Invalid Key"
72
+ if "429" in err: return "❌ Rate Limit Exceeded" # 雖然免費,但如果按太快還是會擋
73
+ return f"❌ Error: {str(e)[:20]}..."