Skip to content

Commit

Permalink
move nomic.login() out of the top level so it's only called when the …
Browse files Browse the repository at this point in the history
…functions are needed... bad idea, but nomic login is broken right now
  • Loading branch information
KastanDay committed Sep 27, 2023
1 parent 6585981 commit b21aad7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ai_ta_backend/nomic_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down

0 comments on commit b21aad7

Please sign in to comment.