01aiYi-NvidiaEmbed / utils.py
Tonic's picture
add intention mapper to embedding flow , refactor into classes
eb88ab8
raw
history blame
No virus
815 Bytes
# utils.py
import re
from dotenv import load_dotenv
import re
import os
from globalvars import tasks
def load_env_variables():
# Load the .env file
load_dotenv()
# Retrieve the environment variables
hf_token = os.getenv('HF_TOKEN')
yi_token = os.getenv('YI_TOKEN')
return hf_token, yi_token
def parse_and_route(example_output: str):
# Regex pattern to match the true task
pattern = r'"(\w+)":\s?true'
# Find the true task
match = re.search(pattern, example_output)
if match:
true_task = match.group(1)
if true_task in tasks:
return {true_task: tasks[true_task]}
else:
return {true_task: "Task description not found"}
else:
return "No true task found in the example output"