Skip to content

Commit

Permalink
o1-preview support
Browse files Browse the repository at this point in the history
cleanup

format

wip
  • Loading branch information
jlopatec authored and mikeldking committed Sep 16, 2024
1 parent 3606e7f commit 0fd14ff
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions packages/phoenix-evals/src/phoenix/evals/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class AzureOptions:
azure_ad_token_provider: Optional[Callable[[], str]]


def _model_supports_temperature(model: str) -> bool:
"""OpenAI 01 models do not support temperature."""
return "o1-" not in model


def _model_supports_max_tokens(model: str) -> bool:
"""OpenAI 01 models do not support max_tokens."""
return "o1-" not in model


@dataclass
class OpenAIModel(BaseModel):
"""
Expand Down Expand Up @@ -380,15 +390,26 @@ def invocation_params(self) -> Dict[str, Any]:
@property
def _default_params(self) -> Dict[str, Any]:
"""Get the default parameters for calling OpenAI API."""
return {
"temperature": self.temperature,
"max_tokens": self.max_tokens,
params = {
"frequency_penalty": self.frequency_penalty,
"presence_penalty": self.presence_penalty,
"top_p": self.top_p,
"n": self.n,
"timeout": self.request_timeout,
}
if _model_supports_max_tokens(self.model):
params.update(
{
"max_tokens": self.max_tokens,
}
)
if _model_supports_temperature(self.model):
params.update(
{
"temperature": self.temperature,
}
)
return params

@property
def supports_function_calling(self) -> bool:
Expand Down

0 comments on commit 0fd14ff

Please sign in to comment.