import json from LibLibUtil import LibLibUtil, SAMPLING_METHODS def test_generate_image_with_obs(): """测试generate_image_with_obs方法""" liblib = LibLibUtil() print("===== 测试 generate_image_with_obs 方法 =====") # 加载配置文件 with open('config.json', 'r', encoding='utf-8') as f: config = json.load(f) # 使用第一个模型的配置 first_model = config['models'][0] # 设置生图参数 template_uuid = first_model["template_uuid"] generate_params = { "prompt": first_model["prompt"], "negative_prompt": first_model["negative_prompt"], "steps": first_model["steps"], "width": first_model["width"], "height": first_model["height"], "cfg_scale": first_model["cfgScale"], "sampler_name": first_model["sampler"], "sampler_index": SAMPLING_METHODS[first_model["sampler"]], "seed": first_model["seed"] } print(f"使用模型: {first_model['name']}") print(f"模板UUID: {template_uuid}") # 使用新的generate_image_with_obs方法 file_url = liblib.generate_image_with_obs(template_uuid, generate_params) if file_url: print(f"✅ 生图任务完成,OBS地址: {file_url}") return file_url else: print("❌ 生图任务失败") return None if __name__ == '__main__': # 测试新的方法 test_generate_image_with_obs()