Spaces:
Sleeping
Sleeping
tweaks
Browse files- pages/3_🕮_Docs_Demo.py +16 -1
pages/3_🕮_Docs_Demo.py
CHANGED
|
@@ -96,10 +96,25 @@ rag_chain = (
|
|
| 96 |
| StrOutputParser()
|
| 97 |
)
|
| 98 |
|
|
|
|
|
|
|
|
|
|
| 99 |
# +
|
| 100 |
-
# rag_chain.invoke("What is the difference between Fee and Easement?")
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
|
|
|
| 103 |
|
| 104 |
# +
|
| 105 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|
|
|
|
| 96 |
| StrOutputParser()
|
| 97 |
)
|
| 98 |
|
| 99 |
+
rag_chain.invoke("What is the difference between Fee and Easement?")
|
| 100 |
+
|
| 101 |
+
|
| 102 |
# +
|
|
|
|
| 103 |
|
| 104 |
+
from langchain_core.runnables import RunnableParallel
|
| 105 |
+
|
| 106 |
+
rag_chain_from_docs = (
|
| 107 |
+
RunnablePassthrough.assign(context=(lambda x: format_docs(x["context"])))
|
| 108 |
+
| prompt
|
| 109 |
+
| llm
|
| 110 |
+
| StrOutputParser()
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
rag_chain_with_source = RunnableParallel(
|
| 114 |
+
{"context": retriever, "question": RunnablePassthrough()}
|
| 115 |
+
).assign(answer=rag_chain_from_docs)
|
| 116 |
|
| 117 |
+
rag_chain_with_source.invoke("What is the difference between Fee and Easement?")
|
| 118 |
|
| 119 |
# +
|
| 120 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|