PentestGPT/example_chatgpt_api.py
Grey_D a3e4d5696c feat: 🎸 API support
Add support for ChatGPT API (for pro only)
2023-03-19 19:13:33 +08:00

23 lines
726 B
Python

import loguru
from config.chatgpt_config import ChatGPTConfig
from utils.chatgpt import ChatGPT
logger = loguru.logger
if __name__ == "__main__":
chatGPTAgent = ChatGPT(ChatGPTConfig())
# the title of this conversation will be new-chat. We can delete it later.
text, conversation_id = chatGPTAgent.send_new_message("Hello, world!")
print(text, conversation_id)
# get history id
history = chatGPTAgent.get_conversation_history()
print(history)
for uuid in history:
print(uuid)
if history[uuid].lower() == "new chat":
result = chatGPTAgent.delete_conversation(uuid)
print(result)
history = chatGPTAgent.get_conversation_history()
print(history)