Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用智能体中包含插件功能,提示超时 #25

Open
jiangwu10057 opened this issue Mar 17, 2025 · 0 comments
Open

调用智能体中包含插件功能,提示超时 #25

jiangwu10057 opened this issue Mar 17, 2025 · 0 comments

Comments

@jiangwu10057
Copy link

req := &coze.CreateChatsReq{
		BotID:  botID,
		UserID: userID,
		Messages: []*coze.Message{
			coze.BuildUserQuestionObjects([]*coze.MessageObjectString{
				coze.NewTextMessageObject(questionText),
				coze.NewFileMessageObjectByID(fileID),
			}, nil),
		},
	}

	ctx := context.Background()
	stream := cozeCli.Chat.Stream(ctx, req)
for {
		event, err := stream.Recv()
		if err != nil {
			if errors.Is(err, io.EOF) {
				fmt.Println("Stream finished")
				return resp, nil
			}
			fmt.Println("Error:")
			fmt.Println(err)
			return resp, err
		}

		if event.Event == coze.ChatEventConversationMessageDelta {
			fmt.Println(event.Message.Content)
			resp += event.Message.Content
		} else if event.Event == coze.ChatEventConversationChatCompleted {
			fmt.Printf("Token usage:%d\n", event.Chat.Usage.TokenCount)
		} else if event.Event == coze.ChatEventConversationMessageCompleted {
			fmt.Printf("ChatEventConversationMessageCompleted")
			fmt.Println(event.Message.Content)
		} else {
			fmt.Println(event)
		}
	}

错误发生前返回信息:
ChatEventConversationMessageCompleted{"name":"tupianlijie-imgUnderstand","arguments":{"text":"理解图片并按图片要求生成文案","url":"https://lf9-bot-platform-tos-sign.coze.cn/bot-studio-bot-platform/bot_files/886654292464611/image/jpeg/7482793159198818341/14d7f2d6fa743e5a636313c50030d6d0_20250317230230.jpg?lk3s=50ccb0c5&x-expires=1742831993&x-signature=dlG9%2BjZhDUc%2BIvmKt29qwZJyXA4%3D"},"plugin_id":7379227414322217010,"plugin_name":"tupianlijie","api_id":7407644410588151819,"api_name":"imgUnderstand","plugin_type":1,"plugin":"图片理解"}

错误信息
Error:
net/http: request canceled (Client.Timeout or context cancellation while reading body)
{"level":"error","time":"2025-03-18T00:00:23.31054+08:00","msg":"net/http: request canceled (Client.Timeout or context cancellation while reading body)","serviceName":"error"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant