From c0e3c3a3508e2f2b5fcfff7dc697fa5eaa7d69d5 Mon Sep 17 00:00:00 2001 From: Alex Riina Date: Mon, 20 May 2024 19:47:43 -0400 Subject: [PATCH] openai[patch], community[patch]: add pricing and max context window for GPT-4o (#21673) # Add pricing and max context window for GPT-4o - community: add cost per 1k tokens and max context window - partners: add max context window **Description:** adds static information about GPT-4o based on https://openai.com/api/pricing/ and https://platform.openai.com/docs/models/gpt-4o so that GPT-4o reporting is accurate. --------- Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Bagatur --- libs/community/langchain_community/llms/openai.py | 2 ++ libs/partners/openai/langchain_openai/llms/base.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libs/community/langchain_community/llms/openai.py b/libs/community/langchain_community/llms/openai.py index 973b92eb5ae..0d891c299f1 100644 --- a/libs/community/langchain_community/llms/openai.py +++ b/libs/community/langchain_community/llms/openai.py @@ -661,6 +661,8 @@ class BaseOpenAI(BaseLLM): max_tokens = openai.modelname_to_contextsize("gpt-3.5-turbo-instruct") """ model_token_mapping = { + "gpt-4o": 128_000, + "gpt-4o-2024-05-13": 128_000, "gpt-4": 8192, "gpt-4-0314": 8192, "gpt-4-0613": 8192, diff --git a/libs/partners/openai/langchain_openai/llms/base.py b/libs/partners/openai/langchain_openai/llms/base.py index 3b557e78036..d156fcc6023 100644 --- a/libs/partners/openai/langchain_openai/llms/base.py +++ b/libs/partners/openai/langchain_openai/llms/base.py @@ -537,6 +537,8 @@ class BaseOpenAI(BaseLLM): max_tokens = openai.modelname_to_contextsize("gpt-3.5-turbo-instruct") """ model_token_mapping = { + "gpt-4o": 128_000, + "gpt-4o-2024-05-13": 128_000, "gpt-4": 8192, "gpt-4-0314": 8192, "gpt-4-0613": 8192,