NarratoAI/app/services/llm/test_openai_compatible_integration.py
linyq 3396644593 feat: 移除 LiteLLM 依赖并迁移至 OpenAI 兼容接口
- 移除 LiteLLM 相关代码和依赖,改用原生 OpenAI 兼容接口
- 重构 LLM 服务提供商注册逻辑,仅支持 OpenAI 兼容接口
- 更新配置文件和文档,移除 LiteLLM 相关说明
- 添加新的测试用例验证 OpenAI 兼容接口集成
- 更新 WebUI 组件以适配新的 OpenAI 兼容接口
2026-03-27 23:49:58 +08:00

36 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
OpenAI 兼容接口集成测试脚本
用于快速检查统一 LLM Provider 是否注册成功。
"""
from loguru import logger
from app.services.llm.manager import LLMServiceManager
from app.services.llm.providers import register_all_providers
def test_provider_registration() -> bool:
"""检查 OpenAI 兼容 provider 是否注册成功。"""
logger.info("测试Provider 注册检查")
register_all_providers()
vision_providers = LLMServiceManager.list_vision_providers()
text_providers = LLMServiceManager.list_text_providers()
assert "openai" in vision_providers, "❌ OpenAI 兼容 Vision Provider 未注册"
assert "openai" in text_providers, "❌ OpenAI 兼容 Text Provider 未注册"
logger.success("✅ OpenAI 兼容 providers 已成功注册")
return True
if __name__ == "__main__":
try:
ok = test_provider_registration()
if ok:
logger.success("\n🎉 集成检查通过")
except Exception as exc:
logger.error(f"\n❌ 集成检查失败: {exc}")
raise