Skip to content

Commit

Permalink
Update openai gpt-4o pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
yadavsahil197 committed Dec 31, 2024
1 parent e82c1b0 commit 5fe3afd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/autolabel/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class OpenAILLM(BaseModel):
"gpt-4-32k-0314": 0.06 / 1000,
"gpt-4-1106-preview": 0.01 / 1000,
"gpt-4-0125-preview": 0.01 / 1000,
"gpt-4o": 0.005 / 1000,
"gpt-4o": 0.0025 / 1000,
"gpt-4o-2024-08-06": 0.0025 / 1000,
"gpt-4o-mini": 0.15 / 1_000_000,
}
Expand All @@ -133,7 +133,7 @@ class OpenAILLM(BaseModel):
"gpt-4-32k-0314": 0.12 / 1000,
"gpt-4-1106-preview": 0.03 / 1000,
"gpt-4-0125-preview": 0.03 / 1000,
"gpt-4o": 0.015 / 1000,
"gpt-4o": 0.01 / 1000,
"gpt-4o-2024-08-06": 0.01 / 1000,
"gpt-4o-mini": 0.60 / 1_000_000,
}
Expand Down Expand Up @@ -174,19 +174,24 @@ def __init__(
if self._engine == "chat":
self.model_params = {**self.DEFAULT_PARAMS_CHAT_ENGINE, **model_params}
self.llm = ChatOpenAI(
model_name=self.model_name, verbose=False, **self.model_params,
model_name=self.model_name,
verbose=False,
**self.model_params,
)
else:
self.model_params = {
**self.DEFAULT_PARAMS_COMPLETION_ENGINE,
**model_params,
}
self.llm = OpenAI(
model_name=self.model_name, verbose=False, **self.model_params,
model_name=self.model_name,
verbose=False,
**self.model_params,
)

def _chat_backward_compatibility(
self, generations: List[LLMResult],
self,
generations: List[LLMResult],
) -> List[LLMResult]:
for generation_options in generations:
for curr_generation in generation_options:
Expand Down Expand Up @@ -254,7 +259,8 @@ async def _alabel(self, prompts: List[str], output_schema: Dict) -> RefuelLLMRes
]
error_code = error_json.get("code")
error_type = self.ERROR_TYPE_MAPPING.get(
error_code, ErrorType.LLM_PROVIDER_ERROR,
error_code,
ErrorType.LLM_PROVIDER_ERROR,
)
error_message = error_json.get("message")
except Exception as e:
Expand Down Expand Up @@ -327,7 +333,8 @@ def _label(self, prompts: List[str], output_schema: Dict) -> RefuelLLMResult:
]
error_code = error_json.get("code")
error_type = self.ERROR_TYPE_MAPPING.get(
error_code, ErrorType.LLM_PROVIDER_ERROR,
error_code,
ErrorType.LLM_PROVIDER_ERROR,
)
error_message = error_json.get("message")
except Exception as e:
Expand Down

0 comments on commit 5fe3afd

Please sign in to comment.