Skip to content

Commit

Permalink
Optimizing the AI command with parameter domain setting to tidbcloud (
Browse files Browse the repository at this point in the history
#125)

## What is the purpose of the change

Setting the AI bot's domain restriction to `tidbcloud` for more precise responses.

## Brief change log

- update swagger json.
- set param domain to `tidbcloud`
  • Loading branch information
xuanyu66 authored Dec 14, 2023
1 parent 8b0826a commit 3b69b14
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
5 changes: 4 additions & 1 deletion internal/cli/ai/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const (
)

var (
re = regexp.MustCompile(regexPattern)
re = regexp.MustCompile(regexPattern)
domain = []string{"tidbcloud"}
)

type AIOpts struct {
Expand Down Expand Up @@ -112,6 +113,7 @@ func AICmd(h *internal.Helper) *cobra.Command {
}
chat, err := client.Chat(param.WithChatInfo(&models.PingchatChatInfo{
Messages: msgs,
Domain: domain,
}))

if err != nil {
Expand Down Expand Up @@ -165,6 +167,7 @@ func AICmd(h *internal.Helper) *cobra.Command {
Role: &role,
},
},
Domain: domain,
}))

if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions pkg/tidbcloud/pingchat/models/pingchat_chat_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/tidbcloud/pingchat/models/pingchat_chat_message.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 32 additions & 3 deletions pkg/tidbcloud/pingchat/pingchat_swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"paths": {
"/ecosystem/api/internal/pingchat/chat": {
"post": {
"description": "Chat with PingChat",
"produces": [
"application/json"
],
Expand All @@ -37,15 +38,21 @@
},
"400": {
"description": "error",
"schema": {}
"schema": {
"type": "object"
}
},
"500": {
"description": "error",
"schema": {}
"schema": {
"type": "object"
}
},
"default": {
"description": "other error",
"schema": {}
"schema": {
"type": "object"
}
}
}
}
Expand All @@ -54,8 +61,27 @@
"definitions": {
"pingchat.ChatInfo": {
"type": "object",
"required": [
"messages"
],
"properties": {
"domain": {
"type": "array",
"items": {
"type": "string",
"enum": [
"tidb",
"tidbcloud",
"asktug",
"blog",
"community",
"knowledge-base-cn",
"kb"
]
}
},
"messages": {
"description": "https://pkg.go.dev/gopkg.in/bluesuncorp/validator.v9#hdr-Dive",
"type": "array",
"items": {
"$ref": "#/definitions/pingchat.ChatMessage"
Expand All @@ -71,9 +97,11 @@
],
"properties": {
"content": {
"description": "Dialogue content",
"type": "string"
},
"role": {
"description": "User's input as \"user\", AI assistant's reply as \"assistant\", see https://github.com/gin-gonic/gin/issues/3234.",
"type": "string",
"enum": [
"user",
Expand All @@ -89,6 +117,7 @@
"type": "string"
},
"links": {
"description": "Reference Document Links",
"type": "array",
"items": {
"$ref": "#/definitions/pingchat.Link"
Expand Down

0 comments on commit 3b69b14

Please sign in to comment.