backup: 完成 HR_position_ 表格前綴重命名與欄位對照表整理
變更內容: - 所有資料表加上 HR_position_ 前綴 - 整理完整欄位顯示名稱與 ID 對照表 - 模組化 JS 檔案 (admin.js, ai.js, csv.js 等) - 專案結構優化 (docs/, scripts/, tests/ 等) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
62
tests/test_deepseek_reasoner.py
Normal file
62
tests/test_deepseek_reasoner.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
Test deepseek-reasoner model on Ollama API
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import urllib3
|
||||
import sys
|
||||
import codecs
|
||||
|
||||
# Set UTF-8 encoding for output
|
||||
if sys.platform == 'win32':
|
||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
|
||||
|
||||
# Disable SSL warnings
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
API_URL = "https://ollama_pjapi.theaken.com"
|
||||
|
||||
print("=" * 60)
|
||||
print("Testing deepseek-reasoner model")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
# Test chat completion with deepseek-reasoner
|
||||
print("Sending test prompt to deepseek-reasoner...")
|
||||
try:
|
||||
chat_request = {
|
||||
"model": "deepseek-reasoner",
|
||||
"messages": [
|
||||
{"role": "user", "content": "請用中文簡單地說明什麼是人工智慧"}
|
||||
]
|
||||
}
|
||||
|
||||
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("\nResponse:")
|
||||
print("-" * 60)
|
||||
print(text)
|
||||
print("-" * 60)
|
||||
|
||||
# Save to file
|
||||
with open('deepseek_reasoner_output.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(text)
|
||||
print("\n✓ Response saved to: deepseek_reasoner_output.txt")
|
||||
else:
|
||||
print(f"Error: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
70
tests/test_ollama.py
Normal file
70
tests/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)
|
||||
79
tests/test_ollama2.py
Normal file
79
tests/test_ollama2.py
Normal file
@@ -0,0 +1,79 @@
|
||||
"""
|
||||
Test Ollama API with different parameters
|
||||
"""
|
||||
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 Chat Completion - Variant Tests")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
# Test 1: Using qwen2.5:72b (actual available model)
|
||||
print("Test 1: Using qwen2.5:72b model...")
|
||||
try:
|
||||
chat_request = {
|
||||
"model": "qwen2.5:72b",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Say hello in Chinese."}
|
||||
]
|
||||
}
|
||||
|
||||
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"Success! Response: {text}")
|
||||
else:
|
||||
print(f"Error: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
|
||||
print()
|
||||
|
||||
# Test 2: Try deepseek-chat model
|
||||
print("Test 2: Using deepseek-chat model...")
|
||||
try:
|
||||
chat_request = {
|
||||
"model": "deepseek-chat",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Say hello in Chinese."}
|
||||
]
|
||||
}
|
||||
|
||||
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"Success! Response: {text}")
|
||||
else:
|
||||
print(f"Error: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
110
tests/test_ollama_final.py
Normal file
110
tests/test_ollama_final.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""
|
||||
Final Ollama API Integration Test
|
||||
Tests the integration with the Flask app
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Set UTF-8 encoding for output
|
||||
if sys.platform == 'win32':
|
||||
import codecs
|
||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
|
||||
|
||||
print("=" * 60)
|
||||
print("Ollama API Integration Test (via Flask App)")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
# Test 1: Test Ollama connection status
|
||||
print("Test 1: Checking Ollama API configuration...")
|
||||
try:
|
||||
response = requests.get("http://localhost:5000/api/llm/config", timeout=10)
|
||||
if response.status_code == 200:
|
||||
config = response.json()
|
||||
ollama_config = config.get('ollama', {})
|
||||
print(f" Name: {ollama_config.get('name', 'N/A')}")
|
||||
print(f" Enabled: {ollama_config.get('enabled', False)}")
|
||||
print(f" Endpoint: {ollama_config.get('endpoint', 'N/A')}")
|
||||
print(" Status: ✓ Configuration OK")
|
||||
else:
|
||||
print(f" Status: ✗ Error {response.status_code}")
|
||||
except Exception as e:
|
||||
print(f" Status: ✗ Error: {str(e)}")
|
||||
|
||||
print()
|
||||
|
||||
# Test 2: Generate text using Ollama
|
||||
print("Test 2: Testing text generation with Ollama...")
|
||||
try:
|
||||
payload = {
|
||||
"api": "ollama",
|
||||
"prompt": "請用中文回答:你好嗎?",
|
||||
"max_tokens": 100
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/llm/generate",
|
||||
json=payload,
|
||||
headers={'Content-Type': 'application/json'},
|
||||
timeout=60
|
||||
)
|
||||
|
||||
print(f" Status Code: {response.status_code}")
|
||||
|
||||
result = response.json()
|
||||
|
||||
if result.get('success'):
|
||||
text = result.get('text', '')
|
||||
print(f" Status: ✓ Generation successful")
|
||||
print(f" Response length: {len(text)} characters")
|
||||
print(f" Response preview: {text[:100]}...")
|
||||
|
||||
# Save full response to file
|
||||
with open('ollama_response.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(text)
|
||||
print(f" Full response saved to: ollama_response.txt")
|
||||
else:
|
||||
error = result.get('error', 'Unknown error')
|
||||
print(f" Status: ✗ Generation failed")
|
||||
print(f" Error: {error}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" Status: ✗ Error: {str(e)}")
|
||||
|
||||
print()
|
||||
|
||||
# Test 3: Test with English prompt
|
||||
print("Test 3: Testing with English prompt...")
|
||||
try:
|
||||
payload = {
|
||||
"api": "ollama",
|
||||
"prompt": "Write a haiku about coding.",
|
||||
"max_tokens": 100
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/llm/generate",
|
||||
json=payload,
|
||||
headers={'Content-Type': 'application/json'},
|
||||
timeout=60
|
||||
)
|
||||
|
||||
result = response.json()
|
||||
|
||||
if result.get('success'):
|
||||
text = result.get('text', '')
|
||||
print(f" Status: ✓ Generation successful")
|
||||
print(f" Response:\n{text}")
|
||||
else:
|
||||
error = result.get('error', 'Unknown error')
|
||||
print(f" Status: ✗ Generation failed")
|
||||
print(f" Error: {error}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" Status: ✗ Error: {str(e)}")
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("Integration test completed!")
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user