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

import os
import sentry_sdk

from anthropic import Anthropic


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

client = Anthropic()

def main():
    # Turn 1
    system_prompt = None
    messages = []
    system_prompt = "You are a helpful assistant that can analyze images. Be concise."
    messages.append({"role": "user", "content": [
            {"type": "text", "text": "What color is this image? Reply with just the color name."},
            {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8z8BQz0AEYBxVSF+FABJADveWkH6oAAAAAElFTkSuQmCC"}},
        ]})

    kwargs = {
        "model": "claude-haiku-4-5",
        "max_tokens": 1024,
        "messages": messages,
    }
    if system_prompt:
        kwargs["system"] = system_prompt

    with client.messages.stream(**kwargs) as stream:
        collected_content = []
        for event in stream:
            if event.type == "content_block_delta":
                collected_content.append(event.delta.text)
        
        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)
