Lumosdev commited on
Commit
d2c6ed6
·
1 Parent(s): ec71974

Vollständige App mit ChatInterface und Textsuche

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,16 +1,22 @@
1
  import gradio as gr
2
  from utils import lade_skript, teile_in_abschnitte, finde_passenden_abschnitt
3
 
 
4
  text = lade_skript()
5
  abschnitte = teile_in_abschnitte(text)
6
 
 
7
  def antwortverlauf(chatverlauf):
8
  frage = chatverlauf[-1]["content"]
9
  antwort = finde_passenden_abschnitt(frage, abschnitte)
10
  return chatverlauf + [{"role": "assistant", "content": antwort}]
11
 
12
- demo = gr.ChatInterface(fn=antwortverlauf,
13
- title="§34a Lern-Dozent",
14
- description="Ich antworte dir mit Wissen aus deinem IHK-Skript.")
 
 
 
15
 
 
16
  demo.launch()
 
1
  import gradio as gr
2
  from utils import lade_skript, teile_in_abschnitte, finde_passenden_abschnitt
3
 
4
+ # Lade und teile das Sachkunde-Skript
5
  text = lade_skript()
6
  abschnitte = teile_in_abschnitte(text)
7
 
8
+ # Hauptfunktion für den Chatverlauf
9
  def antwortverlauf(chatverlauf):
10
  frage = chatverlauf[-1]["content"]
11
  antwort = finde_passenden_abschnitt(frage, abschnitte)
12
  return chatverlauf + [{"role": "assistant", "content": antwort}]
13
 
14
+ # UI mit Gradio ChatInterface
15
+ demo = gr.ChatInterface(
16
+ fn=antwortverlauf,
17
+ title="§34a Lern-Dozent",
18
+ description="Frag mich zur Sachkundeprüfung – ich finde die Antwort in deinem IHK-Skript!"
19
+ )
20
 
21
+ # App starten
22
  demo.launch()