r"""Add a scheduling strategy method provided by user in case when none of existent strategies fits. When custom strategy is provided, it will be set as "self.scheduling_strategy" attribute. Args: name (str): The name of the strategy.
(self, name: str, strategy_fn: Callable)
| 137 | return self.current_model.token_counter |
| 138 | |
| 139 | def add_strategy(self, name: str, strategy_fn: Callable): |
| 140 | r"""Add a scheduling strategy method provided by user in case when none |
| 141 | of existent strategies fits. |
| 142 | When custom strategy is provided, it will be set as |
| 143 | "self.scheduling_strategy" attribute. |
| 144 | |
| 145 | Args: |
| 146 | name (str): The name of the strategy. |
| 147 | strategy_fn (Callable): The scheduling strategy function. |
| 148 | """ |
| 149 | if not callable(strategy_fn): |
| 150 | raise ValueError("strategy_fn must be a callable function.") |
| 151 | setattr(self, name, strategy_fn.__get__(self)) |
| 152 | self.scheduling_strategy = getattr(self, name) |
| 153 | logger.info(f"Custom strategy '{name}' added.") |
| 154 | |
| 155 | # Strategies |
| 156 | def round_robin(self) -> BaseModelBackend: |
no outgoing calls
no test coverage detected