Skip to content

Commit

Permalink
just to be safe
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Oct 26, 2024
1 parent 77114d5 commit 1763e98
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/controlflow/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,24 @@ def __init__(self, instructions: Optional[str] = None, **kwargs):
if instructions is not None:
kwargs["instructions"] = instructions

super().__init__(**kwargs)

@model_validator(mode="before")
@classmethod
def emit_deprecation_warnings(cls, v):
# deprecated in 0.9
if "user_access" in v:
if "user_access" in kwargs:
warnings.warn(
"The `user_access` argument is deprecated. Use `interactive=True` instead.",
DeprecationWarning,
)
v["interactive"] = v.pop("user_access")
return v
kwargs["interactive"] = kwargs.pop("user_access")

@model_validator(mode="after")
def add_instructions(self) -> Self:
if additional_instructions := get_instructions():
self.instructions = (
self.instructions or "" + "\n" + "\n".join(additional_instructions)
kwargs["instructions"] = (
kwargs.get("instructions")
or "" + "\n" + "\n".join(additional_instructions)
).strip()
return self

@model_validator(mode="after")
def generate_id(self) -> Self:
super().__init__(**kwargs)

if not self.id:
self.id = self._generate_id()
return self

def __hash__(self) -> int:
return id(self)
Expand Down

0 comments on commit 1763e98

Please sign in to comment.