feat: 支持上传图片到钉钉平台,在图片生成流程中使用钉钉的图片 CDN 能力 (#225)

This commit is contained in:
金喜@DingTalk
2023-05-22 21:17:40 +08:00
committed by GitHub
parent dfda88d32d
commit 2eda9e8e22
13 changed files with 434 additions and 8 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
package process
import (
"context"
"fmt"
"github.com/eryajf/chatgpt-dingtalk/public"
"strings"
@@ -12,7 +13,7 @@ import (
)
// ImageGenerate openai生成图片
func ImageGenerate(rmsg *dingbot.ReceiveMsg) error {
func ImageGenerate(ctx context.Context, rmsg *dingbot.ReceiveMsg) error {
if public.Config.AzureOn {
_, err := rmsg.ReplyToDingtalk(string(dingbot.
MARKDOWN), "azure 模式下暂不支持图片创作功能")
@@ -32,7 +33,7 @@ func ImageGenerate(rmsg *dingbot.ReceiveMsg) error {
if err != nil {
logger.Error("往MySQL新增数据失败,错误信息:", err)
}
reply, err := chatgpt.ImageQa(rmsg.Text.Content, rmsg.GetSenderIdentifier())
reply, err := chatgpt.ImageQa(ctx, rmsg.Text.Content, rmsg.GetSenderIdentifier())
if err != nil {
logger.Info(fmt.Errorf("gpt request error: %v", err))
_, err = rmsg.ReplyToDingtalk(string(dingbot.TEXT), fmt.Sprintf("请求openai失败了,错误信息:%v", err))