Spaces:
Runtime error
Runtime error
Commit
·
373e8e8
1
Parent(s):
14ace35
Update contribution_example.py
Browse files- contribution_example.py +9 -10
contribution_example.py
CHANGED
|
@@ -53,16 +53,6 @@ class NewModel(BaseTCOModel):
|
|
| 53 |
super().__init__()
|
| 54 |
|
| 55 |
def render(self):
|
| 56 |
-
#Create update functions that adjust the values of your cost/token depending on user's choices
|
| 57 |
-
def on_model_parameter_change(model_parameter):
|
| 58 |
-
if model_parameter == "Option 1":
|
| 59 |
-
input_tokens_cost_per_token = 0.1
|
| 60 |
-
output_tokens_cost_per_token = 0.2
|
| 61 |
-
else:
|
| 62 |
-
input_tokens_cost_per_token = 0.2
|
| 63 |
-
output_tokens_cost_per_token = 0.4
|
| 64 |
-
return input_tokens_cost_per_token, output_tokens_cost_per_token
|
| 65 |
-
|
| 66 |
#Create as many Gradio components as you want to provide information or customization to the user
|
| 67 |
#Put all their visibility to False
|
| 68 |
#Don't forget to put the interactive parameter of the component to False if the value is fixed
|
|
@@ -81,6 +71,15 @@ class NewModel(BaseTCOModel):
|
|
| 81 |
label="($) Price/1K output prompt tokens",
|
| 82 |
interactive=False
|
| 83 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
#Trigger the values modification linked to the parameter change
|
| 86 |
self.model_parameter.change(on_model_parameter_change, inputs=self.model_parameter, outputs=[self.input_cost_per_token, self.output_cost_per_token])
|
|
|
|
| 53 |
super().__init__()
|
| 54 |
|
| 55 |
def render(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
#Create as many Gradio components as you want to provide information or customization to the user
|
| 57 |
#Put all their visibility to False
|
| 58 |
#Don't forget to put the interactive parameter of the component to False if the value is fixed
|
|
|
|
| 71 |
label="($) Price/1K output prompt tokens",
|
| 72 |
interactive=False
|
| 73 |
)
|
| 74 |
+
#Create update functions that adjust the values of your cost/token depending on user's choices
|
| 75 |
+
def on_model_parameter_change(model_parameter):
|
| 76 |
+
if model_parameter == "Option 1":
|
| 77 |
+
input_tokens_cost_per_token = 0.1
|
| 78 |
+
output_tokens_cost_per_token = 0.2
|
| 79 |
+
else:
|
| 80 |
+
input_tokens_cost_per_token = 0.2
|
| 81 |
+
output_tokens_cost_per_token = 0.4
|
| 82 |
+
return input_tokens_cost_per_token, output_tokens_cost_per_token
|
| 83 |
|
| 84 |
#Trigger the values modification linked to the parameter change
|
| 85 |
self.model_parameter.change(on_model_parameter_change, inputs=self.model_parameter, outputs=[self.input_cost_per_token, self.output_cost_per_token])
|