From 2735ba4ec22f46ae2b6258d16d2d1f0de16c9ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 17 Feb 2025 22:58:11 +0900 Subject: [PATCH] feat: add kimoi chat --- README.md | 2 ++ kimoi/chat.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 kimoi/chat.go diff --git a/README.md b/README.md index 81905a9..347a3a9 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ b站相关API 颜文字抽象转写 ## huggingface huggingface API +## kimoi +AI匹配kimoi词库 ## neteasemusic 网易云的一些简单功能 ## novelai diff --git a/kimoi/chat.go b/kimoi/chat.go new file mode 100644 index 0000000..08db1e0 --- /dev/null +++ b/kimoi/chat.go @@ -0,0 +1,32 @@ +package kimoi + +import ( + "bytes" + "encoding/base64" + "encoding/json" + "net/http" + + base14 "github.com/fumiama/go-base16384" +) + +const key = "暻撈莬穔僿貶稙棯悟澸滰蓱咜唕母屬石褤汴儱榅璕婴㴅" + +const api = "https://ninex.azurewebsites.net/api/chat?code=" + +type Response struct { + Reply string `json:"reply"` + Confidence float64 `json:"confidence"` +} + +func Chat(msg string) (r Response, err error) { + resp, err := http.Post( + api+base64.URLEncoding.EncodeToString(base14.DecodeFromString(key)), + "text/plain", bytes.NewBufferString(msg), + ) + if err != nil { + return + } + defer resp.Body.Close() + err = json.NewDecoder(resp.Body).Decode(&r) + return +}