jadehardouin
commited on
Commit
•
bdf4f51
1
Parent(s):
b1abf8e
Update models.py
Browse files
models.py
CHANGED
@@ -45,55 +45,79 @@ class BaseTCOModel(ABC):
|
|
45 |
def get_latency(self):
|
46 |
return self.latency
|
47 |
|
48 |
-
class
|
49 |
|
50 |
def __init__(self):
|
51 |
-
self.set_name("(SaaS) OpenAI")
|
52 |
self.latency = "15s" #Default value for GPT4
|
53 |
super().__init__()
|
54 |
|
55 |
def render(self):
|
56 |
-
def
|
57 |
-
|
58 |
-
if model == "GPT-4":
|
59 |
-
self.latency = "15s"
|
60 |
-
return gr.Dropdown.update(choices=["8K", "32K"])
|
61 |
-
else:
|
62 |
-
self.latency = "5s"
|
63 |
-
return gr.Dropdown.update(choices=["4K", "16K"], value="4K")
|
64 |
-
|
65 |
-
def define_cost_per_token(model, context_length):
|
66 |
-
if model == "GPT-4" and context_length == "8K":
|
67 |
cost_per_1k_input_tokens = 0.03
|
68 |
cost_per_1k_output_tokens = 0.06
|
69 |
-
|
70 |
cost_per_1k_input_tokens = 0.06
|
71 |
cost_per_1k_output_tokens = 0.12
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
cost_per_1k_input_tokens = 0.0015
|
74 |
cost_per_1k_output_tokens = 0.002
|
75 |
else:
|
76 |
cost_per_1k_input_tokens = 0.003
|
77 |
cost_per_1k_output_tokens = 0.004
|
78 |
return cost_per_1k_input_tokens, cost_per_1k_output_tokens
|
79 |
-
|
80 |
-
self.
|
81 |
-
label="OpenAI models",
|
82 |
-
interactive=True, visible=False)
|
83 |
-
self.context_length = gr.Dropdown(["8K", "32K"], value="8K", interactive=True,
|
84 |
label="Context size",
|
85 |
visible=False, info="Number of tokens the model considers when processing text")
|
86 |
-
self.input_tokens_cost_per_second = gr.Number(0.
|
87 |
label="($) Price/1K input prompt tokens",
|
88 |
interactive=False
|
89 |
)
|
90 |
-
self.output_tokens_cost_per_second = gr.Number(0.
|
91 |
label="($) Price/1K output prompt tokens",
|
92 |
interactive=False
|
93 |
)
|
94 |
self.info = gr.Markdown("The cost per input and output tokens values are from OpenAI's [pricing web page](https://openai.com/pricing)", interactive=False, visible=False)
|
95 |
-
self.
|
96 |
-
self.context_length.change(define_cost_per_token, inputs=[self.model, self.context_length], outputs=[self.input_tokens_cost_per_second, self.output_tokens_cost_per_second])
|
97 |
|
98 |
self.labor = gr.Number(0, visible=False,
|
99 |
label="($) Labor cost per month",
|
|
|
45 |
def get_latency(self):
|
46 |
return self.latency
|
47 |
|
48 |
+
class OpenAIModelGPT4(BaseTCOModel):
|
49 |
|
50 |
def __init__(self):
|
51 |
+
self.set_name("(SaaS) OpenAI GPT4")
|
52 |
self.latency = "15s" #Default value for GPT4
|
53 |
super().__init__()
|
54 |
|
55 |
def render(self):
|
56 |
+
def define_cost_per_token(context_length):
|
57 |
+
if context_length == "8K":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
cost_per_1k_input_tokens = 0.03
|
59 |
cost_per_1k_output_tokens = 0.06
|
60 |
+
else:
|
61 |
cost_per_1k_input_tokens = 0.06
|
62 |
cost_per_1k_output_tokens = 0.12
|
63 |
+
return cost_per_1k_input_tokens, cost_per_1k_output_tokens
|
64 |
+
|
65 |
+
self.context_length = gr.Dropdown(["8K", "32K"], value="8K", interactive=True,
|
66 |
+
label="Context size",
|
67 |
+
visible=False, info="Number of tokens the model considers when processing text")
|
68 |
+
self.input_tokens_cost_per_second = gr.Number(0.03, visible=False,
|
69 |
+
label="($) Price/1K input prompt tokens",
|
70 |
+
interactive=False
|
71 |
+
)
|
72 |
+
self.output_tokens_cost_per_second = gr.Number(0.06, visible=False,
|
73 |
+
label="($) Price/1K output prompt tokens",
|
74 |
+
interactive=False
|
75 |
+
)
|
76 |
+
self.info = gr.Markdown("The cost per input and output tokens values are from OpenAI's [pricing web page](https://openai.com/pricing)", interactive=False, visible=False)
|
77 |
+
self.context_length.change(define_cost_per_token, inputs=self.context_length, outputs=[self.input_tokens_cost_per_second, self.output_tokens_cost_per_second])
|
78 |
+
|
79 |
+
self.labor = gr.Number(0, visible=False,
|
80 |
+
label="($) Labor cost per month",
|
81 |
+
info="This is an estimate of the labor cost of the AI engineer in charge of deploying the model",
|
82 |
+
interactive=True
|
83 |
+
)
|
84 |
+
|
85 |
+
def compute_cost_per_token(self, input_tokens_cost_per_second, output_tokens_cost_per_second, labor):
|
86 |
+
cost_per_input_token = (input_tokens_cost_per_second / 1000)
|
87 |
+
cost_per_output_token = (output_tokens_cost_per_second / 1000)
|
88 |
+
|
89 |
+
return cost_per_input_token, cost_per_output_token, labor
|
90 |
+
|
91 |
+
class OpenAIModelGPT3_5(BaseTCOModel):
|
92 |
+
|
93 |
+
def __init__(self):
|
94 |
+
self.set_name("(SaaS) OpenAI GPT3.5 Turbo")
|
95 |
+
self.latency = "5s" #Default value for GPT3.5 Turbo
|
96 |
+
super().__init__()
|
97 |
+
|
98 |
+
def render(self):
|
99 |
+
def define_cost_per_token(context_length):
|
100 |
+
if context_length == "4K":
|
101 |
cost_per_1k_input_tokens = 0.0015
|
102 |
cost_per_1k_output_tokens = 0.002
|
103 |
else:
|
104 |
cost_per_1k_input_tokens = 0.003
|
105 |
cost_per_1k_output_tokens = 0.004
|
106 |
return cost_per_1k_input_tokens, cost_per_1k_output_tokens
|
107 |
+
|
108 |
+
self.context_length = gr.Dropdown(choices=["4K", "16K"], value="4K", interactive=True,
|
|
|
|
|
|
|
109 |
label="Context size",
|
110 |
visible=False, info="Number of tokens the model considers when processing text")
|
111 |
+
self.input_tokens_cost_per_second = gr.Number(0.0015, visible=False,
|
112 |
label="($) Price/1K input prompt tokens",
|
113 |
interactive=False
|
114 |
)
|
115 |
+
self.output_tokens_cost_per_second = gr.Number(0.002, visible=False,
|
116 |
label="($) Price/1K output prompt tokens",
|
117 |
interactive=False
|
118 |
)
|
119 |
self.info = gr.Markdown("The cost per input and output tokens values are from OpenAI's [pricing web page](https://openai.com/pricing)", interactive=False, visible=False)
|
120 |
+
self.context_length.change(define_cost_per_token, inputs=self.context_length, outputs=[self.input_tokens_cost_per_second, self.output_tokens_cost_per_second])
|
|
|
121 |
|
122 |
self.labor = gr.Number(0, visible=False,
|
123 |
label="($) Labor cost per month",
|