Added cli and moved official API to chatgpt_pyapi.openai

This commit is contained in:
Julian Müller (ChaoticByte) 2023-03-13 08:09:32 +01:00
parent 4fd0969457
commit 308bf0730f
4 changed files with 109 additions and 95 deletions

17
cli.py Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env python3
# Copyright (c) 2023 Julian Müller (ChaoticByte)
from os import environ
from sys import argv
from chatgpt_pyapi.openai import ChatGPT, Message, Models
# Read the API key from a environment variable
API_KEY = environ["OPENAI_API_KEY"]
if __name__ == "__main__":
# Create ChatGPT API instance
cgpt = ChatGPT(API_KEY, model=Models.GPT_35_TURBO_0301)
user_input = " ".join(argv[1:])
print(cgpt.chat(Message(user_input)).text)