From e219b9452031301930f3bc1bd30f26faab0e7a7c Mon Sep 17 00:00:00 2001 From: Sina Date: Fri, 24 May 2024 17:01:57 +0000 Subject: [PATCH] Remove unused code --- chainlite/llm_config.py | 16 +++++++++++----- chainlite/load_prompt.py | 10 ---------- setup.py | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/chainlite/llm_config.py b/chainlite/llm_config.py index 3c270a1..d283221 100644 --- a/chainlite/llm_config.py +++ b/chainlite/llm_config.py @@ -7,7 +7,7 @@ from langchain.globals import set_llm_cache import redis -from .load_prompt import set_custom_template_paths +from .load_prompt import initialize_jinja_environment # TODO move cache setting to the config file # We do not use LiteLLM's cache, use LangChain's instead @@ -29,7 +29,7 @@ class GlobalVars: local_engine_set = None -def load_config_from_file(config_file: str): +def load_config_from_file(config_file: str) -> None: with open(config_file, "r") as config_file: config = yaml.unsafe_load(config_file) @@ -91,14 +91,14 @@ def load_config_from_file(config_file: str): if model.startswith("huggingface/"): GlobalVars.local_engine_set.add(engine) - set_custom_template_paths(GlobalVars.prompt_dirs) + initialize_jinja_environment(GlobalVars.prompt_dirs) # this code is not safe to use with multiprocessing, only multithreading thread_lock = threading.Lock() -total_cost = 0 # in USD +total_cost = 0.0 # in USD def add_to_total_cost(amount: float): @@ -107,7 +107,13 @@ def add_to_total_cost(amount: float): total_cost += amount -def get_total_cost(): +def get_total_cost() -> float: + """ + This function is used to get the total LLM cost accumulated so far + + Returns: + float: The total cost accumulated so far in USD. + """ global total_cost return total_cost diff --git a/chainlite/load_prompt.py b/chainlite/load_prompt.py index 2a9f4e6..b4365f8 100644 --- a/chainlite/load_prompt.py +++ b/chainlite/load_prompt.py @@ -39,16 +39,6 @@ def initialize_jinja_environment(loader_paths): ) -def set_custom_template_paths(paths): - """ - Allows the user to set custom paths for the Jinja2 FileSystemLoader. - - Args: - paths (list of str): List of directory paths to use for loading templates. - """ - initialize_jinja_environment(paths) - - @lru_cache() def load_template_file(template_file: str) -> str: """ diff --git a/setup.py b/setup.py index 4c74833..f1c7f07 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="chainlite", - version="0.1.5", + version="0.1.6", author="Sina Semnani", author_email="sinaj@cs.stanford.edu", description="A Python package that uses LangChain and LiteLLM to call large language model APIs easily",