feat: 02_10
Browse files- app/app.py +3 -13
app/app.py
CHANGED
|
@@ -144,7 +144,7 @@ async def on_chat_start():
|
|
| 144 |
await msg.update()
|
| 145 |
|
| 146 |
##########################################################################
|
| 147 |
-
# Exercise
|
| 148 |
# Now we have search engine setup, our Chat with PDF application can do
|
| 149 |
# RAG architecture pattern. Please use the appropriate RetrievalQA Chain
|
| 150 |
# from Langchain.
|
|
@@ -183,24 +183,14 @@ async def main(message: cl.Message):
|
|
| 183 |
)
|
| 184 |
answer = response["answer"]
|
| 185 |
sources = response["sources"].strip()
|
| 186 |
-
source_elements = []
|
| 187 |
|
| 188 |
-
# Get the documents from
|
| 189 |
docs = cl.user_session.get("docs")
|
| 190 |
metadatas = [doc.metadata for doc in docs]
|
| 191 |
all_sources = [m["source"] for m in metadatas]
|
| 192 |
|
| 193 |
-
##########################################################################
|
| 194 |
-
# Exercise 1a:
|
| 195 |
-
# Now we have search engine setup, our Chat with PDF application can do
|
| 196 |
-
# RAG architecture pattern. Please use the appropriate RetrievalQA Chain
|
| 197 |
-
# from Langchain.
|
| 198 |
-
#
|
| 199 |
-
# Remember, we would want to set the model temperature to
|
| 200 |
-
# 0 to ensure model outputs do not vary across runs, and we would want to
|
| 201 |
-
# also return sources to our answers.
|
| 202 |
-
##########################################################################
|
| 203 |
# Adding sources to the answer
|
|
|
|
| 204 |
if sources:
|
| 205 |
found_sources = []
|
| 206 |
|
|
|
|
| 144 |
await msg.update()
|
| 145 |
|
| 146 |
##########################################################################
|
| 147 |
+
# Exercise 1:
|
| 148 |
# Now we have search engine setup, our Chat with PDF application can do
|
| 149 |
# RAG architecture pattern. Please use the appropriate RetrievalQA Chain
|
| 150 |
# from Langchain.
|
|
|
|
| 183 |
)
|
| 184 |
answer = response["answer"]
|
| 185 |
sources = response["sources"].strip()
|
|
|
|
| 186 |
|
| 187 |
+
# Get all of the documents from user session
|
| 188 |
docs = cl.user_session.get("docs")
|
| 189 |
metadatas = [doc.metadata for doc in docs]
|
| 190 |
all_sources = [m["source"] for m in metadatas]
|
| 191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
# Adding sources to the answer
|
| 193 |
+
source_elements = []
|
| 194 |
if sources:
|
| 195 |
found_sources = []
|
| 196 |
|