Skip to content

Commit 2735ba4

Browse files
committed
feat: add kimoi chat
1 parent 28762c8 commit 2735ba4

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ b站相关API
1010
颜文字抽象转写
1111
## huggingface
1212
huggingface API
13+
## kimoi
14+
AI匹配kimoi词库
1315
## neteasemusic
1416
网易云的一些简单功能
1517
## novelai

kimoi/chat.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package kimoi
2+
3+
import (
4+
"bytes"
5+
"encoding/base64"
6+
"encoding/json"
7+
"net/http"
8+
9+
base14 "github.com/fumiama/go-base16384"
10+
)
11+
12+
const key = "暻撈莬穔僿貶稙棯悟澸滰蓱咜唕母屬石褤汴儱榅璕婴㴅"
13+
14+
const api = "https://ninex.azurewebsites.net/api/chat?code="
15+
16+
type Response struct {
17+
Reply string `json:"reply"`
18+
Confidence float64 `json:"confidence"`
19+
}
20+
21+
func Chat(msg string) (r Response, err error) {
22+
resp, err := http.Post(
23+
api+base64.URLEncoding.EncodeToString(base14.DecodeFromString(key)),
24+
"text/plain", bytes.NewBufferString(msg),
25+
)
26+
if err != nil {
27+
return
28+
}
29+
defer resp.Body.Close()
30+
err = json.NewDecoder(resp.Body).Decode(&r)
31+
return
32+
}

0 commit comments

Comments
 (0)