mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
fix(provider): ignore empty token rotation
This commit is contained in:
@@ -30,4 +30,6 @@ class TokenManager:
|
||||
return self.tokens[self.using_token_index]
|
||||
|
||||
def next_token(self):
|
||||
if len(self.tokens) == 0:
|
||||
return
|
||||
self.using_token_index = (self.using_token_index + 1) % len(self.tokens)
|
||||
|
||||
@@ -81,6 +81,15 @@ def test_token_manager_filters_blank_and_duplicate_tokens():
|
||||
assert token_mgr.get_token() == 'first-key'
|
||||
|
||||
|
||||
def test_token_manager_next_token_ignores_empty_token_list():
|
||||
token_mgr = TokenManager('provider-uuid', [])
|
||||
|
||||
token_mgr.next_token()
|
||||
|
||||
assert token_mgr.get_token() == ''
|
||||
assert token_mgr.using_token_index == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_openai_requester_initialize_uses_placeholder_api_key(monkeypatch):
|
||||
captured_kwargs = {}
|
||||
|
||||
Reference in New Issue
Block a user