| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/usr/bin/env python3
- """
- 测试MultimodalEmbedding类的修复
- """
- from services.model.multimodal_embedding import MultimodalEmbedding
- def test_multimodal_embedding_init():
- """测试MultimodalEmbedding实例化"""
- print("=== 测试MultimodalEmbedding实例化 ===")
- try:
- # 尝试实例化MultimodalEmbedding类
- embedding = MultimodalEmbedding()
- print("✓ MultimodalEmbedding实例化成功")
- print(f" 模型提供商: {embedding.model_provider}")
- print(f" 模型名称: {embedding.model_name}")
- return True
- except Exception as e:
- print(f"✗ MultimodalEmbedding实例化失败: {str(e)}")
- return False
- def test_multimodal_embedding_methods():
- """测试MultimodalEmbedding方法"""
- print("\n=== 测试MultimodalEmbedding方法 ===")
- try:
- embedding = MultimodalEmbedding()
-
- # 测试方法是否存在
- methods_to_test = [
- 'get_text_embedding',
- 'get_texts_embedding',
- 'get_image_embedding',
- 'get_multimodal_embedding'
- ]
-
- for method_name in methods_to_test:
- if hasattr(embedding, method_name) and callable(getattr(embedding, method_name)):
- print(f"✓ 方法 {method_name} 存在且可调用")
- else:
- print(f"✗ 方法 {method_name} 不存在或不可调用")
- return False
-
- return True
- except Exception as e:
- print(f"✗ 测试方法存在性失败: {str(e)}")
- return False
- if __name__ == "__main__":
- print("开始测试MultimodalEmbedding修复...")
-
- test1 = test_multimodal_embedding_init()
- test2 = test_multimodal_embedding_methods()
-
- if test1 and test2:
- print("\n🎉 所有测试通过!MultimodalEmbedding修复成功。")
- exit(0)
- else:
- print("\n❌ 测试失败!MultimodalEmbedding修复存在问题。")
- exit(1)
|