mayank1101's picture
Upload 7 files
28d8100 verified
raw
history blame
1.35 kB
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