diff options
author | ggindinson <grisha.gindinson@gmail.com> | 2023-05-26 20:57:22 +0200 |
---|---|---|
committer | ggindinson <grisha.gindinson@gmail.com> | 2023-05-26 20:57:22 +0200 |
commit | 223f09a4f10ccfc369062ae8285b19627bacc3b2 (patch) | |
tree | ddffb97cf607d7a61e03c66b267c05d651b020c8 | |
parent | Added support for AiColors (diff) | |
download | gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar.gz gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar.bz2 gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar.lz gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar.xz gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.tar.zst gpt4free-223f09a4f10ccfc369062ae8285b19627bacc3b2.zip |
Diffstat (limited to '')
-rw-r--r-- | gpt4free/__init__.py | 35 | ||||
-rw-r--r-- | testing/aicolors_test.py | 6 |
2 files changed, 28 insertions, 13 deletions
diff --git a/gpt4free/__init__.py b/gpt4free/__init__.py index 2dc6f5f3..bcc03a3b 100644 --- a/gpt4free/__init__.py +++ b/gpt4free/__init__.py @@ -5,18 +5,20 @@ from gpt4free import quora from gpt4free import theb from gpt4free import usesless from gpt4free import you +from gpt4free import aicolors from gpt4free import deepai class Provider(Enum): """An enum representing different providers.""" - You = 'you' - Poe = 'poe' - ForeFront = 'fore_front' - Theb = 'theb' - UseLess = 'useless' - DeepAI = 'deepai' + You = "you" + Poe = "poe" + ForeFront = "fore_front" + Theb = "theb" + UseLess = "useless" + AiColors = "ai_colors" + DeepAI = "deepai" class Completion: @@ -42,10 +44,16 @@ class Completion: return Completion.__theb_service(prompt, **kwargs) elif provider == Provider.UseLess: return Completion.__useless_service(prompt, **kwargs) + elif provider == Provider.AiColors: + return Completion.__ai_colors_service(prompt, **kwargs) elif provider == Provider.DeepAI: return Completion.__deepai_service(prompt, **kwargs) else: - raise Exception('Provider not exist, Please try again') + raise Exception("Provider not exist, Please try again") + + @staticmethod + def __ai_colors_service(prompt: str): + return aicolors.Completion.create(prompt=prompt) @staticmethod def __useless_service(prompt: str, **kwargs) -> str: @@ -65,11 +73,12 @@ class Completion: @staticmethod def __theb_service(prompt: str, **kwargs): - return ''.join(theb.Completion.create(prompt=prompt)) - + return "".join(theb.Completion.create(prompt=prompt)) + @staticmethod def __deepai_service(prompt: str, **kwargs): - return ''.join(deepai.Completion.create(prompt=prompt)) + return "".join(deepai.Completion.create(prompt=prompt)) + class ChatCompletion: """This class is used to execute a chat completion for a specified provider""" @@ -87,8 +96,8 @@ class ChatCompletion: if provider == Provider.DeepAI: return ChatCompletion.__deepai_service(messages, **kwargs) else: - raise Exception('Provider not exist, Please try again') - + raise Exception("Provider not exist, Please try again") + @staticmethod def __deepai_service(messages: list, **kwargs): - return ''.join(deepai.ChatCompletion.create(messages=messages))
\ No newline at end of file + return "".join(deepai.ChatCompletion.create(messages=messages)) diff --git a/testing/aicolors_test.py b/testing/aicolors_test.py new file mode 100644 index 00000000..853f7e45 --- /dev/null +++ b/testing/aicolors_test.py @@ -0,0 +1,6 @@ +from gpt4free import aicolors + +prompt = "Light green color" +req = aicolors.Completion.create(prompt=prompt) + +print(req) |