jenngang commited on
Commit
0758e93
·
verified ·
1 Parent(s): 4db60d2

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -67,18 +67,18 @@ my_api_key = os.environ["MY_API_KEY"]
67
  # Initialize the OpenAI embedding function for Chroma
68
  embedding_function = chromadb.utils.embedding_functions.OpenAIEmbeddingFunction(
69
  api_base=endpoint, # Complete the code to define the API base endpoint
70
- api_key=api_key, # Complete the code to define the API key
71
- model_name='text-embedding-ada-002' # This is a fixed value and does not need modification
72
  )
 
73
 
74
  # This initializes the OpenAI embedding function for the Chroma vectorstore, using the provided endpoint and API key.
75
 
76
  # Initialize the OpenAI Embeddings
77
  embedding_model = OpenAIEmbeddings(
78
  openai_api_base=endpoint,
79
- openai_api_key=api_key,
80
- model='text-embedding-ada-002'
81
  )
 
82
 
83
  # Initialize the Chat OpenAI model
84
  llm = ChatOpenAI(
@@ -529,11 +529,11 @@ def agentic_rag(query: str):
529
 
530
  return output
531
 
532
-
533
  #================================ Guardrails ===========================#
534
  llama_guard_client = Groq(api_key=groq_api_key) # Groq(api_key=llama_api_key)
535
  # Function to filter user input with Llama Guard
536
- def filter_input_with_llama_guard(user_input, model="llama-guard-3-8b"):
 
537
  """
538
  Filters user input using Llama Guard to ensure it is safe.
539
 
@@ -569,9 +569,12 @@ class NutritionBot:
569
  self.memory = MemoryClient(api_key=MEM0_api_key) # userdata.get("mem0")) # Complete the code to define the memory client API key
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
 
 
67
  # Initialize the OpenAI embedding function for Chroma
68
  embedding_function = chromadb.utils.embedding_functions.OpenAIEmbeddingFunction(
69
  api_base=endpoint, # Complete the code to define the API base endpoint
70
+ api_key=api_key # Complete the code to define the API key
 
71
  )
72
+ #model_name='text-embedding-ada-002' # This is a fixed value and does not need modification
73
 
74
  # This initializes the OpenAI embedding function for the Chroma vectorstore, using the provided endpoint and API key.
75
 
76
  # Initialize the OpenAI Embeddings
77
  embedding_model = OpenAIEmbeddings(
78
  openai_api_base=endpoint,
79
+ openai_api_key=api_key
 
80
  )
81
+ #model='text-embedding-ada-002'
82
 
83
  # Initialize the Chat OpenAI model
84
  llm = ChatOpenAI(
 
529
 
530
  return output
531
 
 
532
  #================================ Guardrails ===========================#
533
  llama_guard_client = Groq(api_key=groq_api_key) # Groq(api_key=llama_api_key)
534
  # Function to filter user input with Llama Guard
535
+ #def filter_input_with_llama_guard(user_input, model="llama-guard-3-8b"):
536
+ def filter_input_with_llama_guard(user_input, model="meta-llama/llama-guard-4-12b"):
537
  """
538
  Filters user input using Llama Guard to ensure it is safe.
539
 
 
569
  self.memory = MemoryClient(api_key=MEM0_api_key) # userdata.get("mem0")) # Complete the code to define the memory client API key
570
 
571
  self.client = ChatOpenAI(
572
+ #model_name="gpt-4o", # Specify the model to use (e.g., GPT-4 optimized version)
573
+ model="gpt-4o-mini",
574
+ #api_key = api_key, # config.get("API_KEY"), # API key for authentication
575
+ openai_api_key=api_key, # Fill in the API key
576
+ #base_url = endpoint, # config.get("OPENAI_API_BASE"),
577
+ openai_api_base=endpoint, # Fill in the endpoint
578
  temperature=0 # Controls randomness in responses; 0 ensures deterministic results
579
  )
580