camparchimedes commited on
Commit
60b15ef
ยท
verified ยท
1 Parent(s): 99d885a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -98,6 +98,26 @@ async def main(message):
98
  metadatas = [doc.metadata for doc in docs]
99
  all_sources = [m["source"] for m in metadatas]
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  for doc, metadata in zip(docs, metadatas):
102
  row_index = metadata.get("row_index", -1) # --when row_index@metadata
103
  if row_index in [2, 8, 14]: # --incl. only rows 2, 8, and 14
@@ -110,7 +130,7 @@ async def main(message):
110
  )
111
 
112
  if source_elements:
113
- answer += f"\nSources: {', '.join([e.content for e in source_elements])}"
114
  else:
115
  answer += "\nNo sources found"
116
 
 
98
  metadatas = [doc.metadata for doc in docs]
99
  all_sources = [m["source"] for m in metadatas]
100
 
101
+
102
+ """
103
+ for source in all_sources:
104
+ if source in visited_sources:
105
+ continue
106
+ visited_sources.add(source)
107
+ # --create text element referenced in message
108
+ source_elements.append(
109
+ cl.Text(content="https://www.daysoff.no" + source, name="Info_Url")
110
+ )
111
+
112
+ if source_elements:
113
+ answer += f"\nSources: {', '.join([e.content.decode('utf-8') for e in source_elements])}"
114
+ else:
115
+ answer += "\nNo sources found"
116
+
117
+
118
+ await cl.Message(content=answer, elements=source_elements).send()
119
+
120
+ """
121
  for doc, metadata in zip(docs, metadatas):
122
  row_index = metadata.get("row_index", -1) # --when row_index@metadata
123
  if row_index in [2, 8, 14]: # --incl. only rows 2, 8, and 14
 
130
  )
131
 
132
  if source_elements:
133
+ answer += f"\nSources: {', '.join([e.content.decode('utf-8') for e in source_elements])}"
134
  else:
135
  answer += "\nNo sources found"
136