MichielvanBeers / Flow.Launcher.Plugin.ChatGPT

MIT License
37 stars 5 forks source link

KeyError #10

Closed bigbadblo closed 1 year ago

bigbadblo commented 1 year ago

Successfully was able to invoke 'ai' without an error on the save-prompts branch, but all responses error out with the following KeyError. Is the ability to report errors from the plugin directly new? It made this report much easier if so -- thank you!

Trace Log

``` Traceback (most recent call last): File "C:\Users\brian\AppData\Roaming\FlowLauncher\Plugins\Flow.Launcher.Plugin.ChatGPT-ability-to-save-prompts-and-answers\lib\flox\launcher.py", line 44, in run results = request_method(*request_parameters) or self._results File "C:\Users\brian\AppData\Roaming\FlowLauncher\Plugins\Flow.Launcher.Plugin.ChatGPT-ability-to-save-prompts-and-answers\lib\flox\__init__.py", line 132, in _query self.query(query) File "C:\Users\brian\AppData\Roaming\FlowLauncher\Plugins\Flow.Launcher.Plugin.ChatGPT-ability-to-save-prompts-and-answers\plugin\main.py", line 52, in query prompt, prompt_keyword, system_message = self.split_prompt(query) File "C:\Users\brian\AppData\Roaming\FlowLauncher\Plugins\Flow.Launcher.Plugin.ChatGPT-ability-to-save-prompts-and-answers\plugin\main.py", line 184, in split_prompt system_message = row["System Message"] KeyError: 'System Message' ```

MichielvanBeers commented 1 year ago

Some progress, that is good :). Can you share the content of your system_messages.csv file?

The ability to report errors directly is from the Flox library by Garul, so all credits there :)

MichielvanBeers commented 1 year ago

Also, could you set your Logging Level setting to 'Debug' and share the content of plugin.log here? Please note that it be default also prints your OpenAI key, so please remove that before posting. Thanks!

bigbadblo commented 1 year ago

Ok, I think I've solved it. When editing the system_messages.csv on Windows, it defaulted to opening up in Excel. I noticed that the default prompts and contexts there were separated to multiple cells.

I elected to open and edit the .csv via a text editor instead (Sublime) and was able to create a new system message with prompt, save it, and then configured the plugin settings to default to the new prompt I created. Success! I also see the conversations .txt file has been created and is updating my chat history as expected!!

I do think it might be worth exploring why opening / editing the .csv in Excel vs a standard text editor would create an issue. If you'd like, I can try to replicate the original issue that caused this problem momentarily and will upload the logs and error messages if you'd like to try to troubleshoot what happened (I'd imagine .csv files may default to opening in Excel in others' systems, right?).

UPDATE: Here is a screenshot of how the .csv file and entries are being split in Excel: image

Once I was able to invoke without error when just editing the .csv via text editor, I then decided to open the .csv in Excel, modifying nothing, and saved the file. Thereafter, when invoking the ai prompt I again received a system KeyError again. The log below shows both successful responses beforehand (having only edited the .csv via text editor), and the KeyError after I saved the system_messages.csv via Excel.

plugin - Copy.log

MichielvanBeers commented 1 year ago

Great, happy to hear it is working!

I also see what might be going wrong: when saving the csv file, I think Excel uses by default a comma ',' delimiter. Since I've set the delimiter to a semi colon ';' (because the default setences contain commas), when saving the csv, Excel assumes the commas determine a new column.

I'll do some research if I can do a check if all the content can be read correctly, before loading the rest of the plugin.

Can I for now close this issue and create a new version? Or are you missing any functionalities?

bigbadblo commented 1 year ago

No, I think this is resolved and closed! Success, and thank you very much! :)