chatImageExtraction.ts ×8

Frontier kind: Code frontier

unlabeled · c_6f1ddabdabd0

30 tests · 41809 LOC · 180 files · introduces 0 tests · 52 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges52 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3654 ranges41809 lines · 180 files · Browse complete extent
All tests (intent)
30 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 52 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatImageExtraction.ts 52 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatImageExtraction.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { decodeBase64, VSBuffer } from '../../../../base/common/buffer.js';
7 > import { IMarkdownString } from '../../../../base/common/htmlContent.js';
8 > import { getExtensionForMimeType, getMediaMime } from '../../../../base/common/mime.js';
9 > import { URI } from '../../../../base/common/uri.js';
10 > import { localize } from '../../../../nls.js';
11 > import { isLocation } from '../../../../editor/common/languages.js';
12 > import { IChatResponseViewModel, IChatRequestViewModel, isRequestVM } from './model/chatViewModel.js';
13 > import { ChatResponseResource } from './model/chatModel.js';
14 > import { IChatContentInlineReference, IChatToolInvocation, IChatToolInvocationSerialized, IToolResultOutputDetailsSerialized } from './chatService/chatService.js';
15 > import { isToolResultInputOutputDetails, isToolResultOutputDetails, IToolResultOutputDetails } from './tools/languageModelToolsService.js';
16 > import { getExplicitFileOrImageAttachmentSummary, type IChatRequestVariableEntry, isImageVariableEntry } from './attachments/chatVariableEntries.js';
17 >
18 > export interface IChatExtractedImage {
19 > readonly id: string;
20 > readonly uri: URI;
21 > readonly name: string;
22 > readonly mimeType: string;
23 > readonly data: VSBuffer;
24 > readonly source: string;
25 > readonly caption: string | IMarkdownString | undefined;
26 > }
27 >
28 > export interface IChatExtractedImageCollection {
29 > readonly id: string;
30 > readonly title: string;
31 > readonly images: IChatExtractedImage[];
32 > }
33 >
34 > /**
35 > * Extract all images from a chat response's tool invocations and inline references.
36 > * Tool invocation images are extracted from output details and message URIs.
37 > * Inline reference images (file URIs) are read via the provided {@link readFile} callback.
38 > */
39 export async function extractImagesFromChatResponse(
40 response: IChatResponseViewModel,
67 };
68 }
70 > export function extractImagesFromToolInvocationOutputDetails(toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized, sessionResource: URI): IChatExtractedImage[] {
71 const images: IChatExtractedImage[] = [];
72
109 return images;
110 }
112 export async function extractImagesFromToolInvocationMessages(
113 toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
147 return images;
148 }
150 function getImageDataFromOutputDetails(resultDetails: IToolResultOutputDetails, toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized): VSBuffer | undefined {
151 if (toolInvocation.kind === 'toolInvocationSerialized') {
159 }
160 }
162 async function extractImageFromInlineReference(
163 part: IChatContentInlineReference,
188 };
189 }
191 > export function coerceImageBuffer(value: unknown): Uint8Array | undefined {
192 if (value instanceof Uint8Array) {
193 return value;
216 return result;
217 }
219 > /**
220 > * Extract images from a chat request's variable attachments (user-attached images).
221 > */
222 > export function extractImagesFromChatRequest(
223 request: IChatRequestViewModel,
224 ): IChatExtractedImage[] {
225 return extractImagesFromChatVariables(request.variables);
226 }
228 > export function extractImagesFromChatVariables(
229 variables: readonly IChatRequestVariableEntry[],
230 ): IChatExtractedImage[] {