Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,18 @@ with gr.Blocks() as app:
|
|
24 |
)
|
25 |
answer = completion.choices[0].message.content
|
26 |
return answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def generate_next(intro, setting, topic, student_identity, teacher_identity, student_start, student_base, teacher_base, dialog_state, llm_teacher, llm_student):
|
29 |
|
@@ -37,6 +49,7 @@ with gr.Blocks() as app:
|
|
37 |
prompt_student+=student_base
|
38 |
student = api_call(prompt_student, llm_student)
|
39 |
print(student)
|
|
|
40 |
student = json.loads(student,strict=False)
|
41 |
analysis_student = student["analyse"]
|
42 |
response = "Schüler: "+student["antwort"]
|
@@ -46,6 +59,7 @@ with gr.Blocks() as app:
|
|
46 |
# TEACHER
|
47 |
prompt_teacher = intro+"\n\nBisheriger Dialog:\n"+dialog_prev+"\n\Verlauf des Dialogs: "+setting+"\n\nThema, bei dem der Schüler Hilfe braucht:"+topic+"\n\nBeschreibung des Tutors:"+teacher_identity+"\n\n"+teacher_base
|
48 |
teacher = api_call(prompt_teacher, llm_teacher)
|
|
|
49 |
print(teacher)
|
50 |
teacher = json.loads(teacher,strict=False)
|
51 |
analysis_teacher = teacher["analyse"]
|
|
|
24 |
)
|
25 |
answer = completion.choices[0].message.content
|
26 |
return answer
|
27 |
+
|
28 |
+
def format(str):
|
29 |
+
s = str.split("\",")
|
30 |
+
for i in range(len(s)):
|
31 |
+
key = s[i].split(":")[0]
|
32 |
+
value = s[i].split(":")[1]
|
33 |
+
value = value.replace("\"", "")
|
34 |
+
s[i]=key+":"+"\""+value+"\""
|
35 |
+
str_new = ",".join(s)
|
36 |
+
str_new = str_new.replace("}\"", "\"}")
|
37 |
+
str_new = str_new.replace("\n", "")
|
38 |
+
return str_new
|
39 |
|
40 |
def generate_next(intro, setting, topic, student_identity, teacher_identity, student_start, student_base, teacher_base, dialog_state, llm_teacher, llm_student):
|
41 |
|
|
|
49 |
prompt_student+=student_base
|
50 |
student = api_call(prompt_student, llm_student)
|
51 |
print(student)
|
52 |
+
student = format(student)
|
53 |
student = json.loads(student,strict=False)
|
54 |
analysis_student = student["analyse"]
|
55 |
response = "Schüler: "+student["antwort"]
|
|
|
59 |
# TEACHER
|
60 |
prompt_teacher = intro+"\n\nBisheriger Dialog:\n"+dialog_prev+"\n\Verlauf des Dialogs: "+setting+"\n\nThema, bei dem der Schüler Hilfe braucht:"+topic+"\n\nBeschreibung des Tutors:"+teacher_identity+"\n\n"+teacher_base
|
61 |
teacher = api_call(prompt_teacher, llm_teacher)
|
62 |
+
teacher = format(teacher)
|
63 |
print(teacher)
|
64 |
teacher = json.loads(teacher,strict=False)
|
65 |
analysis_teacher = teacher["analyse"]
|