Spaces:
Sleeping
Sleeping
File size: 771 Bytes
55fa38e 9a5ad14 55fa38e e0ce0ae 2244ca0 55fa38e 2244ca0 55fa38e |
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 |
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() |