File size: 783 Bytes
2ca300b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"