You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Overwrite Tools Functionality in GPTAssistantAgent (microsoft#1434)
* added overwrite_tools logic to GPTAssistantAgent
* added test test_gpt_assistant_tools_overwrite
* fetch tools without get_assistant_tools method
* fixed code formatting
* fixed no .get found
Copy file name to clipboardExpand all lines: autogen/agentchat/contrib/gpt_assistant_agent.py
+28
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ def __init__(
26
26
instructions: Optional[str] =None,
27
27
llm_config: Optional[Union[Dict, bool]] =None,
28
28
overwrite_instructions: bool=False,
29
+
overwrite_tools: bool=False,
29
30
**kwargs,
30
31
):
31
32
"""
@@ -46,6 +47,7 @@ def __init__(
46
47
or build your own tools using Function calling. ref https://platform.openai.com/docs/assistants/tools
47
48
- file_ids: files used by retrieval in run
48
49
overwrite_instructions (bool): whether to overwrite the instructions of an existing assistant. This parameter is in effect only when assistant_id is specified in llm_config.
50
+
overwrite_tools (bool): whether to overwrite the tools of an existing assistant. This parameter is in effect only when assistant_id is specified in llm_config.
49
51
kwargs (dict): Additional configuration options for the agent.
50
52
- verbose (bool): If set to True, enables more detailed output from the assistant thread.
51
53
- Other kwargs: Except verbose, others are passed directly to ConversableAgent.
@@ -108,6 +110,32 @@ def __init__(
108
110
"overwrite_instructions is False. Provided instructions will be used without permanently modifying the assistant in the API."
109
111
)
110
112
113
+
# Check if tools are specified in llm_config
114
+
specified_tools=llm_config.get("tools", None)
115
+
116
+
ifspecified_toolsisNone:
117
+
# Check if the current assistant has tools defined
118
+
ifself._openai_assistant.tools:
119
+
logger.warning(
120
+
"No tools were provided for given assistant. Using existing tools from assistant API."
121
+
)
122
+
else:
123
+
logger.info(
124
+
"No tools were provided for the assistant, and the assistant currently has no tools set."
125
+
)
126
+
elifoverwrite_toolsisTrue:
127
+
# Tools are specified and overwrite_tools is True; update the assistant's tools
128
+
logger.warning(
129
+
"overwrite_tools is True. Provided tools will be used and will modify the assistant in the API"
0 commit comments