Skip to content

Commit e77b161

Browse files
authored
Include file path in image prompts (#3790)
* Include file path in image prompts * Include id attribute in attachment tag
1 parent 66410bd commit e77b161

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/extension/prompts/node/panel/image.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import { ConfigKey, IConfigurationService } from '../../../../platform/configura
1111
import { modelCanUseImageURL } from '../../../../platform/endpoint/common/chatModelCapabilities';
1212
import { IImageService } from '../../../../platform/image/common/imageService';
1313
import { ILogService } from '../../../../platform/log/common/logService';
14+
import { IPromptPathRepresentationService } from '../../../../platform/prompts/common/promptPathRepresentationService';
1415
import { IExperimentationService } from '../../../../platform/telemetry/common/nullExperimentationService';
1516
import { getMimeType } from '../../../../util/common/imageUtils';
1617
import { Uri } from '../../../../vscodeTypes';
1718
import { IPromptEndpoint } from '../base/promptRenderer';
19+
import { Tag } from '../base/tag';
1820

1921
export interface ImageProps extends BasePromptElementProps {
2022
variableName: string;
@@ -67,7 +69,8 @@ export class Image extends PromptElement<ImageProps, unknown> {
6769
@ILogService private readonly logService: ILogService,
6870
@IImageService private readonly imageService: IImageService,
6971
@IConfigurationService private readonly configurationService: IConfigurationService,
70-
@IExperimentationService private readonly experimentationService: IExperimentationService
72+
@IExperimentationService private readonly experimentationService: IExperimentationService,
73+
@IPromptPathRepresentationService private readonly promptPathRepresentationService: IPromptPathRepresentationService
7174
) {
7275
super(props);
7376
}
@@ -112,7 +115,14 @@ export class Image extends PromptElement<ImageProps, unknown> {
112115
<UserMessage priority={0}>
113116
<BaseImage src={imageSource} detail='high' mimeType={imageMimeType} />
114117
{this.props.reference && (
115-
<references value={[new PromptReference(this.props.variableName ? { variableName: this.props.variableName, value: fillerUri } : fillerUri, undefined)]} />
118+
<>
119+
<Tag name='attachment' attrs={
120+
this.props.variableName
121+
? { id: this.props.variableName, filePath: this.promptPathRepresentationService.getFilePath(this.props.reference) }
122+
: { filePath: this.promptPathRepresentationService.getFilePath(this.props.reference) }
123+
} />
124+
<references value={[new PromptReference(this.props.variableName ? { variableName: this.props.variableName, value: fillerUri } : fillerUri, undefined)]} />
125+
</>
116126
)}
117127
</UserMessage>
118128
);

0 commit comments

Comments
 (0)