mingool-v1 / app.py
nayastudios's picture
Update app.py
1deb3b7 verified
raw
history blame contribute delete
890 Bytes
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()