mirror of
https://github.com/silenceper/wechat.git
synced 2026-11-16 05:12:03 +08:00
feat: add aispeech dialog APIs (#887)
* feat: add aispeech dialog APIs * test: fix aispeech lint failures * test: satisfy aispeech interfacer lint
This commit is contained in:
1 parent
0e34286d78
commit
2bc22dc4ae
18 files changed
+1562
-3
No files matched your search
@@ -0,0 +1,23 @@
|
||||
package config
|
||||
|
||||
import "github.com/silenceper/wechat/v2/cache"
|
||||
|
||||
const defaultBaseURL = "https://openaiapi.weixin.qq.com"
|
||||
|
||||
// Config for 微信智能对话.
|
||||
type Config struct {
|
||||
AppID string `json:"app_id"`
|
||||
Token string `json:"token"`
|
||||
AESKey string `json:"aes_key"`
|
||||
Account string `json:"account"`
|
||||
BaseURL string `json:"base_url"`
|
||||
Cache cache.Cache
|
||||
}
|
||||
|
||||
// GetBaseURL returns the API base URL.
|
||||
func (cfg *Config) GetBaseURL() string {
|
||||
if cfg.BaseURL == "" {
|
||||
return defaultBaseURL
|
||||
}
|
||||
return cfg.BaseURL
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetBaseURL(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
if cfg.GetBaseURL() != defaultBaseURL {
|
||||
t.Fatalf("bad default base url: %s", cfg.GetBaseURL())
|
||||
}
|
||||
|
||||
cfg.BaseURL = "http://example.com"
|
||||
if cfg.GetBaseURL() != "http://example.com" {
|
||||
t.Fatalf("bad custom base url: %s", cfg.GetBaseURL())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user