Spaces:
Sleeping
Sleeping
File size: 780 Bytes
fbce76c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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)
|