-
Notifications
You must be signed in to change notification settings - Fork 39.3k
Prototype: Auto Model Routing collapsible card in chat (dev command) #311442
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
base: main
Are you sure you want to change the base?
Changes from all commits
4075232
d17d6b5
01f4b20
699a7be
c501642
4ef1c49
176af48
e6afdd8
fc4ebf0
b798f70
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,109 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { $ } from '../../../../../../base/browser/dom.js'; | ||
| import { Codicon } from '../../../../../../base/common/codicons.js'; | ||
| import { localize } from '../../../../../../nls.js'; | ||
| import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js'; | ||
| import { IHoverService } from '../../../../../../platform/hover/browser/hover.js'; | ||
| import { IChatAutoModelRoutingPart } from '../../../common/chatService/chatService.js'; | ||
| import { IChatRendererContent } from '../../../common/model/chatViewModel.js'; | ||
| import { ChatTreeItem } from '../../chat.js'; | ||
| import { ChatCollapsibleContentPart } from './chatCollapsibleContentPart.js'; | ||
| import { IChatContentPart, IChatContentPartRenderContext } from './chatContentParts.js'; | ||
| import './media/chatAutoModelRoutingContentPart.css'; | ||
|
|
||
| export class ChatAutoModelRoutingContentPart extends ChatCollapsibleContentPart implements IChatContentPart { | ||
|
|
||
| constructor( | ||
| private readonly routingPart: IChatAutoModelRoutingPart, | ||
| context: IChatContentPartRenderContext, | ||
| @IHoverService hoverService: IHoverService, | ||
| @IConfigurationService configurationService: IConfigurationService, | ||
| ) { | ||
| const title = localize('autoModelRouting.title', "Routed to {0}", routingPart.selectedModel); | ||
| super(title, context, undefined, hoverService, configurationService); | ||
|
|
||
| this.icon = Codicon.sparkle; | ||
| this.domNode.classList.add('chat-auto-model-routing'); | ||
| this.setExpanded(false); | ||
| } | ||
|
|
||
| protected override initContent(): HTMLElement { | ||
| const container = $('.chat-auto-model-routing-body'); | ||
|
|
||
| // Build capability sentence from top 2 capabilities by score | ||
| const caps = this.routingPart.capabilities; | ||
| let capSentence: string; | ||
| if (caps && caps.length >= 2) { | ||
| const top = [...caps].sort((a, b) => b.score - a.score).slice(0, 2).map(c => c.name.toLowerCase()); | ||
| capSentence = localize('autoModelRouting.capSentence', "{0} is selected for high {1} and {2} capability. ", | ||
| this.routingPart.selectedModel, top[0], top[1]); | ||
| } else if (caps && caps.length === 1) { | ||
| capSentence = localize('autoModelRouting.capSentenceSingle', "{0} is selected for high {1} capability. ", | ||
| this.routingPart.selectedModel, caps[0].name.toLowerCase()); | ||
| } else { | ||
| capSentence = ''; | ||
| } | ||
|
|
||
| const para = $('.chat-auto-model-routing-footer'); | ||
| para.appendChild($('span', undefined, capSentence)); | ||
| para.appendChild($('span', undefined, | ||
| localize('autoModelRouting.footer', "Auto routes based on your task and real-time system health and model performance. "))); | ||
| const learnMore = $('a.chat-auto-model-routing-learn-more', { href: 'https://aka.ms/copilot-auto-model', target: '_blank' }, | ||
| localize('autoModelRouting.learnMore', "Learn more")); | ||
| para.appendChild(learnMore); | ||
| container.appendChild(para); | ||
|
|
||
| // Capability score list | ||
| if (this.routingPart.capabilities && this.routingPart.capabilities.length > 0) { | ||
| container.appendChild($('span.chat-auto-model-routing-section-label', undefined, | ||
| localize('autoModelRouting.capabilities', "Task requirements"))); | ||
| const list = $('ul.chat-auto-model-routing-scores'); | ||
| for (const cap of this.routingPart.capabilities) { | ||
| const li = $('li.chat-auto-model-routing-score-row'); | ||
| li.appendChild($('span.chat-auto-model-routing-score-name', undefined, cap.name)); | ||
| li.appendChild($('span.chat-auto-model-routing-score-pct', undefined, `${Math.round(cap.score * 100)}%`)); | ||
| list.appendChild(li); | ||
| } | ||
| container.appendChild(list); | ||
| } | ||
|
Comment on lines
+34
to
+72
|
||
|
|
||
| return container; | ||
| } | ||
|
|
||
| hasSameContent(other: IChatRendererContent, _followingContent: IChatRendererContent[], _element: ChatTreeItem): boolean { | ||
| if (other.kind !== 'autoModelRouting') { | ||
| return false; | ||
| } | ||
| if (other.selectedModel !== this.routingPart.selectedModel | ||
| || other.selectionReason !== this.routingPart.selectionReason) { | ||
| return false; | ||
| } | ||
| const a = this.routingPart.candidates ?? []; | ||
| const b = other.candidates ?? []; | ||
| if (a.length !== b.length) { | ||
| return false; | ||
| } | ||
| for (let i = 0; i < a.length; i++) { | ||
| if (a[i].modelName !== b[i].modelName) { | ||
| return false; | ||
| } | ||
| } | ||
| const ca = this.routingPart.capabilities ?? []; | ||
| const cb = other.capabilities ?? []; | ||
| if (ca.length !== cb.length) { | ||
| return false; | ||
| } | ||
| for (let i = 0; i < ca.length; i++) { | ||
| if (ca[i].name !== cb[i].name || ca[i].score !== cb[i].score) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||||
| /*--------------------------------------------------------------------------------------------- | ||||||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||||||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||||||
| *--------------------------------------------------------------------------------------------*/ | ||||||
|
|
||||||
| .chat-auto-model-routing-body { | ||||||
| display: flex; | ||||||
| flex-direction: column; | ||||||
| gap: 8px; | ||||||
| padding: 4px 12px 10px 12px; | ||||||
| font-size: var(--vscode-chat-font-size-body-s); | ||||||
| } | ||||||
|
|
||||||
| /* Prose sentence */ | ||||||
| .chat-auto-model-routing-prose { | ||||||
| color: var(--vscode-descriptionForeground); | ||||||
| line-height: 1.5; | ||||||
| } | ||||||
|
|
||||||
| /* Curved connector line when expanded (matches Thinking style) */ | ||||||
| .chat-auto-model-routing { | ||||||
| position: relative; | ||||||
| } | ||||||
|
|
||||||
| .chat-auto-model-routing:not(.chat-used-context-collapsed)::after { | ||||||
| content: ''; | ||||||
| position: absolute; | ||||||
| left: 3px; | ||||||
| top: 22px; | ||||||
| height: 16px; | ||||||
| width: 5px; | ||||||
| border-left: 1px solid var(--vscode-chat-requestBorder); | ||||||
| border-bottom: 1px solid var(--vscode-chat-requestBorder); | ||||||
| border-bottom-left-radius: 5px; | ||||||
| } | ||||||
|
|
||||||
| /* Footer / prose paragraph */ | ||||||
| .chat-auto-model-routing-footer { | ||||||
| color: var(--vscode-descriptionForeground); | ||||||
| font-size: var(--vscode-chat-font-size-body-s); | ||||||
| line-height: 1.5; | ||||||
| } | ||||||
|
|
||||||
| .chat-auto-model-routing-learn-more { | ||||||
| color: var(--vscode-textLink-foreground); | ||||||
| text-decoration: none; | ||||||
| } | ||||||
|
|
||||||
| .chat-auto-model-routing-learn-more:hover { | ||||||
| text-decoration: underline; | ||||||
| } | ||||||
|
|
||||||
| /* Section label */ | ||||||
| .chat-auto-model-routing-section-label { | ||||||
| font-size: 10px; | ||||||
| text-transform: uppercase; | ||||||
| letter-spacing: 0.06em; | ||||||
| color: var(--vscode-descriptionForeground); | ||||||
| opacity: 0.6; | ||||||
| } | ||||||
|
|
||||||
| /* Capability score list */ | ||||||
| .chat-auto-model-routing-scores { | ||||||
| list-style: none; | ||||||
| margin: 0; | ||||||
| padding: 0 0 0 10px; | ||||||
| display: grid; | ||||||
| grid-template-columns: 1fr 1fr; | ||||||
| gap: 2px 12px; | ||||||
| border-left: 1px solid var(--vscode-chat-requestBorder); | ||||||
| } | ||||||
|
|
||||||
| .chat-auto-model-routing-score-row { | ||||||
| display: flex; | ||||||
| align-items: center; | ||||||
| gap: 4px; | ||||||
| color: var(--vscode-descriptionForeground); | ||||||
| padding: 1px 0; | ||||||
| } | ||||||
| color: var(--vscode-descriptionForeground); | ||||||
| } | ||||||
|
Comment on lines
+80
to
+81
|
||||||
| color: var(--vscode-descriptionForeground); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The injected chat markdown strings (
"Routing your request through Copilot Auto…","Done — using …") are user-visible but not localized. Please wrap these inlocalize(...)(or otherwise externalize them) even though the command is Developer-only, to keep the codebase’s localization guarantees consistent.