import sys import os from PIL import Image # 添加项目根目录到Python路径 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from services.model.multimodal_embedding import MultimodalEmbedding from conf.config import ModelConfig def main(): """测试主函数""" print("开始测试VL嵌入...") print("=" * 50) # 初始化OpenAIEmbedding模型 embedding_model = MultimodalEmbedding("qwen2.5-vl-embedding", "sk-bc0f1026a41c4c92beb014be8973e4e2") # 图片 image_path = r"D:\project\work\ragflow_plugs\book\output\temp\不一样的卡梅拉1-我想去看海_12.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()