CineAI commited on
Commit
5cdab92
1 Parent(s): e602799

Update llm/llamacpp/lc_model.py

Browse files
Files changed (1) hide show
  1. llm/llamacpp/lc_model.py +15 -7
llm/llamacpp/lc_model.py CHANGED
@@ -37,14 +37,19 @@ class LC_TinyLlama(LLMInterface, ABC):
37
  path_to_model = os.path.join("../models", self.model_config["model_name"])
38
  with open(path_to_model, "wb") as f:
39
  f.write(get_file.content)
40
- logger.info("Model file successfully recorded")
41
- f.close()
 
 
42
  except OSError as e:
43
- print(f"Error while write a file to directory : {e}")
44
  logger.error(msg="Error while write a file to directory", exc_info=e)
 
 
45
 
46
  @staticmethod
47
  def __read_yaml():
 
48
  try:
49
  yaml_file = os.path.join("../", 'prompts.yaml')
50
  with open(yaml_file, 'r') as file:
@@ -95,7 +100,7 @@ class LC_TinyLlama(LLMInterface, ABC):
95
  logger.info(f"Unfortunately dictionary empty or None")
96
 
97
  def get_unused(self, current_lc):
98
- models_dir = "../models"
99
 
100
  if len(os.listdir(models_dir)) > 1:
101
  file_names = [os.path.basename(md) for md in os.listdir(models_dir)]
@@ -126,11 +131,14 @@ class LC_Phi3(LLMInterface, ABC):
126
  path_to_model = os.path.join("../models", self.model_config["model_name"])
127
  with open(path_to_model, "wb") as f:
128
  f.write(get_file.content)
129
- logger.info("Model file successfully recorded")
130
- f.close()
 
131
  except OSError as e:
132
- print(f"Error while write a file to directory : {e}")
133
  logger.error(msg="Error while write a file to directory", exc_info=e)
 
 
134
 
135
  @staticmethod
136
  def __read_yaml():
 
37
  path_to_model = os.path.join("../models", self.model_config["model_name"])
38
  with open(path_to_model, "wb") as f:
39
  f.write(get_file.content)
40
+ logger.info("Model file successfully recorded")
41
+ except FileExistsError:
42
+ print(f"Model file {path_to_model} already exists. Skipping download.")
43
+ logger.info(f"Model file {path_to_model} already exists. Skipping download.")
44
  except OSError as e:
45
+ print(f"Error while writing a file to directory : {e}")
46
  logger.error(msg="Error while write a file to directory", exc_info=e)
47
+ finally:
48
+ f.close()
49
 
50
  @staticmethod
51
  def __read_yaml():
52
+ print(os.listdir('../'))
53
  try:
54
  yaml_file = os.path.join("../", 'prompts.yaml')
55
  with open(yaml_file, 'r') as file:
 
100
  logger.info(f"Unfortunately dictionary empty or None")
101
 
102
  def get_unused(self, current_lc):
103
+ models_dir = ".../models"
104
 
105
  if len(os.listdir(models_dir)) > 1:
106
  file_names = [os.path.basename(md) for md in os.listdir(models_dir)]
 
131
  path_to_model = os.path.join("../models", self.model_config["model_name"])
132
  with open(path_to_model, "wb") as f:
133
  f.write(get_file.content)
134
+ logger.info("Model file successfully recorded")
135
+ except FileExistsError:
136
+ logger.info(f"Model file {path_to_model} already exists. Skipping download.")
137
  except OSError as e:
138
+ print(f"Error while writing a file to directory : {e}")
139
  logger.error(msg="Error while write a file to directory", exc_info=e)
140
+ finally:
141
+ f.close()
142
 
143
  @staticmethod
144
  def __read_yaml():