Initial: integrated 2025 LawGraph (graphrag_pipeline) + 2026 kg_project
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
测试硅基流动API并找到可用的模型
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
sys.path = [p for p in sys.path if 'anaconda3' not in p.lower() and 'conda' not in p.lower()]
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from src.utils.config import load_config
|
||||
from src.utils.llm_client import LLMClient, LLMProvider
|
||||
|
||||
# 常见的硅基流动模型名称
|
||||
TEST_MODELS = [
|
||||
"deepseek-ai/DeepSeek-V2.5",
|
||||
"deepseek-ai/DeepSeek-V2",
|
||||
"Qwen/Qwen2.5-72B-Instruct",
|
||||
"Qwen/Qwen2.5-72B-Chat",
|
||||
"meta-llama/Llama-3.1-70B-Instruct",
|
||||
"01-ai/Yi-1.5-34B-Chat",
|
||||
"mistralai/Mistral-7B-Instruct-v0.2",
|
||||
]
|
||||
|
||||
def test_model(provider, model_name):
|
||||
"""测试单个模型"""
|
||||
try:
|
||||
config = load_config()
|
||||
client = LLMClient(provider=provider, model=model_name, config=config)
|
||||
messages = [{"role": "user", "content": "你好"}]
|
||||
response = client.chat(messages)
|
||||
print(f"✅ 模型 {model_name} 可用")
|
||||
print(f" 响应: {response[:50]}...")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ 模型 {model_name} 不可用: {str(e)[:100]}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=" * 60)
|
||||
print("测试硅基流动模型")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
config = load_config()
|
||||
if not config.SILICONFLOW_API_KEY:
|
||||
print("❌ SILICONFLOW_API_KEY 未配置")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"API密钥: {config.SILICONFLOW_API_KEY[:20]}...")
|
||||
print(f"API Base: {config.SILICONFLOW_API_BASE}")
|
||||
print()
|
||||
|
||||
# 测试所有模型
|
||||
available_models = []
|
||||
for model in TEST_MODELS:
|
||||
if test_model(LLMProvider.SILICONFLOW, model):
|
||||
available_models.append(model)
|
||||
print()
|
||||
|
||||
print("=" * 60)
|
||||
if available_models:
|
||||
print(f"✅ 找到 {len(available_models)} 个可用模型:")
|
||||
for model in available_models:
|
||||
print(f" - {model}")
|
||||
print(f"\n建议使用的模型: {available_models[0]}")
|
||||
else:
|
||||
print("❌ 没有找到可用的模型,请检查API密钥或模型名称")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user