import sys import os from PIL import Image # 添加项目根目录到Python路径 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from model.multimodal_embedding import Embedding from conf.config import ModelConfig def main(): """测试主函数""" print("开始测试VL嵌入...") print("=" * 50) # 初始化OpenAIEmbedding模型 embedding_model = Embedding("qwen2.5-vl-embedding", "sk-bc0f1026a41c4c92beb014be8973e4e2") # 图片 image_path = r"D:\project\work\ragflow_plugs\book\output\temp\美美.png" # 检查图片文件是否存在 if not os.path.exists(image_path): print(f"图片文件不存在: {image_path}") return try: # 打开图像文件 image = Image.open(image_path) text = "美美" res = embedding_model.get_multimodal_embedding(text, image) print(f"图片embedding值: {res}") except Exception as e: print(f"测试失败: {str(e)}") print("=" * 50) if __name__ == "__main__": main()