@@ -77,57 +77,6 @@ def to_dict(self) -> dict:
7777 }
7878
7979
80- class ToolDefinition :
81- """
82- Definition of a tool available to an AI configuration.
83-
84- Each tool has a name used to match against the tool registry,
85- and optional custom parameters that can be configured via the
86- LaunchDarkly dashboard.
87- """
88-
89- def __init__ (
90- self ,
91- name : str ,
92- custom_parameters : Optional [Dict [str , Any ]] = None ,
93- ):
94- """
95- :param name: The name of the tool.
96- :param custom_parameters: Optional custom parameters for
97- the tool, configured via the LaunchDarkly dashboard.
98- """
99- self ._name = name
100- self ._custom_parameters = custom_parameters
101-
102- @property
103- def name (self ) -> str :
104- """
105- The name of the tool.
106- """
107- return self ._name
108-
109- def get_custom_parameter (self , key : str ) -> Any :
110- """
111- Retrieve a custom parameter by key.
112-
113- :param key: The custom parameter key to look up.
114- :return: The parameter value, or None if not found.
115- """
116- if self ._custom_parameters is None :
117- return None
118-
119- return self ._custom_parameters .get (key )
120-
121- def to_dict (self ) -> dict :
122- """
123- Render the tool definition as a dictionary object.
124- """
125- result : Dict [str , Any ] = {'name' : self ._name }
126- if self ._custom_parameters is not None :
127- result ['customParameters' ] = self ._custom_parameters
128- return result
129-
130-
13180class ProviderConfig :
13281 """
13382 Configuration related to the provider.
@@ -259,7 +208,22 @@ class AICompletionConfigDefault(AIConfigDefault):
259208 """
260209 messages : Optional [List [LDMessage ]] = None
261210 judge_configuration : Optional [JudgeConfiguration ] = None
262- tools : Optional [List [ToolDefinition ]] = None
211+ tool_custom_parameters : Optional [Dict [str , Dict [str , Any ]]] = None
212+
213+ def get_tool_custom_parameter (self , tool_name : str , key : str ) -> Any :
214+ """
215+ Retrieve a custom parameter for a specific tool.
216+
217+ :param tool_name: The name of the tool.
218+ :param key: The custom parameter key to look up.
219+ :return: The parameter value, or None if not found.
220+ """
221+ if self .tool_custom_parameters is None :
222+ return None
223+ tool_params = self .tool_custom_parameters .get (tool_name )
224+ if tool_params is None :
225+ return None
226+ return tool_params .get (key )
263227
264228 def to_dict (self ) -> dict :
265229 """
@@ -269,10 +233,16 @@ def to_dict(self) -> dict:
269233 result ['messages' ] = [message .to_dict () for message in self .messages ] if self .messages else None
270234 if self .judge_configuration is not None :
271235 result ['judgeConfiguration' ] = self .judge_configuration .to_dict ()
272- if self .tools is not None :
236+ if self .tool_custom_parameters is not None :
273237 model = result .get ('model' ) or {}
274238 params = model .get ('parameters' ) or {}
275- params ['tools' ] = [tool .to_dict () for tool in self .tools ]
239+ tools_list = []
240+ for name , custom_params in self .tool_custom_parameters .items ():
241+ tool_entry : Dict [str , Any ] = {'name' : name }
242+ if custom_params :
243+ tool_entry ['customParameters' ] = custom_params
244+ tools_list .append (tool_entry )
245+ params ['tools' ] = tools_list
276246 model ['parameters' ] = params
277247 result ['model' ] = model
278248 return result
@@ -285,7 +255,22 @@ class AICompletionConfig(AIConfig):
285255 """
286256 messages : Optional [List [LDMessage ]] = None
287257 judge_configuration : Optional [JudgeConfiguration ] = None
288- tools : Optional [List [ToolDefinition ]] = None
258+ tool_custom_parameters : Optional [Dict [str , Dict [str , Any ]]] = None
259+
260+ def get_tool_custom_parameter (self , tool_name : str , key : str ) -> Any :
261+ """
262+ Retrieve a custom parameter for a specific tool.
263+
264+ :param tool_name: The name of the tool.
265+ :param key: The custom parameter key to look up.
266+ :return: The parameter value, or None if not found.
267+ """
268+ if self .tool_custom_parameters is None :
269+ return None
270+ tool_params = self .tool_custom_parameters .get (tool_name )
271+ if tool_params is None :
272+ return None
273+ return tool_params .get (key )
289274
290275 def to_dict (self ) -> dict :
291276 """
@@ -309,7 +294,22 @@ class AIAgentConfigDefault(AIConfigDefault):
309294 """
310295 instructions : Optional [str ] = None
311296 judge_configuration : Optional [JudgeConfiguration ] = None
312- tools : Optional [List [ToolDefinition ]] = None
297+ tool_custom_parameters : Optional [Dict [str , Dict [str , Any ]]] = None
298+
299+ def get_tool_custom_parameter (self , tool_name : str , key : str ) -> Any :
300+ """
301+ Retrieve a custom parameter for a specific tool.
302+
303+ :param tool_name: The name of the tool.
304+ :param key: The custom parameter key to look up.
305+ :return: The parameter value, or None if not found.
306+ """
307+ if self .tool_custom_parameters is None :
308+ return None
309+ tool_params = self .tool_custom_parameters .get (tool_name )
310+ if tool_params is None :
311+ return None
312+ return tool_params .get (key )
313313
314314 def to_dict (self ) -> Dict [str , Any ]:
315315 """
@@ -320,10 +320,16 @@ def to_dict(self) -> Dict[str, Any]:
320320 result ['instructions' ] = self .instructions
321321 if self .judge_configuration is not None :
322322 result ['judgeConfiguration' ] = self .judge_configuration .to_dict ()
323- if self .tools is not None :
323+ if self .tool_custom_parameters is not None :
324324 model = result .get ('model' ) or {}
325325 params = model .get ('parameters' ) or {}
326- params ['tools' ] = [tool .to_dict () for tool in self .tools ]
326+ tools_list = []
327+ for name , custom_params in self .tool_custom_parameters .items ():
328+ tool_entry : Dict [str , Any ] = {'name' : name }
329+ if custom_params :
330+ tool_entry ['customParameters' ] = custom_params
331+ tools_list .append (tool_entry )
332+ params ['tools' ] = tools_list
327333 model ['parameters' ] = params
328334 result ['model' ] = model
329335 return result
@@ -336,7 +342,22 @@ class AIAgentConfig(AIConfig):
336342 """
337343 instructions : Optional [str ] = None
338344 judge_configuration : Optional [JudgeConfiguration ] = None
339- tools : Optional [List [ToolDefinition ]] = None
345+ tool_custom_parameters : Optional [Dict [str , Dict [str , Any ]]] = None
346+
347+ def get_tool_custom_parameter (self , tool_name : str , key : str ) -> Any :
348+ """
349+ Retrieve a custom parameter for a specific tool.
350+
351+ :param tool_name: The name of the tool.
352+ :param key: The custom parameter key to look up.
353+ :return: The parameter value, or None if not found.
354+ """
355+ if self .tool_custom_parameters is None :
356+ return None
357+ tool_params = self .tool_custom_parameters .get (tool_name )
358+ if tool_params is None :
359+ return None
360+ return tool_params .get (key )
340361
341362 def to_dict (self ) -> Dict [str , Any ]:
342363 """
0 commit comments