Update app.py
Browse files
app.py
CHANGED
|
@@ -51,7 +51,7 @@ chats={}
|
|
| 51 |
|
| 52 |
#############################################
|
| 53 |
# Allgemeine Konstanten
|
| 54 |
-
|
| 55 |
|
| 56 |
##################################################
|
| 57 |
#Für MongoDB statt Chroma als Vektorstore
|
|
@@ -133,18 +133,18 @@ def clear_all(history):
|
|
| 133 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
| 134 |
summary = "\n\n".join(f'{schluessel}: \n {wert}' for schluessel, wert in dic_history.items())
|
| 135 |
#schlagwort finden zu dem chatverlauf
|
|
|
|
| 136 |
headers, payload = process_chatverlauf(summary, MODEL_NAME, OAI_API_KEY)
|
| 137 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 138 |
#als json ausgeben
|
| 139 |
data = response.json()
|
| 140 |
# Den "content" auswählen, da dort die Antwort der Ki enthalten ist
|
| 141 |
result = data['choices'][0]['message']['content']
|
| 142 |
-
|
| 143 |
-
#Alternatives Model umd schlagworte zu finden
|
| 144 |
"""
|
|
|
|
| 145 |
llm = HuggingFaceHub(repo_id=repo_id, model_kwargs={"temperature": 0.5, "max_length": 128})
|
| 146 |
result = process_chatverlauf_hf(prompt,llm)
|
| 147 |
-
|
| 148 |
#chat hinzufügen zu den chatverläufen und in GUI anzeigen
|
| 149 |
id_neu = str(len(chats)+1) + "_" + result
|
| 150 |
#chats ist ein dictionary
|
|
@@ -169,7 +169,7 @@ def download_chats(selected_chats):
|
|
| 169 |
# Diese Funktion bereitet die ausgewählten Chats zum Download vor
|
| 170 |
data = "\n\n".join(chats[chat] for chat in selected_chats)
|
| 171 |
# Dateipfad festlegen (hier wird die Datei im aktuellen Verzeichnis gespeichert)
|
| 172 |
-
file_path =
|
| 173 |
|
| 174 |
# Datei im Schreibmodus öffnen (erstellt die Datei, wenn sie nicht existiert)
|
| 175 |
with open(file_path, 'w') as file:
|
|
|
|
| 51 |
|
| 52 |
#############################################
|
| 53 |
# Allgemeine Konstanten
|
| 54 |
+
FILE_PATH = 'data/chatverlauf.txt'
|
| 55 |
|
| 56 |
##################################################
|
| 57 |
#Für MongoDB statt Chroma als Vektorstore
|
|
|
|
| 133 |
dic_history = {schluessel: wert for schluessel, wert in history}
|
| 134 |
summary = "\n\n".join(f'{schluessel}: \n {wert}' for schluessel, wert in dic_history.items())
|
| 135 |
#schlagwort finden zu dem chatverlauf
|
| 136 |
+
"""
|
| 137 |
headers, payload = process_chatverlauf(summary, MODEL_NAME, OAI_API_KEY)
|
| 138 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 139 |
#als json ausgeben
|
| 140 |
data = response.json()
|
| 141 |
# Den "content" auswählen, da dort die Antwort der Ki enthalten ist
|
| 142 |
result = data['choices'][0]['message']['content']
|
|
|
|
|
|
|
| 143 |
"""
|
| 144 |
+
#Alternatives Model umd schlagworte zu finden
|
| 145 |
llm = HuggingFaceHub(repo_id=repo_id, model_kwargs={"temperature": 0.5, "max_length": 128})
|
| 146 |
result = process_chatverlauf_hf(prompt,llm)
|
| 147 |
+
|
| 148 |
#chat hinzufügen zu den chatverläufen und in GUI anzeigen
|
| 149 |
id_neu = str(len(chats)+1) + "_" + result
|
| 150 |
#chats ist ein dictionary
|
|
|
|
| 169 |
# Diese Funktion bereitet die ausgewählten Chats zum Download vor
|
| 170 |
data = "\n\n".join(chats[chat] for chat in selected_chats)
|
| 171 |
# Dateipfad festlegen (hier wird die Datei im aktuellen Verzeichnis gespeichert)
|
| 172 |
+
file_path = FILE_PATH #'data/chatverlauf.txt'
|
| 173 |
|
| 174 |
# Datei im Schreibmodus öffnen (erstellt die Datei, wenn sie nicht existiert)
|
| 175 |
with open(file_path, 'w') as file:
|