This commit is contained in:
2025-08-20 10:14:11 +08:00
parent d03274eeb2
commit 3fb398d6a3

View File

@@ -26,7 +26,7 @@ payload = {
'type': 'image_url' 'type': 'image_url'
}, },
{ {
'text': '图片主要讲了什么?', 'text': '以这张图片为首帧帮我生成一个5秒的视频提示词。提示词包括镜号、运镜、画面内容',
'type': 'text' 'type': 'text'
} }
], ],
@@ -45,7 +45,21 @@ try:
# 解析响应数据 # 解析响应数据
result = response.json() result = response.json()
print('请求成功:') print('请求成功:')
print(json.dumps(result, ensure_ascii=False, indent=2))
# 提取choices[0].message.content的内容
if 'choices' in result and len(result['choices']) > 0:
choice = result['choices'][0]
if 'message' in choice and 'content' in choice['message']:
content = choice['message']['content']
print('提取的内容:')
print(content)
# 这里可以添加对content的进一步处理逻辑
# 例如保存到文件、解析表格内容等
else:
print('响应中未找到message或content字段')
else:
print('响应中未找到choices字段或choices为空')
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print(f'请求发生错误: {e}') print(f'请求发生错误: {e}')