Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/node/panel/promptCategorization.tsx
13405 views
1
/*---------------------------------------------------------------------------------------------
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 { BasePromptElementProps, PromptElement, PromptSizing, SystemMessage, UserMessage } from '@vscode/prompt-tsx';
7
import { generateTaxonomyPrompt } from '../../../prompt/common/promptCategorizationTaxonomy';
8
import { SafetyRules } from '../base/safetyRules';
9
import { CurrentEditor } from './currentEditor';
10
import { WorkspaceStructure } from './workspace/workspaceStructure';
11
12
// Re-export types for consumers
13
export type { PromptClassification, PromptIntent, PromptDomain, PromptScope } from '../../../prompt/common/promptCategorizationTaxonomy';
14
15
export interface PromptCategorizationProps extends BasePromptElementProps {
16
userRequest: string;
17
}
18
19
export class PromptCategorizationPrompt extends PromptElement<PromptCategorizationProps> {
20
override async render(_state: void, sizing: PromptSizing) {
21
const systemPrompt = [
22
'You are an expert classifier for AI coding assistant prompts. Classify developer requests in context of their workspace and active file across domain, intent, time estimate, and scope.',
23
'You MUST use the categorize_prompt tool to provide your classification.',
24
generateTaxonomyPrompt(),
25
].join('\n\n') + '\n\n';
26
27
return (
28
<>
29
<SystemMessage priority={1000}>
30
{systemPrompt}
31
<SafetyRules />
32
</SystemMessage>
33
<UserMessage priority={900}>
34
<WorkspaceStructure priority={600} flexGrow={0} maxSize={Math.min(300, Math.floor(sizing.tokenBudget * 0.1))} /><br />
35
<CurrentEditor priority={600} flexGrow={0} /><br />
36
User message:<br />
37
{this.props.userRequest}
38
</UserMessage>
39
</>
40
);
41
}
42
}
43
44