alexkueck commited on
Commit
fdf7515
·
verified ·
1 Parent(s): e281f74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -55
app.py CHANGED
@@ -186,60 +186,6 @@ def reset_textbox():
186
  return gr.update(value=""),""
187
 
188
 
189
- #####################################################################
190
- # Antwort des Vektorstores in ein Dictionary packen
191
- def parse_vectorstore_response(response_text):
192
- # Trenne die verschiedenen Einträge anhand des Musters
193
- entries = re.split(r"(\d+\. page_content=)", response_text)
194
-
195
- # Entferne das erste leere Element, falls vorhanden
196
- if entries[0] == '':
197
- entries.pop(0)
198
-
199
- # Kombiniere die Identifier und Inhalte wieder zu vollständigen Einträgen
200
- combined_entries = []
201
- for i in range(0, len(entries), 2):
202
- if i + 1 < len(entries):
203
- combined_entries.append(entries[i] + entries[i + 1])
204
-
205
- parsed_entries = []
206
-
207
- for entry in combined_entries:
208
- # Extrahiere page_content
209
- page_content_match = re.search(r"page_content='(.*?)' metadata=", entry, re.DOTALL)
210
- page_content = page_content_match.group(1) if page_content_match else ''
211
-
212
- # Extrahiere metadata
213
- metadata_match = re.search(r"metadata=\{(.*?)\}", entry)
214
- metadata_str = metadata_match.group(1) if metadata_match else ''
215
-
216
- # Konvertiere metadata in ein Dictionary
217
- metadata = {}
218
- for item in metadata_str.split(', '):
219
- if ': ' in item:
220
- key, value = item.split(': ', 1)
221
- metadata[key.strip("'")] = value.strip("'")
222
-
223
- parsed_entries.append({
224
- "page_content": page_content,
225
- "metadata": metadata
226
- })
227
-
228
- return parsed_entries
229
-
230
- #History Eintrag vorbereiten
231
- def create_history_entry(page_content, metadata):
232
- source = metadata.get('source', 'No source available')
233
- page = metadata.get('page', 'No page information available')
234
- download_link = f"https://example.com/download/{source.replace('pdf/', '')}"
235
-
236
- return {
237
- "page_content": page_content,
238
- "page": page,
239
- "download_link": download_link
240
- }
241
-
242
-
243
 
244
 
245
  ####################################################
@@ -327,7 +273,7 @@ def generate_auswahl(prompt_in, file, file_history, chatbot, history, anzahl_doc
327
  summary += " ".join([doc["content"] for doc in results['relevant_docs']])
328
  print("summary:....................." + summary)
329
  history = history + [[prompt_in, summary]]
330
-
331
  return chatbot, history, None, file_history, ""
332
 
333
  else: #noch nicht validiert, oder kein Prompt
 
186
  return gr.update(value=""),""
187
 
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
 
191
  ####################################################
 
273
  summary += " ".join([doc["content"] for doc in results['relevant_docs']])
274
  print("summary:....................." + summary)
275
  history = history + [[prompt_in, summary]]
276
+ print("history.........................."+str(history))
277
  return chatbot, history, None, file_history, ""
278
 
279
  else: #noch nicht validiert, oder kein Prompt