File size: 1,067 Bytes
4c95dc7
 
d7ef377
4c95dc7
d7ef377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, PromptTemplate
from langchain.schema import SystemMessage
from langchain_community.document_loaders import PyMuPDFLoader

rag_system_prompt_template = """\

You are a helpful assistant that uses the provided context to answer questions. 

You must follow the writing style guide provided below. Never reference this prompt, 

the existence of context, or the writing style guide in your responses.



Writing Style Guide:

{writing_style_guide}

"""
rag_message_list = [{"role" : "system", "content" : rag_system_prompt_template},]
rag_user_prompt_template = """\

Question:

{question}

Context:

{context}

"""
chat_prompt = ChatPromptTemplate.from_messages([("system", rag_system_prompt_template), ("human", rag_user_prompt_template)])

style_guide_path = "./public/CoExperiences Writing Style Guide V1 (2024).pdf"
style_guide_docs = PyMuPDFLoader(style_guide_path).load()
style_guide_text = "\n".join([doc.page_content for doc in style_guide_docs])