camparchimedes commited on
Commit
3be33ef
ยท
verified ยท
1 Parent(s): 08f1bef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -62
app.py CHANGED
@@ -45,7 +45,7 @@ chain_type_kwargs = {"prompt": prompt}
45
 
46
  @cl.author_rename
47
  def rename(orig_author: str):
48
- rename_dict = {"RetrievalQA": "Consulting Daysoff data"}
49
  return rename_dict.get(orig_author, orig_author)
50
 
51
  @cl.on_chat_start
@@ -54,12 +54,12 @@ async def init():
54
  await msg.send()
55
 
56
  # --builds FAISS index from csv
57
- loader = CSVLoader(file_path="./data/total_faq.csv", source_column="Answer") # columns in csv: Answer, Question, Info_Url
58
  data = loader.load()
59
 
60
  # --adding spec. metadata-------------------------------------------------------------------------------------------------
61
  for i, doc in enumerate(data):
62
- doc.metadata["row_index"] = i + 1 # Add row index (1-based)
63
  doc.metadata["source"] = doc.metadata.get("Info_Url", "")
64
  # ------------------------------------------------------------------------------------------------------------------------
65
 
@@ -123,63 +123,5 @@ async def main(message):
123
  return
124
 
125
  else:
126
- #answer = f"{answer}\nNo sources found"
127
  await cl.Message(content=f"No sources found").send()
128
-
129
- #await cl.Message(content=answer, elements=source_elements).send()
130
-
131
-
132
-
133
-
134
- """
135
- if source_elements:
136
- answer += f"\nSources: {', '.join([e.content for e in source_elements])}"
137
-
138
- else:
139
- answer += "\nNo sources found"
140
-
141
- await cl.Message(content=answer, elements=source_elements).send()
142
- return
143
-
144
- """
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- """
168
- for source in all_sources:
169
- if source in visited_sources:
170
- continue
171
- visited_sources.add(source)
172
- # --create text element referenced in message
173
- source_elements.append(
174
- cl.Text(content="https://www.daysoff.no" + source, name="Info_Url")
175
- )
176
-
177
- if source_elements:
178
- answer += f"\nSources: {', '.join([e.content.decode('utf-8') for e in source_elements])}"
179
- else:
180
- answer += "\nNo sources found"
181
-
182
-
183
- await cl.Message(content=answer, elements=source_elements).send()
184
-
185
- """
 
45
 
46
  @cl.author_rename
47
  def rename(orig_author: str):
48
+ rename_dict = {"RetrievalQA": "Checking FAQ for ansatte & utleiere.."}
49
  return rename_dict.get(orig_author, orig_author)
50
 
51
  @cl.on_chat_start
 
54
  await msg.send()
55
 
56
  # --builds FAISS index from csv
57
+ loader = CSVLoader(file_path="./data/total_faq.csv", source_column="Answer")
58
  data = loader.load()
59
 
60
  # --adding spec. metadata-------------------------------------------------------------------------------------------------
61
  for i, doc in enumerate(data):
62
+ doc.metadata["row_index"] = i + 1 # --adding row index (1-based)
63
  doc.metadata["source"] = doc.metadata.get("Info_Url", "")
64
  # ------------------------------------------------------------------------------------------------------------------------
65
 
 
123
  return
124
 
125
  else:
126
+
127
  await cl.Message(content=f"No sources found").send()