Update app.py
Browse files
app.py
CHANGED
|
@@ -127,7 +127,15 @@ def clear_all(history):
|
|
| 127 |
global chats
|
| 128 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
| 129 |
summary = "\n".join(f'{schluessel}: {wert}' for schluessel, wert in dic_history.items())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
|
|
|
| 131 |
id_neu = len(chats)+1
|
| 132 |
#chats ist ein dictionary
|
| 133 |
chats[id_neu]= summary
|
|
@@ -216,16 +224,6 @@ def umwandeln_fuer_anzeige(image):
|
|
| 216 |
image.save(buffer, format='PNG')
|
| 217 |
return buffer.getvalue()
|
| 218 |
|
| 219 |
-
#########################################
|
| 220 |
-
# Funktionen, um vergangene Chats anzuzeigen und zum Download anzubieten
|
| 221 |
-
def update_chat_options():
|
| 222 |
-
# Diese Funktion aktualisiert die verfügbaren Chat-Optionen
|
| 223 |
-
return list(chats.keys())
|
| 224 |
-
|
| 225 |
-
def download_chats(selected_chats):
|
| 226 |
-
# Diese Funktion bereitet die ausgewählten Chats zum Download vor
|
| 227 |
-
data = "\n\n".join(chats[chat] for chat in selected_chats)
|
| 228 |
-
return gr.File.save_text(data, "selected_chats.txt")
|
| 229 |
|
| 230 |
|
| 231 |
##########################################
|
|
@@ -621,9 +619,6 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
| 621 |
anzahl_docs = gr.Slider(label="Anzahl Dokumente", value=3, minimum=1, maximum=10, step=1, interactive=True, info="wie viele Dokumententeile aus dem Vektorstore an den prompt gehängt werden", visible=False)
|
| 622 |
openai_key = gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1, visible = False)
|
| 623 |
|
| 624 |
-
with gr.Tab(label="Chats ..."):
|
| 625 |
-
vergangene_chats = gr.Interface(fn=download_chats, inputs=chat_selector, outputs=gr.File(label="Download"))
|
| 626 |
-
|
| 627 |
|
| 628 |
################################################
|
| 629 |
# Tab zum Zeichnen mit Stable Diffusion
|
|
|
|
| 127 |
global chats
|
| 128 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
| 129 |
summary = "\n".join(f'{schluessel}: {wert}' for schluessel, wert in dic_history.items())
|
| 130 |
+
#schlagwort finden zu dem chatverlauf
|
| 131 |
+
headers, payload = process_chatverlauf(summary)
|
| 132 |
+
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 133 |
+
#als json ausgeben
|
| 134 |
+
data = response.json()
|
| 135 |
+
# Den "content" auswählen, da dort die Antwort der Ki enthalten ist
|
| 136 |
+
result = data['choices'][0]['message']['content']
|
| 137 |
|
| 138 |
+
#chat hinzufügen zu den chatverläufen und in GUI anzeigen
|
| 139 |
id_neu = len(chats)+1
|
| 140 |
#chats ist ein dictionary
|
| 141 |
chats[id_neu]= summary
|
|
|
|
| 224 |
image.save(buffer, format='PNG')
|
| 225 |
return buffer.getvalue()
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
|
| 229 |
##########################################
|
|
|
|
| 619 |
anzahl_docs = gr.Slider(label="Anzahl Dokumente", value=3, minimum=1, maximum=10, step=1, interactive=True, info="wie viele Dokumententeile aus dem Vektorstore an den prompt gehängt werden", visible=False)
|
| 620 |
openai_key = gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1, visible = False)
|
| 621 |
|
|
|
|
|
|
|
|
|
|
| 622 |
|
| 623 |
################################################
|
| 624 |
# Tab zum Zeichnen mit Stable Diffusion
|