Skip to content

Commit f754464

Browse files
Add mode to conversation model messages (#517)
* Add mode to conversation model messages This updates the conversation.message with source=model to include `mode` details in the telemetry * Add "mode" field to snapshot responses and update imports in tests
1 parent 9198a1b commit f754464

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

src/extension/prompt/node/chatParticipantTelemetry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ export abstract class ChatTelemetry<C extends IDocumentContext | undefined = IDo
358358
response,
359359
this.telemetryMessageId, // That's the message id of the user message
360360
this._documentContext?.document,
361-
this._userTelemetry.extendedBy({ replyType: interactionOutcome.kind })
361+
this._userTelemetry.extendedBy({ replyType: interactionOutcome.kind }),
362+
this._getModeName()
362363
);
363364
}
364365

src/extension/prompt/node/defaultIntentRequestHandler.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,20 @@ export class DefaultIntentRequestHandler {
392392
appliedText,
393393
requestId,
394394
this.documentContext?.document,
395-
baseModelTelemetry
395+
baseModelTelemetry,
396+
this.getModeName()
396397
);
397398

398399
return chatResult;
399400
}
400401

402+
private getModeName(): string {
403+
return this.request.modeInstructions ? 'custom' :
404+
this.intent.id === 'editAgent' ? 'agent' :
405+
(this.intent.id === 'edit' || this.intent.id === 'edit2') ? 'edit' :
406+
'ask';
407+
}
408+
401409
private processOffTopicFetchResult(baseModelTelemetry: ConversationalBaseTelemetryData): ChatResult {
402410
// Create starting off topic telemetry and mark event as issued and displayed
403411
this.stream.markdown(this.options.rejectionMessage);

src/extension/prompt/node/telemetry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export function sendModelMessageTelemetry(
9191
appliedText: string,
9292
requestId: string,
9393
doc: TextDocumentSnapshot | undefined,
94-
baseTelemetry: ConversationalBaseTelemetryData
94+
baseTelemetry: ConversationalBaseTelemetryData,
95+
modeName: string,
9596
): void {
9697
// Get the languages of code blocks within the message
9798
const codeBlockLanguages = getCodeBlocks(appliedText);
@@ -108,6 +109,7 @@ export function sendModelMessageTelemetry(
108109
headerRequestId: requestId,
109110
uiKind: ChatLocation.toString(location),
110111
codeBlockLanguages: JSON.stringify({ ...codeBlockLanguages }),
112+
mode: modeName,
111113
},
112114
{ messageCharLen: appliedText.length, numCodeBlocks: codeBlockLanguages.length },
113115
baseTelemetry

0 commit comments

Comments
 (0)