"""Chat tools for {{ project_name }}."""

import openai
from tenacity import retry, stop_after_attempt, wait_random_exponential

@retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
def chat_completion_with_backoff(**kwargs):
    return openai.ChatCompletion.create(**kwargs)

def get_chat_response(messages, model="{{ default_model }}", temperature=0.7):
    """
    Get a response from the OpenAI chat model.
    
    Args:
        messages (list): List of message dictionaries.
        model (str): The model to use for chat completion.
        temperature (float): The temperature for response generation.
    
    Returns:
        str: The generated response.
    """
    response = chat_completion_with_backoff(
        model=model,
        messages=messages,
        temperature=temperature,
    )
    return response.choices[0].message["content"].strip()

# Add more chat-related functions as needed