#!/usr/bin/env python3
"""
Generated test file for Vision LLM Test
Framework: openai
Execution mode: async
Streaming: yes"""

import os
import sentry_sdk
import asyncio

from openai import AsyncOpenAI


sentry_sdk.init(
    dsn=os.environ.get("SENTRY_DSN"),
    traces_sample_rate=1.0,
    send_default_pii=True,
    stream_gen_ai_spans=True,
)

client = AsyncOpenAI()

async def main():
    # Turn 1
    stream = await client.responses.create(
        model="gpt-4o-mini",
        instructions="You are a helpful assistant that can analyze images. Be concise.",
        input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "What color is this image? Reply with just the color name."},
                {"type": "input_image", "image_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8z8BQz0AEYBxVSF+FABJADveWkH6oAAAAAElFTkSuQmCC"},
            ]
        },
    ]
,
        stream=True,
    )

    collected_content = []
    async for event in stream:
        if event.type == "response.output_text.delta":
            collected_content.append(event.delta)

    full_response = "".join(collected_content)
    print(f"Turn 1 Response: {full_response}")

if __name__ == "__main__":
    with sentry_sdk.start_transaction(op="test", name="Vision LLM Test"):
        asyncio.run(main())
    sentry_sdk.flush(timeout=5)
