Update app.py
Browse files
app.py
CHANGED
@@ -127,7 +127,7 @@ general_assistant_suche= openai_assistant_suche(client)
|
|
127 |
def clear_all(history):
|
128 |
global chats
|
129 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
130 |
-
summary = "\n".join(f'{schluessel}: {wert}' for schluessel, wert in dic_history.items())
|
131 |
#schlagwort finden zu dem chatverlauf
|
132 |
headers, payload = process_chatverlauf(summary, MODEL_NAME, OAI_API_KEY)
|
133 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
@@ -137,11 +137,11 @@ def clear_all(history):
|
|
137 |
result = data['choices'][0]['message']['content']
|
138 |
|
139 |
#chat hinzufügen zu den chatverläufen und in GUI anzeigen
|
140 |
-
id_neu =
|
141 |
#chats ist ein dictionary
|
142 |
chats[id_neu]= summary
|
143 |
|
144 |
-
return None, gr.Image(visible=False), [], gr.CheckboxGroup( choices=update_chat_options())
|
145 |
|
146 |
|
147 |
#########################################
|
@@ -167,14 +167,6 @@ def download_chats(selected_chats):
|
|
167 |
# String in die Datei schreiben
|
168 |
file.write(data)
|
169 |
return gr.File(file_path, label="Download-Chat", visible = True)
|
170 |
-
|
171 |
-
"""
|
172 |
-
# Erstelle eine temporäre Datei mit den Chat-Daten
|
173 |
-
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as tmp:
|
174 |
-
tmp.write(data)
|
175 |
-
tmp_path = tmp.name
|
176 |
-
return gr.File(tmp_path, label="Download-Chat", visible = True)
|
177 |
-
"""
|
178 |
else:
|
179 |
return gr.File(visible=False)
|
180 |
|
@@ -546,7 +538,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
546 |
with gr.Column():
|
547 |
with gr.Column(min_width=50, scale=1):
|
548 |
with gr.Tab(label="Chats ..."):
|
549 |
-
chat_selector = gr.CheckboxGroup( choices=update_chat_options())
|
550 |
download_button = gr.Button("Download ausgewählte Chats")
|
551 |
file_download = gr.File(label="Download-Chat", visible=False)
|
552 |
with gr.Tab(label="Parameter Einstellung"):
|
|
|
127 |
def clear_all(history):
|
128 |
global chats
|
129 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
130 |
+
summary = "\n\n".join(f'{schluessel}: {wert}' for schluessel, wert in dic_history.items())
|
131 |
#schlagwort finden zu dem chatverlauf
|
132 |
headers, payload = process_chatverlauf(summary, MODEL_NAME, OAI_API_KEY)
|
133 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
|
|
137 |
result = data['choices'][0]['message']['content']
|
138 |
|
139 |
#chat hinzufügen zu den chatverläufen und in GUI anzeigen
|
140 |
+
id_neu = len(chats)+1 + "_" + result
|
141 |
#chats ist ein dictionary
|
142 |
chats[id_neu]= summary
|
143 |
|
144 |
+
return None, gr.Image(visible=False), [], gr.CheckboxGroup(label=None, choices=update_chat_options())
|
145 |
|
146 |
|
147 |
#########################################
|
|
|
167 |
# String in die Datei schreiben
|
168 |
file.write(data)
|
169 |
return gr.File(file_path, label="Download-Chat", visible = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
else:
|
171 |
return gr.File(visible=False)
|
172 |
|
|
|
538 |
with gr.Column():
|
539 |
with gr.Column(min_width=50, scale=1):
|
540 |
with gr.Tab(label="Chats ..."):
|
541 |
+
chat_selector = gr.CheckboxGroup(label=None, choices=update_chat_options())
|
542 |
download_button = gr.Button("Download ausgewählte Chats")
|
543 |
file_download = gr.File(label="Download-Chat", visible=False)
|
544 |
with gr.Tab(label="Parameter Einstellung"):
|