farling42 / obsidian-import-json

Plug-in for Obsidian.md which will create Notes from JSON files
MIT License
85 stars 5 forks source link

Can you provide an example template? #59

Closed jkjoker closed 6 months ago

jkjoker commented 8 months ago

Can you provide an example template?

Mainly used to import JSON files exported from chat text web into observer.

At the beginning, we only need to be able to fully import, and later we can adjust the template ourselves.

Thank you.

Here is an example of the json file:

{
    "chat-next-web-store": {
        "sessions": [
            {
                "id": "Ide_XrLx_EW2cshFFxCdR",
                "topic": "时间戳放在内容前面",
                "memoryPrompt": "",
                "messages": [
                    {
                        "id": "deImQMAKdIs-22PvyzxdK",
                        "date": "2023/8/2 01:38:17",
                        "role": "user",
                        "content": "你理解错了,我重新描述"
                    },
                    {
                        "id": "DCaBAcr6qkxup38D68YRG",
                        "date": "2023/8/2 01:38:17",
                        "role": "assistant",
                        "content": "非常抱歉理解错误。请重新描述你想要实现的目标,我将尽力提供正确的帮助。",
                        "streaming": false
                    }
                ],
                "stat": {
                    "tokenCount": 0,
                    "wordCount": 0,
                    "charCount": 0
                },
                "lastUpdate": 1696655976822,
                "lastSummarizeIndex": 0,
                "mask": {
                    "id": "QRUEfUlkcAr6xTtUAWKAS",
                    "avatar": "gpt-bot",
                    "name": "新的聊天",
                    "context": [],
                    "syncGlobalConfig": true,
                    "modelConfig": {
                        "model": "gpt-3.5-turbo",
                        "temperature": 0.5,
                        "top_p": 1,
                        "max_tokens": 2000,
                        "presence_penalty": 0,
                        "frequency_penalty": 0,
                        "sendMemory": true,
                        "historyMessageCount": 4,
                        "compressMessageLengthThreshold": 1000,
                        "enableInjectSystemPrompts": true,
                        "template": "{{input}}"
                    },
                    "lang": "cn",
                    "builtin": false,
                    "createdAt": 1696655976822
                }
            }
        ],
        "currentSessionIndex": 0,
        "lastUpdateTime": 0
    },
    "access-control": {
        "token": "1979hhhhhhggfdsshj123456789",
        "accessCode": "",
        "needCode": true,
        "hideUserApiKey": false,
        "hideBalanceQuery": false,
        "disableGPT4": false,
        "openaiUrl": "https://oa.hh.llff.1234567889",
        "lastUpdateTime": 0,
        "disableFastLink": false
    },
    "app-config": {
        "lastUpdate": 1696654742652,
        "submitKey": "Ctrl + Enter",
        "avatar": "1fa93",
        "fontSize": 16,
        "theme": "auto",
        "tightBorder": false,
        "sendPreviewBubble": true,
        "enableAutoGenerateTitle": true,
        "sidebarWidth": 293.3333435058594,
        "disablePromptHint": false,
        "dontShowMaskSplashScreen": true,
        "hideBuiltinMasks": true,
        "customModels": "",
        "models": [
            {
                "name": "gpt-4",
                "available": true
            },
            {
                "name": "gpt-4-0314",
                "available": true
            },
            {
                "name": "gpt-4-0613",
                "available": true
            },
            {
                "name": "gpt-4-32k",
                "available": true
            },
            {
                "name": "gpt-4-32k-0314",
                "available": true
            },
            {
                "name": "gpt-4-32k-0613",
                "available": true
            },
            {
                "name": "gpt-3.5-turbo",
                "available": true
            },
            {
                "name": "gpt-3.5-turbo-0301",
                "available": true
            },
            {
                "name": "gpt-3.5-turbo-0613",
                "available": true
            },
            {
                "name": "gpt-3.5-turbo-16k",
                "available": true
            },
            {
                "name": "gpt-3.5-turbo-16k-0613",
                "available": true
            },
            {
                "name": "gpt-4-1106-preview",
                "available": false
            },
            {
                "name": "gpt-4-vision-preview",
                "available": false
            },
            {
                "name": "gpt-3.5-turbo-1106",
                "available": false
            }
        ],
        "modelConfig": {
            "model": "gpt-3.5-turbo",
            "temperature": 0.5,
            "top_p": 1,
            "max_tokens": 2000,
            "presence_penalty": 0,
            "frequency_penalty": 0,
            "sendMemory": true,
            "historyMessageCount": 4,
            "compressMessageLengthThreshold": 1000,
            "enableInjectSystemPrompts": true,
            "template": "{{input}}"
        },
        "lastUpdateTime": 0
    },
    "mask-store": {
        "masks": {
            "YJdkJLEeYg2e7_0gu4yvM": {
                "id": "YJdkJLEeYg2e7_0gu4yvM",
                "avatar": "gpt-bot",
                "name": "新的聊天",
                "context": [],
                "syncGlobalConfig": false,
                "modelConfig": {
                    "model": "gpt-3.5-turbo",
                    "temperature": 0.5,
                    "top_p": 1,
                    "max_tokens": 2000,
                    "presence_penalty": 0,
                    "frequency_penalty": 0,
                    "sendMemory": false,
                    "historyMessageCount": 0,
                    "compressMessageLengthThreshold": 1000,
                    "enableInjectSystemPrompts": true,
                    "template": "{{input}}"
                },
                "lang": "cn",
                "builtin": false,
                "createdAt": 1696904323295
            }

        },
        "lastUpdateTime": 0
    },
    "prompt-store": {
        "counter": 0,
        "prompts": {},
        "lastUpdateTime": 0
    }
}
farling42 commented 8 months ago

You might want to set the following in the import dialog to create one Note for "session".

Field containing the data = chat-next-web-store.sessions
Field to use as Note name = topic

Something like the following as a simple template will create one section for each message of that session.

{{#each messages}}
## {{date}} - {{role}}
{{content}}
{{/each}}