FricIntegrated / app.py
Fric7ion's picture
Update app.py
2244ca0 verified
raw
history blame contribute delete
771 Bytes
import gradio as gr
import requests
url = "https://fric7ion-fricfast.hf.space/chat"
def chatgpt(message, history):
try:
# Attempt to make the external request
response = requests.post(url, params={"prompt": message, "max_token": "140"})
print("Raw response:", response.text)
if response.text:
data = response.json()
print(data)
reply = data.get('message', '')
else:
print("Empty response")
reply = "Error: No response from server"
except Exception as e:
print("Error making external request:", e)
reply = "Error: Unable to process request"
return reply
iface = gr.Blocks()
with iface:
chat = gr.ChatInterface(chatgpt)
iface.launch()