Get trainable variables from tools, filtering out tools with require_grad=False. Only returns variables for tools where require_grad=True. Args: tool_name (Optional[str]): Name of a specific tool. If None, returns trainable variables for all tools.
(self, tool_name: Optional[str] = None)
| 1159 | return variables |
| 1160 | |
| 1161 | async def get_trainable_variables(self, tool_name: Optional[str] = None) -> Dict[str, 'Variable']: |
| 1162 | """Get trainable variables from tools, filtering out tools with require_grad=False. |
| 1163 | |
| 1164 | Only returns variables for tools where require_grad=True. |
| 1165 | |
| 1166 | Args: |
| 1167 | tool_name (Optional[str]): Name of a specific tool. If None, returns trainable variables for all tools. |
| 1168 | |
| 1169 | Returns: |
| 1170 | Dict[str, Variable]: Dictionary mapping tool names to Variable objects for tools with require_grad=True. |
| 1171 | Each Variable has: |
| 1172 | - name: tool name |
| 1173 | - type: "tool_code" |
| 1174 | - description: tool description |
| 1175 | - require_grad: True |
| 1176 | - variables: tool's code (as string value) |
| 1177 | """ |
| 1178 | async with self._variables_lock: |
| 1179 | # Get all variables first |
| 1180 | all_variables = await self.get_variables(tool_name=tool_name) |
| 1181 | |
| 1182 | # Filter to only include variables with require_grad=True |
| 1183 | trainable_variables = { |
| 1184 | name: variable for name, variable in all_variables.items() |
| 1185 | if variable.require_grad is True |
| 1186 | } |
| 1187 | |
| 1188 | return trainable_variables |
| 1189 | |
| 1190 | async def set_variables(self, tool_name: str, variable_updates: Dict[str, Any], new_version: Optional[str] = None, description: Optional[str] = None) -> ToolConfig: |
| 1191 | """Set variable values in a tool and create a new version. |
nothing calls this directly
no test coverage detected