Spaces:
Runtime error
Runtime error
Commit
·
b1abf8e
1
Parent(s):
4e90465
Update models.py
Browse files
models.py
CHANGED
|
@@ -155,38 +155,37 @@ class CohereModel(BaseTCOModel):
|
|
| 155 |
super().__init__()
|
| 156 |
|
| 157 |
def render(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
self.model = gr.Dropdown(["Default", "Custom"], value="Default",
|
| 159 |
label="Model",
|
| 160 |
interactive=True, visible=False)
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
| 167 |
self.info = gr.Markdown("The cost per input and output tokens value is from Cohere's [pricing web page](https://cohere.com/pricing?utm_term=&utm_campaign=Cohere+Brand+%26+Industry+Terms&utm_source=adwords&utm_medium=ppc&hsa_acc=4946693046&hsa_cam=20368816223&hsa_grp=154209120409&hsa_ad=666081801359&hsa_src=g&hsa_tgt=dsa-19959388920&hsa_kw=&hsa_mt=&hsa_net=adwords&hsa_ver=3&gad=1&gclid=CjwKCAjww7KmBhAyEiwA5-PUSlyO7pq0zxeVrhViXMd8WuILW6uY-cfP1-SVuUfs-leUAz14xHlOHxoCmfkQAvD_BwE)", interactive=False, visible=False)
|
| 168 |
-
|
| 169 |
self.labor = gr.Number(0, visible=False,
|
| 170 |
label="($) Labor cost per month",
|
| 171 |
info="This is an estimate of the labor cost of the AI engineer in charge of deploying the model",
|
| 172 |
interactive=True
|
| 173 |
)
|
| 174 |
|
| 175 |
-
def compute_cost_per_token(self,
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
if use_case == "Generate":
|
| 180 |
-
if model == "Default":
|
| 181 |
-
cost_per_1M_tokens = 15
|
| 182 |
-
else:
|
| 183 |
-
cost_per_1M_tokens = 30
|
| 184 |
-
elif use_case == "Summarize":
|
| 185 |
-
cost_per_1M_tokens = 15
|
| 186 |
-
else:
|
| 187 |
-
cost_per_1M_tokens = 200
|
| 188 |
-
cost_per_input_token = cost_per_1M_tokens / 1000000
|
| 189 |
-
cost_per_output_token = cost_per_1M_tokens / 1000000
|
| 190 |
|
| 191 |
return cost_per_input_token, cost_per_output_token, labor
|
| 192 |
|
|
|
|
| 155 |
super().__init__()
|
| 156 |
|
| 157 |
def render(self):
|
| 158 |
+
def on_model_change(model):
|
| 159 |
+
if model == "Default":
|
| 160 |
+
cost_per_1M_tokens = 15
|
| 161 |
+
else:
|
| 162 |
+
cost_per_1M_tokens = 30
|
| 163 |
+
cost_per_1K_tokens = cost_per_1M_tokens / 1000
|
| 164 |
+
return gr.update(value=cost_per_1K_tokens), gr.update(value=cost_per_1K_tokens)
|
| 165 |
+
|
| 166 |
self.model = gr.Dropdown(["Default", "Custom"], value="Default",
|
| 167 |
label="Model",
|
| 168 |
interactive=True, visible=False)
|
| 169 |
+
self.input_tokens_cost_per_second = gr.Number(0.015, visible=False,
|
| 170 |
+
label="($) Price/1K input prompt tokens",
|
| 171 |
+
interactive=False
|
| 172 |
+
)
|
| 173 |
+
self.output_tokens_cost_per_second = gr.Number(0.015, visible=False,
|
| 174 |
+
label="($) Price/1K output prompt tokens",
|
| 175 |
+
interactive=False
|
| 176 |
+
)
|
| 177 |
self.info = gr.Markdown("The cost per input and output tokens value is from Cohere's [pricing web page](https://cohere.com/pricing?utm_term=&utm_campaign=Cohere+Brand+%26+Industry+Terms&utm_source=adwords&utm_medium=ppc&hsa_acc=4946693046&hsa_cam=20368816223&hsa_grp=154209120409&hsa_ad=666081801359&hsa_src=g&hsa_tgt=dsa-19959388920&hsa_kw=&hsa_mt=&hsa_net=adwords&hsa_ver=3&gad=1&gclid=CjwKCAjww7KmBhAyEiwA5-PUSlyO7pq0zxeVrhViXMd8WuILW6uY-cfP1-SVuUfs-leUAz14xHlOHxoCmfkQAvD_BwE)", interactive=False, visible=False)
|
| 178 |
+
self.model.change(on_model_change, inputs=self.model, outputs=[self.input_tokens_cost_per_second, self.output_tokens_cost_per_second])
|
| 179 |
self.labor = gr.Number(0, visible=False,
|
| 180 |
label="($) Labor cost per month",
|
| 181 |
info="This is an estimate of the labor cost of the AI engineer in charge of deploying the model",
|
| 182 |
interactive=True
|
| 183 |
)
|
| 184 |
|
| 185 |
+
def compute_cost_per_token(self, input_tokens_cost_per_second, output_tokens_cost_per_second, labor):
|
| 186 |
+
|
| 187 |
+
cost_per_input_token = input_tokens_cost_per_second / 1000
|
| 188 |
+
cost_per_output_token = output_tokens_cost_per_second / 1000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
return cost_per_input_token, cost_per_output_token, labor
|
| 191 |
|