File size: 1,350 Bytes
28d8100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import yaml
import datetime
from typing import Dict, List


def get_current_date() -> str:
    """returns present date.

    Returns:
        str: return present date as a string.
    """
    current_date = datetime.date.today().strftime("%Y-%m-%d")  # provide current date to LLM context
    return current_date
    
    
def read_yaml(file_path: str) -> Dict:
    """_summary_

    Args:
        file_path (str): wesites.yaml file path

    Raises:
        ValueError: raise error is file_path is empty or if websites.yaml file is missing.

    Returns:
        Dict: return List websites to be used for websearch.
    """
    websites_yaml = None
    if not read_yaml:
        raise ValueError("Website yaml config file missing")
        return websites_yaml
    else:
        with open(file_path, 'r') as file:
            websites_yaml = yaml.load(file, Loader=yaml.SafeLoader)  # reads .yaml file
    return websites_yaml


def get_websites() -> List[str]:
    """reads websites.yaml file and return list of webistes

    Returns:
        List[str]: List of websites
    """
    file_path = os.path.join(os.getcwd(), 'websites.yaml')  # get websites.yaml file path
    websites = read_yaml(file_path) # read wesbites.yaml file
    if not websites:
        return []
    return websites['public_websites'] # return list of public files