From fd01f19cba251ebf3dfef0e795ce0c97b80ab75f Mon Sep 17 00:00:00 2001 From: Daniel Hu Date: Tue, 14 Nov 2023 16:29:45 +0800 Subject: [PATCH] Docs: update api documents Signed-off-by: Daniel Hu --- api/chat.md | 109 +++++++++++++ api/code-action.md | 73 +++++++++ api/command.md | 37 +++++ api/context.md | 86 +++++++++++ api/key.md | 43 ++++++ api/message.md | 378 --------------------------------------------- api/model.md | 31 ++++ api/topic.md | 100 ++++++++++++ 8 files changed, 479 insertions(+), 378 deletions(-) create mode 100644 api/chat.md create mode 100644 api/code-action.md create mode 100644 api/command.md create mode 100644 api/context.md create mode 100644 api/key.md delete mode 100644 api/message.md create mode 100644 api/model.md create mode 100644 api/topic.md diff --git a/api/chat.md b/api/chat.md new file mode 100644 index 0000000..969ab4e --- /dev/null +++ b/api/chat.md @@ -0,0 +1,109 @@ +[TOC] + +## Chat Message + +### JS to Java + +```json +{ + "action": "sendMessage/request", + "metadata": { + "callback": "responseFunctionName", + "parent": "b67937dd845afdf59dec505efafd2d18854cb2b147ae0cecd7f266d856373137" + }, + "payload": { + "context": [ + { + "languageId": "python", + "path": "xxx/a.py", + "startLine": 1, + "content": "adkfjj\n" + }, + { + "command": "ls -l", + "content": "adkfjj\n" + } + ], + "message": "Hello" + } +} +``` + +### Java to JS + +- success + +**round 1** + +```json +{ + "action": "sendMessage/response", + "metadata": { + "currentChunkId": 1, + "isFinalChunk": false, + "finishReason": "", + "error": "" + }, + "payload": { + "message": "Hello!", + "user": "Daniel Hu ", + "date": "Wed Oct 18 09:02:42 2023 +0800", + "promptHash": "" + } +} +``` + +**round 2** + +```json +{ + "action": "sendMessage/response", + "metadata": { + "currentChunkId": 2, + "isFinalChunk": false, + "finishReason": "", + "error": "" + }, + "payload": { + "message": "Hello!\nHow can I assist you?", + "user": "Daniel Hu ", + "date": "Wed Oct 18 09:02:42 2023 +0800", + "promptHash": "" + } +} +``` + +**round 3** + +```json +{ + "action": "sendMessage/response", + "metadata": { + "currentChunkId": 3, + "isFinalChunk": true, + "finishReason": "success", + "error": "" + }, + "payload": { + "message": "Hello!\nHow can I assist you?", + "user": "Daniel Hu ", + "date": "Wed Oct 18 09:02:42 2023 +0800", + "promptHash": "b67937dd845afdf59dec505efafd2d18854cb2b147ae0cecd7f266d856373137" + } +} +``` + +- failed + +```json +{ + "action": "sendMessage/response", + "metadata": { + "currentChunkId": 0, + "isFinalChunk": true, + "finishReason": "error", + "error": "Network error." + }, + "payload": null +} +``` diff --git a/api/code-action.md b/api/code-action.md new file mode 100644 index 0000000..6b5bd7d --- /dev/null +++ b/api/code-action.md @@ -0,0 +1,73 @@ +## Insert Code + +### JS to Java + +```json +{ + "action": "insertCode/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": { + "content": "adkfjj\n" + } +} +``` + +### Java to JS + +```json +{ + "action": "insertCode/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": null +} +``` + +## Replace All Content + +### JS to Java + +```json +{ + "action": "replaceFileContent/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": { + "content": "adkfjj\n" + } +} +``` + +### Java to JS + +```json +{ + "action": "replaceFileContent/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": null +} +``` + +## View Diff + +### JS to Java + +```json +{ + "action": "viewDiff/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": { + "content": "package ai.devchat" + } +} +``` diff --git a/api/command.md b/api/command.md new file mode 100644 index 0000000..a6fd643 --- /dev/null +++ b/api/command.md @@ -0,0 +1,37 @@ +## Query Command List + +### JS to Java + +```json +{ + "action": "listCommands/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": null +} +``` + +### Java to JS + +```json +{ + "action": "listCommands/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "commands": [ + { + "name": "code", + "description": "Generate code with a general template embedded into the prompt." + }, + { + "name": "release_note", + "description": "Generate a release note for the given commit log." + } + ] + } +} +``` diff --git a/api/context.md b/api/context.md new file mode 100644 index 0000000..9ae2022 --- /dev/null +++ b/api/context.md @@ -0,0 +1,86 @@ +## Add Context(Add to DevChat) + +### Java to JS (notify) + +```json +{ + "action": "addContext/notify", + "metadata": null, + "payload": { + "path": "src/main/Hello.java", + "startLine": 1, + "languageId": "Java", + "content": "public static void main(..." + } +} +``` + +## List Contexts + +### JS to Java (command) + +```json +{ + "action": "listContexts/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": null +} +``` + +### Java to JS + +```json +{ + "action": "listContexts/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "contexts": [ + { + "command": "git diff -cached", + "description": "xxx." + }, + { + "command": "git diff HEAD", + "description": "xxx." + } + ] + } +} +``` + +## Get Context with Command + +### JS to Java + +```json +{ + "action": "addContext/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": { + "command": "git diff --cached" + } +} +``` + +### Java to JS + +```json +{ + "action": "addContext/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "command": "git diff --cached", + "content": "xxx" + } +} +``` diff --git a/api/key.md b/api/key.md new file mode 100644 index 0000000..db7d1eb --- /dev/null +++ b/api/key.md @@ -0,0 +1,43 @@ +## Set or Update key + +### JS to Java + +```json +{ + "action": "setOrUpdateKey/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": { + "key": "DC.abcdef123456" + } +} +``` + +### Java to JS + +- success + +```json +{ + "action": "setOrUpdateKey/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": null +} +``` + +- failed + +```json +{ + "action": "setOrUpdateKey/response", + "metadata": { + "status": "Failed", + "error": "Failed to set key." + }, + "payload": null +} +``` diff --git a/api/message.md b/api/message.md deleted file mode 100644 index 78668e1..0000000 --- a/api/message.md +++ /dev/null @@ -1,378 +0,0 @@ -# JS <--> Java - -## Set or Update key - -### Request - -```json -{ - "action": "setOrUpdateKey/request", - "metadata": { - "callback": "responseFunctionName" - }, - "payload": { - "key": "DC.abcdef123456" - } -} -``` - -### Response - -- success - -```json -{ - "action": "setOrUpdateKey/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": null -} -``` - -- failed - -```json -{ - "action": "setOrUpdateKey/response", - "metadata": { - "status": "Failed", - "error": "Failed to set key." - }, - "payload": null -} -``` - -## Chat Message - -### Request - -```json -{ - "action": "sendMessage/request", - "metadata": { - "callback": "responseFunctionName", - "parent": "b67937dd845afdf59dec505efafd2d18854cb2b147ae0cecd7f266d856373137" - }, - "payload": { - "context": "Hello!", - "message": "Hello" - } -} -``` - -### Response - -- success - -**round 1** - -```json -{ - "action": "sendMessage/response", - "metadata": { - "currentChunkId": 1, - "isFinalChunk": false, - "finishReason": "", - "error": "" - }, - "payload": { - "message": "Hello!", - "user": "Daniel Hu ", - "date": "Wed Oct 18 09:02:42 2023 +0800", - "promptHash": "" - } -} -``` - -**round 2** - -```json -{ - "action": "sendMessage/response", - "metadata": { - "currentChunkId": 2, - "isFinalChunk": false, - "finishReason": "", - "error": "" - }, - "payload": { - "message": "Hello!\nHow can I assist you?", - "user": "Daniel Hu ", - "date": "Wed Oct 18 09:02:42 2023 +0800", - "promptHash": "" - } -} -``` - -**round 3** - -```json -{ - "action": "sendMessage/response", - "metadata": { - "currentChunkId": 3, - "isFinalChunk": true, - "finishReason": "success", - "error": "" - }, - "payload": { - "message": "Hello!\nHow can I assist you?", - "user": "Daniel Hu ", - "date": "Wed Oct 18 09:02:42 2023 +0800", - "promptHash": "b67937dd845afdf59dec505efafd2d18854cb2b147ae0cecd7f266d856373137" - } -} -``` - -- failed - -```json -{ - "action": "sendMessage/response", - "metadata": { - "currentChunkId": 0, - "isFinalChunk": true, - "finishReason": "error", - "error": "Network error." - }, - "payload": null -} -``` - -## Add Context(Add to DevChat) - -### Java to JS - -```json -{ - "action": "addContext/request", - "metadata": null, - "payload": { - "file": "/Users/xxx/yyy/Hello.java", - "content": "public static void main(..." - } -} -``` - -### JS to Java - -```json -{ - "action": "addContext/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": null -} -``` - -```json -{ - "action": "addContext/response", - "metadata": { - "status": "error", - "error": "some error message here" - }, - "payload": null -} -``` - -## Query Command List - -### JS to Java - -```json -{ - "action": "listCommands/request", - "metadata": { - "callback": "responseFunctionName" - }, - "payload": null -} -``` - -### Java to JS - -```json -{ - "action": "listCommands/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": { - "commands": [ - { - "name": "code", - "description": "Generate code with a general template embedded into the prompt." - }, - { - "name": "release_note", - "description": "Generate a release note for the given commit log." - } - ] - } -} -``` - -## Query Topic List - -### JS to Java - -```json -{ - "action": "listTopics/request", - "metadata": { - "callback": "responseFunctionName" - }, - "payload": null -} -``` - -### Java to JS - -```json -{ - "action": "listTopics/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": { - "topics": [ - { - "root_prompt": { - "user": "Daniel Hu ", - "date": 1698828624, - "context": [ - { - "content": "{\"languageId\":\"python\",\"path\":\"a.py\",\"startLine\":0,\"content\":\"adkfjj\\n\"}", - "role": "system" - } - ], - "request": "hello", - "responses": [ - "Hi there! How can I assist you with Python today?" - ], - "hash": "596cf7c60a936e33409c71b67ba7f9903886bbeb7c7d2aacf6d1556b0831f04b", - "parent": null - }, - "latest_time": 1698828867, - "title": "hello - Hi there! How can I assist you with Python today?" - } - ] - } -} -``` - -## Query Topic History Conversations - -### JS to Java - -```json -{ - "action": "listConversations/request", - "metadata": { - "topicHash": "xxx", - "callback": "responseFunctionName" - }, - "payload": null -} -``` - -### Java to JS - -```json -{ - "action": "listConversations/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": { - "conversations": [ - { - "user": "Daniel Hu ", - "date": 1686727177, - "context": [ - { - "content": "{\"command\":\"ls -l\",\"content\":\"total 8\\n-rw-r--r--@ 1 danielhu staff 7 Nov 1 16:49 a.py\\n\"}", - "role": "system" - }, - { - "content": "{\"languageId\":\"python\",\"path\":\"a.py\",\"startLine\":0,\"content\":\"adkfjj\\n\"}", - "role": "system" - } - ], - "request": "hello", - "responses": [ - "world" - ], - "hash": "44871db06eaabbbeabaa262d1666481b7ea89ce6a4d30649cf3575fa13bf3c42", - "parent": "596cf7c60a936e33409c71b67ba7f9903886bbeb7c7d2aacf6d1556b0831f04b" - } - ] - } -} -``` - -## Insert Code - -### JS to Java - -```json -{ - "action": "insertCode/request", - "metadata": { - "callback": "responseFunctionName" - }, - "payload": { - "content": "adkfjj\n" - } -} -``` - -### Java to JS - -```json -{ - "action": "insertCode/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": null -} -``` - -## Replace All Content - -### JS to Java - -```json -{ - "action": "replaceFileContent/request", - "metadata": { - "callback": "responseFunctionName" - }, - "payload": { - "content": "adkfjj\n" - } -} -``` - -### Java to JS - -```json -{ - "action": "replaceFileContent/response", - "metadata": { - "status": "success", - "error": "" - }, - "payload": null -} -``` diff --git a/api/model.md b/api/model.md new file mode 100644 index 0000000..ba1a450 --- /dev/null +++ b/api/model.md @@ -0,0 +1,31 @@ +## List models + +### JS to Java + +```json +{ + "action": "listModels/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": null +} +``` + +### Java to JS + +```json +{ + "action": "listModels/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "models": [ + "gpt-3.5-turbo", + "gpt-4" + ] + } +} +``` diff --git a/api/topic.md b/api/topic.md new file mode 100644 index 0000000..c40efee --- /dev/null +++ b/api/topic.md @@ -0,0 +1,100 @@ +## Query Topic List + +### JS to Java + +```json +{ + "action": "listTopics/request", + "metadata": { + "callback": "responseFunctionName" + }, + "payload": null +} +``` + +### Java to JS + +```json +{ + "action": "listTopics/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "topics": [ + { + "root_prompt": { + "user": "Daniel Hu ", + "date": 1698828624, + "context": [ + { + "content": "{\"languageId\":\"python\",\"path\":\"a.py\",\"startLine\":0,\"content\":\"adkfjj\\n\"}", + "role": "system" + } + ], + "request": "hello", + "responses": [ + "Hi there! How can I assist you with Python today?" + ], + "hash": "596cf7c60a936e33409c71b67ba7f9903886bbeb7c7d2aacf6d1556b0831f04b", + "parent": null + }, + "latest_time": 1698828867, + "title": "hello - Hi there! How can I assist you with Python today?" + } + ] + } +} +``` + +## Query Topic History Conversations + +### JS to Java + +```json +{ + "action": "listConversations/request", + "metadata": { + "topicHash": "xxx", + "callback": "responseFunctionName" + }, + "payload": null +} +``` + +### Java to JS + +```json +{ + "action": "listConversations/response", + "metadata": { + "status": "success", + "error": "" + }, + "payload": { + "conversations": [ + { + "user": "Daniel Hu ", + "date": 1686727177, + "context": [ + { + "content": "{\"command\":\"ls -l\",\"content\":\"total 8\\n-rw-r--r--@ 1 danielhu staff 7 Nov 1 16:49 a.py\\n\"}", + "role": "system" + }, + { + "content": "{\"languageId\":\"python\",\"path\":\"a.py\",\"startLine\":0,\"content\":\"adkfjj\\n\"}", + "role": "system" + } + ], + "request": "hello", + "responses": [ + "world" + ], + "hash": "44871db06eaabbbeabaa262d1666481b7ea89ce6a4d30649cf3575fa13bf3c42", + "parent": "596cf7c60a936e33409c71b67ba7f9903886bbeb7c7d2aacf6d1556b0831f04b" + } + ] + } +} +```