2023-04-27 19:10:43 +00:00
|
|
|
from enum import Enum
|
|
|
|
|
2023-04-27 20:57:06 +00:00
|
|
|
from openai_rev import forefront
|
|
|
|
from openai_rev import quora
|
|
|
|
from openai_rev import you
|
2023-04-27 19:10:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Provider(Enum):
|
|
|
|
You = 'you'
|
|
|
|
Poe = 'poe'
|
2023-04-27 20:57:06 +00:00
|
|
|
ForeFront = 'fore_front'
|
2023-04-27 19:10:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Completion:
|
|
|
|
@staticmethod
|
|
|
|
def create(provider: Provider, prompt: str, **kwargs):
|
|
|
|
if provider == Provider.Poe:
|
|
|
|
return Completion.__poe_service(prompt, **kwargs)
|
|
|
|
elif provider == Provider.You:
|
|
|
|
return Completion.__you_service(prompt, **kwargs)
|
2023-04-27 20:57:06 +00:00
|
|
|
elif provider == Provider.ForeFront:
|
|
|
|
return Completion.__fore_front_service(prompt, **kwargs)
|
2023-04-27 19:10:43 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __you_service(cls, prompt: str, **kwargs) -> str:
|
2023-04-27 20:57:06 +00:00
|
|
|
return you.Completion.create(prompt, **kwargs).text
|
2023-04-27 19:10:43 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __poe_service(cls, prompt: str, **kwargs) -> str:
|
2023-04-27 20:57:06 +00:00
|
|
|
return quora.Completion.create(prompt=prompt, **kwargs).text
|
2023-04-27 19:10:43 +00:00
|
|
|
|
2023-04-27 20:57:06 +00:00
|
|
|
@classmethod
|
|
|
|
def __fore_front_service(cls, prompt: str, **kwargs) -> str:
|
|
|
|
return forefront.Completion.create(prompt=prompt, **kwargs).text
|