Optimize the project structure and introduce DDD design (#394)

This commit is contained in:
Archer
2023-10-12 17:46:37 +08:00
committed by GitHub
parent 76ac5238b6
commit ad7a17bf40
193 changed files with 1169 additions and 1084 deletions

View File

@@ -7,6 +7,7 @@ export type AnswerProps = ModuleDispatchProps<{
}>;
export type AnswerResponse = {
finish: boolean;
[TaskResponseKeyEnum.answerText]: string;
};
export const dispatchAnswer = (props: Record<string, any>): AnswerResponse => {
@@ -17,17 +18,20 @@ export const dispatchAnswer = (props: Record<string, any>): AnswerResponse => {
inputs: { text = '' }
} = props as AnswerProps;
const formatText = typeof text === 'string' ? text : JSON.stringify(text, null, 2);
if (stream) {
sseResponse({
res,
event: detail ? sseResponseEventEnum.answer : undefined,
data: textAdaptGptResponse({
text
text: formatText
})
});
}
return {
finish: true
finish: true,
[TaskResponseKeyEnum.answerText]: formatText
};
};