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

import os
import sentry_sdk

import time

import litellm
from sentry_sdk.integrations.litellm import LiteLLMIntegration
from sentry_sdk.integrations.openai import OpenAIIntegration


sentry_sdk.init(
    dsn=os.environ.get("SENTRY_DSN"),
    traces_sample_rate=1.0,
    send_default_pii=True,
    stream_gen_ai_spans=True,
    integrations=[LiteLLMIntegration(include_prompts=True)],
    disabled_integrations=[OpenAIIntegration()],
)


def main():
    # Turn 1
    response = litellm.responses(
        model="openai/gpt-5-nano",
        instructions="You are a helpful assistant.",
        input=[
        {
            "role": "user",
            "content": "What is the capital of France?"
        },
    ]
,
    )
    print(f"Turn 1 Response: {response.output_text}")
    time.sleep(0.1)  # sleep is necessary for LiteLLM because it needs threaded callbacks to finish

    # Turn 2
    response = litellm.responses(
        model="openai/gpt-5-nano",
        instructions="You are a helpful assistant.",
        input=[
        {
            "role": "user",
            "content": "What is the capital of France?"
        },
        {
            "role": "assistant",
            "content": "The capital of France is Paris."
        },
        {
            "role": "user",
            "content": "What is the population of that city?"
        },
    ]
,
    )
    print(f"Turn 2 Response: {response.output_text}")
    time.sleep(0.1)  # sleep is necessary for LiteLLM because it needs threaded callbacks to finish

    # Turn 3
    response = litellm.responses(
        model="openai/gpt-5-nano",
        instructions="You are a helpful assistant.",
        input=[
        {
            "role": "user",
            "content": "What is the capital of France?"
        },
        {
            "role": "assistant",
            "content": "The capital of France is Paris."
        },
        {
            "role": "user",
            "content": "What is the population of that city?"
        },
        {
            "role": "assistant",
            "content": "Paris has a population of approximately 2.2 million people in the city proper."
        },
        {
            "role": "user",
            "content": "What about the metropolitan area?"
        },
    ]
,
    )
    print(f"Turn 3 Response: {response.output_text}")
    time.sleep(0.1)  # sleep is necessary for LiteLLM because it needs threaded callbacks to finish

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