refactor: 新增 ui.js 和 main.js 模組,啟用 ES6 Modules
新增檔案: - js/ui.js - UI 操作、模組切換、預覽更新、表單資料收集 - js/main.js - 主程式初始化、事件監聽器設置、快捷鍵 更新檔案: - index.html - 引用 ES6 模組 (type="module") 功能: ✅ 模組切換功能 ✅ 標籤頁切換 ✅ 表單欄位監聽 ✅ JSON 預覽更新 ✅ 快捷鍵支援 (Ctrl+S, Ctrl+N) ✅ 用戶信息載入 ✅ 登出功能 注意: - 大部分 JavaScript 代碼仍在 HTML 中(約 2400 行) - 已建立核心模組架構,便於後續逐步遷移 - 使用 ES6 Modules,需要通過 HTTP Server 運行 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
70
test_ollama.py
Normal file
70
test_ollama.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Test Ollama API integration
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import urllib3
|
||||
|
||||
# Disable SSL warnings
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
API_URL = "https://ollama_pjapi.theaken.com"
|
||||
|
||||
print("=" * 60)
|
||||
print("Testing Ollama API Connection")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
# Test 1: List models
|
||||
print("Test 1: Listing available models...")
|
||||
try:
|
||||
response = requests.get(f"{API_URL}/v1/models", timeout=10, verify=False)
|
||||
print(f"Status Code: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
models = data.get('data', [])
|
||||
print(f"Found {len(models)} models:")
|
||||
for model in models[:5]:
|
||||
print(f" - {model.get('id', 'Unknown')}")
|
||||
else:
|
||||
print(f"Error: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
|
||||
print()
|
||||
|
||||
# Test 2: Chat completion
|
||||
print("Test 2: Testing chat completion...")
|
||||
try:
|
||||
chat_request = {
|
||||
"model": "qwen2.5:3b",
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Say hello in Chinese."}
|
||||
],
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 50
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
f"{API_URL}/v1/chat/completions",
|
||||
json=chat_request,
|
||||
headers={'Content-Type': 'application/json'},
|
||||
timeout=60,
|
||||
verify=False
|
||||
)
|
||||
|
||||
print(f"Status Code: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
text = result['choices'][0]['message']['content']
|
||||
print(f"Response: {text}")
|
||||
else:
|
||||
print(f"Error: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user