移除不存在的備用端點

變更內容:
- 從 llama_chat.py 移除備用端點配置
- 從 llama_full_api.py 移除備用端點配置
- 簡化端點測試邏輯
- 更新所有文檔移除備用端點說明
- 專注於實際存在的三個端點:
  * https://llama.theaken.com/v1
  * https://llama.theaken.com/v1/gpt-oss-120b
  * https://llama.theaken.com/v1/deepseek-r1-671b

程式結構更清晰,移除虛假的備用選項。
This commit is contained in:
2025-09-19 22:09:15 +08:00
parent 3c0fba5fc8
commit 390a8cc7f7
4 changed files with 25 additions and 80 deletions

View File

@@ -33,19 +33,7 @@ ENDPOINTS = [
}
]
# 備用外網端點(如果主要端點無法使用
BACKUP_ENDPOINTS = [
{
"name": "備用端點 1",
"url": "https://api.llama.theaken.com/v1",
"models": ["gpt-oss-120b", "deepseek-r1-671b", "qwen3-embedding-8b"]
},
{
"name": "備用端點 2",
"url": "https://llama-api.theaken.com/v1",
"models": ["gpt-oss-120b", "deepseek-r1-671b", "qwen3-embedding-8b"]
}
]
# 外網 API 端點配置(僅包含實際存在的端點
def clean_response(text):
"""清理 AI 回應中的特殊標記"""
@@ -112,21 +100,13 @@ def test_endpoint(endpoint_info, timeout=10):
def find_working_endpoint():
"""尋找可用的端點"""
print("\n正在測試外網端點...")
print("\n正在測試可用端點...")
print("-" * 50)
# 先測試主要端點
print("主要端點:")
for endpoint in ENDPOINTS:
if test_endpoint(endpoint):
return endpoint
# 如果主要端點都不可用,測試備用端點
print("\n備用端點:")
for endpoint in BACKUP_ENDPOINTS:
if test_endpoint(endpoint):
return endpoint
return None
def chat_session(endpoint_info):
@@ -239,16 +219,16 @@ def main():
if not working_endpoint:
print("\n" + "="*60)
print("錯誤:無法連接到任何外網端點")
print("錯誤:無法連接到任何 API 端點")
print("="*60)
print("\n可能的原因:")
print("1. 外網 API 伺服器暫時離線")
print("1. API 伺服器暫時離線")
print("2. 網路連接問題")
print("3. 防火牆或代理設定")
print("\n建議:")
print("1. 稍後再試10-30分鐘後")
print("2. 檢查網路連接")
print("3. 聯繫 API 管理員")
print("3. 確認可以訪問 https://llama.theaken.com")
sys.exit(1)
print("\n" + "="*60)