Convomate-module / gradio_app.py
shevadesuyash's picture
Create gradio_app.py
fbce76c verified
raw
history blame
780 Bytes
import gradio as gr
import requests
BACKEND_URL = "http://127.0.0.1:8080" # your internal Flask app
def correct_text(paragraph):
try:
resp = requests.post(f"{BACKEND_URL}/correct_text", json={"paragraph": paragraph})
return resp.json().get("grammar_corrected", "Error occurred")
except Exception as e:
return f"Error: {str(e)}"
def chat_with_bot(message):
try:
resp = requests.post(f"{BACKEND_URL}/chat", json={"message": message})
data = resp.json()
return data.get("corrected_text", "Error occurred")
except Exception as e:
return f"Error: {str(e)}"
demo = gr.Interface(fn=correct_text, inputs="text", outputs="text", title="Paragraph Correction")
demo.launch(server_name="0.0.0.0", server_port=7860)