-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
29 lines (22 loc) · 842 Bytes
/
Copy pathmodels.py
File metadata and controls
29 lines (22 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ADA = "text-ada-001"
BABBAGE = "text-babbage-001"
CURIE = "text-curie-001"
DAVINCI = "text-davinci-003"
ADA_UNIT_COST = 0.0004
BABBAGE_UNIT_COST = 0.0005
CURIE_UNIT_COST = 0.0020
DAVINCI_UNIT_COST = 0.0200
def log_cost(completion, total):
print('> ↑' + str(completion.usage.prompt_tokens) + ' ↓' +
str(completion.usage.completion_tokens) + ' (=' + str(completion.usage.total_tokens) + ')')
unit_cost = 0
if completion.model == ADA:
unit_cost = ADA_UNIT_COST
elif completion.model == BABBAGE:
unit_cost = BABBAGE_UNIT_COST
elif completion.model == CURIE:
unit_cost = CURIE_UNIT_COST
elif completion.model == DAVINCI:
unit_cost = DAVINCI_UNIT_COST
total.append((completion.usage.total_tokens,
unit_cost * completion.usage.total_tokens / 1000.0))