Skip to content

Commit f939d97

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
Refactor LLM monitor. Add the ability to use monitor as a context manager. Centralize OpenAI costs table
1 parent 7845002 commit f939d97

File tree

7 files changed

+300
-285
lines changed

7 files changed

+300
-285
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
## Unreleased
99

1010
### Added
11+
* Added the ability to use the `llm_monitor.OpenAIMonitor` as a context manager.
1112
* Added `openlayer_inference_pipeline_id` as an optional parameter to the `OpenAIMonitor`. This is an alternative to `openlayer_inference_pipeline_name` and `openlayer_inference_project_name` parameters for identifying the inference pipeline on the platform.
1213
* Added `monitor_output_only` as an argument to the OpenAI `llm_monitor`. If set to `True`, the monitor will only record the output of the model, and not the input.
1314
* Added `costColumnName` as an optional field in the config for LLM data.

openlayer/constants.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,71 @@
3434
),
3535
COLUMN_NAME_REGEX,
3636
]
37+
# --------------------------- LLM usage costs table -------------------------- #
38+
# Last update: 2024-02-05
39+
OPENAI_COST_PER_TOKEN = {
40+
"babbage-002": {
41+
"input": 0.0004e-3,
42+
"output": 0.0004e-3,
43+
},
44+
"davinci-002": {
45+
"input": 0.002e-3,
46+
"output": 0.002e-3,
47+
},
48+
"gpt-3.5-turbo": {
49+
"input": 0.0005e-3,
50+
"output": 0.0015e-3,
51+
},
52+
"gpt-3.5-turbo-0125": {
53+
"input": 0.0005e-3,
54+
"output": 0.0015e-3,
55+
},
56+
"gpt-3.5-turbo-0301": {
57+
"input": 0.0015e-3,
58+
"output": 0.002e-3,
59+
},
60+
"gpt-3.5-turbo-0613": {
61+
"input": 0.0015e-3,
62+
"output": 0.002e-3,
63+
},
64+
"gpt-3.5-turbo-1106": {
65+
"input": 0.001e-3,
66+
"output": 0.002e-3,
67+
},
68+
"gpt-3.5-turbo-16k-0613": {
69+
"input": 0.003e-3,
70+
"output": 0.004e-3,
71+
},
72+
"gpt-3.5-turbo-instruct": {
73+
"input": 0.0015e-3,
74+
"output": 0.002e-3,
75+
},
76+
"gpt-4": {
77+
"input": 0.03e-3,
78+
"output": 0.06e-3,
79+
},
80+
"gpt-4-0125-preview": {
81+
"input": 0.01e-3,
82+
"output": 0.03e-3,
83+
},
84+
"gpt-4-1106-preview": {
85+
"input": 0.01e-3,
86+
"output": 0.03e-3,
87+
},
88+
"gpt-4-0314": {
89+
"input": 0.03e-3,
90+
"output": 0.06e-3,
91+
},
92+
"gpt-4-1106-vision-preview": {
93+
"input": 0.01e-3,
94+
"output": 0.03e-3,
95+
},
96+
"gpt-4-32k": {
97+
"input": 0.06e-3,
98+
"output": 0.12e-3,
99+
},
100+
"gpt-4-32k-0314": {
101+
"input": 0.06e-3,
102+
"output": 0.12e-3,
103+
},
104+
}

0 commit comments

Comments
 (0)