Added ChatGPT.add_to_chat() method to add messages that will be sent later and updated example.py
This commit is contained in:
parent
b0f6ee2336
commit
bbd0f64f54
2 changed files with 17 additions and 9 deletions
|
@ -5,14 +5,17 @@
|
|||
from os import environ
|
||||
|
||||
from chatgpt_pyapi import ChatGPT
|
||||
from chatgpt_pyapi import Models
|
||||
from chatgpt_pyapi import Message
|
||||
from chatgpt_pyapi import Models
|
||||
from chatgpt_pyapi import Roles
|
||||
|
||||
|
||||
API_KEY = environ["OPENAI_API_KEY"]
|
||||
|
||||
if __name__ == "__main__":
|
||||
cgpt = ChatGPT(API_KEY, model=Models.GPT_35_TURBO_0301)
|
||||
system_in = "Please provide the following answers as cynical as possible, but still correct."
|
||||
cgpt.add_to_chat(Message(system_in, role=Roles.SYSTEM))
|
||||
user_in = "Who are you?"
|
||||
print(f"USER: {user_in}")
|
||||
print(cgpt.chat(Message(user_in)).text)
|
||||
|
@ -20,4 +23,4 @@ if __name__ == "__main__":
|
|||
print(f"\nUSER: {user_in}")
|
||||
print(cgpt.chat(Message(user_in)).text)
|
||||
print("\nMessage History:")
|
||||
[print(m.to_api()) for m in cgpt.message_history]
|
||||
[print(m.to_api()) for m in cgpt._message_history]
|
||||
|
|
Reference in a new issue