diff --git a/.gitignore b/.gitignore index 314582d..0094cd3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /connection.py +/__pycache__ diff --git a/talk.py b/talk.py index 97ee334..3142a0e 100644 --- a/talk.py +++ b/talk.py @@ -5,12 +5,30 @@ import openai class Talk: + max_tokens_count: int = 100 + responses_count: int = 5 + temperature: float = .7 + top_p: int = 1 + @classmethod - def main (message: str) -> None: + def main (cls, message: str) -> None: openai.organization = OPENAI_ORGANISATION openai.api_key = OPENAI_API_KEY + print (cls.__get_answers (message)[0]) + + @classmethod + def __get_answers (cls, message: str) -> list[str]: + return openai.Completion.create ( + model = 'text-davinci-002', + prompt = message, + max_tokens = cls.max_tokens_count, + n = cls.temperature, + stop = None, + temperature = cls.temperature, + top_p = cls.top_p).choices + if __name__ == '__main__': - Talk.main (sys.argv[1]) + Talk.main (sys.argv[1] if len (sys.argv) > 1 else '')