Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -581,12 +581,25 @@ class NutritionBot:
|
|
| 581 |
# Initialize a memory client to store and retrieve customer interactions
|
| 582 |
self.memory = MemoryClient(api_key=userdata.get("mem0")) # Complete the code to define the memory client API key
|
| 583 |
|
| 584 |
-
# Initialize the OpenAI client using the provided credentials
|
| 585 |
-
self.client = ChatOpenAI(
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
)
|
| 591 |
|
| 592 |
# Define tools available to the chatbot, such as web search
|
|
|
|
| 581 |
# Initialize a memory client to store and retrieve customer interactions
|
| 582 |
self.memory = MemoryClient(api_key=userdata.get("mem0")) # Complete the code to define the memory client API key
|
| 583 |
|
| 584 |
+
# # Initialize the OpenAI client using the provided credentials
|
| 585 |
+
# self.client = ChatOpenAI(
|
| 586 |
+
# model_name="gpt-4o-mini", # Specify the model to use (e.g., GPT-4 optimized version)
|
| 587 |
+
# api_key=config.get("API_KEY"), # API key for authentication
|
| 588 |
+
# endpoint = config.get("OPENAI_API_BASE"),
|
| 589 |
+
# temperature=0 # Controls randomness in responses; 0 ensures deterministic results
|
| 590 |
+
# )
|
| 591 |
+
|
| 592 |
+
import os
|
| 593 |
+
from openai import OpenAI
|
| 594 |
+
|
| 595 |
+
# Set environment variables beforehand, if not already
|
| 596 |
+
os.environ['OPENAI_API_KEY'] = config.get("API_KEY")
|
| 597 |
+
os.environ['OPENAI_API_BASE'] = config.get("OPENAI_API_BASE")
|
| 598 |
+
|
| 599 |
+
# Use the proper OpenAI client
|
| 600 |
+
self.client = OpenAI(
|
| 601 |
+
api_key=os.environ["OPENAI_API_KEY"],
|
| 602 |
+
base_url=os.environ["OPENAI_API_BASE"]
|
| 603 |
)
|
| 604 |
|
| 605 |
# Define tools available to the chatbot, such as web search
|