From b21aad72890863be8f3421324b4c7acd7d495a0d Mon Sep 17 00:00:00 2001 From: Kastan Day Date: Wed, 27 Sep 2023 16:17:41 -0700 Subject: [PATCH] move nomic.login() out of the top level so it's only called when the functions are needed... bad idea, but nomic login is broken right now --- ai_ta_backend/nomic_logging.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ai_ta_backend/nomic_logging.py b/ai_ta_backend/nomic_logging.py index 374313d4..652d035f 100644 --- a/ai_ta_backend/nomic_logging.py +++ b/ai_ta_backend/nomic_logging.py @@ -9,11 +9,11 @@ from langchain.embeddings import OpenAIEmbeddings from nomic import AtlasProject, atlas -nomic.login(os.getenv('NOMIC_API_KEY')) # login during start of flask app -NOMIC_MAP_NAME_PREFIX = 'Conversation Map for ' - def log_convo_to_nomic(course_name: str, conversation) -> str: + nomic.login(os.getenv('NOMIC_API_KEY')) # login during start of flask app + NOMIC_MAP_NAME_PREFIX = 'Conversation Map for ' + """ Logs conversation to Nomic. 1. Check if map exists for given course @@ -145,6 +145,9 @@ def get_nomic_map(course_name: str): map link: https://atlas.nomic.ai/map/ed222613-97d9-46a9-8755-12bbc8a06e3a/f4967ad7-ff37-4098-ad06-7e1e1a93dd93 map id: f4967ad7-ff37-4098-ad06-7e1e1a93dd93 """ + nomic.login(os.getenv('NOMIC_API_KEY')) # login during start of flask app + NOMIC_MAP_NAME_PREFIX = 'Conversation Map for ' + project_name = NOMIC_MAP_NAME_PREFIX + course_name start_time = time.monotonic() @@ -169,6 +172,9 @@ def create_nomic_map(course_name: str, log_data: list): 2. appends current embeddings and metadata to it 2. creates map if there are at least 20 queries """ + nomic.login(os.getenv('NOMIC_API_KEY')) # login during start of flask app + NOMIC_MAP_NAME_PREFIX = 'Conversation Map for ' + print(f"in create_nomic_map() for {course_name}") # initialize supabase supabase_client = supabase.create_client( # type: ignore