Compare commits

...

2 Commits

Author SHA1 Message Date
Fierelier d8e0446f40 Add note about editor 2023-10-31 00:00:52 +01:00
Fierelier d3718bb297 Switch editor and topic arguments 2023-10-31 00:00:45 +01:00
2 changed files with 4 additions and 2 deletions

View File

@ -8,3 +8,5 @@ Usage:
* Put your OpenAI API key into the environment variable OPENAI_API_KEY or the file $USER/.config/me.fier.simpleGPT/api_key.txt (Linux) / %appdata%\me.fier.simpleGPT/api_key.txt (Windows)
Syntax: ./simpleGPT <text editor> <topic>
(I use nano, you best use some editor that opens a process per file)

View File

@ -49,7 +49,7 @@ def convertHumanReadableToList(txt):
lst.append(message)
return lst
userFile = os.path.join(userDir,"conversations",sys.argv[1] + ".txt")
userFile = os.path.join(userDir,"conversations",sys.argv[2] + ".txt")
userFileTmp = userFile + ".tmp"
if not os.path.isfile(userFile):
lst = []
@ -58,7 +58,7 @@ if not os.path.isfile(userFile):
open(userFile,"w",encoding="utf-8").write(convertListToHumanReadable(lst).strip(" \t\r\n") + "\n")
while True:
subprocess.Popen([sys.argv[2],userFile]).wait()
subprocess.Popen([sys.argv[1],userFile]).wait()
lst = convertHumanReadableToList(open(userFile,"r",encoding="utf8").read())
if lst[-1]["role"] != "user" or lst[-1]["content"].strip(" \t\r\n") == "": sys.exit(0)
print("Awaiting response ...")