arajshiva commited on
Commit
ee477e6
·
verified ·
1 Parent(s): ee141dc

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -624,25 +624,24 @@ class NutritionBot:
624
  Initialize the NutritionBot class, setting up memory, the LLM client, tools, and the agent executor.
625
  """
626
  # Define tools available to the chatbot, such as web search
627
- tools = [agentic_rag]
 
 
 
628
 
629
- # Define the system prompt to set the behavior of the chatbot
630
- system_prompt = """You are a helpful nutrition assistant.
631
- Answer user questions about nutrition disorders accurately, clearly, and respectfully using available information."""
632
-
633
- # Build the prompt template for the agent
634
- prompt = ChatPromptTemplate.from_messages([
635
  ("system", system_prompt), # System instructions
636
  ("human", "{input}"), # Placeholder for human input
637
  ("placeholder", "{agent_scratchpad}") # Placeholder for intermediate reasoning steps
638
- ])
639
 
640
- # Create an agent capable of interacting with tools and executing tasks
641
- agent = create_tool_calling_agent(self.client, tools, prompt)
642
 
643
- # Wrap the agent in an executor to manage tool interactions and execution flow
644
- self.agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
645
-
646
 
647
  def store_customer_interaction(self, user_id: str, message: str, response: str, metadata: Dict = None):
648
  """
 
624
  Initialize the NutritionBot class, setting up memory, the LLM client, tools, and the agent executor.
625
  """
626
  # Define tools available to the chatbot, such as web search
627
+ tools = [agentic_rag]
628
+ # Define the system prompt to set the behavior of the chatbot
629
+ system_prompt = """You are a helpful nutrition assistant.
630
+ Answer user questions about nutrition disorders accurately, clearly, and respectfully using available information."""
631
 
632
+ # Build the prompt template for the agent
633
+ prompt = ChatPromptTemplate.from_messages([
 
 
 
 
634
  ("system", system_prompt), # System instructions
635
  ("human", "{input}"), # Placeholder for human input
636
  ("placeholder", "{agent_scratchpad}") # Placeholder for intermediate reasoning steps
637
+ ])
638
 
639
+ # Create an agent capable of interacting with tools and executing tasks
640
+ agent = create_tool_calling_agent(self.client, tools, prompt)
641
 
642
+ # Wrap the agent in an executor to manage tool interactions and execution flow
643
+ self.agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
644
+
645
 
646
  def store_customer_interaction(self, user_id: str, message: str, response: str, metadata: Dict = None):
647
  """