Spaces:
Sleeping
Sleeping
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() |