seawolf2357 commited on
Commit
41a091f
1 Parent(s): 8bc41cb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +184 -0
app.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ import pandas as pd
4
+
5
+ # 데이터를 pandas DataFrame으로 변환
6
+ mockData = [
7
+ {
8
+ 'provider': 'OpenAI',
9
+ 'uri': 'https://openai.com/api/pricing/',
10
+ 'models': [
11
+ {'name': 'GPT-4o', 'inputPrice': 5.0, 'outputPrice': 15.0},
12
+ {'name': 'GPT-4 (8K)', 'inputPrice': 30.0, 'outputPrice': 60.0},
13
+ {'name': 'GPT-4 Turbo', 'inputPrice': 10.0, 'outputPrice': 30.0},
14
+ {'name': 'GPT-3.5-turbo', 'inputPrice': 0.5, 'outputPrice': 1.5},
15
+ ],
16
+ },
17
+ {
18
+ 'provider': 'Anthropic',
19
+ 'uri': 'https://www.anthropic.com/pricing',
20
+ 'models': [
21
+ {'name': 'Claude 3 (Opus)', 'inputPrice': 15.0, 'outputPrice': 75.0},
22
+ {'name': 'Claude 3.5 (Sonnet)', 'inputPrice': 3.0, 'outputPrice': 15.0},
23
+ {'name': 'Claude 3 (Haiku)', 'inputPrice': 0.25, 'outputPrice': 1.25},
24
+ ],
25
+ },
26
+ {
27
+ 'provider': 'Google',
28
+ 'uri': 'https://ai.google.dev/pricing?hl=en',
29
+ 'models': [
30
+ {'name': 'Gemini 1.5 Pro', 'inputPrice': 3.5, 'outputPrice': 7.0},
31
+ {'name': 'Gemini 1.5 Flash', 'inputPrice': 0.35, 'outputPrice': 0.7},
32
+ ],
33
+ },
34
+ {
35
+ 'provider': 'Cohere',
36
+ 'uri': 'https://cohere.com/pricing',
37
+ 'models': [
38
+ {'name': 'Command R+', 'inputPrice': 3.0, 'outputPrice': 15.0},
39
+ {'name': 'Command R', 'inputPrice': 0.5, 'outputPrice': 1.5},
40
+ ],
41
+ },
42
+ {
43
+ 'provider': 'Mistral',
44
+ 'uri': 'https://docs.mistral.ai/platform/pricing',
45
+ 'models': [
46
+ {'name': 'mistral-large-2402', 'inputPrice': 4.0, 'outputPrice': 12.0},
47
+ {'name': 'codestral-2405', 'inputPrice': 1.0, 'outputPrice': 3.0},
48
+ {'name': 'Mixtral 8x22B', 'inputPrice': 2.0, 'outputPrice': 6.0},
49
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.7, 'outputPrice': 0.7},
50
+ ],
51
+ },
52
+ {
53
+ 'provider': 'Deepspeek',
54
+ 'uri': 'https://platform.deepseek.com/api-docs/pricing/',
55
+ 'models': [
56
+ {'name': 'deepseek-chat', 'inputPrice': 0.14, 'outputPrice': 0.28},
57
+ {'name': 'deepseek-coder', 'inputPrice': 0.14, 'outputPrice': 0.28},
58
+ ],
59
+ },
60
+ {
61
+ 'provider': 'Anyscale',
62
+ 'uri': 'https://www.anyscale.com/pricing-detail',
63
+ 'models': [
64
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.5, 'outputPrice': 0.5},
65
+ {'name': 'Llama 3 70b', 'inputPrice': 1.0, 'outputPrice': 1.0},
66
+ ],
67
+ },
68
+ {
69
+ 'provider': 'Together.AI',
70
+ 'uri': 'https://www.together.ai/pricing',
71
+ 'models': [
72
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.6, 'outputPrice': 0.6},
73
+ {'name': 'Llama 3 70b', 'inputPrice': 0.9, 'outputPrice': 0.9},
74
+ ],
75
+ },
76
+ {
77
+ 'provider': 'Replicate',
78
+ 'uri': 'https://replicate.com/pricing',
79
+ 'models': [
80
+ {'name': 'Llama 3 70b', 'inputPrice': 0.65, 'outputPrice': 2.75},
81
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.30, 'outputPrice': 1.00},
82
+ ],
83
+ },
84
+ {
85
+ 'provider': 'IBM WatsonX',
86
+ 'uri': 'https://www.ibm.com/products/watsonx-ai/foundation-models',
87
+ 'models': [
88
+ {'name': 'Llama 3 70b', 'inputPrice': 1.80, 'outputPrice': 1.80},
89
+ ],
90
+ },
91
+ {
92
+ 'provider': 'Groq',
93
+ 'uri': 'https://wow.groq.com/',
94
+ 'models': [
95
+ {'name': 'Llama 3 70b', 'inputPrice': 0.59, 'outputPrice': 0.79},
96
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.24, 'outputPrice': 0.24},
97
+ ],
98
+ },
99
+ {
100
+ 'provider': 'Fireworks',
101
+ 'uri': 'https://fireworks.ai/pricing',
102
+ 'models': [
103
+ {'name': 'Llama 3 70b', 'inputPrice': 0.90, 'outputPrice': 0.90},
104
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.50, 'outputPrice': 0.50},
105
+ ],
106
+ },
107
+ {
108
+ 'provider': '01.ai',
109
+ 'uri': 'https://platform.01.ai/docs#models-and-pricing',
110
+ 'models': [
111
+ {'name': 'Yi-Large', 'inputPrice': 3.00, 'outputPrice': 3.00},
112
+ ],
113
+ },
114
+ {
115
+ 'provider': 'Perplexity',
116
+ 'uri': 'https://docs.perplexity.ai/docs/pricing',
117
+ 'models': [
118
+ {'name': 'Llama 3 70b', 'inputPrice': 1.0, 'outputPrice': 1.0},
119
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0.60, 'outputPrice': 0.60},
120
+ ],
121
+ },
122
+ {
123
+ 'provider': 'OpenFreeAI',
124
+ 'uri': 'https://discord.gg/openfreeai',
125
+ 'models': [
126
+ {'name': 'kAI', 'inputPrice': 0, 'outputPrice': 0},
127
+ {'name': 'Llama 3 70b', 'inputPrice': 0, 'outputPrice': 0},
128
+ {'name': 'Llama 3 8b', 'inputPrice': 0, 'outputPrice': 0},
129
+ {'name': 'Mixtral 8x7B', 'inputPrice': 0, 'outputPrice': 0},
130
+ ],
131
+ },
132
+ {
133
+ 'provider': 'Writer',
134
+ 'uri': 'https://dev.writer.com/home/pricing',
135
+ 'models': [
136
+ {'name': 'Palmyra X 003', 'inputPrice': 7.50, 'outputPrice': 22.50},
137
+ {'name': 'Palmyra X 32k', 'inputPrice': 1.0, 'outputPrice': 2.0},
138
+ {'name': 'Palmyra X 002', 'inputPrice': 1.0, 'outputPrice': 2.0},
139
+ {'name': 'Palmyra X 002 32k', 'inputPrice': 1.0, 'outputPrice': 2.0}
140
+ ],
141
+ }
142
+ ]
143
+
144
+ # DataFrame으로 변환
145
+ data = []
146
+ for provider in mockData:
147
+ for model in provider['models']:
148
+ total_price = model['inputPrice'] + model['outputPrice']
149
+ data.append({
150
+ 'Provider': provider['provider'],
151
+ 'URI': provider['uri'],
152
+ 'Model': model['name'],
153
+ 'Input Price': model['inputPrice'],
154
+ 'Output Price': model['outputPrice'],
155
+ 'Total Price': total_price
156
+ })
157
+
158
+ df = pd.DataFrame(data)
159
+
160
+ # 정렬 함수
161
+ def sort_data(column, ascending):
162
+ sorted_df = df.sort_values(by=column, ascending=ascending)
163
+ return sorted_df
164
+
165
+ # Gradio 인터페이스 설정
166
+ with gr.Blocks() as demo:
167
+ gr.Markdown("# AI 모델 가격 비교")
168
+
169
+ with gr.Row():
170
+ column = gr.Dropdown(choices=df.columns.tolist(), label="정렬할 컬럼 선택")
171
+ ascending = gr.Checkbox(label="오름차순", value=True)
172
+ sort_button = gr.Button("정렬")
173
+
174
+ table = gr.Dataframe(value=df, interactive=True)
175
+
176
+ def update_table(column, ascending):
177
+ sorted_df = sort_data(column, ascending)
178
+ return sorted_df
179
+
180
+ sort_button.click(update_table, inputs=[column, ascending], outputs=table)
181
+
182
+ # 애플리케이션 실행
183
+ if __name__ == "__main__":
184
+ demo.launch()