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

import os
import sentry_sdk

from openai import OpenAI


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

client = OpenAI()

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

    collected_content = []
    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content is not None:
            collected_content.append(chunk.choices[0].delta.content)

    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"):
        main()
    sentry_sdk.flush(timeout=5)
