cloudwp commited on
Commit
9c34cc1
1 Parent(s): b9db857

Update frontend.py

Browse files
Files changed (1) hide show
  1. frontend.py +11 -7
frontend.py CHANGED
@@ -1,37 +1,41 @@
1
  import gradio as gr
2
  import requests
3
 
4
- # Backend API Base URL
5
  API_BASE_URL = "http://localhost:5000"
6
 
7
  # Funktion zur Analyse von Text über die API
8
- def analyze_text(text, desired_length, synonym_api_key, grammar_api_key):
 
9
  configure_payload = {
10
- "synonym_api_key": synonym_api_key,
11
  "grammar_api_key": grammar_api_key
12
  }
13
  requests.post(f"{API_BASE_URL}/configure", json=configure_payload)
14
 
15
- analyze_payload = {"text": text, "desired_length": desired_length}
 
16
  response = requests.post(f"{API_BASE_URL}/analyze-text", json=analyze_payload)
17
  return response.json()
18
 
19
- # Gradio-Interface
20
  with gr.Blocks() as interface:
21
  gr.Markdown("<h1>Textanpassungstool</h1>")
22
 
23
  with gr.Row():
24
  input_text = gr.Textbox(label="Eingabetext", placeholder="Geben Sie hier den Text ein.")
25
  desired_length = gr.Number(label="Gewünschte Zeichenanzahl", placeholder="Ziel-Zeichenanzahl.")
 
26
 
27
  with gr.Row():
28
- synonym_api_key = gr.Textbox(label="Synonym API-Schlüssel")
29
  grammar_api_key = gr.Textbox(label="Grammatik API-Schlüssel")
30
 
31
  analyze_button = gr.Button("Text analysieren")
32
  result_output = gr.JSON(label="Ergebnisse")
33
 
34
- analyze_button.click(fn=analyze_text, inputs=[input_text, desired_length, synonym_api_key, grammar_api_key], outputs=result_output)
 
35
 
36
  # Starten der Gradio-Oberfläche
37
  interface.launch()
 
1
  import gradio as gr
2
  import requests
3
 
4
+ # Backend API URL
5
  API_BASE_URL = "http://localhost:5000"
6
 
7
  # Funktion zur Analyse von Text über die API
8
+ def analyze_text(text, desired_length, language, synonym_api_key, grammar_api_key):
9
+ # Konfiguration der APIs
10
  configure_payload = {
11
+ "synonym_primary_api_key": synonym_api_key,
12
  "grammar_api_key": grammar_api_key
13
  }
14
  requests.post(f"{API_BASE_URL}/configure", json=configure_payload)
15
 
16
+ # Analyse des Textes
17
+ analyze_payload = {"text": text, "desired_length": desired_length, "language": language}
18
  response = requests.post(f"{API_BASE_URL}/analyze-text", json=analyze_payload)
19
  return response.json()
20
 
21
+ # Gradio-Interface erstellen
22
  with gr.Blocks() as interface:
23
  gr.Markdown("<h1>Textanpassungstool</h1>")
24
 
25
  with gr.Row():
26
  input_text = gr.Textbox(label="Eingabetext", placeholder="Geben Sie hier den Text ein.")
27
  desired_length = gr.Number(label="Gewünschte Zeichenanzahl", placeholder="Ziel-Zeichenanzahl.")
28
+ language = gr.Dropdown(choices=["en", "de", "fr"], label="Sprache")
29
 
30
  with gr.Row():
31
+ synonym_api_key = gr.Textbox(label="Primärer Synonym-API-Schlüssel")
32
  grammar_api_key = gr.Textbox(label="Grammatik API-Schlüssel")
33
 
34
  analyze_button = gr.Button("Text analysieren")
35
  result_output = gr.JSON(label="Ergebnisse")
36
 
37
+ # Klick-Interaktion
38
+ analyze_button.click(fn=analyze_text, inputs=[input_text, desired_length, language, synonym_api_key, grammar_api_key], outputs=result_output)
39
 
40
  # Starten der Gradio-Oberfläche
41
  interface.launch()