#!/usr/bin/env python3
from anthropic import Anthropic
from dotenv import load_dotenv

load_dotenv()
client = Anthropic()

def get_response(conversation):
    response = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=1024,
        system="""Respond code only if possible. Keep
                  explanations to a minimum (2 paragraphs
                  max). Don't use markdown formatting,
                  output plain text.""",
        messages=conversation
    )
    return response.content[0].text

print("Welcome to your programming assistant!")
print("Type 'exit' to quit.")

conversation = []

while True:
    prompt = input("You: ")
    if prompt.lower() == 'exit':
        print("Goodbye!")
        break

    conversation.append({"role": "user", "content": prompt})
    response = get_response(conversation)
    print("AI:")
    print(response)
    print()

    conversation.append({"role": "assistant", "content": response})
