feat: add midjouney api implements, optimize function calls

This commit is contained in:
RockYang
2023-08-11 18:46:56 +08:00
parent b0e02b43fc
commit 2165ba3406
17 changed files with 298 additions and 183 deletions

View File

@@ -24,7 +24,7 @@ func NewWeiboHot(config types.ChatPlusApiConfig) FuncWeiboHot {
client: req.C().SetTimeout(10 * time.Second)}
}
func (f FuncWeiboHot) Invoke(...interface{}) (string, error) {
func (f FuncWeiboHot) Invoke(map[string]interface{}) (string, error) {
if f.config.Token == "" {
return "", errors.New("无效的 API Token")
}
@@ -35,11 +35,8 @@ func (f FuncWeiboHot) Invoke(...interface{}) (string, error) {
SetHeader("AppId", f.config.AppId).
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
SetSuccessResult(&res).Get(url)
if err != nil {
return "", err
}
if r.IsErrorState() {
return "", r.Err
if err != nil || r.IsErrorState() {
return "", fmt.Errorf("%v%v", err, r.Err)
}
if res.Code != types.Success {
@@ -57,3 +54,5 @@ func (f FuncWeiboHot) Invoke(...interface{}) (string, error) {
func (f FuncWeiboHot) Name() string {
return f.name
}
var _ Function = &FuncWeiboHot{}