fast_block / gradio_app.py
harshSethi's picture
Update gradio_app.py
57e591c verified
raw
history blame contribute delete
773 Bytes
import gradio as gr
import requests
import logging
def predict(message, history):
# API request to FastAPI backend
response = requests.post("http://0.0.0.0:8000/chat", json={"message": message, "history": history})
if response.status_code == 200:
response_data = response.json()
return response_data['response']
else:
return "Error: Unable to connect to the FastAPI backend."
demo = gr.ChatInterface(
predict,
title="Blockchain Teacher",
theme=gr.themes.Soft(),
chatbot=gr.Chatbot(label="Learn about blockchain technology"),
textbox=gr.Textbox(
placeholder="Ask me anything about blockchain",
scale=7,
max_lines=2,
),
)
def start_gradio():
demo.launch(server_name="0.0.0.0")