File size: 890 Bytes
7487d3b
6638ec3
66213b7
02c6e36
993cf0a
1deb3b7
02c6e36
7ddbb96
7487d3b
 
 
 
 
 
 
 
 
 
7ddbb96
7487d3b
1deb3b7
7487d3b
 
 
a14af47
7ddbb96
ecde2e7
 
7ddbb96
ecde2e7
1deb3b7
7ddbb96
1deb3b7
7487d3b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()