Skip to content

Commit f005988

Browse files
authored
community[patch]: fix cost calculations for o3 in OpenAI callback (#30807)
Resolves #30795
1 parent 446361a commit f005988

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/community/langchain_community/callbacks/openai_info.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,17 @@ def standardize_model_name(
218218
or model_name.startswith("gpt-3.5")
219219
or model_name.startswith("gpt-35")
220220
or model_name.startswith("o1-")
221+
or model_name.startswith("o3-")
221222
or ("finetuned" in model_name and "legacy" not in model_name)
222223
):
223224
return model_name + "-completion"
224225
if (
225226
token_type == TokenType.PROMPT_CACHED
226-
and (model_name.startswith("gpt-4o") or model_name.startswith("o1"))
227+
and (
228+
model_name.startswith("gpt-4o")
229+
or model_name.startswith("o1")
230+
or model_name.startswith("o3")
231+
)
227232
and not (model_name.startswith("gpt-4o-2024-05-13"))
228233
):
229234
return model_name + "-cached"

0 commit comments

Comments
 (0)