Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
import plotly.graph_objects as go
|
4 |
-
# import time
|
5 |
|
6 |
st.set_page_config()
|
7 |
-
st.title('
|
8 |
-
|
9 |
|
10 |
@st.dialog("Assumptions")
|
11 |
def note():
|
12 |
st.markdown('''
|
13 |
# ChatGPT plans
|
14 |
-
- Plus - $20/month with 320 and 640 msgs per day cap for
|
15 |
-
- Teams - $30/month with 800 and 1600 msgs per day cap for
|
16 |
[link](https://openai.com/chatgpt/pricing)
|
17 |
|
18 |
# API plans
|
@@ -21,60 +19,77 @@ def note():
|
|
21 |
[link](https://openai.com/api/pricing)
|
22 |
|
23 |
# Assumptions
|
24 |
-
- 1 token = 0.75 words (1.33
|
25 |
-
- For
|
26 |
-
|
27 |
''')
|
28 |
|
29 |
-
# st.button("
|
30 |
-
|
31 |
-
note()
|
32 |
|
33 |
with st.sidebar:
|
34 |
-
|
35 |
-
|
36 |
-
options
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
options = np.arange(0, 1520, 20, dtype=int), value=100)
|
45 |
-
|
46 |
-
input_prompts_word_cnt = st.select_slider("No. of words given as prompt to llm",
|
47 |
-
options = np.arange(0, 1050, 50, dtype=int), value=200)
|
48 |
-
|
49 |
-
output_prompts_word_cnt = st.select_slider("No. of words in the output response from llm",
|
50 |
-
options = np.arange(0, 1050, 50, dtype=int), value=200)
|
51 |
-
|
52 |
-
|
53 |
-
# fixed
|
54 |
plan_limits = {"Plus": {"GPT-4o": 640, "GPT4": 320, "price": 20}, # 40 messages/3hrs
|
55 |
"Team": {"GPT-4o": 1600, "GPT4": 800, "price": 30}} # 100 messages/3hrs, minimum 2 users price 25 pm if billed annually
|
56 |
|
57 |
-
api_limits = {"GPT-4o": {"input":
|
58 |
-
|
59 |
-
# assumptions
|
60 |
-
token_to_word_ratio = 0.75
|
61 |
-
word_to_token_ratio = 1/token_to_word_ratio
|
62 |
|
|
|
63 |
x = np.arange(0, max_months, dtype=int) # in months timeline
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
|
|
|
69 |
fig = go.Figure()
|
70 |
-
fig.add_trace(go.Scatter(x=x, y=
|
71 |
-
fig.add_trace(go.Scatter(x=x, y=api_price_per_month
|
72 |
-
fig.add_trace(go.Scatter(x=x, y=x*no_of_users*plan_limits["Team"]['price'], name='Chatgpt Team', fillcolor="firebrick"))
|
73 |
-
fig.add_trace(go.Scatter(x=x, y=x*no_of_users*plan_limits["Plus"]['price'], name='Chatgpt Plus', fillcolor="dodgerblue"))
|
74 |
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
|
80 |
st.plotly_chart(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
import plotly.graph_objects as go
|
|
|
4 |
|
5 |
st.set_page_config()
|
6 |
+
st.title('Cost Comparison Chatgpt Plus vs Custom-Chatgpt CoPilot')
|
|
|
7 |
|
8 |
@st.dialog("Assumptions")
|
9 |
def note():
|
10 |
st.markdown('''
|
11 |
# ChatGPT plans
|
12 |
+
- Plus - $20/month with 320 and 640 msgs per day cap for GPT-4 and GPT-4o models resp
|
13 |
+
- Teams - $30/month with 800 and 1600 msgs per day cap for GPT-4 and GPT-4o models resp (minimum 2 users)
|
14 |
[link](https://openai.com/chatgpt/pricing)
|
15 |
|
16 |
# API plans
|
|
|
19 |
[link](https://openai.com/api/pricing)
|
20 |
|
21 |
# Assumptions
|
22 |
+
- 1 token = 0.75 words (1.33 tokens ≈ 1 word)
|
23 |
+
- For ChatGPT API plans, we consider 1 input prompt = 250 words and same word count for output messages
|
|
|
24 |
''')
|
25 |
|
26 |
+
# if st.button("Show Assumptions"):
|
27 |
+
# note()
|
|
|
28 |
|
29 |
with st.sidebar:
|
30 |
+
st.title("Model Parameters")
|
31 |
+
max_months = st.select_slider("No. of months to show on plot (x-axis)",
|
32 |
+
options=np.arange(0, 37, 1, dtype=int), value=13)
|
33 |
|
34 |
+
no_of_users = st.select_slider("No. of users",
|
35 |
+
options=np.arange(0, 100, 1, dtype=int), value=2)
|
36 |
|
37 |
+
st.subheader("One-Time Development Cost (Custom App)", divider="gray")
|
38 |
+
development_cost = st.select_slider("Development Cost for Custom App ($)",
|
39 |
+
options=np.arange(3000, 5001, 100, dtype=int), value=3000)
|
40 |
|
41 |
+
# Fixed parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
plan_limits = {"Plus": {"GPT-4o": 640, "GPT4": 320, "price": 20}, # 40 messages/3hrs
|
43 |
"Team": {"GPT-4o": 1600, "GPT4": 800, "price": 30}} # 100 messages/3hrs, minimum 2 users price 25 pm if billed annually
|
44 |
|
45 |
+
api_limits = {"GPT-4o": {"input": 0.0100, "output": 0.0300}, "GPT4": {"input": 0.0100, "output": 0.0300}} #usd per 1K tokens
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
# Timeline
|
48 |
x = np.arange(0, max_months, dtype=int) # in months timeline
|
49 |
|
50 |
+
# Accumulated cost for ChatGPT-4o API
|
51 |
+
api_price_per_month = x * (api_limits["GPT4"]["input"] * 85000 *0.001 +
|
52 |
+
api_limits["GPT4"]["output"] * 85000*0.001) * no_of_users
|
53 |
+
|
54 |
+
# Accumulated cost for ChatGPT Team
|
55 |
+
team_price_per_month = x * no_of_users * plan_limits["Plus"]["price"]
|
56 |
+
# # Calculate breakeven month
|
57 |
|
58 |
+
savings_per_month=(team_price_per_month-api_price_per_month)/x
|
59 |
+
if savings_per_month[1] > 0:
|
60 |
+
breakeven_month = development_cost / savings_per_month[1]
|
61 |
+
else:
|
62 |
+
breakeven_month = None
|
63 |
|
64 |
+
# Plotting
|
65 |
fig = go.Figure()
|
66 |
+
fig.add_trace(go.Scatter(x=x, y=team_price_per_month, name='ChatGPT Plus', fillcolor="firebrick"))
|
67 |
+
fig.add_trace(go.Scatter(x=x, y=api_price_per_month + development_cost, name='Custom-Chatgpt', fillcolor="darkgreen"))
|
|
|
|
|
68 |
|
69 |
+
fig.update_layout(title="Accumulated Monthly Costs Over Time",
|
70 |
+
xaxis_title="Time in Months",
|
71 |
+
yaxis_title="Accumulated Cost in $")
|
72 |
|
73 |
+
|
74 |
+
# Add breakeven annotation if applicable
|
75 |
+
if breakeven_month is not None and breakeven_month < max_months:
|
76 |
+
fig.add_vline(x=breakeven_month, line_dash="dash", line_color="black")
|
77 |
+
fig.add_annotation(x=breakeven_month, y=api_price_per_month[int(breakeven_month)] + development_cost,
|
78 |
+
text=f"Breakeven at {breakeven_month:.1f} months",
|
79 |
+
showarrow=True, arrowhead=1)
|
80 |
|
81 |
st.plotly_chart(fig)
|
82 |
+
|
83 |
+
# Description
|
84 |
+
st.info('''
|
85 |
+
This plot compares the accumulated costs of two options over time: ChatGPT Teams and GPT-4o API with a Custom Application.
|
86 |
+
|
87 |
+
1. **ChatGPT Teams**: A fixed cost per user with no upfront development costs.
|
88 |
+
2. **GPT-4o API with Custom Application**: Includes a one-time development cost and usage-based charges for input and output tokens.
|
89 |
+
|
90 |
+
#### Key Insights:
|
91 |
+
- The black dashed line indicates the **breakeven point**, where the total cost of the custom application becomes equal to or less than the cost of ChatGPT Teams.
|
92 |
+
- Beyond this point, the custom application provides **cost savings** compared to ChatGPT Teams.
|
93 |
+
|
94 |
+
Use the sliders to adjust parameters like the number of users and the one-time development cost to see how they affect the breakeven point and accumulated costs.
|
95 |
+
''')
|