Skip to content

Instantly share code, notes, and snippets.

@oswalpalash
Last active December 11, 2022 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oswalpalash/46c940d7059c67769314e6e21ba5792a to your computer and use it in GitHub Desktop.
Save oswalpalash/46c940d7059c67769314e6e21ba5792a to your computer and use it in GitHub Desktop.
Make AI go brr
import sys
import os
import time
from chatgpt import Conversation
conversation1 = Conversation(config_path="./config.json")
conversation2 = Conversation(config_path="./config2.json")
if os.path.exists("log.txt"):
conversation1.reset()
op1 = conversation1.chat("My name is Assistant. How's it going?")
print("Assistant1: " + op1 + "\n")
else:
with open("log.txt", "r") as f:
op1 = f.readlines()[-1].split("Assistant: ")[1].strip()
if os.path.exists("log2.txt"):
conversation2.reset()
op2 = conversation2.chat(op1)
print("Assistant2: " + op2 + "\n")
else:
with open("log.txt", "r") as f:
op2 = f.readlines()[-1].split("Assistant: ")[1].strip()
for i in range(500):
assert(conversation1._conversation_id != conversation2._conversation_id)
# retry conversation.chat() if there are timeouts
try:
op1 = conversation1.chat(op2)
except:
time.sleep(10)
op1 = conversation1.chat(op2)
try:
op2 = conversation2.chat(op1)
except:
time.sleep(10)
op2 = conversation2.chat(op1)
print("Assistant1: " + op1 + "\n")
print("Assistant2: " + op2 + "\n")
#print(str(i) + "\n")
sys.stdout.flush()
time.sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment