Uhhy commited on
Commit
cf56a9f
·
verified ·
1 Parent(s): 4cf05e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -54,8 +54,9 @@ class ModelManager:
54
  def load_model(self, model_config):
55
  try:
56
  return {"model": Llama.from_pretrained(repo_id=model_config['repo_id'], filename=model_config['filename']), "name": model_config['name']}
57
- except Exception:
58
- pass
 
59
 
60
  def load_all_models(self):
61
  if self.loaded:
@@ -73,8 +74,9 @@ class ModelManager:
73
  global_data['models'] = models
74
  self.loaded = True
75
  return models
76
- except Exception:
77
- pass
 
78
 
79
  model_manager = ModelManager()
80
  model_manager.load_all_models()
@@ -117,8 +119,9 @@ def generate_chat_response(request, model_data):
117
  user_input = normalize_input(request.message)
118
  response = model(user_input, top_k=request.top_k, top_p=request.top_p, temperature=request.temperature)
119
  return response
120
- except Exception:
121
- pass
 
122
 
123
  @app.post("/generate")
124
  @spaces.GPU(duration=0)
 
54
  def load_model(self, model_config):
55
  try:
56
  return {"model": Llama.from_pretrained(repo_id=model_config['repo_id'], filename=model_config['filename']), "name": model_config['name']}
57
+ except Exception as e:
58
+ print(f"Error loading model {model_config['name']}: {e}")
59
+ return None
60
 
61
  def load_all_models(self):
62
  if self.loaded:
 
74
  global_data['models'] = models
75
  self.loaded = True
76
  return models
77
+ except Exception as e:
78
+ print(f"Error loading all models: {e}")
79
+ return []
80
 
81
  model_manager = ModelManager()
82
  model_manager.load_all_models()
 
119
  user_input = normalize_input(request.message)
120
  response = model(user_input, top_k=request.top_k, top_p=request.top_p, temperature=request.temperature)
121
  return response
122
+ except Exception as e:
123
+ print(f"Error generating response with model {model_data['name']}: {e}")
124
+ return None
125
 
126
  @app.post("/generate")
127
  @spaces.GPU(duration=0)