feat: Support for Chat Flow & Agent Support for binding a single chat flow (#765)

Co-authored-by: Yu Yang <72337138+tomasyu985@users.noreply.github.com>
Co-authored-by: zengxiaohui <csu.zengxiaohui@gmail.com>
Co-authored-by: lijunwen.gigoo <lijunwen.gigoo@bytedance.com>
Co-authored-by: lvxinyu.1117 <lvxinyu.1117@bytedance.com>
Co-authored-by: liuyunchao.0510 <liuyunchao.0510@bytedance.com>
Co-authored-by: haozhenfei <37089575+haozhenfei@users.noreply.github.com>
Co-authored-by: July <jiangxujin@bytedance.com>
Co-authored-by: tecvan-fe <fanwenjie.fe@bytedance.com>
This commit is contained in:
Zhj
2025-08-28 21:53:32 +08:00
committed by GitHub
parent bbc615a18e
commit d70101c979
503 changed files with 48036 additions and 3427 deletions

View File

@@ -42,7 +42,6 @@ import { MessageManager } from '@/message/message-manager';
import { ChunkProcessor, PreSendLocalMessageFactory } from '@/message';
import { HttpChunk } from '@/channel/http-chunk';
import { type TokenManager } from '../credential';
import {
type ChatASRParams,
type BreakMessageParams,
@@ -70,6 +69,7 @@ import { MessageManagerService } from './services/message-manager-service';
import { HttpChunkService } from './services/http-chunk-service';
import { CreateMessageService } from './services/create-message-service';
import { ReportEventsTracer, SlardarEvents } from './events/slardar-events';
import { type TokenManager } from '../credential';
export default class ChatSDK {
private static instances: Map<string, ChatSDK> = new Map();
@@ -523,4 +523,10 @@ export default class ChatSDK {
}
return this.messageManagerService.chatASR(params);
}
updateConversationId(conversationId: string) {
this.conversation_id = conversationId;
this.messageManagerService.conversation_id = conversationId;
this.preSendLocalMessageFactory.conversation_id = conversationId;
}
}

View File

@@ -137,7 +137,7 @@ export class RequestManager {
// Execute incoming unified hooks
const onCommonAfterResponse = async (
response: AxiosResponse,
hooksName: 'onAfterResponse' | 'onErrrorResponse' = 'onAfterResponse',
hooksName: 'onAfterResponse' | 'onErrorResponse' = 'onAfterResponse',
): Promise<AxiosResponse> => {
// eslint-disable-next-line @typescript-eslint/naming-convention -- temporary variable, quite normal
let _response: AxiosResponse | Promise<AxiosResponse> = response;
@@ -154,7 +154,7 @@ export class RequestManager {
// Execute hooks for each scene
const onSceneAfterResponse = async (
response: AxiosResponse,
hooksName: 'onAfterResponse' | 'onErrrorResponse' = 'onAfterResponse',
hooksName: 'onAfterResponse' | 'onErrorResponse' = 'onAfterResponse',
): Promise<AxiosResponse> => {
const { scenes } = this.mergedBaseOptions;
// eslint-disable-next-line @typescript-eslint/naming-convention -- temporary variable, quite normal
@@ -188,9 +188,9 @@ export class RequestManager {
// eslint-disable-next-line @typescript-eslint/naming-convention -- temporary variable, quite normal
const _response = await onCommonAfterResponse(
response,
'onErrrorResponse',
'onErrorResponse',
);
return await onSceneAfterResponse(_response, 'onErrrorResponse');
return await onSceneAfterResponse(_response, 'onErrorResponse');
},
);
}

View File

@@ -66,7 +66,7 @@ interface Hooks {
onGetMessageStreamParser?: (
requestMessageRawBody: Record<string, unknown>,
) => FetchSteamConfig<ParsedEvent>['streamParser'];
onErrrorResponse?: Array<(response: AxiosResponse) => Promise<AxiosResponse>>;
onErrorResponse?: Array<(response: AxiosResponse) => Promise<AxiosResponse>>;
}
export enum RequestScene {