mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
ChatFragments: VoidPlaceholder with alternative presentations - improve a single model op to a list of ops
This commit is contained in:
@@ -255,17 +255,34 @@ export type DVoidModelAuxPart = {
|
||||
redactedData?: readonly string[],
|
||||
};
|
||||
|
||||
|
||||
export type DVoidPlaceholderPart = {
|
||||
pt: 'ph',
|
||||
pText: string,
|
||||
pType?: 'chat-gen-follow-up', // a follow-up is being generated
|
||||
modelOp?: DVoidPlaceholderModelOp,
|
||||
aixControl?: DVoidPlaceholderAixControlRetry,
|
||||
|
||||
// render type
|
||||
pType?:
|
||||
| 'chat-gen-follow-up', // a follow-up is being generated
|
||||
|
||||
// operation history for stacked progress UI
|
||||
opLog?: readonly DVoidPlaceholderMOp[],
|
||||
|
||||
// NOTE: the following should be extracted as its own part over time
|
||||
aixControl?:
|
||||
| { ctl: 'ac-info', ait: 'flow-cont' }
|
||||
| DVoidPlaceholderAixControlRetry,
|
||||
};
|
||||
|
||||
export type DVoidPlaceholderModelOp = {
|
||||
mot: 'search-web' | 'gen-image' | 'code-exec' | 'flow-cont',
|
||||
cts: number, // client-based timestamp
|
||||
export type DVoidPlaceholderMOp = {
|
||||
readonly opId: string, // upstream operation ID (srvtoolu_*, item_id, etc.)
|
||||
readonly mot: 'search-web' | 'gen-image' | 'code-exec',
|
||||
text: string, // latest status text
|
||||
state: 'active' | 'done' | 'error', // lifecycle state
|
||||
iTexts?: readonly string[], // decorative input context (e.g., search queries, code snippets, gen image prompt)
|
||||
oTexts?: readonly string[], // decorative output context (e.g., result urls, code exec outputs, file IDs, error details)
|
||||
readonly parentOpId?: string, // parent operation ID for nesting (e.g., code_execution that triggered this web_search)
|
||||
readonly level: number, // nesting depth (0 = root, inferred from parentOpId)
|
||||
readonly cts: number, // client timestamp (first seen)
|
||||
};
|
||||
|
||||
type DVoidPlaceholderAixControlRetry = {
|
||||
@@ -277,6 +294,7 @@ type DVoidPlaceholderAixControlRetry = {
|
||||
rCauseConn?: string, // connection error type if available (e.g., 'net-disconnected', 'timeout')
|
||||
};
|
||||
|
||||
|
||||
type _SentinelPart = { pt: '_pt_sentinel' };
|
||||
|
||||
|
||||
@@ -456,8 +474,8 @@ export function createModelAuxVoidFragment(aType: DVoidModelAuxPart['aType'], aT
|
||||
return _createVoidFragment(_create_ModelAux_Part(aType, aText, textSignature, redactedData));
|
||||
}
|
||||
|
||||
export function createPlaceholderVoidFragment(placeholderText: string, placeholderType?: DVoidPlaceholderPart['pType'], modelOp?: DVoidPlaceholderModelOp, aixControl?: DVoidPlaceholderPart['aixControl']): DMessageVoidFragment {
|
||||
return _createVoidFragment(_create_Placeholder_Part(placeholderText, placeholderType, modelOp, aixControl));
|
||||
export function createPlaceholderVoidFragment(placeholderText: string, placeholderType?: DVoidPlaceholderPart['pType'], aixControl?: DVoidPlaceholderPart['aixControl'], opLog?: readonly DVoidPlaceholderMOp[]): DMessageVoidFragment {
|
||||
return _createVoidFragment(_create_Placeholder_Part(placeholderText, placeholderType, aixControl, opLog));
|
||||
}
|
||||
|
||||
function _createVoidFragment(part: DMessageVoidFragment['part']): DMessageVoidFragment {
|
||||
@@ -588,8 +606,8 @@ function _create_ModelAux_Part(aType: DVoidModelAuxPart['aType'], aText: string,
|
||||
};
|
||||
}
|
||||
|
||||
function _create_Placeholder_Part(placeholderText: string, pType?: DVoidPlaceholderPart['pType'], modelOp?: DVoidPlaceholderModelOp, aixControl?: DVoidPlaceholderPart['aixControl']): DVoidPlaceholderPart {
|
||||
return { pt: 'ph', pText: placeholderText, ...(pType ? { pType } : undefined), ...(modelOp ? { modelOp: { ...modelOp } } : undefined), ...(aixControl ? { aixControl: { ...aixControl } } : undefined) };
|
||||
function _create_Placeholder_Part(placeholderText: string, pType?: DVoidPlaceholderPart['pType'], aixControl?: DVoidPlaceholderPart['aixControl'], opLog?: readonly DVoidPlaceholderMOp[]): DVoidPlaceholderPart {
|
||||
return { pt: 'ph', pText: placeholderText, ...(pType ? { pType } : undefined), ...(opLog ? { opLog: opLog.map(e => ({ ...e })) } : undefined), ...(aixControl ? { aixControl: { ...aixControl } } : undefined) };
|
||||
}
|
||||
|
||||
function _create_Sentinel_Part(): _SentinelPart {
|
||||
@@ -644,7 +662,7 @@ function _duplicate_Part<TPart extends (DMessageContentFragment | DMessageAttach
|
||||
return _create_ModelAux_Part(part.aType, part.aText, part.textSignature, part.redactedData) as TPart;
|
||||
|
||||
case 'ph':
|
||||
return _create_Placeholder_Part(part.pText, part.pType, part.modelOp, part.aixControl) as TPart;
|
||||
return _create_Placeholder_Part(part.pText, part.pType, part.aixControl, part.opLog) as TPart;
|
||||
|
||||
case 'text':
|
||||
return _create_Text_Part(part.text) as TPart;
|
||||
|
||||
Reference in New Issue
Block a user