simone-papicchio commited on
Commit
947409c
·
1 Parent(s): 2792e5a

chore: removed unused pipeline

Browse files
Files changed (1) hide show
  1. prediction.py +0 -24
prediction.py CHANGED
@@ -8,7 +8,6 @@ from xml.parsers.expat import model
8
  if os.environ.get("SPACES_ZERO_GPU") is not None:
9
  import spaces
10
  else:
11
-
12
  class spaces:
13
  @staticmethod
14
  def GPU(func):
@@ -67,11 +66,6 @@ class ModelPrediction:
67
  "{db_schema}\n"
68
  )
69
 
70
- def _reset_pipeline(self, model_name):
71
- if self._model_name != model_name:
72
- self._model_name = model_name
73
- self._pipeline = None
74
-
75
  @staticmethod
76
  def _extract_answer_from_pred(pred: str) -> str:
77
  # extract with regex everything is between <answer> and </answer>
@@ -120,24 +114,6 @@ class ModelPrediction:
120
  "cost": response._hidden_params["response_cost"],
121
  }
122
 
123
- @spaces.GPU(duration=20)
124
- def predict_with_hf(self, prompt, model_name): # -> dict[str, Any | float]:
125
- start_time = time.time()
126
- outputs = pipeline(
127
- [{"role": "user", "content": prompt}],
128
- max_new_tokens=256,
129
- )
130
- end_time = time.time()
131
- elapsed_time = end_time - start_time
132
- # inference endpoint costs HF per Hour 3.6$/h -> 0.001 $ per second
133
- cost_per_second=0.001
134
- response = outputs[0]["generated_text"][-1]['content']
135
- # print(response)
136
- return {
137
- "response": response,
138
- "cost": elapsed_time * cost_per_second
139
- }
140
-
141
  def _init_model_prediction(self, model_name):
142
  predict_fun = self.predict_with_api
143
  if "gpt-3.5" in model_name:
 
8
  if os.environ.get("SPACES_ZERO_GPU") is not None:
9
  import spaces
10
  else:
 
11
  class spaces:
12
  @staticmethod
13
  def GPU(func):
 
66
  "{db_schema}\n"
67
  )
68
 
 
 
 
 
 
69
  @staticmethod
70
  def _extract_answer_from_pred(pred: str) -> str:
71
  # extract with regex everything is between <answer> and </answer>
 
114
  "cost": response._hidden_params["response_cost"],
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  def _init_model_prediction(self, model_name):
118
  predict_fun = self.predict_with_api
119
  if "gpt-3.5" in model_name: