Create a user message with optional image. Args: text: Text content. image_base64: Optional base64-encoded image. Returns: Message dictionary.
(
text: str, image_base64: str | None = None
)
| 226 | |
| 227 | @staticmethod |
| 228 | def create_user_message( |
| 229 | text: str, image_base64: str | None = None |
| 230 | ) -> dict[str, Any]: |
| 231 | """ |
| 232 | Create a user message with optional image. |
| 233 | |
| 234 | Args: |
| 235 | text: Text content. |
| 236 | image_base64: Optional base64-encoded image. |
| 237 | |
| 238 | Returns: |
| 239 | Message dictionary. |
| 240 | """ |
| 241 | content = [] |
| 242 | |
| 243 | if image_base64: |
| 244 | content.append( |
| 245 | { |
| 246 | "type": "image_url", |
| 247 | "image_url": {"url": f"data:image/png;base64,{image_base64}"}, |
| 248 | } |
| 249 | ) |
| 250 | |
| 251 | content.append({"type": "text", "text": text}) |
| 252 | |
| 253 | return {"role": "user", "content": content} |
| 254 | |
| 255 | @staticmethod |
| 256 | def create_assistant_message(content: str) -> dict[str, Any]: |
no outgoing calls
no test coverage detected