Skip to content

Commit

Permalink
Docs: update api documents
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hu <[email protected]>
  • Loading branch information
daniel-hutao committed Nov 14, 2023
1 parent 5c4f631 commit fd01f19
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 378 deletions.
109 changes: 109 additions & 0 deletions api/chat.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"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 <[email protected]>",
"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 <[email protected]>",
"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
}
```
73 changes: 73 additions & 0 deletions api/code-action.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
```
37 changes: 37 additions & 0 deletions api/command.md
Original file line number Diff line number Diff line change
@@ -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."
}
]
}
}
```
86 changes: 86 additions & 0 deletions api/context.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
```
43 changes: 43 additions & 0 deletions api/key.md
Original file line number Diff line number Diff line change
@@ -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
}
```
Loading

0 comments on commit fd01f19

Please sign in to comment.