Mirrowel commited on
Commit
4bc7613
·
1 Parent(s): 0ca1651

refactor(client): 🔨 initialize provider plugins before rotation mode detection

Browse files

Move provider plugin initialization earlier in the constructor to ensure they are available when building the provider rotation modes map. This prevents potential issues where rotation mode detection logic might need access to provider instances before they were initialized.

Files changed (1) hide show
  1. src/rotator_library/client.py +4 -2
src/rotator_library/client.py CHANGED
@@ -140,6 +140,10 @@ class RotatingClient:
140
  self.global_timeout = global_timeout
141
  self.abort_on_callback_error = abort_on_callback_error
142
 
 
 
 
 
143
  # Build provider rotation modes map
144
  # Each provider can specify its preferred rotation mode ("balanced" or "sequential")
145
  provider_rotation_modes = {}
@@ -164,8 +168,6 @@ class RotatingClient:
164
  provider_plugins=PROVIDER_PLUGINS,
165
  )
166
  self._model_list_cache = {}
167
- self._provider_plugins = PROVIDER_PLUGINS
168
- self._provider_instances = {}
169
  self.http_client = httpx.AsyncClient()
170
  self.all_providers = AllProviders()
171
  self.cooldown_manager = CooldownManager()
 
140
  self.global_timeout = global_timeout
141
  self.abort_on_callback_error = abort_on_callback_error
142
 
143
+ # Initialize provider plugins early so they can be used for rotation mode detection
144
+ self._provider_plugins = PROVIDER_PLUGINS
145
+ self._provider_instances = {}
146
+
147
  # Build provider rotation modes map
148
  # Each provider can specify its preferred rotation mode ("balanced" or "sequential")
149
  provider_rotation_modes = {}
 
168
  provider_plugins=PROVIDER_PLUGINS,
169
  )
170
  self._model_list_cache = {}
 
 
171
  self.http_client = httpx.AsyncClient()
172
  self.all_providers = AllProviders()
173
  self.cooldown_manager = CooldownManager()