Skip to content

Commit

Permalink
修改文件保存位置
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOFF-ive committed Apr 2, 2023
1 parent 9736a1a commit 2d7507a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ def chat():

def setFile():
global currentFile
path = os.getcwd()
generateCatalogue()
doc_path = os.path.join(os.path.expanduser("~"), "Documents")
chat_logs_path = os.path.join(doc_path, "chat_logs")
Log.point("Existing Files:")
for file in glob.glob(os.path.join(path, "*.json")):
for file in glob.glob(os.path.join(chat_logs_path, "*.json")):
Log.answer(file)

while True:
Expand All @@ -114,8 +116,11 @@ def setFile():
def save():
global messages, currentFile
fileName = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + ".json" if currentFile == "" else currentFile
generateCatalogue()
doc_path = os.path.join(os.path.expanduser("~"), "Documents")
chat_logs_path = os.path.join(doc_path, "chat_logs")
Log.info("Saving File {}".format(fileName))
with open(fileName, 'w') as f:
with open(os.path.join(chat_logs_path, fileName), 'w') as f:
for item in messages:
json.dump(item, f)
f.write('\n')
Expand Down Expand Up @@ -176,6 +181,13 @@ def audio():
Log.error("File Does Not Exist")


def generateCatalogue():
doc_path = os.path.join(os.path.expanduser("~"), "Documents")
chat_logs_path = os.path.join(doc_path, "chat_logs")
if not os.path.exists(chat_logs_path):
os.makedirs(chat_logs_path)


if __name__ == "__main__":
Log.info("Project Launch")
initOpenAI()
Expand Down

0 comments on commit 2d7507a

Please sign in to comment.