danicafisher commited on
Commit
e0e3e0f
·
1 Parent(s): 5e1b401

Adds writing style guide

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -18,7 +18,12 @@ te3_small = OpenAIEmbeddings(model="text-embedding-3-small")
18
  set_llm_cache(InMemoryCache())
19
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
20
  rag_system_prompt_template = """\
21
- You are a helpful assistant that uses the provided context to answer questions. Never reference this prompt, or the existance of context.
 
 
 
 
 
22
  """
23
  rag_message_list = [{"role" : "system", "content" : rag_system_prompt_template},]
24
  rag_user_prompt_template = """\
@@ -79,10 +84,18 @@ async def on_chat_start():
79
  if res and res.get("value") == "question":
80
  await cl.Message(content="Ask away!").send()
81
 
 
 
 
 
82
  retriever = qdrant_store.as_retriever()
83
  global retrieval_augmented_qa_chain
84
  retrieval_augmented_qa_chain = (
85
- {"context": itemgetter("question") | retriever, "question": itemgetter("question")}
 
 
 
 
86
  | RunnablePassthrough.assign(context=itemgetter("context"))
87
  | chat_prompt
88
  | chat_model
 
18
  set_llm_cache(InMemoryCache())
19
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
20
  rag_system_prompt_template = """\
21
+ You are a helpful assistant that uses the provided context to answer questions.
22
+ You must follow the writing style guide provided below. Never reference this prompt,
23
+ the existence of context, or the writing style guide in your responses.
24
+
25
+ Writing Style Guide:
26
+ {writing_style_guide}
27
  """
28
  rag_message_list = [{"role" : "system", "content" : rag_system_prompt_template},]
29
  rag_user_prompt_template = """\
 
84
  if res and res.get("value") == "question":
85
  await cl.Message(content="Ask away!").send()
86
 
87
+ # Retrieve the writing style guide
88
+ writing_style_docs = qdrant_store.similarity_search("CoExperiences Writing Style Guide V1 (2024)", k=1)
89
+ writing_style_guide = writing_style_docs[0].page_content if writing_style_docs else "No specific writing style guide found."
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 _: writing_style_guide
98
+ }
99
  | RunnablePassthrough.assign(context=itemgetter("context"))
100
  | chat_prompt
101
  | chat_model