Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
130 lines
4.4 KiB
Python
130 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify provider configuration
|
|
"""
|
|
|
|
import os
|
|
|
|
from _bootstrap import add_project_root
|
|
|
|
add_project_root()
|
|
|
|
from agent import ContextAwareAgent, ContextMode
|
|
|
|
def test_providers():
|
|
"""Test different provider configurations"""
|
|
|
|
print("\n" + "="*60)
|
|
print("🧪 PROVIDER CONFIGURATION TEST")
|
|
print("="*60)
|
|
|
|
# Test Alibaba Cloud Model Studio / Bailian
|
|
dashscope_key = os.getenv("DASHSCOPE_API_KEY")
|
|
if dashscope_key:
|
|
print("\n✅ Alibaba Cloud Model Studio API key found")
|
|
try:
|
|
agent = ContextAwareAgent(
|
|
dashscope_key, ContextMode.FULL, provider="dashscope"
|
|
)
|
|
print(f" Provider: {agent.provider}")
|
|
print(f" Model: {agent.model}")
|
|
print(f" Base URL: {agent.client.base_url}")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {str(e)}")
|
|
else:
|
|
print("\n⚠️ Alibaba Cloud Model Studio API key not found (DASHSCOPE_API_KEY)")
|
|
|
|
# Test SiliconFlow
|
|
sf_key = os.getenv("SILICONFLOW_API_KEY")
|
|
if sf_key:
|
|
print("\n✅ SiliconFlow API key found")
|
|
try:
|
|
agent = ContextAwareAgent(sf_key, ContextMode.FULL, provider="siliconflow")
|
|
print(f" Provider: {agent.provider}")
|
|
print(f" Model: {agent.model}")
|
|
print(f" Base URL: {agent.client.base_url}")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {str(e)}")
|
|
else:
|
|
print("\n⚠️ SiliconFlow API key not found (SILICONFLOW_API_KEY)")
|
|
|
|
# Test Doubao
|
|
ark_key = os.getenv("ARK_API_KEY")
|
|
if ark_key:
|
|
print("\n✅ Doubao/ARK API key found")
|
|
try:
|
|
agent = ContextAwareAgent(ark_key, ContextMode.FULL, provider="doubao")
|
|
print(f" Provider: {agent.provider}")
|
|
print(f" Model: {agent.model}")
|
|
print(f" Base URL: {agent.client.base_url}")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {str(e)}")
|
|
else:
|
|
print("\n⚠️ Doubao/ARK API key not found (ARK_API_KEY)")
|
|
|
|
# Test DeepSeek
|
|
deepseek_key = os.getenv("DEEPSEEK_API_KEY")
|
|
if deepseek_key:
|
|
print("\n✅ DeepSeek API key found")
|
|
try:
|
|
agent = ContextAwareAgent(deepseek_key, ContextMode.FULL, provider="deepseek")
|
|
print(f" Provider: {agent.provider}")
|
|
print(f" Model: {agent.model}")
|
|
print(f" Base URL: {agent.client.base_url}")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {str(e)}")
|
|
else:
|
|
print("\n⚠️ DeepSeek API key not found (DEEPSEEK_API_KEY)")
|
|
|
|
# Test custom model
|
|
if sf_key:
|
|
print("\n🔧 Testing custom model specification:")
|
|
try:
|
|
agent = ContextAwareAgent(sf_key, ContextMode.FULL,
|
|
provider="siliconflow",
|
|
model="Qwen/QwQ-32B")
|
|
print(f" Provider: {agent.provider}")
|
|
print(f" Custom Model: {agent.model}")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {str(e)}")
|
|
|
|
print("\n" + "="*60)
|
|
print("Test complete!")
|
|
|
|
# Show usage examples
|
|
print("\n📖 Usage Examples:")
|
|
print("-"*40)
|
|
|
|
if dashscope_key:
|
|
print("\n# Using Qwen directly through Alibaba Cloud Model Studio:")
|
|
print("python main.py --provider dashscope")
|
|
print("python main.py --provider dashscope --model qwen3.7-plus")
|
|
|
|
if sf_key:
|
|
print("\n# Using SiliconFlow:")
|
|
print("python main.py --provider siliconflow")
|
|
print("python main.py --provider siliconflow --model Qwen/QwQ-32B")
|
|
|
|
if ark_key:
|
|
print("\n# Using Doubao:")
|
|
print("python main.py --provider doubao")
|
|
print("python main.py --provider doubao --model doubao-seed-1-6-thinking-250715")
|
|
|
|
if deepseek_key:
|
|
print("\n# Using DeepSeek:")
|
|
print("python main.py --provider deepseek")
|
|
print("python main.py --provider deepseek --model deepseek-v4-pro")
|
|
|
|
if not dashscope_key and not sf_key and not ark_key and not deepseek_key:
|
|
print("\n⚠️ No API keys found. Please set one of:")
|
|
print(" export DASHSCOPE_API_KEY=your_key")
|
|
print(" export SILICONFLOW_API_KEY=your_key")
|
|
print(" export ARK_API_KEY=your_key")
|
|
print(" export DEEPSEEK_API_KEY=your_key")
|
|
|
|
print("\n" + "="*60)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_providers()
|