import gradio as gr import requests import os GROQ_API_KEY = os.getenv("GROQ_API_KEY") MODEL = "mosaicml/mpt-7b-chat" def chat_with_ai(message): response = requests.post( "https://api.groq.com/openai/v1/chat/completions", headers={ "Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json" }, json={ "model": MODEL, "messages": [ {"role": "system", "content": "You are Mingool AI, a friendly assistant for single parents."}, {"role": "user", "content": message} ] } ) data = response.json() return data["choices"][0]["message"]["content"] demo = gr.Interface( fn=chat_with_ai, inputs="text", outputs="text", title="Mingool AI Chat", api_name="/chat_with_ai" # ✅ this is critical ) demo.launch()