Skip to content

Commit 5e28c03

Browse files
awesomeYGdhsifssawesomeYGxbingW
authored
Feat/v2.33.0 (#215)
* feat: wecom service * feat: enable WeCom customer service configuration and integrate related UI components. * fix: wecom service * fix: prompt image * feat: log * feat: rag * fix: decode URL question parameter when retrieving from search params in customer service content. * fix: wecom service source --------- Co-authored-by: 姚凯 <kai.yao@chaitin.com> Co-authored-by: awesomeYG <gang.yang@chaitin.com> Co-authored-by: xiaobing.wang <xiaobing.wang@chaitin.com>
1 parent 03ebde9 commit 5e28c03

27 files changed

Lines changed: 597 additions & 286 deletions

File tree

.github/workflows/build-base-img.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: raglite
4545
dockerfile: docker/raglite/Dockerfile
4646
context: docker/raglite
47-
tag: "v2.13.0"
47+
tag: "v2.14.0"
4848

4949
steps:
5050
- name: Checkout code

backend/assets/assets.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ var (
1010

1111
//go:embed blog
1212
Blog embed.FS
13+
14+
//go:embed wecom_service.png
15+
WecomService []byte
1316
)

backend/assets/wecom_service.png

158 KB
Loading

backend/docs/docs.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8172,12 +8172,14 @@ const docTemplate = `{
81728172
"enum": [
81738173
0,
81748174
1,
8175-
2
8175+
2,
8176+
3
81768177
],
81778178
"x-enum-varnames": [
81788179
"AskSessionSourceWeb",
81798180
"AskSessionSourcePlugin",
8180-
"AskSessionSourceBot"
8181+
"AskSessionSourceBot",
8182+
"AskSessionSourceWecomService"
81818183
]
81828184
},
81838185
"model.AskSessionSummaryDisc": {
@@ -10406,7 +10408,8 @@ const docTemplate = `{
1040610408
"source": {
1040710409
"enum": [
1040810410
0,
10409-
1
10411+
1,
10412+
3
1041010413
],
1041110414
"allOf": [
1041210415
{
@@ -11481,7 +11484,8 @@ const docTemplate = `{
1148111484
"source": {
1148211485
"enum": [
1148311486
0,
11484-
1
11487+
1,
11488+
3
1148511489
],
1148611490
"allOf": [
1148711491
{

backend/docs/swagger.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8165,12 +8165,14 @@
81658165
"enum": [
81668166
0,
81678167
1,
8168-
2
8168+
2,
8169+
3
81698170
],
81708171
"x-enum-varnames": [
81718172
"AskSessionSourceWeb",
81728173
"AskSessionSourcePlugin",
8173-
"AskSessionSourceBot"
8174+
"AskSessionSourceBot",
8175+
"AskSessionSourceWecomService"
81748176
]
81758177
},
81768178
"model.AskSessionSummaryDisc": {
@@ -10399,7 +10401,8 @@
1039910401
"source": {
1040010402
"enum": [
1040110403
0,
10402-
1
10404+
1,
10405+
3
1040310406
],
1040410407
"allOf": [
1040510408
{
@@ -11474,7 +11477,8 @@
1147411477
"source": {
1147511478
"enum": [
1147611479
0,
11477-
1
11480+
1,
11481+
3
1147811482
],
1147911483
"allOf": [
1148011484
{

backend/docs/swagger.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ definitions:
101101
- 0
102102
- 1
103103
- 2
104+
- 3
104105
type: integer
105106
x-enum-varnames:
106107
- AskSessionSourceWeb
107108
- AskSessionSourcePlugin
108109
- AskSessionSourceBot
110+
- AskSessionSourceWecomService
109111
model.AskSessionSummaryDisc:
110112
properties:
111113
forum_id:
@@ -1651,6 +1653,7 @@ definitions:
16511653
enum:
16521654
- 0
16531655
- 1
1656+
- 3
16541657
required:
16551658
- question
16561659
- session_id
@@ -2357,6 +2360,7 @@ definitions:
23572360
enum:
23582361
- 0
23592362
- 1
2363+
- 3
23602364
required:
23612365
- forum_id
23622366
- session_id

backend/model/ask_history.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const (
1212
AskSessionSourceWeb AskSessionSource = iota
1313
AskSessionSourcePlugin
1414
AskSessionSourceBot
15+
AskSessionSourceWecomService
1516
)
1617

1718
type AskSession struct {

backend/model/system.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package model
22

33
import (
4+
"context"
5+
46
"github.com/chaitin/koalaqa/pkg/util"
57
)
68

@@ -143,3 +145,5 @@ type SystemChatConfig struct {
143145
Token string `json:"client_token"`
144146
AESKey string `json:"aes_key"`
145147
}
148+
149+
type EnabledCallback func(context.Context) (bool, error)

backend/pkg/chat/chat.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414

1515
var sf singleflight.Group
1616

17-
type accessToken struct {
17+
type token struct {
1818
token string
1919
expireAt time.Time
2020
}
2121

22-
func (d *accessToken) expired() bool {
22+
func (d *token) expired() bool {
2323
return d.token == "" || time.Now().After(d.expireAt.Add(-time.Minute*5))
2424
}
2525

@@ -122,7 +122,7 @@ type Bot interface {
122122
}
123123

124124
func New(typ Type, cfg model.SystemChatConfig, callback BotCallback,
125-
accessAddrCallback model.AccessAddrCallback, stateManager *StateManager) (Bot, error) {
125+
accessAddrCallback model.AccessAddrCallback, enabledCallback model.EnabledCallback) (Bot, error) {
126126
switch typ {
127127
case TypeDingtalk:
128128
return newDingtalk(cfg, callback)
@@ -131,7 +131,7 @@ func New(typ Type, cfg model.SystemChatConfig, callback BotCallback,
131131
case TypeWecomIntelligent:
132132
return newWecomIntelligent(cfg, callback)
133133
case TypeWecomService:
134-
return newWecomService(cfg, callback, accessAddrCallback, stateManager)
134+
return newWecomService(cfg, callback, accessAddrCallback, enabledCallback)
135135
default:
136136
return nil, errors.ErrUnsupported
137137
}

backend/pkg/chat/dingtalk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type dingtalk struct {
2828
streamCli *client.StreamClient
2929
oauthCli *dingtalkoauth2_1_0.Client
3030
cardCli *dingtalkcard_1_0.Client
31-
tokenCache accessToken
31+
tokenCache token
3232
}
3333

3434
func (d *dingtalk) accessToken() (string, error) {
@@ -52,7 +52,7 @@ func (d *dingtalk) accessToken() (string, error) {
5252
return nil, fmt.Errorf("get access_token status code: %d", *resp.StatusCode)
5353
}
5454

55-
d.tokenCache = accessToken{
55+
d.tokenCache = token{
5656
token: *resp.Body.AccessToken,
5757
expireAt: time.Now().Add(time.Duration(*resp.Body.ExpireIn) * time.Second),
5858
}

0 commit comments

Comments
 (0)