MP: rename to contentRef

This commit is contained in:
Enrico Ros
2024-05-25 00:40:39 -07:00
parent 428babf856
commit 28fc7deefc
3 changed files with 11 additions and 11 deletions
@@ -27,12 +27,12 @@ export const DEBUG_LLMATTACHMENTS = true;
* Note: this utility function could be extracted more broadly to chat.message.ts, but
* I don't want to introduce a (circular) dependency from chat.message.ts to dblobs.db.ts.
*/
async function handleShowContentInNewTab(source: DContentRef) {
async function handleShowContentInNewTab(contentRef: DContentRef) {
let imageUrl: string | null = null;
if (source.reftype === 'url')
imageUrl = source.url;
else if (source.reftype === 'dblob')
imageUrl = await getImageBlobURLById(source.dblobId);
if (contentRef.reftype === 'url')
imageUrl = contentRef.url;
else if (contentRef.reftype === 'dblob')
imageUrl = await getImageBlobURLById(contentRef.dblobId);
if (imageUrl && typeof window !== 'undefined')
window.open(imageUrl, '_blank', 'noopener,noreferrer');
}
@@ -172,12 +172,12 @@ export function LLMAttachmentMenu(props: {
draft.outputParts.map((output, index) => {
if (output.atype === 'aimage') {
const resolution = output.width && output.height ? `${output.width} x ${output.height}` : 'unknown resolution';
const mime = output.source.reftype === 'dblob' ? output.source.mimeType : 'unknown image';
const mime = output.contentRef.reftype === 'dblob' ? output.contentRef.mimeType : 'unknown image';
return (
<Typography key={index} level='body-sm'>
🡒 {mime/*unic.replace('image/', 'img: ')*/} · {resolution} · {output.source.reftype === 'dblob' ? output.source.bytesSize?.toLocaleString() : '(remote)'}
🡒 {mime/*unic.replace('image/', 'img: ')*/} · {resolution} · {output.contentRef.reftype === 'dblob' ? output.contentRef.bytesSize?.toLocaleString() : '(remote)'}
{' · '}
<Link onClick={() => handleShowContentInNewTab(output.source)}>
<Link onClick={() => handleShowContentInNewTab(output.contentRef)}>
open <LaunchIcon sx={{ mx: 0.5, fontSize: 16 }} />
</Link>
</Typography>
@@ -85,7 +85,7 @@ export async function attachmentImageToPartViaDBlob(mimeType: string, inputData:
// Create Part
return {
atype: 'aimage',
source: {
contentRef: {
reftype: 'dblob',
dblobId: dblobId,
mimeType: mimeType,
+2 -2
View File
@@ -56,7 +56,7 @@ export type DContentParts = DContentPart[];
type DContentPart =
| { ptype: 'text'; text: string } // H/A
| { ptype: 'image'; /*mimeType: string;*/ source: DContentRef, title?: string, width?: number, height?: number }
| { ptype: 'image'; /*mimeType: string;*/ contentRef: DContentRef, title?: string, width?: number, height?: number }
// | { ptype: 'audio'; mimeType: string; source: DContentRef }
// | { ptype: 'video'; mimeType: string; source: DContentRef }
// | { ptype: 'document'; source: DContentRef } // H
@@ -71,7 +71,7 @@ type DContentPart =
export type DAttachmentPart =
| { atype: 'atext', text: string, title?: string, collapsible: boolean }
| { atype: 'aimage', source: DContentRef, title?: string, width?: number, height?: number, collapsible: false }
| { atype: 'aimage', contentRef: DContentRef, title?: string, width?: number, height?: number, collapsible: false }
// Metadata