#!/usr/bin/env python3
"""
Generated test file for Multi-Turn LLM Test
Framework: anthropic
Execution mode: async
Streaming: no"""

import os
import sentry_sdk
import asyncio

from anthropic import AsyncAnthropic


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

client = AsyncAnthropic()

async def main():
    # Turn 1
    system_prompt = None
    messages = []
    system_prompt = "You are a helpful assistant."
    messages.append({"role": "user", "content": "What is the capital of France?"})

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

    response = await client.messages.create(**kwargs)
    print(f"Turn 1 Response: {response.content[0].text}")

    # Turn 2
    system_prompt = None
    messages = []
    system_prompt = "You are a helpful assistant."
    messages.append({"role": "user", "content": "What is the capital of France?"})
    messages.append({"role": "assistant", "content": "The capital of France is Paris."})
    messages.append({"role": "user", "content": "What is the population of that city?"})

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

    response = await client.messages.create(**kwargs)
    print(f"Turn 2 Response: {response.content[0].text}")

    # Turn 3
    system_prompt = None
    messages = []
    system_prompt = "You are a helpful assistant."
    messages.append({"role": "user", "content": "What is the capital of France?"})
    messages.append({"role": "assistant", "content": "The capital of France is Paris."})
    messages.append({"role": "user", "content": "What is the population of that city?"})
    messages.append({"role": "assistant", "content": "Paris has a population of approximately 2.2 million people in the city proper."})
    messages.append({"role": "user", "content": "What about the metropolitan area?"})

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

    response = await client.messages.create(**kwargs)
    print(f"Turn 3 Response: {response.content[0].text}")

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