Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -570,9 +570,9 @@ class NutritionBot:
|
|
570 |
|
571 |
self.client = ChatOpenAI(
|
572 |
model_name="gpt-4o", # Specify the model to use (e.g., GPT-4 optimized version)
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
)
|
577 |
|
578 |
# Define tools available to the chatbot, such as web search
|
@@ -590,7 +590,6 @@ class NutritionBot:
|
|
590 |
Always use the agentic_rag tool to retrieve up-to-date and evidence-based nutrition insights.
|
591 |
Keep track of ongoing issues and follow-ups to ensure continuity in support.
|
592 |
Your primary goal is to help customers make informed nutrition decisions that align with their health conditions and personal preferences.
|
593 |
-
|
594 |
"""
|
595 |
|
596 |
# Build the prompt template for the agent
|
@@ -678,7 +677,7 @@ class NutritionBot:
|
|
678 |
context += "---\n"
|
679 |
|
680 |
# Print context for debugging purposes
|
681 |
-
|
682 |
|
683 |
# Prepare a prompt combining past context and the current query
|
684 |
prompt = f"""
|
@@ -686,9 +685,11 @@ class NutritionBot:
|
|
686 |
Current customer query: {query}
|
687 |
Provide a helpful response that takes into account any relevant past interactions.
|
688 |
"""
|
|
|
689 |
|
690 |
# Generate a response using the agent
|
691 |
response = self.agent_executor.invoke({"input": prompt})
|
|
|
692 |
|
693 |
# Store the current interaction for future reference
|
694 |
self.store_customer_interaction(
|
|
|
570 |
|
571 |
self.client = ChatOpenAI(
|
572 |
model_name="gpt-4o", # Specify the model to use (e.g., GPT-4 optimized version)
|
573 |
+
api_key = api_key, # config.get("API_KEY"), # API key for authentication
|
574 |
+
base_url = endpoint, # config.get("OPENAI_API_BASE"),
|
575 |
+
temperature=0 # Controls randomness in responses; 0 ensures deterministic results
|
576 |
)
|
577 |
|
578 |
# Define tools available to the chatbot, such as web search
|
|
|
590 |
Always use the agentic_rag tool to retrieve up-to-date and evidence-based nutrition insights.
|
591 |
Keep track of ongoing issues and follow-ups to ensure continuity in support.
|
592 |
Your primary goal is to help customers make informed nutrition decisions that align with their health conditions and personal preferences.
|
|
|
593 |
"""
|
594 |
|
595 |
# Build the prompt template for the agent
|
|
|
677 |
context += "---\n"
|
678 |
|
679 |
# Print context for debugging purposes
|
680 |
+
st.write("Context: ", context)
|
681 |
|
682 |
# Prepare a prompt combining past context and the current query
|
683 |
prompt = f"""
|
|
|
685 |
Current customer query: {query}
|
686 |
Provide a helpful response that takes into account any relevant past interactions.
|
687 |
"""
|
688 |
+
st.write("Context: ", prompt)
|
689 |
|
690 |
# Generate a response using the agent
|
691 |
response = self.agent_executor.invoke({"input": prompt})
|
692 |
+
st.write("Context: ", response)
|
693 |
|
694 |
# Store the current interaction for future reference
|
695 |
self.store_customer_interaction(
|