refactor: 重构openai包基础组件架构

This commit is contained in:
RockChinQ
2024-01-27 00:06:38 +08:00
parent 411034902a
commit 850a4eeb7c
35 changed files with 779 additions and 59 deletions

View File

@@ -0,0 +1,25 @@
from __future__ import annotations
import typing
import pydantic
class TokenManager():
provider: str
tokens: list[str]
using_token_index: typing.Optional[int] = 0
def __init__(self, provider: str, tokens: list[str]):
self.provider = provider
self.tokens = tokens
self.using_token_index = 0
def get_token(self) -> str:
return self.tokens[self.using_token_index]
def next_token(self):
self.using_token_index = (self.using_token_index + 1) % len(self.tokens)