feat: unify creation agent chat fill
This commit is contained in:
63
src/services/creation-agent/creationAgentChat.ts
Normal file
63
src/services/creation-agent/creationAgentChat.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
export const CREATION_AGENT_SUMMARY_ACTION_KEY = 'summarize';
|
||||
export const CREATION_AGENT_QUICK_FILL_ACTION_KEY = 'quickFill';
|
||||
|
||||
export const CREATION_AGENT_SUMMARY_ACTION_LABEL = '总结当前设定';
|
||||
export const CREATION_AGENT_QUICK_FILL_ACTION_LABEL = '补充剩余设定';
|
||||
export const CREATION_AGENT_QUICK_FILL_MESSAGE = '请补充剩余设定。';
|
||||
|
||||
type CreationAgentChatQuickAction = {
|
||||
key: string;
|
||||
label: string;
|
||||
minTurn?: number;
|
||||
};
|
||||
|
||||
type CreationAgentChatMessageBase = {
|
||||
clientMessageId: string;
|
||||
text: string;
|
||||
quickFillRequested?: boolean;
|
||||
};
|
||||
|
||||
export function createCreationAgentChatQuickActions(): CreationAgentChatQuickAction[] {
|
||||
return [
|
||||
{
|
||||
key: CREATION_AGENT_SUMMARY_ACTION_KEY,
|
||||
label: CREATION_AGENT_SUMMARY_ACTION_LABEL,
|
||||
},
|
||||
{
|
||||
key: CREATION_AGENT_QUICK_FILL_ACTION_KEY,
|
||||
label: CREATION_AGENT_QUICK_FILL_ACTION_LABEL,
|
||||
minTurn: 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function resolveCreationAgentQuickActionMessage(
|
||||
actionKey: string,
|
||||
summaryMessage: string,
|
||||
) {
|
||||
const quickFillRequested = actionKey === CREATION_AGENT_QUICK_FILL_ACTION_KEY;
|
||||
|
||||
return {
|
||||
text: quickFillRequested ? CREATION_AGENT_QUICK_FILL_MESSAGE : summaryMessage,
|
||||
quickFillRequested,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildCreationAgentChatMessage<TExtraPayload extends object = Record<string, never>>({
|
||||
clientMessageId,
|
||||
text,
|
||||
quickFillRequested = false,
|
||||
extraPayload,
|
||||
}: {
|
||||
clientMessageId: string;
|
||||
text: string;
|
||||
quickFillRequested?: boolean;
|
||||
extraPayload?: TExtraPayload;
|
||||
}): CreationAgentChatMessageBase & TExtraPayload {
|
||||
return {
|
||||
...(extraPayload ?? ({} as TExtraPayload)),
|
||||
clientMessageId,
|
||||
text,
|
||||
quickFillRequested,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user