Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompt/node/promptVariablesService.ts
13399 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 type { ChatLanguageModelToolReference, ChatPromptReference } from 'vscode';
7
import { createServiceIdentifier } from '../../../util/common/services';
8
9
10
export const IPromptVariablesService = createServiceIdentifier<IPromptVariablesService>('IPromptVariablesService');
11
12
export interface IPromptVariablesService {
13
readonly _serviceBrand: undefined;
14
resolveVariablesInPrompt(message: string, variables: readonly ChatPromptReference[]): Promise<{ message: string }>;
15
resolveToolReferencesInPrompt(message: string, toolReferences: readonly ChatLanguageModelToolReference[]): Promise<string>;
16
17
/**
18
* Builds a context string describing resolved template variables for
19
* injection into system prompts. This allows skills that reference
20
* `{{VARIABLE_NAME}}` placeholders to have their values available
21
* via session context.
22
*/
23
buildTemplateVariablesContext(sessionId: string | undefined, debugTargetSessionIds?: readonly string[]): string;
24
}
25
26
export class NullPromptVariablesService implements IPromptVariablesService {
27
declare readonly _serviceBrand: undefined;
28
29
async resolveVariablesInPrompt(message: string, variables: readonly ChatPromptReference[]): Promise<{ message: string }> {
30
return { message };
31
}
32
33
async resolveToolReferencesInPrompt(message: string, toolReferences: readonly ChatLanguageModelToolReference[]): Promise<string> {
34
return message;
35
}
36
37
buildTemplateVariablesContext(): string {
38
return '';
39
}
40
}
41
42