mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
fix(provider): ignore empty token rotation (#2184)
This commit is contained in:
@@ -30,4 +30,6 @@ class TokenManager:
|
|||||||
return self.tokens[self.using_token_index]
|
return self.tokens[self.using_token_index]
|
||||||
|
|
||||||
def next_token(self):
|
def next_token(self):
|
||||||
|
if len(self.tokens) == 0:
|
||||||
|
return
|
||||||
self.using_token_index = (self.using_token_index + 1) % len(self.tokens)
|
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'
|
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
|
@pytest.mark.asyncio
|
||||||
async def test_openai_requester_initialize_uses_placeholder_api_key(monkeypatch):
|
async def test_openai_requester_initialize_uses_placeholder_api_key(monkeypatch):
|
||||||
captured_kwargs = {}
|
captured_kwargs = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user