-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add resolved model for events #4210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0627856
630e645
efde35c
b13ae3b
726fe10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| const autoModelId = 'copilot/auto'; | ||
|
|
||
| /** | ||
| * When the user has selected the "auto" model, replace the modelId with | ||
| * the actual model that served the request so that downstream telemetry | ||
| * reflects the resolved model rather than the opaque "copilot/auto" identifier. | ||
| */ | ||
| export function resolveModelIdForTelemetry(modelId: string, resolvedModel: string | undefined): string { | ||
| return modelId === autoModelId ? (resolvedModel || autoModelId) : modelId; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { describe, expect, test } from 'vitest'; | ||
| import { resolveModelIdForTelemetry } from '../resolveModelId'; | ||
|
|
||
| /** | ||
| * Tests the resolveModelIdForTelemetry helper used by copy/insert/apply | ||
| * telemetry events to substitute 'copilot/auto' with the actual resolved model. | ||
| * | ||
| * Integration tests verifying that resolvedModel is propagated through | ||
| * DefaultIntentRequestHandler into result metadata live in | ||
| * defaultIntentRequestHandler.spec.ts. | ||
| */ | ||
| describe('resolveModelIdForTelemetry', () => { | ||
| test('returns resolvedModel when modelId is copilot/auto', () => { | ||
| expect(resolveModelIdForTelemetry('copilot/auto', 'gpt-4o')).toBe('gpt-4o'); | ||
| }); | ||
|
|
||
| test('falls back to copilot/auto when resolvedModel is undefined', () => { | ||
| expect(resolveModelIdForTelemetry('copilot/auto', undefined)).toBe('copilot/auto'); | ||
| }); | ||
|
|
||
| test('falls back to copilot/auto when resolvedModel is empty string', () => { | ||
| expect(resolveModelIdForTelemetry('copilot/auto', '')).toBe('copilot/auto'); | ||
| }); | ||
|
|
||
| test('returns original modelId when not copilot/auto', () => { | ||
| expect(resolveModelIdForTelemetry('gpt-4o', 'gpt-4o-2024-05-13')).toBe('gpt-4o'); | ||
| }); | ||
|
|
||
| test('returns original modelId when not copilot/auto and no resolvedModel', () => { | ||
| expect(resolveModelIdForTelemetry('claude-sonnet-4', undefined)).toBe('claude-sonnet-4'); | ||
| }); | ||
|
|
||
| test('does not substitute for empty modelId', () => { | ||
| expect(resolveModelIdForTelemetry('', 'gpt-4o')).toBe(''); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,6 +154,7 @@ export class DefaultIntentRequestHandler { | |
| const metadataFragment: Partial<IResultMetadata> = { | ||
| toolCallRounds: resultDetails.toolCallRounds, | ||
| toolCallResults: this._collectRelevantToolCallResults(resultDetails.toolCallRounds, resultDetails.toolCallResults), | ||
| resolvedModel: resultDetails.response.type === ChatFetchResponseType.Success ? resultDetails.response.resolvedModel : undefined, | ||
| }; | ||
|
Comment on lines
154
to
158
|
||
| mixin(chatResult, { metadata: metadataFragment }, true); | ||
| const baseModelTelemetry = createTelemetryWithId(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.