jenngang commited on
Commit
37f1fa5
·
verified ·
1 Parent(s): 8f500ed

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -57,7 +57,8 @@ from datetime import datetime
57
  api_key = config.get("API_KEY")
58
  endpoint = config.get("OPENAI_API_BASE")
59
  groq_api_key = config.get('LLAMA_API_KEY') # llama_api_key = os.environ['GROQ_API_KEY']
60
- MEM0_api_key = config.get('mem0') # MEM0_api_key = os.environ['mem0']
 
61
 
62
  # Initialize the OpenAI embedding function for Chroma
63
  embedding_function = chromadb.utils.embedding_functions.OpenAIEmbeddingFunction(
@@ -480,7 +481,7 @@ def create_workflow() -> StateGraph:
480
  should_continue_precision, # ___________, # Use the conditional function
481
  {
482
  "pass": END, # ___________, # If precise, complete the workflow.
483
- "refine_query": "refine_query" # ___________, # If imprecise, refine the query.
484
  "max_iterations_reached": "max_iterations_reached" # ___________ # If max loops reached, exit.
485
  }
486
  )
@@ -514,8 +515,8 @@ def agentic_rag(query: str):
514
  "context": [], # Retrieved documents (initially empty)
515
  "response": "", # "_____", # Complete the code to define the AI-generated response
516
  "precision_score": 0.0, # _____, # Complete the code to define the precision score of the response
517
- "groundedness_score": 0.0 # _____, # Complete the code to define the groundedness score of the response
518
- "groundedness_loop_count": 0 # _____, # Complete the code to define the counter for groundedness loops
519
  "precision_loop_count": 0, # _____, # Complete the code to define the counter for precision loops
520
  "feedback": "", # "_____", # Complete the code to define the feedback
521
  "query_feedback": "", # "_____", # Complete the code to define the query feedback
@@ -767,7 +768,7 @@ def nutrition_disorder_streamlit():
767
  if filtered_result in ["safe", "safe S7", "safe S6"]: # __________, __________, __________]: # Blanks #3, #4, #5: Fill in with allowed safe statuses (e.g., "safe", "unsafe S7", "unsafe S6")
768
  try:
769
  if 'chatbot' not in st.session_state:
770
- st.session_state.chatbot = NutritionBot # () __________() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
771
  response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query) # __________(st.session_state.user_id, user_query)
772
  # Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
773
  st.write(response)
 
57
  api_key = config.get("API_KEY")
58
  endpoint = config.get("OPENAI_API_BASE")
59
  groq_api_key = config.get('LLAMA_API_KEY') # llama_api_key = os.environ['GROQ_API_KEY']
60
+ MEM0_api_key = config.get('MEM0_API_KEY') # MEM0_api_key = os.environ['mem0']
61
+ my_api_key = config.get("MY_API_KEY")
62
 
63
  # Initialize the OpenAI embedding function for Chroma
64
  embedding_function = chromadb.utils.embedding_functions.OpenAIEmbeddingFunction(
 
481
  should_continue_precision, # ___________, # Use the conditional function
482
  {
483
  "pass": END, # ___________, # If precise, complete the workflow.
484
+ "refine_query": "refine_query", # ___________, # If imprecise, refine the query.
485
  "max_iterations_reached": "max_iterations_reached" # ___________ # If max loops reached, exit.
486
  }
487
  )
 
515
  "context": [], # Retrieved documents (initially empty)
516
  "response": "", # "_____", # Complete the code to define the AI-generated response
517
  "precision_score": 0.0, # _____, # Complete the code to define the precision score of the response
518
+ "groundedness_score": 0.0, # _____, # Complete the code to define the groundedness score of the response
519
+ "groundedness_loop_count": 0, # _____, # Complete the code to define the counter for groundedness loops
520
  "precision_loop_count": 0, # _____, # Complete the code to define the counter for precision loops
521
  "feedback": "", # "_____", # Complete the code to define the feedback
522
  "query_feedback": "", # "_____", # Complete the code to define the query feedback
 
768
  if filtered_result in ["safe", "safe S7", "safe S6"]: # __________, __________, __________]: # Blanks #3, #4, #5: Fill in with allowed safe statuses (e.g., "safe", "unsafe S7", "unsafe S6")
769
  try:
770
  if 'chatbot' not in st.session_state:
771
+ st.session_state.chatbot = NutritionBot() # __________() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
772
  response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query) # __________(st.session_state.user_id, user_query)
773
  # Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
774
  st.write(response)