mpav commited on
Commit
578e74d
1 Parent(s): f6c0062
.env → .env_sample RENAMED
File without changes
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -107,21 +107,26 @@ async def start_chat():
107
  async def main(message: cl.Message):
108
  chain = cl.user_session.get("chain")
109
 
110
- resp = chain.invoke({"question" : message.content})
111
  source_documents = resp["context"]
112
 
113
  text_elements = [] # type: List[cl.Text]
114
 
115
  resp_msg = resp["response"].content
116
 
 
 
117
  if source_documents:
118
  for source_idx, source_doc in enumerate(source_documents):
119
  source_name = f"source_{source_idx}"
120
 
121
  # Create the text element referenced in the message
122
  text_elements.append(
123
- cl.Text(content=source_doc[0].page_content, name="{} (scr: {})".format(source_name, round(source_doc[1],2)), display="side")
124
  )
 
 
 
125
  source_names = [text_el.name for text_el in text_elements]
126
 
127
  if source_names:
@@ -131,7 +136,7 @@ async def main(message: cl.Message):
131
 
132
  msg = cl.Message(content=resp_msg, elements=text_elements)
133
 
134
- print(msg.content)
135
  await msg.send()
136
 
137
 
 
107
  async def main(message: cl.Message):
108
  chain = cl.user_session.get("chain")
109
 
110
+ resp = await chain.ainvoke({"question" : message.content})
111
  source_documents = resp["context"]
112
 
113
  text_elements = [] # type: List[cl.Text]
114
 
115
  resp_msg = resp["response"].content
116
 
117
+ #print(source_documents)
118
+
119
  if source_documents:
120
  for source_idx, source_doc in enumerate(source_documents):
121
  source_name = f"source_{source_idx}"
122
 
123
  # Create the text element referenced in the message
124
  text_elements.append(
125
+ cl.Text(content=source_doc.page_content, name="{}".format(source_name), display="side")
126
  )
127
+ # text_elements.append(
128
+ # cl.Text(content=source_doc.page_content, name="{} (scr: {})".format(source_name, round(source_doc[1],2)), display="side")
129
+ #)
130
  source_names = [text_el.name for text_el in text_elements]
131
 
132
  if source_names:
 
136
 
137
  msg = cl.Message(content=resp_msg, elements=text_elements)
138
 
139
+ #print(msg.content)
140
  await msg.send()
141
 
142