fix type hint

This commit is contained in:
MIDORIBIN 2023-09-16 10:33:03 +09:00
parent ac581361da
commit 51cfcde2b3
3 changed files with 137 additions and 130 deletions

View File

@ -6,6 +6,7 @@ import random
logging = False logging = False
class ChatCompletion: class ChatCompletion:
@staticmethod @staticmethod
def create( def create(
@ -21,9 +22,8 @@ class ChatCompletion:
except KeyError: except KeyError:
raise Exception(f'The model: {model} does not exist') raise Exception(f'The model: {model} does not exist')
if not provider: if not provider:
if isinstance(model.best_provider, tuple): if isinstance(model.best_provider, list):
provider = random.choice(model.best_provider) provider = random.choice(model.best_provider)
else: else:
provider = model.best_provider provider = model.best_provider

View File

@ -1,36 +1,41 @@
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from .Provider import BaseProvider, Bard, H2o, Vercel
from .Provider import Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin, CodeLinkAva from .Provider import (Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin, CodeLinkAva, BaseProvider, Bard, H2o, DeepAi,
from .Provider import DeepAi, Vercel, Vitalentum, Ylokh, You, Yqcloud Vercel, Vitalentum, Ylokh, You, Yqcloud)
from .typing import Union from .typing import Union
@dataclass @dataclass
class Model: class Model:
name: str name: str
base_provider: str base_provider: str
best_provider: Union[type[BaseProvider], tuple[type[BaseProvider]]] = None best_provider: Union[type[BaseProvider], list[type[BaseProvider]]]
# Config for HuggingChat, OpenAssistant # Config for HuggingChat, OpenAssistant
# Works for Liaobots, H2o, OpenaiChat, Yqcloud, You # Works for Liaobots, H2o, OpenaiChat, Yqcloud, You
default = Model( default = Model(
name="", name="",
base_provider="huggingface" base_provider="huggingface",
best_provider=H2o,
) )
# GPT-3.5 / GPT-4 # GPT-3.5 / GPT-4
gpt_35_turbo = Model( gpt_35_turbo = Model(
name='gpt-3.5-turbo', name='gpt-3.5-turbo',
base_provider='openai', base_provider='openai',
best_provider = ( best_provider=[
Vercel, Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin, Vercel, Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin,
CodeLinkAva, DeepAi, Vitalentum, Ylokh, You, Yqcloud CodeLinkAva, DeepAi, Vitalentum, Ylokh, You, Yqcloud
) ]
) )
gpt_4 = Model( gpt_4 = Model(
name='gpt-4', name='gpt-4',
base_provider='openai', base_provider='openai',
best_provider=Aivvm
) )
# Bard # Bard
@ -123,7 +128,8 @@ gpt_35_turbo_16k = Model(
gpt_35_turbo_16k_0613 = Model( gpt_35_turbo_16k_0613 = Model(
name='openai:gpt-3.5-turbo-16k-0613', name='openai:gpt-3.5-turbo-16k-0613',
base_provider = 'openai') base_provider='openai',
best_provider=Vercel)
gpt_4_0613 = Model( gpt_4_0613 = Model(
name='openai:gpt-4-0613', name='openai:gpt-4-0613',

View File

@ -12,9 +12,10 @@ CreateResult = Generator[str, None, None]
__all__ = [ __all__ = [
'Any', 'Any',
'AsyncGenerator', 'AsyncGenerator',
'CreateResult',
'Generator', 'Generator',
'SHA256',
'Tuple', 'Tuple',
'TypedDict', 'TypedDict',
'SHA256', 'Union',
'CreateResult',
] ]