fix: coze api流程调整
parent
f6bf09e2f7
commit
e1acc4973a
|
|
@ -14,7 +14,7 @@ import {
|
|||
useState,
|
||||
} from "react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { FileParser, FileParseStatus } from "./FileParser";
|
||||
import { FileParser, FileParseStatus } from "./fileParser";
|
||||
|
||||
type RoomInfo = {
|
||||
appId: string;
|
||||
|
|
@ -216,7 +216,7 @@ export const RealtimeClientProvider = ({ children }: { children: ReactNode }) =>
|
|||
client: RealtimeClient,
|
||||
{ initMessage, fileInfo }: { initMessage?: string; fileInfo?: FileInfo }
|
||||
) => {
|
||||
client.on(EventNames.ALL_SERVER, async (eventName, event: any) => {
|
||||
client.on(EventNames.ALL_SERVER, async (eventName, _event: any) => {
|
||||
if (eventName === "server.session.created") {
|
||||
await client.sendMessage({
|
||||
id: "",
|
||||
|
|
@ -302,9 +302,6 @@ export const RealtimeClientProvider = ({ children }: { children: ReactNode }) =>
|
|||
const content = event.data.content;
|
||||
setMessageList(prev => {
|
||||
// 合并增量
|
||||
console.log("合并增量",prev);
|
||||
console.log("信息",content);
|
||||
|
||||
// 处理工具回调结果
|
||||
try {
|
||||
const parsedContent = JSON.parse(content);
|
||||
|
|
@ -398,7 +395,7 @@ export const RealtimeClientProvider = ({ children }: { children: ReactNode }) =>
|
|||
setIsConnecting(false);
|
||||
setIsConnected(true);
|
||||
});
|
||||
client.on(EventNames.ALL_SERVER, (name, evt) => {
|
||||
client.on(EventNames.ALL_SERVER, (_name, _evt) => {
|
||||
// 其它全局服务端事件可在此处理
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class WaitingState implements IFileParseState {
|
|||
status: FileParseStatus = 0;
|
||||
constructor(private ctx: FileParser) {}
|
||||
|
||||
handleEvent(eventType: string, event: any) {
|
||||
handleEvent(_eventType: string, event: any) {
|
||||
if (
|
||||
event.event_type === ChatEventType.CONVERSATION_MESSAGE_DELTA &&
|
||||
event.data.type === "function_call" &&
|
||||
|
|
@ -71,12 +71,12 @@ class ParsingState implements IFileParseState {
|
|||
status: FileParseStatus = 1;
|
||||
constructor(private ctx: FileParser) {}
|
||||
|
||||
handleEvent(eventType: string, event: any) {
|
||||
handleEvent(_eventType: string, event: any) {
|
||||
if (
|
||||
event.event_type === ChatEventType.CONVERSATION_MESSAGE_COMPLETED &&
|
||||
event.data.type === "tool_response"
|
||||
) {
|
||||
this.ctx.transitionTo(new CompletedState(this.ctx));
|
||||
this.ctx.transitionTo(new CompletedState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,9 +84,9 @@ class ParsingState implements IFileParseState {
|
|||
/** 解析完成:2 */
|
||||
class CompletedState implements IFileParseState {
|
||||
status: FileParseStatus = 2;
|
||||
constructor(private ctx: FileParser) {}
|
||||
constructor() {}
|
||||
|
||||
handleEvent(eventType: string, event: any) {
|
||||
handleEvent(_eventType: string, _event: any) {
|
||||
// 如需重置或其他后续逻辑,可在此处理
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue