File size: 1,362 Bytes
0f79706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import requests

# Backend API Base URL
API_BASE_URL = "http://localhost:5000"

# Funktion zur Analyse von Text über die API
def analyze_text(text, desired_length, synonym_api_key, grammar_api_key):
    configure_payload = {
        "synonym_api_key": synonym_api_key,
        "grammar_api_key": grammar_api_key
    }
    requests.post(f"{API_BASE_URL}/configure", json=configure_payload)

    analyze_payload = {"text": text, "desired_length": desired_length}
    response = requests.post(f"{API_BASE_URL}/analyze-text", json=analyze_payload)
    return response.json()

# Gradio-Interface
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.")

    with gr.Row():
        synonym_api_key = gr.Textbox(label="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")

    analyze_button.click(fn=analyze_text, inputs=[input_text, desired_length, synonym_api_key, grammar_api_key], outputs=result_output)

# Starten der Gradio-Oberfläche
interface.launch()