Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/node/panel/searchPanelKeywordsPrompt.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, PromptPiece, PromptSizing, SystemMessage, UserMessage } from '@vscode/prompt-tsx';
7
import { IChatEndpoint } from '../../../../platform/networking/common/networking';
8
import { IBuildPromptContext } from '../../../prompt/common/intents';
9
import { CopilotIdentityRules } from '../base/copilotIdentity';
10
import { InstructionMessage } from '../base/instructionMessage';
11
import { SafetyRules } from '../base/safetyRules';
12
import { ChatToolReferences, ChatVariablesAndQuery } from './chatVariables';
13
import { HistoryWithInstructions } from './conversationHistory';
14
15
interface ISearchPanelKeywordsPrompt extends BasePromptElementProps {
16
promptContext: ISearchPanelKeywordsPromptContext;
17
endpoint: IChatEndpoint;
18
}
19
20
export interface ISearchPanelKeywordsPromptContext extends IBuildPromptContext {
21
symbols: string[];
22
}
23
24
25
export class SearchPanelKeywordsPrompt extends PromptElement<ISearchPanelKeywordsPrompt> {
26
27
// todo: get workspace resolver to share TSX prompt so that we can reuse here
28
override render(state: void, sizing: PromptSizing): PromptPiece<any, any> | undefined {
29
const { query, history, chatVariables } = this.props.promptContext;
30
return (
31
<>
32
<SystemMessage priority={1000}>
33
You are a software engineer with expert knowledge of the codebase the user has open in their workspace.<br />
34
You will be provided with a few code symbols that have been extracted as very relevant to a user's search query.<br />
35
The user will be searching code extracts using natural language queries.<br />
36
Your job is to find the best symbols to search for in order to find the exact code the user is looking for.<br />
37
<br />
38
<CopilotIdentityRules />
39
<SafetyRules />
40
</SystemMessage>
41
<HistoryWithInstructions flexGrow={2} historyPriority={400} history={history} passPriority>
42
<InstructionMessage priority={1000}>
43
# Additional Rules<br />
44
Think step by step:<br />
45
1. Read the provided relevant workspace symbols to understand the code the user is searching for.<br />
46
2. Provide concise keyword symbols that are the most relevant for what the user is searching for.<br />
47
<br />
48
The keywords MUST have enough characters for the user to search for and find the relevant piece of code.<br />
49
You MUST NOT include decorators or any other characters in the response.<br />
50
# Examples<br />
51
Question:<br />
52
base64 encoding<br />
53
<br />
54
Response:<br />
55
convertEncoding()<br />
56
toBase64()<br />
57
<br />
58
Question:<br />
59
npm scripts<br />
60
<br />
61
Response:<br />
62
npm run test<br />
63
npm run build<br />
64
<br />
65
Question:<br />
66
register result provider<br />
67
<br />
68
Response:<br />
69
export class ResultProvider<br />
70
registerResultProvider()<br />
71
IResultProvider<br />
72
<br />
73
</InstructionMessage>
74
</HistoryWithInstructions>
75
<UserMessage>
76
<>
77
{'Here are all the relevant symbols for the user query:'}<br />
78
{this.props.promptContext.symbols.join('\n')}
79
<br /><br />
80
</>
81
<ChatToolReferences priority={899} flexGrow={3} promptContext={this.props.promptContext} />
82
<ChatVariablesAndQuery flexGrow={3} chatVariables={chatVariables} priority={900} query={query} />
83
</UserMessage>
84
</>
85
);
86
}
87
}
88
89