Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/context/node/resolvers/genericPanelIntentInvocation.ts
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
7
import { BasePromptElementProps } from '@vscode/prompt-tsx';
8
import type * as vscode from 'vscode';
9
import { ChatLocation } from '../../../../platform/chat/common/commonTypes';
10
import { IChatEndpoint } from '../../../../platform/networking/common/networking';
11
import { IInstantiationService } from '../../../../util/vs/platform/instantiation/common/instantiation';
12
import { IBuildPromptContext } from '../../../prompt/common/intents';
13
import { IDocumentContext } from '../../../prompt/node/documentContext';
14
import { IIntent, IIntentInvocation } from '../../../prompt/node/intents';
15
import { PromptElementCtor } from '../../../prompts/node/base/promptElement';
16
import { PromptRenderer, RendererIntentInvocation } from '../../../prompts/node/base/promptRenderer';
17
import { PanelChatBasePrompt } from '../../../prompts/node/panel/panelChatBasePrompt';
18
19
export interface GenericBasePromptElementProps extends BasePromptElementProps {
20
readonly documentContext?: IDocumentContext;
21
readonly promptContext: IBuildPromptContext;
22
}
23
24
export class GenericPanelIntentInvocation extends RendererIntentInvocation implements IIntentInvocation {
25
26
constructor(
27
intent: IIntent,
28
location: ChatLocation,
29
endpoint: IChatEndpoint,
30
private readonly prompt: PromptElementCtor<GenericBasePromptElementProps, any> = PanelChatBasePrompt,
31
private readonly documentContext: IDocumentContext | undefined,
32
@IInstantiationService private readonly instantiationService: IInstantiationService,
33
) {
34
super(intent, location, endpoint);
35
}
36
37
createRenderer(
38
promptContext: IBuildPromptContext,
39
endpoint: IChatEndpoint,
40
progress: vscode.Progress<vscode.ChatResponseReferencePart | vscode.ChatResponseProgressPart>,
41
token: vscode.CancellationToken
42
) {
43
return PromptRenderer.create(this.instantiationService, endpoint, this.prompt, {
44
documentContext: this.documentContext,
45
promptContext
46
});
47
}
48
}
49
50