Skip to content
Merged

temp #1185

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/slackbot/src/slackbot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import ClassVar, Literal

from prefect.variables import Variable
from pydantic import Field, field_validator
from pydantic import Field, field_validator, model_validator
from pydantic_settings import BaseSettings, SettingsConfigDict


Expand Down Expand Up @@ -70,6 +70,12 @@ def validate_log_level(cls, v: str) -> str:

slack_api_token: str = Field(default=..., description="Slack API bot user token")

@model_validator(mode="after")
def validate_temperature(self) -> "SlackbotSettings":
if "gpt-5" in self.model_name:

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validator is checking self.model_name which is a property that calls Variable.get(), but this validation occurs during model initialization when the Variable system may not be properly initialized yet. This could cause the validator to fail or behave unexpectedly.

Copilot uses AI. Check for mistakes.
self.temperature = 1.0

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct assignment to self.temperature in a model validator may not work as expected with Pydantic models. The temperature field should be validated and set through the proper Pydantic field validation mechanism or the validator should return a modified copy of the model.

Suggested change
self.temperature = 1.0
return self.model_copy(update={"temperature": 1.0})

Copilot uses AI. Check for mistakes.
return self

@property
def model_name(self) -> str:
return Variable.get(
Expand Down