import os
from langchain_groq import ChatGroq

def get_llm(temperature=0):
    """
    Returns the configured LLM instance.
    Currently set to use Groq with Llama 3 (8B).
    
    Requires GROQ_API_KEY environment variable to be set.
    Get your free API key at: https://console.groq.com/
    """
    api_key = os.environ.get("GROQ_API_KEY")
    
    if not api_key:
        raise ValueError(
            "❌ GROQ_API_KEY not found!\n"
            "Please set your API key:\n"
            "  Windows: $env:GROQ_API_KEY='your_key'\n"
            "  Linux/Mac: export GROQ_API_KEY='your_key'\n"
            "\nGet a free key at: https://console.groq.com/"
        )
    
    return ChatGroq(
        temperature=temperature,
        model_name="llama-3.1-8b-instant",
        api_key=api_key
    )
