为什么流式对话调用client.chat.cancel(),无法中断请求?

for await (const part of v) { console.log(part); if (part.event === ChatEventType.CONVERSATION_CHAT_CREATED) { // opt.chatCreated && opt.chatCreated(part.data); const res = await (part.data.conversation_id, part.data.id) console.log('client.chat.cancel', res);

	} else if (part.event === ChatEventType.CONVERSATION_MESSAGE_DELTA) {
		opt.callback && opt.callback(part.data.content);
	} else if (part.event === ChatEventType.CONVERSATION_MESSAGE_COMPLETED) {
		const {
			role,
			type,
			content
		} = part.data;
		if (role === 'assistant' && type === 'answer') {
			opt.callback && opt.callback('\n');
		} else if (role === 'assistant' && type === 'follow_up') {
			opt.followUpCallback && opt.followUpCallback(content)
		}
	} else if (part.event === ChatEventType.CONVERSATION_CHAT_COMPLETED) {

		console.log(part.data.usage);
	} else if (part.event === ChatEventType.DONE) {
		console.log(part.data);
		opt.done && opt.done();
	} else if (part.event === ChatEventType.ERROR) {
		opt.error && opt.error();
	}
}
49
0
0
avatar

您好,这是什么产品?

0
0评论
0
关于作者

文章

0

获赞

0

收藏

0