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