diff --git a/chatgpt_core.py b/chatgpt_core.py index 76a2c9a..c8d18f0 100644 --- a/chatgpt_core.py +++ b/chatgpt_core.py @@ -1,6 +1,7 @@ # Note that this file was not purpose-made for the reddit history thing, I use it for other conversation scripts I've made and have removed a bunch of functions that aren't relevant. import os +import time import json import openai import pandas as pd @@ -19,7 +20,7 @@ def __init__(self, instructions="You are a helpful assistant.", model="gpt-3.5-t self.filename = filename self.inserts = inserts if inserts else {} self.messages = pd.DataFrame(columns=["actor", "message", "sendable"]) - + if filename: try: with open(filename, 'r') as f: @@ -91,7 +92,7 @@ def generate_response(self, message=None, store_message=True, retries=5): assistant_message = response.choices[0].message['content'] if store_message: self.add_message(assistant_message, actor="assistant") - + if self.filename: self.save_chat()