-
Notifications
You must be signed in to change notification settings - Fork 165
/
client.go
33 lines (26 loc) · 933 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package semantic
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
)
type Client struct {
BaseClient *kernel.BaseClient
}
// 语义接口
// https://developers.weixin.qq.com/doc/offiaccount/Intelligent_Interface/Natural_Language_Processing.html
func (comp *Client) Query(ctx context.Context, keyword string, categories string, optional *power.HashMap) (interface{}, error) {
config := (*comp.BaseClient.App).GetConfig()
params := &object.HashMap{
"query": keyword,
"category": categories,
"appid": config.GetString("app_id", ""),
}
objOptional, err := power.PowerHashMapToObjectHashMap(optional)
if err != nil {
return nil, err
}
params = object.MergeHashMap(params, objOptional)
return comp.BaseClient.HttpPostJson(ctx, "semantic/semproxy/search", params, nil, nil, nil)
}