from typing import List, Dict from config import DEFAULT_SYSTEM_PROMPT def build_messages(frames_b64: List[str], edit_instruction: str) -> list[dict]: """ 多帧图像 + 文本,OpenAI Chat Completions 标准格式: - 每张图一个 {"type":"image_url","image_url":{"url":"data:image/jpeg;base64,..."}} - 文本 {"type":"text","text": "..."} - 放在同一条 user 消息的 content 数组中 """ content_parts = [ {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}} for b64 in frames_b64 ] content_parts.append({"type": "text", "text": edit_instruction}) return [ {"role": "system", "content": [{"type": "text", "text": DEFAULT_SYSTEM_PROMPT}]}, {"role": "user", "content": content_parts} ]