Skip to content

Commit

Permalink
Add refresh from id parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Oct 17, 2024
1 parent a1791c8 commit dc65148
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions agency_swarm/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(
examples: List[ExampleMessage] = None,
file_search: FileSearchConfig = None,
parallel_tool_calls: bool = True,
refresh_from_id: bool = True,
):
"""
Initializes an Agent with specified attributes, tools, and OpenAI client.
Expand Down Expand Up @@ -120,6 +121,7 @@ def __init__(
examples (List[Dict], optional): A list of example messages for the agent. Defaults to None.
file_search (FileSearchConfig, optional): A dictionary containing the file search tool configuration. Defaults to None.
parallel_tool_calls (bool, optional): Whether to enable parallel function calling during tool use. Defaults to True.
refresh_from_id (bool, optional): Whether to load and update the agent from the OpenAI assistant ID when provided. Defaults to True.
This constructor sets up the agent with its unique properties, initializes the OpenAI client, reads instructions if provided, and uploads any associated files.
"""
Expand Down Expand Up @@ -151,6 +153,7 @@ def __init__(
self.examples = examples
self.file_search = file_search
self.parallel_tool_calls = parallel_tool_calls
self.refresh_from_id = refresh_from_id

self.settings_path = './settings.json'

Expand Down Expand Up @@ -187,7 +190,7 @@ def init_oai(self):
path = self.get_settings_path()

# load assistant from id
if self.id:
if self.id and self.refresh_from_id:
self.assistant = self.client.beta.assistants.retrieve(self.id)

# Assign attributes to self if they are None
Expand All @@ -211,9 +214,9 @@ def init_oai(self):
if tool.type == "retrieval":
self.client.beta.assistants.update(self.id, tools=self.get_oai_tools())

# # update assistant if parameters are different
# if not self._check_parameters(self.assistant.model_dump()):
# self._update_assistant()
# update assistant if parameters are different
if not self._check_parameters(self.assistant.model_dump()):
self._update_assistant()

return self

Expand Down

0 comments on commit dc65148

Please sign in to comment.