ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

[Bug] Custom prompts do not sync with Github JSON

Open Manamama opened this issue 2 years ago • 4 comments

Version

0.7.4

Bug description

I have created a couple of custom prompts in the app and it works in the local cache upon restart. I have also created an empty JSON file on Gighub, taking the hint from the .rs files that sync the public prompts:

grep -R "sync" /ChatGPT/src-tauri/src
/ChatGPT/src-tauri/src/main.rs:async fn main() {
/ChatGPT/src-tauri/src/main.rs:    // If the file does not exist, creating the file will block menu synchronization
/ChatGPT/src-tauri/src/main.rs:            cmd::sync_prompts,
/ChatGPT/src-tauri/src/app/fs_extra.rs:pub async fn metadata(path: PathBuf) -> Result<Metadata> {
/ChatGPT/src-tauri/src/app/fs_extra.rs:// pub async fn exists(path: PathBuf) -> bool {
/ChatGPT/src-tauri/src/app/cmd.rs:pub fn sync_prompts(app: AppHandle, data: String, time: u64) {
/ChatGPT/src-tauri/src/app/cmd.rs:        "sync_prompts".to_string(),
/ChatGPT/src-tauri/src/app/cmd.rs:        "ChatGPT Prompts data has been synchronized!",
/ChatGPT/src-tauri/src/app/window.rs:    tokio::spawn(async move {
/ChatGPT/src-tauri/src/app/window.rs:    tokio::spawn(async move {
/ChatGPT/src-tauri/src/app/menu.rs:            CustomMenuItem::new("sync_prompts".to_string(), "Sync Prompts").into(),
/ChatGPT/src-tauri/src/app/menu.rs:        "sync_prompts" => {
/ChatGPT/src-tauri/src/app/menu.rs:                "Data sync will enable all prompts, are you sure you want to sync?",
/ChatGPT/src-tauri/src/app/menu.rs:                            .eval("window.__sync_prompts && window.__sync_prompts()")
/ChatGPT/src-tauri/src/app/setup.rs:    tokio::spawn(async move {
/ChatGPT/src-tauri/src/app/setup.rs:        tokio::spawn(async move {
/ChatGPT/src-tauri/src/assets/core.js:async function invoke(cmd, args) {
/ChatGPT/src-tauri/src/assets/core.js:async function init() {
/ChatGPT/src-tauri/src/assets/core.js:  async function platform() {
/ChatGPT/src-tauri/src/assets/core.js:  window.__sync_prompts = async function() {
/ChatGPT/src-tauri/src/assets/core.js:      await invoke('sync_prompts', { data, time: Date.now() });
/ChatGPT/src-tauri/src/assets/core.js:          message: 'ChatGPT Prompts data sync failed, please try again!'.toString(),
etc.

My public custom github JSON file is here and I have put its path into the UI: github.com/Manamama/ChatGPT_prompts/blob/main/ChatGPT_prompts1 In the Synch Custom UI, the synch process shows no error:

https | https://raw.githubusercontent.com/Manamama/ChatGPT_prompts/main/ChatGPT_prompts1.json | 2023-01-03 12:26:33 | Sync View Edit Delete

Despite this, the Github Json file is not created (when empty) or overwritten (when manually versioned, to check the sync directions).

What am I doing wrong?

OS

Ubuntu

Environment

No response

Manamama avatar Jan 03 '23 11:01 Manamama

The data is in the wrong format and should look like this (array):

[
    {
      "cmd": "error_finder",
      "act": "Critic",
      "tags": [
        "error"
      ],
      "enable": true,
      "prompt": "I want you to act as a critic and error finder.  Review the following text and identify any errors or inadequacies it may contain: \""
    },
    {
      "cmd": "emoji_add",
      "act": "Emoji Adder",
      "tags": [
        "emoji"
      ],
      "enable": true,
      "prompt": "I want you to adorn the sentences I wrote with emojis. I will write the sentences, and you will add emojis to each sentence. When I need to tell you something in English, I will do it by wrapping it in curly brackets like {this}. Here is the text with sentences:"
    }
]

lencx avatar Jan 03 '23 11:01 lencx

I knew that: as I wrote, it did not synch even against an empty JSON online file.

Do recheck now, I have copy pasted from the local cache version, changing only the numbers: the Github version is 2.0 while the local, below, is 3.0. It still does not synch, despite the OK UI message, as per above:

[
  {
    "cmd": "_ignore_version_only",
    "act": "Versioner",
    "tags": [],
    "enable": true,
    "prompt": "Version 3.0, local cache - here as the more elegant: \n\n{\n  \"version\": \"1.1\",\n  \"prompts\": [\n  {\n\nsolution does now work"
  },
  {
    "cmd": "error_finder",
    "act": "Critic",
    "tags": [
      "error"
    ],
    "enable": true,
    "prompt": "I want you to act as a critic and error finder.  Review the following text and identify any errors or inadequacies it may contain: \""
  },
  {
    "cmd": "emoji_add",
    "act": "Emoji Adder",
    "tags": [
      "emoji"
    ],
    "enable": true,
    "prompt": "I want you to adorn the sentences I wrote with emojis. I will write the sentences, and you will add emojis to each sentence. When I need to tell you something in English, I will do it by wrapping it in curly brackets like {this}. Here is the text with sentences:"
  }
]

Manamama avatar Jan 03 '23 12:01 Manamama

Once the sync is complete, click the view button after the sync button to see. I haven't implemented the user-defined tag yet, I'll fix it in the next release.

sync

lencx avatar Jan 03 '23 12:01 lencx

Oh, so it seems to work somehow on your end. On mine it still is:

Sync Custom -> Sync -> "Sync will overwrite the previous data, confirm to sync?" -> Yes -> ... -> "View"

-nothing happens, no version change, but then .chatgpt/cache_model/82bfd9c8935c4d9199d17fd519f7ff48.json is created and synced with Github. When I delete .chatgpt/cache_model/user_custom.json to "make room" and synch, then .chatgpt/cache_model/user_custom.json gets recreated but with empty json: []

I thus gather that it is a bug and you will fix it. Glad to help by reporting! 👍🏽

Manamama avatar Jan 03 '23 20:01 Manamama