AlanOC commited on
Commit
a80efa0
1 Parent(s): f0a8d35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -23
app.py CHANGED
@@ -88,6 +88,33 @@ if not os.path.exists(db_path):
88
  vectordb = Chroma(persist_directory="./data", embedding_function=OpenAIEmbeddings())
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  def ask_alans_ai(query, vectordb):
92
  global chat_history
93
  result = pdf_qa(
@@ -126,30 +153,7 @@ if __name__ == "__main__":
126
 
127
 
128
 
129
- # Define the system message template
130
- system_template = """Use only the following pieces of context to answer the question at the end.
131
- If you don't know the answer, just say that you don't know. Don't try to make up an answer.
132
- Always answer in Englsih. Split the answer into easily readable paragraphs. Use bullet points and number points where possible.
133
- Include any useful URLs and/or contact details from the context provided whereever possible.
134
- Always end by adding a carrage return and then saying: Thank you for your query to CitizensInformation.ie chat!
135
- ----------------
136
- {context}"""
137
 
138
- # Create the chat prompt templates
139
- messages = [
140
- SystemMessagePromptTemplate.from_template(system_template),
141
- HumanMessagePromptTemplate.from_template("{question}")
142
- ]
143
- qa_prompt = ChatPromptTemplate.from_messages(messages)
144
-
145
-
146
-
147
-
148
-
149
- pdf_qa = ConversationalRetrievalChain.from_llm(
150
- ChatOpenAI(temperature=0.9, model_name="gpt-3.5-turbo"),
151
- vectordb.as_retriever(),return_source_documents=True,verbose=False,combine_docs_chain_kwargs={"prompt": qa_prompt})
152
-
153
 
154
 
155
  # print("system_template is:", system_template, end="\n")
 
88
  vectordb = Chroma(persist_directory="./data", embedding_function=OpenAIEmbeddings())
89
 
90
 
91
+ # Define the system message template
92
+ system_template = """Use only the following pieces of context to answer the question at the end.
93
+ If you don't know the answer, just say that you don't know. Don't try to make up an answer.
94
+ Always answer in Englsih. Split the answer into easily readable paragraphs. Use bullet points and number points where possible.
95
+ Include any useful URLs and/or contact details from the context provided whereever possible.
96
+ Always end by adding a carrage return and then saying: Thank you for your query to CitizensInformation.ie chat!
97
+ ----------------
98
+ {context}"""
99
+
100
+ # Create the chat prompt templates
101
+ messages = [
102
+ SystemMessagePromptTemplate.from_template(system_template),
103
+ HumanMessagePromptTemplate.from_template("{question}")
104
+ ]
105
+ qa_prompt = ChatPromptTemplate.from_messages(messages)
106
+
107
+
108
+
109
+
110
+
111
+ pdf_qa = ConversationalRetrievalChain.from_llm(
112
+ ChatOpenAI(temperature=0.9, model_name="gpt-3.5-turbo"),
113
+ vectordb.as_retriever(),return_source_documents=True,verbose=False,combine_docs_chain_kwargs={"prompt": qa_prompt})
114
+
115
+
116
+
117
+
118
  def ask_alans_ai(query, vectordb):
119
  global chat_history
120
  result = pdf_qa(
 
153
 
154
 
155
 
 
 
 
 
 
 
 
 
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
 
159
  # print("system_template is:", system_template, end="\n")