Spaces:
Runtime error
Runtime error
File size: 1,580 Bytes
374b8bc b9db857 374b8bc 9c34cc1 b9db857 374b8bc b9db857 9c34cc1 b9db857 9c34cc1 b9db857 374b8bc 9c34cc1 b9db857 9c34cc1 b9db857 9c34cc1 b9db857 9c34cc1 b9db857 9c34cc1 b9db857 |
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 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
import requests
# Backend API URL
API_BASE_URL = "http://localhost:5000"
# Funktion zur Analyse von Text über die API
def analyze_text(text, desired_length, language, synonym_api_key, grammar_api_key):
# Konfiguration der APIs
configure_payload = {
"synonym_primary_api_key": synonym_api_key,
"grammar_api_key": grammar_api_key
}
requests.post(f"{API_BASE_URL}/configure", json=configure_payload)
# Analyse des Textes
analyze_payload = {"text": text, "desired_length": desired_length, "language": language}
response = requests.post(f"{API_BASE_URL}/analyze-text", json=analyze_payload)
return response.json()
# Gradio-Interface erstellen
with gr.Blocks() as interface:
gr.Markdown("<h1>Textanpassungstool</h1>")
with gr.Row():
input_text = gr.Textbox(label="Eingabetext", placeholder="Geben Sie hier den Text ein.")
desired_length = gr.Number(label="Gewünschte Zeichenanzahl", placeholder="Ziel-Zeichenanzahl.")
language = gr.Dropdown(choices=["en", "de", "fr"], label="Sprache")
with gr.Row():
synonym_api_key = gr.Textbox(label="Primärer Synonym-API-Schlüssel")
grammar_api_key = gr.Textbox(label="Grammatik API-Schlüssel")
analyze_button = gr.Button("Text analysieren")
result_output = gr.JSON(label="Ergebnisse")
# Klick-Interaktion
analyze_button.click(fn=analyze_text, inputs=[input_text, desired_length, language, synonym_api_key, grammar_api_key], outputs=result_output)
# Starten der Gradio-Oberfläche
interface.launch() |