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 |
-
api_key =
|
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
|
@@ -776,9 +776,8 @@ def nutrition_disorder_streamlit():
|
|
776 |
st.write(response)
|
777 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
778 |
except Exception as e:
|
779 |
-
|
780 |
-
st.
|
781 |
-
st.session_state.chat_history.append({"role": "assistant", "content": error_msg})
|
782 |
else:
|
783 |
inappropriate_msg = "I apologize, but I cannot process that input as it may be inappropriate. Please try again."
|
784 |
st.write(inappropriate_msg)
|
|
|
570 |
|
571 |
self.client = ChatOpenAI(
|
572 |
model_name="gpt-4o", # Specify the model to use (e.g., GPT-4 optimized version)
|
573 |
+
api_key = my_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
|
|
|
776 |
st.write(response)
|
777 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
778 |
except Exception as e:
|
779 |
+
st.write(f"Sorry, I encountered an error while processing your query. Please try again. Error: {e}", str(e))
|
780 |
+
st.session_state.chat_history.append({"role": "assistant", "content": f"Sorry, I encountered an error while processing your query. Please try again. Error: {e}"})
|
|
|
781 |
else:
|
782 |
inappropriate_msg = "I apologize, but I cannot process that input as it may be inappropriate. Please try again."
|
783 |
st.write(inappropriate_msg)
|