forked from 77media/video-flow
update transformMessage
This commit is contained in:
parent
1af5fda76a
commit
3c57131443
@ -208,7 +208,7 @@ function transformSystemMessage(
|
|||||||
*/
|
*/
|
||||||
function transformMessage(apiMessage: RealApiMessage): ChatMessage {
|
function transformMessage(apiMessage: RealApiMessage): ChatMessage {
|
||||||
try {
|
try {
|
||||||
const { id, role, content, created_at, function_name, custom_data, status, intent_type, error_message } = apiMessage;
|
const { id, role, content, created_at, function_name, custom_data, status, intent_type } = apiMessage;
|
||||||
let message: ChatMessage = {
|
let message: ChatMessage = {
|
||||||
id: id ? id.toString() : Date.now().toString(),
|
id: id ? id.toString() : Date.now().toString(),
|
||||||
role: role,
|
role: role,
|
||||||
@ -218,7 +218,8 @@ function transformMessage(apiMessage: RealApiMessage): ChatMessage {
|
|||||||
status: status || 'success',
|
status: status || 'success',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (error_message && error_message === 'no enough credits') {
|
const errorMessage = custom_data?.error_message;
|
||||||
|
if (errorMessage && errorMessage === 'no enough credits') {
|
||||||
message.blocks = NoEnoughCreditsMessageBlocks;
|
message.blocks = NoEnoughCreditsMessageBlocks;
|
||||||
} else {
|
} else {
|
||||||
if (role === 'assistant' || role === 'user') {
|
if (role === 'assistant' || role === 'user') {
|
||||||
|
|||||||
@ -131,14 +131,19 @@ export interface ApiMessageContent {
|
|||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BaseCustomData {
|
||||||
|
error_message?: string;
|
||||||
|
rejected_reason?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RealApiMessage {
|
export interface RealApiMessage {
|
||||||
created_at: string;
|
created_at: string;
|
||||||
id: number;
|
id: number;
|
||||||
role: Role;
|
role: Role;
|
||||||
content: string;
|
content: string;
|
||||||
function_name?: FunctionName;
|
function_name?: FunctionName;
|
||||||
custom_data?: ProjectInit | ScriptSummary | CharacterGeneration | SketchGeneration | ShotSketchGeneration | ShotVideoGeneration;
|
custom_data?: (ProjectInit | ScriptSummary | CharacterGeneration | SketchGeneration | ShotSketchGeneration | ShotVideoGeneration) & BaseCustomData;
|
||||||
status: MessageStatus;
|
status: MessageStatus;
|
||||||
intent_type: IntentType;
|
intent_type: IntentType;
|
||||||
error_message?: string;
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user