Skip to content

Commit

Permalink
feat: add kimoi chat
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Feb 17, 2025
1 parent 28762c8 commit 2735ba4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ b站相关API
颜文字抽象转写
## huggingface
huggingface API
## kimoi
AI匹配kimoi词库
## neteasemusic
网易云的一些简单功能
## novelai
Expand Down
32 changes: 32 additions & 0 deletions kimoi/chat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package kimoi

Check failure on line 1 in kimoi/chat.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: should have a package comment (revive)

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 {

Check failure on line 16 in kimoi/chat.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported type Response should have comment or be unexported (revive)
Reply string `json:"reply"`
Confidence float64 `json:"confidence"`
}

func Chat(msg string) (r Response, err error) {

Check failure on line 21 in kimoi/chat.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function Chat should have comment or be unexported (revive)
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
}

0 comments on commit 2735ba4

Please sign in to comment.