Spaces:
Paused
Paused
danicafisher
commited on
Commit
•
d6dc547
1
Parent(s):
41c371f
Update app.py
Browse filesUses locally stored style guide
app.py
CHANGED
@@ -84,17 +84,19 @@ async def on_chat_start():
|
|
84 |
if res and res.get("value") == "question":
|
85 |
await cl.Message(content="Ask away!").send()
|
86 |
|
87 |
-
#
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
91 |
retriever = qdrant_store.as_retriever()
|
92 |
global retrieval_augmented_qa_chain
|
93 |
retrieval_augmented_qa_chain = (
|
94 |
{
|
95 |
"context": itemgetter("question") | retriever,
|
96 |
"question": itemgetter("question"),
|
97 |
-
"writing_style_guide": lambda _:
|
98 |
}
|
99 |
| RunnablePassthrough.assign(context=itemgetter("context"))
|
100 |
| chat_prompt
|
|
|
84 |
if res and res.get("value") == "question":
|
85 |
await cl.Message(content="Ask away!").send()
|
86 |
|
87 |
+
# Load the style guide from the local file system
|
88 |
+
style_guide_path = "./public/CoExperiences Writing Style Guide V1 (2024).pdf"
|
89 |
+
loader = PyPDFLoader(style_guide_path)
|
90 |
+
style_guide_docs = loader.load()
|
91 |
+
style_guide_text = "\n".join([doc.page_content for doc in style_guide_docs])
|
92 |
+
|
93 |
retriever = qdrant_store.as_retriever()
|
94 |
global retrieval_augmented_qa_chain
|
95 |
retrieval_augmented_qa_chain = (
|
96 |
{
|
97 |
"context": itemgetter("question") | retriever,
|
98 |
"question": itemgetter("question"),
|
99 |
+
"writing_style_guide": lambda _: style_guide_text
|
100 |
}
|
101 |
| RunnablePassthrough.assign(context=itemgetter("context"))
|
102 |
| chat_prompt
|