MichaelWelsch
commited on
Commit
·
0c1b111
1
Parent(s):
21c1429
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ model_name = "ft:gpt-3.5-turbo-0613:metric-space-ug:rechtsberatung2:7zmeC6ps"
|
|
8 |
prompt0 = "Liegt ein rechtlich relevanter Sachverhalt mit einer passenden Frage vor?"
|
9 |
prompt1 = "Du stellst Fragen, um fehlende Informationen für eine anwaltliche Erstberatung zu klären. Stelle bis zu 5 Fragen für die Klärung der Sachlage und antworte mit „Danke für die Antworten.“, sobald die Sachlage klar ist. Vermeide fragen zu stellen, die schon benantwortet sind"
|
10 |
prompt2 = "Schreibe den Sachverhalt auf Basis der folgenden Informationen zusammen."
|
11 |
-
prompt3 = "Schreibe eine anwaltliche Erstberatung auf Basis des geschilderten Sachverhalts. Vermeide Konjuktive
|
12 |
|
13 |
def respond_prompt0(Selbstauskunft, Kernfrage, chat):
|
14 |
# preprocess data
|
@@ -24,9 +24,9 @@ def respond_prompt0(Selbstauskunft, Kernfrage, chat):
|
|
24 |
output = completion.choices[0].message.content
|
25 |
########
|
26 |
|
27 |
-
out = "
|
28 |
if "ja" in output[:4].lower():
|
29 |
-
out += "\n
|
30 |
|
31 |
# openai api call prompt 1
|
32 |
########
|
@@ -43,7 +43,7 @@ def respond_prompt0(Selbstauskunft, Kernfrage, chat):
|
|
43 |
return out, gr.update(value=chat, visible=True), gr.update(value="", visible=True)
|
44 |
|
45 |
else:
|
46 |
-
return out + "\nLeider
|
47 |
|
48 |
|
49 |
def respond_prompt1(Selbstauskunft, Kernfrage, chat, text):
|
@@ -69,9 +69,9 @@ def respond_prompt1(Selbstauskunft, Kernfrage, chat, text):
|
|
69 |
|
70 |
if ("<ENDOFQA>" in output_prompt1) or len(chat) > 10:
|
71 |
sachverhalt = respond_prompt2(Selbstauskunft, Kernfrage, chat)
|
72 |
-
chat.append(("Danke für die Antworten. Hier findest du eine Zusamenfassung des Sachverhalts", ""))
|
73 |
|
74 |
-
return chat, gr.update(value="", visible=False), gr.update(value=sachverhalt, visible=True), gr.update(value="
|
75 |
|
76 |
chat.append((output_prompt1, ""))
|
77 |
|
@@ -119,8 +119,8 @@ def respond_prompt3(Selbstauskunft, Kernfrage, chat, Sachverhalt):
|
|
119 |
return gr.update(value=output_prompt3, visible=True), gr.update(visible=False)
|
120 |
|
121 |
with gr.Blocks() as demo:
|
122 |
-
Selbstauskunft = gr.Textbox("", label="
|
123 |
-
Kernfrage = gr.Textbox("", label="
|
124 |
|
125 |
button_prompt1 = gr.Button(value="Weiter")
|
126 |
|
@@ -130,7 +130,7 @@ with gr.Blocks() as demo:
|
|
130 |
chat = gr.Chatbot(visible=False)
|
131 |
msg = gr.Textbox(visible=False, label="Antwort")
|
132 |
Sachverhalt = gr.Textbox(visible=False, label = "Zusammenfassung")
|
133 |
-
Erstberatung = gr.Textbox(visible=False, label="
|
134 |
button_erstberatung = gr.Button(value="Weiter", visible=False)
|
135 |
|
136 |
button_prompt1.click(respond_prompt0, [Selbstauskunft, Kernfrage, chat], outputs=[label_prompt0, chat, msg])
|
|
|
8 |
prompt0 = "Liegt ein rechtlich relevanter Sachverhalt mit einer passenden Frage vor?"
|
9 |
prompt1 = "Du stellst Fragen, um fehlende Informationen für eine anwaltliche Erstberatung zu klären. Stelle bis zu 5 Fragen für die Klärung der Sachlage und antworte mit „Danke für die Antworten.“, sobald die Sachlage klar ist. Vermeide fragen zu stellen, die schon benantwortet sind"
|
10 |
prompt2 = "Schreibe den Sachverhalt auf Basis der folgenden Informationen zusammen."
|
11 |
+
prompt3 = "Schreibe eine anwaltliche Erstberatung auf Basis des geschilderten Sachverhalts. Vermeide Konjuktive, formuliere in gutem Deutsch und verwende die Struktur 1.Zusammenfassung der Ergebnisse und Empfehlung, 2. Rechtslage"
|
12 |
|
13 |
def respond_prompt0(Selbstauskunft, Kernfrage, chat):
|
14 |
# preprocess data
|
|
|
24 |
output = completion.choices[0].message.content
|
25 |
########
|
26 |
|
27 |
+
out = "Kann ich dir mit deinem Anliegen helfen?\n" + output
|
28 |
if "ja" in output[:4].lower():
|
29 |
+
out += "\n Ich werde nun noch ein paar Fragen stellen, um den Sachverhalt genauer zu verstehen" #
|
30 |
|
31 |
# openai api call prompt 1
|
32 |
########
|
|
|
43 |
return out, gr.update(value=chat, visible=True), gr.update(value="", visible=True)
|
44 |
|
45 |
else:
|
46 |
+
return out + "\nLeider kann ich dir nicht weiterhelfen, Grund: ", chat, ""
|
47 |
|
48 |
|
49 |
def respond_prompt1(Selbstauskunft, Kernfrage, chat, text):
|
|
|
69 |
|
70 |
if ("<ENDOFQA>" in output_prompt1) or len(chat) > 10:
|
71 |
sachverhalt = respond_prompt2(Selbstauskunft, Kernfrage, chat)
|
72 |
+
chat.append(("Danke für die Antworten. Hier findest du eine aufarbeitete Zusamenfassung des Sachverhalts. Bitte prüfe und ergänze ggf. noch etwas, bevor ich zu meiner Einschätzung komme.", ""))
|
73 |
|
74 |
+
return chat, gr.update(value="", visible=False), gr.update(value=sachverhalt, visible=True), gr.update(value="Weiter", visible=True)
|
75 |
|
76 |
chat.append((output_prompt1, ""))
|
77 |
|
|
|
119 |
return gr.update(value=output_prompt3, visible=True), gr.update(visible=False)
|
120 |
|
121 |
with gr.Blocks() as demo:
|
122 |
+
Selbstauskunft = gr.Textbox("", label="Erzähl mir, was passiert ist")
|
123 |
+
Kernfrage = gr.Textbox("", label="Stelle eine Frage, die ich dir beantworten soll?")
|
124 |
|
125 |
button_prompt1 = gr.Button(value="Weiter")
|
126 |
|
|
|
130 |
chat = gr.Chatbot(visible=False)
|
131 |
msg = gr.Textbox(visible=False, label="Antwort")
|
132 |
Sachverhalt = gr.Textbox(visible=False, label = "Zusammenfassung")
|
133 |
+
Erstberatung = gr.Textbox(visible=False, label="Rechtliche Einschätzung")
|
134 |
button_erstberatung = gr.Button(value="Weiter", visible=False)
|
135 |
|
136 |
button_prompt1.click(respond_prompt0, [Selbstauskunft, Kernfrage, chat], outputs=[label_prompt0, chat, msg])
|