ProtonDataLabs commited on
Commit
605eceb
·
unverified ·
1 Parent(s): 3bc3ef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -42
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('RoI on Openai Chatgpt vs API plans') #
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 GPT4 and GPT-4o models resp
15
- - Teams - $30/month with 800 and 1600 msgs per day cap for GPT4 and GPT-4o models resp (minimum 2 users)
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 token $\\approx$ 1 word)
25
- - For Chatgpt API plans, we consider 1 input prompt = 250 words and same word count for output messages
26
-
27
  ''')
28
 
29
- # st.button("Note")
30
- if st.button("Show Assumptions"):
31
- note()
32
 
33
  with st.sidebar:
34
- st.title("Model Parameters")
35
- max_months = st.select_slider("No. of months to show on plot (x-axis)",
36
- options = np.arange(0, 37, 1, dtype=int), value=13)
37
 
38
- no_of_users = st.select_slider("No. of users",
39
- options = np.arange(0, 100, 1, dtype=int), value=2)
40
 
41
- st.subheader("Rest params app. for API plans only", divider="gray")
 
 
42
 
43
- daily_no_of_prompts = st.select_slider("No. of prompts expected per day per user",
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": 5, "output": 15}, "GPT4": {"input": 30, "output": 60}} #usd per 1M tokens
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
- api_price_per_month = {k: x*(v["input"] * daily_no_of_prompts * input_prompts_word_cnt * word_to_token_ratio +
66
- v["output"] * daily_no_of_prompts * output_prompts_word_cnt * word_to_token_ratio)*30/1_000_000 for k, v in api_limits.items()}
 
 
 
 
 
67
 
 
 
 
 
 
68
 
 
69
  fig = go.Figure()
70
- fig.add_trace(go.Scatter(x=x, y=api_price_per_month['GPT4'], name='GPT-4 API', fillcolor="darkkhaki"))
71
- fig.add_trace(go.Scatter(x=x, y=api_price_per_month['GPT-4o'], name='GPT-4o API', fillcolor="darkgreen"))
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
- fig.update_layout(title="Accumulated monthly costs over time",
77
- xaxis_title="time in months",
78
- yaxis_title="accu. cost in $")
 
 
 
 
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
+ ''')