Pijush2023 commited on
Commit
8b111d1
·
verified ·
1 Parent(s): 8ac223f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -170,29 +170,30 @@ prompt = ChatPromptTemplate.from_messages(
170
  chain_neo4j = (
171
  RunnableParallel(
172
  {
173
- "chat_history": _search_query,
174
- "input": RunnablePassthrough(),
175
- "agent_scratchpad": retriever_neo4j,
176
  }
177
  )
178
- | prompt
179
- | llm
180
- | StrOutputParser()
181
  )
182
 
183
  # Define the function to get the response
184
  def get_response(input_text):
185
  try:
186
- # Adjust input to match expected structure
187
  return chain_neo4j.invoke({
188
- "input": input_text,
189
  "chat_history": [], # Replace with actual chat history if available
190
- "agent_scratchpad": "" # Replace with actual content if needed
191
  })
192
  except Exception as e:
193
  return f"Error: {str(e)}"
194
 
195
 
 
196
  # Define the function to clear input and output
197
  def clear_fields():
198
  return [],"",None
 
170
  chain_neo4j = (
171
  RunnableParallel(
172
  {
173
+ "chat_history": _search_query, # Pass chat history through the _search_query
174
+ "input": RunnablePassthrough(), # Directly pass user input as 'input'
175
+ "agent_scratchpad": retriever_neo4j, # Use the retriever to get additional context
176
  }
177
  )
178
+ | prompt # Use the prompt with the provided context
179
+ | llm # Use the LLM for generating a response
180
+ | StrOutputParser() # Parse the response into a string
181
  )
182
 
183
  # Define the function to get the response
184
  def get_response(input_text):
185
  try:
186
+ # Call the chain with the proper variables
187
  return chain_neo4j.invoke({
188
+ "input": input_text, # User's question as 'input'
189
  "chat_history": [], # Replace with actual chat history if available
190
+ "agent_scratchpad": "" # Placeholder for any additional data
191
  })
192
  except Exception as e:
193
  return f"Error: {str(e)}"
194
 
195
 
196
+
197
  # Define the function to clear input and output
198
  def clear_fields():
199
  return [],"",None