ai-uncensored / app.py
JANGALA SAKETH
Rename pp.py to app.py
418ecfa verified
raw
history blame contribute delete
871 Bytes
import gradio as gr
import requests
# 🔗 Put your Kaggle API URL later
KAGGLE_API_URL = "https://your-kaggle-endpoint.run"
def chat(message, history):
try:
r = requests.post(
KAGGLE_API_URL,
json={"message": message},
timeout=60
)
return r.json()["reply"]
except:
return "⚠️ Backend not running. Start Kaggle session."
with gr.Blocks(title="Free AI Chat") as demo:
gr.Markdown("# 🤖 Free AI Chat (CPU)")
gr.Markdown("Start Kaggle session before chatting.")
chatbot = gr.Chatbot()
msg = gr.Textbox(placeholder="Type your message...")
def respond(message, chat_history):
reply = chat(message, chat_history)
chat_history.append((message, reply))
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
demo.launch()