Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
s-jse committed May 24, 2024
1 parent 09e2b04 commit e219b94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
16 changes: 11 additions & 5 deletions chainlite/llm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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):
Expand All @@ -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

Expand Down
10 changes: 0 additions & 10 deletions chainlite/load_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e219b94

Please sign in to comment.