Pijush2023 commited on
Commit
3011887
·
verified ·
1 Parent(s): 619241c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -153,6 +153,7 @@ _search_query = RunnableBranch(
153
  #Answer:"""
154
 
155
 
 
156
  prompt = ChatPromptTemplate.from_messages(
157
  [
158
  (
@@ -165,9 +166,7 @@ prompt = ChatPromptTemplate.from_messages(
165
  ]
166
  )
167
 
168
-
169
-
170
- #qa_prompt = ChatPromptTemplate.from_template(prompt)
171
  qa_prompt = prompt
172
 
173
 
@@ -175,8 +174,9 @@ qa_prompt = prompt
175
  chain_neo4j = (
176
  RunnableParallel(
177
  {
178
- "context": _search_query | retriever_neo4j,
179
- "question": RunnablePassthrough(),
 
180
  }
181
  )
182
  | qa_prompt
@@ -184,10 +184,11 @@ chain_neo4j = (
184
  | StrOutputParser()
185
  )
186
 
 
187
  # Define the function to get the response
188
  def get_response(question):
189
  try:
190
- return chain_neo4j.invoke({"question": question})
191
  except Exception as e:
192
  return f"Error: {str(e)}"
193
 
 
153
  #Answer:"""
154
 
155
 
156
+ # Define the ChatPromptTemplate
157
  prompt = ChatPromptTemplate.from_messages(
158
  [
159
  (
 
166
  ]
167
  )
168
 
169
+ # Ensure 'context' and 'question' map correctly to the prompt's expected variables
 
 
170
  qa_prompt = prompt
171
 
172
 
 
174
  chain_neo4j = (
175
  RunnableParallel(
176
  {
177
+ "chat_history": _search_query,
178
+ "input": RunnablePassthrough(),
179
+ "agent_scratchpad": retriever_neo4j,
180
  }
181
  )
182
  | qa_prompt
 
184
  | StrOutputParser()
185
  )
186
 
187
+
188
  # Define the function to get the response
189
  def get_response(question):
190
  try:
191
+ return chain_neo4j.invoke({"input": question, "chat_history": [], "agent_scratchpad": ""})
192
  except Exception as e:
193
  return f"Error: {str(e)}"
194