Wajahat698 commited on
Commit
615e4be
·
verified ·
1 Parent(s): 5628832

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -124,8 +124,8 @@ def google_search_tool(query: str):
124
  """
125
  return google_search(query)
126
 
127
- tools = [knowledge_base_tool, google_search_tool]
128
-
129
  # Create the prompt template
130
  prompt_message = """
131
  Act as an expert copywriter who specializes in creating compelling marketing copy using AI technologies.
@@ -175,8 +175,17 @@ chat_history = []
175
 
176
  def chatbot_response(message, history):
177
  try:
 
178
  output = agent_executor.invoke({"input": message, "chat_history": chat_history})
179
- chat_history.extend([HumanMessage(content=message), AIMessage(content=output["output"])])
 
 
 
 
 
 
 
 
180
  return output["output"]
181
  except Exception as e:
182
  logger.error(f"Error generating chatbot response: {e}")
 
124
  """
125
  return google_search(query)
126
 
127
+ tools = [
128
+ knowledge_base_tool]
129
  # Create the prompt template
130
  prompt_message = """
131
  Act as an expert copywriter who specializes in creating compelling marketing copy using AI technologies.
 
175
 
176
  def chatbot_response(message, history):
177
  try:
178
+ # Generate response using the agent executor
179
  output = agent_executor.invoke({"input": message, "chat_history": chat_history})
180
+
181
+ # Save the interaction context
182
+ chat_history.extend(
183
+ [
184
+ HumanMessage(content=message),
185
+ AIMessage(content=output["output"]),
186
+ ]
187
+ )
188
+
189
  return output["output"]
190
  except Exception as e:
191
  logger.error(f"Error generating chatbot response: {e}")