mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Fragments: support placeholders with purpose
This commit is contained in:
@@ -153,7 +153,7 @@ type DMessageToolEnvironment = 'upstream' | 'server' | 'client';
|
||||
|
||||
type DVoidModelAuxPart = { pt: 'ma', aType: 'reasoning' | string, aText: string };
|
||||
|
||||
type DVoidPlaceholderPart = { pt: 'ph', pText: string };
|
||||
type DVoidPlaceholderPart = { pt: 'ph', pText: string, pType?: 'chat-gen-follow-up', /* 2025-02-23: added for non-pure-text placeholders */ };
|
||||
|
||||
type _SentinelPart = { pt: '_pt_sentinel' };
|
||||
|
||||
@@ -292,8 +292,8 @@ export function createModelAuxVoidFragment(aType: DVoidModelAuxPart['aType'], aT
|
||||
return _createVoidFragment(_create_ModelAux_Part(aType, aText));
|
||||
}
|
||||
|
||||
export function createPlaceholderVoidFragment(placeholderText: string): DMessageVoidFragment {
|
||||
return _createVoidFragment(_create_Placeholder_Part(placeholderText));
|
||||
export function createPlaceholderVoidFragment(placeholderText: string, placeholderType?: DVoidPlaceholderPart['pType']): DMessageVoidFragment {
|
||||
return _createVoidFragment(_create_Placeholder_Part(placeholderText, placeholderType));
|
||||
}
|
||||
|
||||
function _createVoidFragment(part: DMessageVoidFragment['part']): DMessageVoidFragment {
|
||||
@@ -372,8 +372,8 @@ function _create_ModelAux_Part(aType: DVoidModelAuxPart['aType'], aText: string)
|
||||
return { pt: 'ma', aType, aText };
|
||||
}
|
||||
|
||||
function _create_Placeholder_Part(placeholderText: string): DVoidPlaceholderPart {
|
||||
return { pt: 'ph', pText: placeholderText };
|
||||
function _create_Placeholder_Part(placeholderText: string, pType?: DVoidPlaceholderPart['pType']): DVoidPlaceholderPart {
|
||||
return { pt: 'ph', pText: placeholderText, ...(pType ? { pType } : undefined) };
|
||||
}
|
||||
|
||||
function _create_Sentinel_Part(): _SentinelPart {
|
||||
@@ -396,7 +396,7 @@ function _duplicate_Part<TPart extends (DMessageContentFragment | DMessageAttach
|
||||
return _create_ModelAux_Part(part.aType, part.aText) as TPart;
|
||||
|
||||
case 'ph':
|
||||
return _create_Placeholder_Part(part.pText) as TPart;
|
||||
return _create_Placeholder_Part(part.pText, part.pType) as TPart;
|
||||
|
||||
case 'text':
|
||||
return _create_Text_Part(part.text) as TPart;
|
||||
|
||||
@@ -112,7 +112,7 @@ export function createDMessageTextContent(role: DMessageRole, text: string): DMe
|
||||
}
|
||||
|
||||
export function createDMessagePlaceholderIncomplete(role: DMessageRole, placeholderText: string): DMessage {
|
||||
const placeholderFragment = createPlaceholderVoidFragment(placeholderText);
|
||||
const placeholderFragment = createPlaceholderVoidFragment(placeholderText, undefined);
|
||||
const message = createDMessageFromFragments(role, [placeholderFragment]);
|
||||
message.pendingIncomplete = true;
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user