@theia/plugin 1.55.0-next.71 → 1.55.0-next.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/plugin",
|
|
3
|
-
"version": "1.55.0-next.
|
|
3
|
+
"version": "1.55.0-next.97+52cad8a35",
|
|
4
4
|
"description": "Theia - Plugin API",
|
|
5
5
|
"types": "./src/theia.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"nyc": {
|
|
33
33
|
"extends": "../../configs/nyc.json"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "52cad8a35c3c86231f1b3efc74608bd159840a69"
|
|
36
36
|
}
|
package/src/theia.d.ts
CHANGED
|
@@ -2696,6 +2696,11 @@ export module '@theia/plugin' {
|
|
|
2696
2696
|
* Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
|
|
2697
2697
|
*/
|
|
2698
2698
|
export class ThemeColor {
|
|
2699
|
+
/**
|
|
2700
|
+
* The id of this color.
|
|
2701
|
+
*/
|
|
2702
|
+
readonly id: string;
|
|
2703
|
+
|
|
2699
2704
|
/**
|
|
2700
2705
|
* Creates a reference to a theme color.
|
|
2701
2706
|
*/
|
|
@@ -17262,6 +17267,7 @@ export module '@theia/plugin' {
|
|
|
17262
17267
|
|
|
17263
17268
|
/**
|
|
17264
17269
|
* Represents a user request in chat history.
|
|
17270
|
+
* @stubbed
|
|
17265
17271
|
*/
|
|
17266
17272
|
export class ChatRequestTurn {
|
|
17267
17273
|
/**
|
|
@@ -17289,14 +17295,20 @@ export module '@theia/plugin' {
|
|
|
17289
17295
|
*/
|
|
17290
17296
|
readonly references: ChatPromptReference[];
|
|
17291
17297
|
|
|
17298
|
+
/**
|
|
17299
|
+
* The list of tools were attached to this request.
|
|
17300
|
+
*/
|
|
17301
|
+
readonly toolReferences: readonly ChatLanguageModelToolReference[];
|
|
17302
|
+
|
|
17292
17303
|
/**
|
|
17293
17304
|
* @hidden
|
|
17294
17305
|
*/
|
|
17295
|
-
private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string);
|
|
17306
|
+
private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[]);
|
|
17296
17307
|
}
|
|
17297
17308
|
|
|
17298
17309
|
/**
|
|
17299
17310
|
* Represents a chat participant's response in chat history.
|
|
17311
|
+
* @stubbed
|
|
17300
17312
|
*/
|
|
17301
17313
|
export class ChatResponseTurn {
|
|
17302
17314
|
/**
|
|
@@ -17327,6 +17339,7 @@ export module '@theia/plugin' {
|
|
|
17327
17339
|
|
|
17328
17340
|
/**
|
|
17329
17341
|
* Extra context passed to a participant.
|
|
17342
|
+
* @stubbed
|
|
17330
17343
|
*/
|
|
17331
17344
|
export interface ChatContext {
|
|
17332
17345
|
/**
|
|
@@ -17337,6 +17350,7 @@ export module '@theia/plugin' {
|
|
|
17337
17350
|
|
|
17338
17351
|
/**
|
|
17339
17352
|
* Represents an error result from a chat request.
|
|
17353
|
+
* @stubbed
|
|
17340
17354
|
*/
|
|
17341
17355
|
export interface ChatErrorDetails {
|
|
17342
17356
|
/**
|
|
@@ -17352,6 +17366,7 @@ export module '@theia/plugin' {
|
|
|
17352
17366
|
|
|
17353
17367
|
/**
|
|
17354
17368
|
* The result of a chat request.
|
|
17369
|
+
* @stubbed
|
|
17355
17370
|
*/
|
|
17356
17371
|
export interface ChatResult {
|
|
17357
17372
|
/**
|
|
@@ -17382,6 +17397,7 @@ export module '@theia/plugin' {
|
|
|
17382
17397
|
|
|
17383
17398
|
/**
|
|
17384
17399
|
* Represents user feedback for a result.
|
|
17400
|
+
* @stubbed
|
|
17385
17401
|
*/
|
|
17386
17402
|
export interface ChatResultFeedback {
|
|
17387
17403
|
/**
|
|
@@ -17398,6 +17414,7 @@ export module '@theia/plugin' {
|
|
|
17398
17414
|
|
|
17399
17415
|
/**
|
|
17400
17416
|
* A followup question suggested by the participant.
|
|
17417
|
+
* @stubbed
|
|
17401
17418
|
*/
|
|
17402
17419
|
export interface ChatFollowup {
|
|
17403
17420
|
/**
|
|
@@ -17424,11 +17441,13 @@ export module '@theia/plugin' {
|
|
|
17424
17441
|
|
|
17425
17442
|
/**
|
|
17426
17443
|
* Will be invoked once after each request to get suggested followup questions to show the user. The user can click the followup to send it to the chat.
|
|
17444
|
+
* @stubbed
|
|
17427
17445
|
*/
|
|
17428
17446
|
export interface ChatFollowupProvider {
|
|
17429
17447
|
/**
|
|
17430
17448
|
* Provide followups for the given result.
|
|
17431
17449
|
* @param result This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
|
|
17450
|
+
* @param context Extra context passed to a participant.
|
|
17432
17451
|
* @param token A cancellation token.
|
|
17433
17452
|
*/
|
|
17434
17453
|
provideFollowups(result: ChatResult, context: ChatContext, token: CancellationToken): ProviderResult<ChatFollowup[]>;
|
|
@@ -17436,12 +17455,14 @@ export module '@theia/plugin' {
|
|
|
17436
17455
|
|
|
17437
17456
|
/**
|
|
17438
17457
|
* A chat request handler is a callback that will be invoked when a request is made to a chat participant.
|
|
17458
|
+
* @stubbed
|
|
17439
17459
|
*/
|
|
17440
17460
|
export type ChatRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
|
|
17441
17461
|
|
|
17442
17462
|
/**
|
|
17443
17463
|
* A chat participant can be invoked by the user in a chat session, using the `@` prefix. When it is invoked, it handles the chat request and is solely
|
|
17444
17464
|
* responsible for providing a response to the user. A ChatParticipant is created using {@link chat.createChatParticipant}.
|
|
17465
|
+
* @stubbed
|
|
17445
17466
|
*/
|
|
17446
17467
|
export interface ChatParticipant {
|
|
17447
17468
|
/**
|
|
@@ -17490,6 +17511,7 @@ export module '@theia/plugin' {
|
|
|
17490
17511
|
|
|
17491
17512
|
/**
|
|
17492
17513
|
* A reference to a value that the user added to their chat request.
|
|
17514
|
+
* @stubbed
|
|
17493
17515
|
*/
|
|
17494
17516
|
export interface ChatPromptReference {
|
|
17495
17517
|
/**
|
|
@@ -17518,6 +17540,7 @@ export module '@theia/plugin' {
|
|
|
17518
17540
|
|
|
17519
17541
|
/**
|
|
17520
17542
|
* A request to a chat participant.
|
|
17543
|
+
* @stubbed
|
|
17521
17544
|
*/
|
|
17522
17545
|
export interface ChatRequest {
|
|
17523
17546
|
/**
|
|
@@ -17545,12 +17568,35 @@ export module '@theia/plugin' {
|
|
|
17545
17568
|
* string-manipulation of the prompt.
|
|
17546
17569
|
*/
|
|
17547
17570
|
readonly references: readonly ChatPromptReference[];
|
|
17571
|
+
|
|
17572
|
+
/**
|
|
17573
|
+
* The list of tools that the user attached to their request.
|
|
17574
|
+
*
|
|
17575
|
+
* When a tool reference is present, the chat participant should make a chat request using
|
|
17576
|
+
* {@link LanguageModelChatToolMode.Required} to force the language model to generate input for the tool. Then, the
|
|
17577
|
+
* participant can use {@link lm.invokeTool} to use the tool attach the result to its request for the user's prompt. The
|
|
17578
|
+
* tool may contribute useful extra context for the user's request.
|
|
17579
|
+
*/
|
|
17580
|
+
readonly toolReferences: readonly ChatLanguageModelToolReference[];
|
|
17581
|
+
|
|
17582
|
+
/**
|
|
17583
|
+
* A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
|
|
17584
|
+
* This associates the tool invocation to a chat session.
|
|
17585
|
+
*/
|
|
17586
|
+
readonly toolInvocationToken: ChatParticipantToolToken;
|
|
17587
|
+
|
|
17588
|
+
/**
|
|
17589
|
+
* This is the model that is currently selected in the UI. Extensions can use this or use {@link chat.selectChatModels} to
|
|
17590
|
+
* pick another model. Don't hold onto this past the lifetime of the request.
|
|
17591
|
+
*/
|
|
17592
|
+
readonly model: LanguageModelChat;
|
|
17548
17593
|
}
|
|
17549
17594
|
|
|
17550
17595
|
/**
|
|
17551
17596
|
* The ChatResponseStream is how a participant is able to return content to the chat view. It provides several methods for streaming different types of content
|
|
17552
17597
|
* which will be rendered in an appropriate way in the chat view. A participant can use the helper method for the type of content it wants to return, or it
|
|
17553
17598
|
* can instantiate a {@link ChatResponsePart} and use the generic {@link ChatResponseStream.push} method to return it.
|
|
17599
|
+
* @stubbed
|
|
17554
17600
|
*/
|
|
17555
17601
|
export interface ChatResponseStream {
|
|
17556
17602
|
/**
|
|
@@ -17567,7 +17613,7 @@ export module '@theia/plugin' {
|
|
|
17567
17613
|
* `push(new ChatResponseAnchorPart(value, title))`.
|
|
17568
17614
|
* An anchor is an inline reference to some type of resource.
|
|
17569
17615
|
*
|
|
17570
|
-
* @param value A uri
|
|
17616
|
+
* @param value A uri or location.
|
|
17571
17617
|
* @param title An optional title that is rendered with value.
|
|
17572
17618
|
*/
|
|
17573
17619
|
anchor(value: Uri | Location, title?: string): void;
|
|
@@ -17627,6 +17673,7 @@ export module '@theia/plugin' {
|
|
|
17627
17673
|
|
|
17628
17674
|
/**
|
|
17629
17675
|
* Represents a part of a chat response that is formatted as Markdown.
|
|
17676
|
+
* @stubbed
|
|
17630
17677
|
*/
|
|
17631
17678
|
export class ChatResponseMarkdownPart {
|
|
17632
17679
|
/**
|
|
@@ -17644,6 +17691,7 @@ export module '@theia/plugin' {
|
|
|
17644
17691
|
|
|
17645
17692
|
/**
|
|
17646
17693
|
* Represents a file tree structure in a chat response.
|
|
17694
|
+
* @stubbed
|
|
17647
17695
|
*/
|
|
17648
17696
|
export interface ChatResponseFileTree {
|
|
17649
17697
|
/**
|
|
@@ -17659,6 +17707,7 @@ export module '@theia/plugin' {
|
|
|
17659
17707
|
|
|
17660
17708
|
/**
|
|
17661
17709
|
* Represents a part of a chat response that is a file tree.
|
|
17710
|
+
* @stubbed
|
|
17662
17711
|
*/
|
|
17663
17712
|
export class ChatResponseFileTreePart {
|
|
17664
17713
|
/**
|
|
@@ -17681,6 +17730,7 @@ export module '@theia/plugin' {
|
|
|
17681
17730
|
|
|
17682
17731
|
/**
|
|
17683
17732
|
* Represents a part of a chat response that is an anchor, that is rendered as a link to a target.
|
|
17733
|
+
* @stubbed
|
|
17684
17734
|
*/
|
|
17685
17735
|
export class ChatResponseAnchorPart {
|
|
17686
17736
|
/**
|
|
@@ -17703,6 +17753,7 @@ export module '@theia/plugin' {
|
|
|
17703
17753
|
|
|
17704
17754
|
/**
|
|
17705
17755
|
* Represents a part of a chat response that is a progress message.
|
|
17756
|
+
* @stubbed
|
|
17706
17757
|
*/
|
|
17707
17758
|
export class ChatResponseProgressPart {
|
|
17708
17759
|
/**
|
|
@@ -17719,6 +17770,7 @@ export module '@theia/plugin' {
|
|
|
17719
17770
|
|
|
17720
17771
|
/**
|
|
17721
17772
|
* Represents a part of a chat response that is a reference, rendered separately from the content.
|
|
17773
|
+
* @stubbed
|
|
17722
17774
|
*/
|
|
17723
17775
|
export class ChatResponseReferencePart {
|
|
17724
17776
|
/**
|
|
@@ -17759,6 +17811,7 @@ export module '@theia/plugin' {
|
|
|
17759
17811
|
|
|
17760
17812
|
/**
|
|
17761
17813
|
* Represents a part of a chat response that is a button that executes a command.
|
|
17814
|
+
* @stubbed
|
|
17762
17815
|
*/
|
|
17763
17816
|
export class ChatResponseCommandButtonPart {
|
|
17764
17817
|
/**
|
|
@@ -17813,6 +17866,7 @@ export module '@theia/plugin' {
|
|
|
17813
17866
|
|
|
17814
17867
|
/**
|
|
17815
17868
|
* Represents a message in a chat. Can assume different roles, like user or assistant.
|
|
17869
|
+
* @stubbed
|
|
17816
17870
|
*/
|
|
17817
17871
|
export class LanguageModelChatMessage {
|
|
17818
17872
|
|
|
@@ -17822,7 +17876,7 @@ export module '@theia/plugin' {
|
|
|
17822
17876
|
* @param content The content of the message.
|
|
17823
17877
|
* @param name The optional name of a user for the message.
|
|
17824
17878
|
*/
|
|
17825
|
-
static User(content: string, name?: string): LanguageModelChatMessage;
|
|
17879
|
+
static User(content: string | (LanguageModelTextPart | LanguageModelToolResultPart)[], name?: string): LanguageModelChatMessage;
|
|
17826
17880
|
|
|
17827
17881
|
/**
|
|
17828
17882
|
* Utility to create a new assistant message.
|
|
@@ -17830,7 +17884,7 @@ export module '@theia/plugin' {
|
|
|
17830
17884
|
* @param content The content of the message.
|
|
17831
17885
|
* @param name The optional name of a user for the message.
|
|
17832
17886
|
*/
|
|
17833
|
-
static Assistant(content: string, name?: string): LanguageModelChatMessage;
|
|
17887
|
+
static Assistant(content: string | (LanguageModelTextPart | LanguageModelToolCallPart)[], name?: string): LanguageModelChatMessage;
|
|
17834
17888
|
|
|
17835
17889
|
/**
|
|
17836
17890
|
* The role of this message.
|
|
@@ -17838,9 +17892,10 @@ export module '@theia/plugin' {
|
|
|
17838
17892
|
role: LanguageModelChatMessageRole;
|
|
17839
17893
|
|
|
17840
17894
|
/**
|
|
17841
|
-
*
|
|
17895
|
+
* A string or heterogeneous array of things that a message can contain as content. Some parts may be message-type
|
|
17896
|
+
* specific for some models.
|
|
17842
17897
|
*/
|
|
17843
|
-
content:
|
|
17898
|
+
content: (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)[];
|
|
17844
17899
|
|
|
17845
17900
|
/**
|
|
17846
17901
|
* The optional name of a user for this message.
|
|
@@ -17854,31 +17909,40 @@ export module '@theia/plugin' {
|
|
|
17854
17909
|
* @param content The content of the message.
|
|
17855
17910
|
* @param name The optional name of a user for the message.
|
|
17856
17911
|
*/
|
|
17857
|
-
constructor(role: LanguageModelChatMessageRole, content: string, name?: string);
|
|
17912
|
+
constructor(role: LanguageModelChatMessageRole, content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)[], name?: string);
|
|
17858
17913
|
}
|
|
17859
17914
|
|
|
17860
17915
|
/**
|
|
17861
17916
|
* Represents a language model response.
|
|
17862
17917
|
*
|
|
17863
17918
|
* @see {@link LanguageModelAccess.chatRequest}
|
|
17919
|
+
* @stubbed
|
|
17864
17920
|
*/
|
|
17865
17921
|
export interface LanguageModelChatResponse {
|
|
17866
17922
|
|
|
17867
17923
|
/**
|
|
17868
|
-
* An async iterable that is a stream of text
|
|
17924
|
+
* An async iterable that is a stream of text and tool-call parts forming the overall response. A
|
|
17925
|
+
* {@link LanguageModelTextPart} is part of the assistant's response to be shown to the user. A
|
|
17926
|
+
* {@link LanguageModelToolCallPart} is a request from the language model to call a tool. The latter will
|
|
17927
|
+
* only be returned if tools were passed in the request via {@link LanguageModelChatRequestOptions.tools}. The
|
|
17928
|
+
* `unknown`-type is used as a placeholder for future parts, like image data parts.
|
|
17869
17929
|
*
|
|
17870
|
-
* *Note* that this stream will error when during data receiving an error occurs. Consumers of
|
|
17871
|
-
* the
|
|
17930
|
+
* *Note* that this stream will error when during data receiving an error occurs. Consumers of the stream should handle
|
|
17931
|
+
* the errors accordingly.
|
|
17872
17932
|
*
|
|
17873
|
-
* To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make
|
|
17874
|
-
* or break from the for-loop.
|
|
17933
|
+
* To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make
|
|
17934
|
+
* the request or break from the for-loop.
|
|
17875
17935
|
*
|
|
17876
17936
|
* @example
|
|
17877
17937
|
* ```ts
|
|
17878
17938
|
* try {
|
|
17879
17939
|
* // consume stream
|
|
17880
|
-
* for await (const chunk of response.
|
|
17881
|
-
*
|
|
17940
|
+
* for await (const chunk of response.stream) {
|
|
17941
|
+
* if (chunk instanceof LanguageModelTextPart) {
|
|
17942
|
+
* console.log("TEXT", chunk);
|
|
17943
|
+
* } else if (chunk instanceof LanguageModelToolCallPart) {
|
|
17944
|
+
* console.log("TOOL CALL", chunk);
|
|
17945
|
+
* }
|
|
17882
17946
|
* }
|
|
17883
17947
|
*
|
|
17884
17948
|
* } catch(e) {
|
|
@@ -17887,6 +17951,13 @@ export module '@theia/plugin' {
|
|
|
17887
17951
|
* }
|
|
17888
17952
|
* ```
|
|
17889
17953
|
*/
|
|
17954
|
+
stream: AsyncIterable<LanguageModelTextPart | LanguageModelToolCallPart | unknown>;
|
|
17955
|
+
|
|
17956
|
+
/**
|
|
17957
|
+
* This is equivalent to filtering everything except for text parts from a {@link LanguageModelChatResponse.stream}.
|
|
17958
|
+
*
|
|
17959
|
+
* @see {@link LanguageModelChatResponse.stream}
|
|
17960
|
+
*/
|
|
17890
17961
|
text: AsyncIterable<string>;
|
|
17891
17962
|
}
|
|
17892
17963
|
|
|
@@ -17894,6 +17965,7 @@ export module '@theia/plugin' {
|
|
|
17894
17965
|
* Represents a language model for making chat requests.
|
|
17895
17966
|
*
|
|
17896
17967
|
* @see {@link lm.selectChatModels}
|
|
17968
|
+
* @stubbed
|
|
17897
17969
|
*/
|
|
17898
17970
|
export interface LanguageModelChat {
|
|
17899
17971
|
|
|
@@ -17934,8 +18006,8 @@ export module '@theia/plugin' {
|
|
|
17934
18006
|
* Make a chat request using a language model.
|
|
17935
18007
|
*
|
|
17936
18008
|
* *Note* that language model use may be subject to access restrictions and user consent. Calling this function
|
|
17937
|
-
* for the first time (for
|
|
17938
|
-
* must _only be called in response to a user action!_
|
|
18009
|
+
* for the first time (for an extension) will show a consent dialog to the user and because of that this function
|
|
18010
|
+
* must _only be called in response to a user action!_ Extensions can use {@link LanguageModelAccessInformation.canSendRequest}
|
|
17939
18011
|
* to check if they have the necessary permissions to make a request.
|
|
17940
18012
|
*
|
|
17941
18013
|
* This function will return a rejected promise if making a request to the language model is not
|
|
@@ -17946,6 +18018,10 @@ export module '@theia/plugin' {
|
|
|
17946
18018
|
* - quota limits exceeded, see {@link LanguageModelError.Blocked `Blocked`}
|
|
17947
18019
|
* - other issues in which case extension must check {@link LanguageModelError.cause `LanguageModelError.cause`}
|
|
17948
18020
|
*
|
|
18021
|
+
* An extension can make use of language model tool calling by passing a set of tools to
|
|
18022
|
+
* {@link LanguageModelChatRequestOptions.tools}. The language model will return a {@link LanguageModelToolCallPart} and
|
|
18023
|
+
* the extension can invoke the tool and make another request with the result.
|
|
18024
|
+
*
|
|
17949
18025
|
* @param messages An array of message instances.
|
|
17950
18026
|
* @param options Options that control the request.
|
|
17951
18027
|
* @param token A cancellation token which controls the request. See {@link CancellationTokenSource} for how to create one.
|
|
@@ -17966,6 +18042,7 @@ export module '@theia/plugin' {
|
|
|
17966
18042
|
* Describes how to select language models for chat requests.
|
|
17967
18043
|
*
|
|
17968
18044
|
* @see {@link lm.selectChatModels}
|
|
18045
|
+
* @stubbed
|
|
17969
18046
|
*/
|
|
17970
18047
|
export interface LanguageModelChatSelector {
|
|
17971
18048
|
|
|
@@ -18001,6 +18078,7 @@ export module '@theia/plugin' {
|
|
|
18001
18078
|
* failure causes, like `if(someError.code === vscode.LanguageModelError.NotFound.name) {...}`
|
|
18002
18079
|
* for the case of referring to an unknown language model. For unspecified errors the `cause`-property
|
|
18003
18080
|
* will contain the actual error.
|
|
18081
|
+
* @stubbed
|
|
18004
18082
|
*/
|
|
18005
18083
|
export class LanguageModelError extends Error {
|
|
18006
18084
|
|
|
@@ -18034,6 +18112,7 @@ export module '@theia/plugin' {
|
|
|
18034
18112
|
* Options for making a chat request using a language model.
|
|
18035
18113
|
*
|
|
18036
18114
|
* @see {@link LanguageModelChat.sendRequest}
|
|
18115
|
+
* @stubbed
|
|
18037
18116
|
*/
|
|
18038
18117
|
export interface LanguageModelChatRequestOptions {
|
|
18039
18118
|
|
|
@@ -18047,6 +18126,24 @@ export module '@theia/plugin' {
|
|
|
18047
18126
|
* and need to be lookup in the respective documentation.
|
|
18048
18127
|
*/
|
|
18049
18128
|
modelOptions?: { [name: string]: any };
|
|
18129
|
+
|
|
18130
|
+
/**
|
|
18131
|
+
* An optional list of tools that are available to the language model. These could be registered tools available via
|
|
18132
|
+
* {@link lm.tools}, or private tools that are just implemented within the calling extension.
|
|
18133
|
+
*
|
|
18134
|
+
* If the LLM requests to call one of these tools, it will return a {@link LanguageModelToolCallPart} in
|
|
18135
|
+
* {@link LanguageModelChatResponse.stream}. It's the caller's responsibility to invoke the tool. If it's a tool
|
|
18136
|
+
* registered in {@link lm.tools}, that means calling {@link lm.invokeTool}.
|
|
18137
|
+
*
|
|
18138
|
+
* Then, the tool result can be provided to the LLM by creating an Assistant-type {@link LanguageModelChatMessage} with a
|
|
18139
|
+
* {@link LanguageModelToolCallPart}, followed by a User-type message with a {@link LanguageModelToolResultPart}.
|
|
18140
|
+
*/
|
|
18141
|
+
tools?: LanguageModelChatTool[];
|
|
18142
|
+
|
|
18143
|
+
/**
|
|
18144
|
+
* The tool-selecting mode to use. {@link LanguageModelChatToolMode.Auto} by default.
|
|
18145
|
+
*/
|
|
18146
|
+
toolMode?: LanguageModelChatToolMode;
|
|
18050
18147
|
}
|
|
18051
18148
|
|
|
18052
18149
|
/**
|
|
@@ -18087,10 +18184,56 @@ export module '@theia/plugin' {
|
|
|
18087
18184
|
* @stubbed
|
|
18088
18185
|
*/
|
|
18089
18186
|
export function selectChatModels(selector?: LanguageModelChatSelector): Thenable<LanguageModelChat[]>;
|
|
18187
|
+
|
|
18188
|
+
/**
|
|
18189
|
+
* Register a LanguageModelTool. The tool must also be registered in the package.json `languageModelTools` contribution
|
|
18190
|
+
* point. A registered tool is available in the {@link lm.tools} list for any extension to see. But in order for it to
|
|
18191
|
+
* be seen by a language model, it must be passed in the list of available tools in {@link LanguageModelChatRequestOptions.tools}.
|
|
18192
|
+
* @returns A {@link Disposable} that unregisters the tool when disposed.
|
|
18193
|
+
* @stubbed
|
|
18194
|
+
*/
|
|
18195
|
+
export function registerTool<T>(name: string, tool: LanguageModelTool<T>): Disposable;
|
|
18196
|
+
|
|
18197
|
+
/**
|
|
18198
|
+
* A list of all available tools that were registered by all extensions using {@link lm.registerTool}. They can be called
|
|
18199
|
+
* with {@link lm.invokeTool} with input that match their declared `inputSchema`.
|
|
18200
|
+
* @stubbed
|
|
18201
|
+
*/
|
|
18202
|
+
export const tools: readonly LanguageModelToolInformation[];
|
|
18203
|
+
|
|
18204
|
+
/**
|
|
18205
|
+
* Invoke a tool listed in {@link lm.tools} by name with the given input. The input will be validated against
|
|
18206
|
+
* the schema declared by the tool
|
|
18207
|
+
*
|
|
18208
|
+
* A tool can be invoked by a chat participant, in the context of handling a chat request, or globally by any extension in
|
|
18209
|
+
* any custom flow.
|
|
18210
|
+
*
|
|
18211
|
+
* In the former case, the caller shall pass the
|
|
18212
|
+
* {@link LanguageModelToolInvocationOptions.toolInvocationToken toolInvocationToken}, which comes with the a
|
|
18213
|
+
* {@link ChatRequest.toolInvocationToken chat request}. This makes sure the chat UI shows the tool invocation for the
|
|
18214
|
+
* correct conversation.
|
|
18215
|
+
*
|
|
18216
|
+
* A tool {@link LanguageModelToolResult result} is an array of {@link LanguageModelTextPart text-} and
|
|
18217
|
+
* {@link LanguageModelPromptTsxPart prompt-tsx}-parts. If the tool caller is using `@vscode/prompt-tsx`, it can
|
|
18218
|
+
* incorporate the response parts into its prompt using a `ToolResult`. If not, the parts can be passed along to the
|
|
18219
|
+
* {@link LanguageModelChat} via a user message with a {@link LanguageModelToolResultPart}.
|
|
18220
|
+
*
|
|
18221
|
+
* If a chat participant wants to preserve tool results for requests across multiple turns, it can store tool results in
|
|
18222
|
+
* the {@link ChatResult.metadata} returned from the handler and retrieve them on the next turn from
|
|
18223
|
+
* {@link ChatResponseTurn.result}.
|
|
18224
|
+
*
|
|
18225
|
+
* @param name The name of the tool to call.
|
|
18226
|
+
* @param options The options to use when invoking the tool.
|
|
18227
|
+
* @param token A cancellation token. See {@link CancellationTokenSource} for how to create one.
|
|
18228
|
+
* @returns The result of the tool invocation.
|
|
18229
|
+
* @stubbed
|
|
18230
|
+
*/
|
|
18231
|
+
export function invokeTool(name: string, options: LanguageModelToolInvocationOptions<object>, token?: CancellationToken): Thenable<LanguageModelToolResult>;
|
|
18090
18232
|
}
|
|
18091
18233
|
|
|
18092
18234
|
/**
|
|
18093
18235
|
* Represents extension specific information about the access to language models.
|
|
18236
|
+
* @stubbed
|
|
18094
18237
|
*/
|
|
18095
18238
|
export interface LanguageModelAccessInformation {
|
|
18096
18239
|
|
|
@@ -18109,6 +18252,327 @@ export module '@theia/plugin' {
|
|
|
18109
18252
|
* model does not exist or consent hasn't been asked for.
|
|
18110
18253
|
*/
|
|
18111
18254
|
canSendRequest(chat: LanguageModelChat): boolean | undefined;
|
|
18255
|
+
|
|
18256
|
+
}
|
|
18257
|
+
|
|
18258
|
+
/**
|
|
18259
|
+
* A tool that is available to the language model via {@link LanguageModelChatRequestOptions}. A language model uses all the
|
|
18260
|
+
* properties of this interface to decide which tool to call, and how to call it.
|
|
18261
|
+
* @stubbed
|
|
18262
|
+
*/
|
|
18263
|
+
export interface LanguageModelChatTool {
|
|
18264
|
+
/**
|
|
18265
|
+
* The name of the tool.
|
|
18266
|
+
*/
|
|
18267
|
+
name: string;
|
|
18268
|
+
|
|
18269
|
+
/**
|
|
18270
|
+
* The description of the tool.
|
|
18271
|
+
*/
|
|
18272
|
+
description: string;
|
|
18273
|
+
|
|
18274
|
+
/**
|
|
18275
|
+
* A JSON schema for the input this tool accepts.
|
|
18276
|
+
*/
|
|
18277
|
+
inputSchema?: object;
|
|
18278
|
+
}
|
|
18279
|
+
|
|
18280
|
+
/**
|
|
18281
|
+
* A tool-calling mode for the language model to use.
|
|
18282
|
+
*/
|
|
18283
|
+
export enum LanguageModelChatToolMode {
|
|
18284
|
+
/**
|
|
18285
|
+
* The language model can choose to call a tool or generate a message. Is the default.
|
|
18286
|
+
*/
|
|
18287
|
+
Auto = 1,
|
|
18288
|
+
|
|
18289
|
+
/**
|
|
18290
|
+
* The language model must call one of the provided tools. Note- some models only support a single tool when using this
|
|
18291
|
+
* mode.
|
|
18292
|
+
*/
|
|
18293
|
+
Required = 2
|
|
18294
|
+
}
|
|
18295
|
+
|
|
18296
|
+
/**
|
|
18297
|
+
* A language model response part indicating a tool call, returned from a {@link LanguageModelChatResponse}, and also can be
|
|
18298
|
+
* included as a content part on a {@link LanguageModelChatMessage}, to represent a previous tool call in a chat request.
|
|
18299
|
+
* @stubbed
|
|
18300
|
+
*/
|
|
18301
|
+
export class LanguageModelToolCallPart {
|
|
18302
|
+
/**
|
|
18303
|
+
* The ID of the tool call. This is a unique identifier for the tool call within the chat request.
|
|
18304
|
+
*/
|
|
18305
|
+
callId: string;
|
|
18306
|
+
|
|
18307
|
+
/**
|
|
18308
|
+
* The name of the tool to call.
|
|
18309
|
+
*/
|
|
18310
|
+
name: string;
|
|
18311
|
+
|
|
18312
|
+
/**
|
|
18313
|
+
* The input with which to call the tool.
|
|
18314
|
+
*/
|
|
18315
|
+
input: object;
|
|
18316
|
+
|
|
18317
|
+
/**
|
|
18318
|
+
* Create a new LanguageModelToolCallPart.
|
|
18319
|
+
*
|
|
18320
|
+
* @param callId The ID of the tool call.
|
|
18321
|
+
* @param name The name of the tool to call.
|
|
18322
|
+
* @param input The input with which to call the tool.
|
|
18323
|
+
*/
|
|
18324
|
+
constructor(callId: string, name: string, input: object);
|
|
18325
|
+
}
|
|
18326
|
+
|
|
18327
|
+
/**
|
|
18328
|
+
* The result of a tool call. This is the counterpart of a {@link LanguageModelToolCallPart tool call} and
|
|
18329
|
+
* it can only be included in the content of a User message
|
|
18330
|
+
* @stubbed
|
|
18331
|
+
*/
|
|
18332
|
+
export class LanguageModelToolResultPart {
|
|
18333
|
+
/**
|
|
18334
|
+
* The ID of the tool call.
|
|
18335
|
+
*
|
|
18336
|
+
* *Note* that this should match the {@link LanguageModelToolCallPart.callId callId} of a tool call part.
|
|
18337
|
+
*/
|
|
18338
|
+
callId: string;
|
|
18339
|
+
|
|
18340
|
+
/**
|
|
18341
|
+
* The value of the tool result.
|
|
18342
|
+
*/
|
|
18343
|
+
content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[];
|
|
18344
|
+
|
|
18345
|
+
/**
|
|
18346
|
+
* @param callId The ID of the tool call.
|
|
18347
|
+
* @param content The content of the tool result.
|
|
18348
|
+
*/
|
|
18349
|
+
constructor(callId: string, content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[]);
|
|
18350
|
+
}
|
|
18351
|
+
|
|
18352
|
+
/**
|
|
18353
|
+
* A language model response part containing a piece of text, returned from a {@link LanguageModelChatResponse}.
|
|
18354
|
+
* @stubbed
|
|
18355
|
+
*/
|
|
18356
|
+
export class LanguageModelTextPart {
|
|
18357
|
+
/**
|
|
18358
|
+
* The text content of the part.
|
|
18359
|
+
*/
|
|
18360
|
+
value: string;
|
|
18361
|
+
|
|
18362
|
+
/**
|
|
18363
|
+
* Construct a text part with the given content.
|
|
18364
|
+
* @param value The text content of the part.
|
|
18365
|
+
*/
|
|
18366
|
+
constructor(value: string);
|
|
18367
|
+
}
|
|
18368
|
+
|
|
18369
|
+
/**
|
|
18370
|
+
* A language model response part containing a PromptElementJSON from `@vscode/prompt-tsx`.
|
|
18371
|
+
* @see {@link LanguageModelToolResult}
|
|
18372
|
+
* @stubbed
|
|
18373
|
+
*/
|
|
18374
|
+
export class LanguageModelPromptTsxPart {
|
|
18375
|
+
/**
|
|
18376
|
+
* The value of the part.
|
|
18377
|
+
*/
|
|
18378
|
+
value: unknown;
|
|
18379
|
+
|
|
18380
|
+
/**
|
|
18381
|
+
* Construct a prompt-tsx part with the given content.
|
|
18382
|
+
* @param value The value of the part, the result of `renderPromptElementJSON` from `@vscode/prompt-tsx`.
|
|
18383
|
+
*/
|
|
18384
|
+
constructor(value: unknown);
|
|
18385
|
+
}
|
|
18386
|
+
|
|
18387
|
+
/**
|
|
18388
|
+
* A result returned from a tool invocation. If using `@vscode/prompt-tsx`, this result may be rendered using a `ToolResult`.
|
|
18389
|
+
* @stubbed
|
|
18390
|
+
*/
|
|
18391
|
+
export class LanguageModelToolResult {
|
|
18392
|
+
/**
|
|
18393
|
+
* A list of tool result content parts. Includes `unknown` becauses this list may be extended with new content types in
|
|
18394
|
+
* the future.
|
|
18395
|
+
* @see {@link lm.invokeTool}.
|
|
18396
|
+
*/
|
|
18397
|
+
content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[];
|
|
18398
|
+
|
|
18399
|
+
/**
|
|
18400
|
+
* Create a LanguageModelToolResult
|
|
18401
|
+
* @param content A list of tool result content parts
|
|
18402
|
+
*/
|
|
18403
|
+
constructor(content: (LanguageModelTextPart | LanguageModelPromptTsxPart)[]);
|
|
18404
|
+
}
|
|
18405
|
+
|
|
18406
|
+
/**
|
|
18407
|
+
* A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
|
|
18408
|
+
*/
|
|
18409
|
+
export type ChatParticipantToolToken = never;
|
|
18410
|
+
|
|
18411
|
+
/**
|
|
18412
|
+
* Options provided for tool invocation.
|
|
18413
|
+
* @stubbed
|
|
18414
|
+
*/
|
|
18415
|
+
export interface LanguageModelToolInvocationOptions<T> {
|
|
18416
|
+
/**
|
|
18417
|
+
* An opaque object that ties a tool invocation to a chat request from a {@link ChatParticipant chat participant}.
|
|
18418
|
+
*
|
|
18419
|
+
* The _only_ way to get a valid tool invocation token is using the provided {@link ChatRequest.toolInvocationToken toolInvocationToken}
|
|
18420
|
+
* from a chat request. In that case, a progress bar will be automatically shown for the tool invocation in the chat response view, and if
|
|
18421
|
+
* the tool requires user confirmation, it will show up inline in the chat view.
|
|
18422
|
+
*
|
|
18423
|
+
* If the tool is being invoked outside of a chat request, `undefined` should be passed instead, and no special UI except for
|
|
18424
|
+
* confirmations will be shown.
|
|
18425
|
+
*
|
|
18426
|
+
* *Note* that a tool that invokes another tool during its invocation, can pass along the `toolInvocationToken` that it received.
|
|
18427
|
+
*/
|
|
18428
|
+
toolInvocationToken: ChatParticipantToolToken | undefined;
|
|
18429
|
+
|
|
18430
|
+
/**
|
|
18431
|
+
* The input with which to invoke the tool. The input must match the schema defined in
|
|
18432
|
+
* {@link LanguageModelToolInformation.inputSchema}
|
|
18433
|
+
*/
|
|
18434
|
+
input: T;
|
|
18435
|
+
|
|
18436
|
+
/**
|
|
18437
|
+
* Options to hint at how many tokens the tool should return in its response, and enable the tool to count tokens
|
|
18438
|
+
* accurately.
|
|
18439
|
+
*/
|
|
18440
|
+
tokenizationOptions?: LanguageModelToolTokenizationOptions;
|
|
18441
|
+
}
|
|
18442
|
+
|
|
18443
|
+
/**
|
|
18444
|
+
* Options related to tokenization for a tool invocation.
|
|
18445
|
+
* @stubbed
|
|
18446
|
+
*/
|
|
18447
|
+
export interface LanguageModelToolTokenizationOptions {
|
|
18448
|
+
/**
|
|
18449
|
+
* If known, the maximum number of tokens the tool should emit in its result.
|
|
18450
|
+
*/
|
|
18451
|
+
tokenBudget: number;
|
|
18452
|
+
|
|
18453
|
+
/**
|
|
18454
|
+
* Count the number of tokens in a message using the model specific tokenizer-logic.
|
|
18455
|
+
* @param text A string.
|
|
18456
|
+
* @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
|
|
18457
|
+
* @returns A thenable that resolves to the number of tokens.
|
|
18458
|
+
*/
|
|
18459
|
+
countTokens(text: string, token?: CancellationToken): Thenable<number>;
|
|
18460
|
+
}
|
|
18461
|
+
|
|
18462
|
+
/**
|
|
18463
|
+
* Information about a registered tool available in {@link lm.tools}.
|
|
18464
|
+
* @stubbed
|
|
18465
|
+
*/
|
|
18466
|
+
export interface LanguageModelToolInformation {
|
|
18467
|
+
/**
|
|
18468
|
+
* A unique name for the tool.
|
|
18469
|
+
*/
|
|
18470
|
+
readonly name: string;
|
|
18471
|
+
|
|
18472
|
+
/**
|
|
18473
|
+
* A description of this tool that may be passed to a language model.
|
|
18474
|
+
*/
|
|
18475
|
+
readonly description: string;
|
|
18476
|
+
|
|
18477
|
+
/**
|
|
18478
|
+
* A JSON schema for the input this tool accepts.
|
|
18479
|
+
*/
|
|
18480
|
+
readonly inputSchema: object | undefined;
|
|
18481
|
+
|
|
18482
|
+
/**
|
|
18483
|
+
* A set of tags, declared by the tool, that roughly describe the tool's capabilities. A tool user may use these to filter
|
|
18484
|
+
* the set of tools to just ones that are relevant for the task at hand.
|
|
18485
|
+
*/
|
|
18486
|
+
readonly tags: readonly string[];
|
|
18487
|
+
}
|
|
18488
|
+
|
|
18489
|
+
/**
|
|
18490
|
+
* Options for {@link LanguageModelTool.prepareInvocation}.
|
|
18491
|
+
* @stubbed
|
|
18492
|
+
*/
|
|
18493
|
+
export interface LanguageModelToolInvocationPrepareOptions<T> {
|
|
18494
|
+
/**
|
|
18495
|
+
* The input that the tool is being invoked with.
|
|
18496
|
+
*/
|
|
18497
|
+
input: T;
|
|
18498
|
+
}
|
|
18499
|
+
|
|
18500
|
+
/**
|
|
18501
|
+
* A tool that can be invoked by a call to a {@link LanguageModelChat}.
|
|
18502
|
+
* @stubbed
|
|
18503
|
+
*/
|
|
18504
|
+
export interface LanguageModelTool<T> {
|
|
18505
|
+
/**
|
|
18506
|
+
* Invoke the tool with the given input and return a result.
|
|
18507
|
+
*
|
|
18508
|
+
* The provided {@link LanguageModelToolInvocationOptions.input} has been validated against the declared schema.
|
|
18509
|
+
*/
|
|
18510
|
+
invoke(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolResult>;
|
|
18511
|
+
|
|
18512
|
+
/**
|
|
18513
|
+
* Called once before a tool is invoked. It's recommended to implement this to customize the progress message that appears
|
|
18514
|
+
* while the tool is running, and to provide a more useful message with context from the invocation input. Can also
|
|
18515
|
+
* signal that a tool needs user confirmation before running, if appropriate.
|
|
18516
|
+
*
|
|
18517
|
+
* * *Note 1:* Must be free of side-effects.
|
|
18518
|
+
* * *Note 2:* A call to `prepareInvocation` is not necessarily followed by a call to `invoke`.
|
|
18519
|
+
*/
|
|
18520
|
+
prepareInvocation?(options: LanguageModelToolInvocationPrepareOptions<T>, token: CancellationToken): ProviderResult<PreparedToolInvocation>;
|
|
18521
|
+
}
|
|
18522
|
+
|
|
18523
|
+
/**
|
|
18524
|
+
* When this is returned in {@link PreparedToolInvocation}, the user will be asked to confirm before running the tool. These
|
|
18525
|
+
* messages will be shown with buttons that say "Continue" and "Cancel".
|
|
18526
|
+
* @stubbed
|
|
18527
|
+
*/
|
|
18528
|
+
export interface LanguageModelToolConfirmationMessages {
|
|
18529
|
+
/**
|
|
18530
|
+
* The title of the confirmation message.
|
|
18531
|
+
*/
|
|
18532
|
+
title: string;
|
|
18533
|
+
|
|
18534
|
+
/**
|
|
18535
|
+
* The body of the confirmation message.
|
|
18536
|
+
*/
|
|
18537
|
+
message: string | MarkdownString;
|
|
18538
|
+
}
|
|
18539
|
+
|
|
18540
|
+
/**
|
|
18541
|
+
* The result of a call to {@link LanguageModelTool.prepareInvocation}.
|
|
18542
|
+
* @stubbed
|
|
18543
|
+
*/
|
|
18544
|
+
export interface PreparedToolInvocation {
|
|
18545
|
+
/**
|
|
18546
|
+
* A customized progress message to show while the tool runs.
|
|
18547
|
+
*/
|
|
18548
|
+
invocationMessage?: string;
|
|
18549
|
+
|
|
18550
|
+
/**
|
|
18551
|
+
* The presence of this property indicates that the user should be asked to confirm before running the tool. The user
|
|
18552
|
+
* should be asked for confirmation for any tool that has a side-effect or may potentially be dangerous.
|
|
18553
|
+
*/
|
|
18554
|
+
confirmationMessages?: LanguageModelToolConfirmationMessages;
|
|
18555
|
+
}
|
|
18556
|
+
|
|
18557
|
+
/**
|
|
18558
|
+
* A reference to a tool that the user manually attached to their request, either using the `#`-syntax inline, or as an
|
|
18559
|
+
* attachment via the paperclip button.
|
|
18560
|
+
* @stubbed
|
|
18561
|
+
*/
|
|
18562
|
+
export interface ChatLanguageModelToolReference {
|
|
18563
|
+
/**
|
|
18564
|
+
* The tool name. Refers to a tool listed in {@link lm.tools}.
|
|
18565
|
+
*/
|
|
18566
|
+
readonly name: string;
|
|
18567
|
+
|
|
18568
|
+
/**
|
|
18569
|
+
* The start and end index of the reference in the {@link ChatRequest.prompt prompt}. When undefined, the reference was
|
|
18570
|
+
* not part of the prompt text.
|
|
18571
|
+
*
|
|
18572
|
+
* *Note* that the indices take the leading `#`-character into account which means they can be used to modify the prompt
|
|
18573
|
+
* as-is.
|
|
18574
|
+
*/
|
|
18575
|
+
readonly range?: [start: number, end: number];
|
|
18112
18576
|
}
|
|
18113
18577
|
|
|
18114
18578
|
/**
|
|
@@ -35,6 +35,7 @@ export module '@theia/plugin' {
|
|
|
35
35
|
export interface ConversationResponse {
|
|
36
36
|
readonly type: 'response';
|
|
37
37
|
readonly message: string;
|
|
38
|
+
readonly result?: ChatResult;
|
|
38
39
|
readonly references?: DocumentContextItem[];
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -69,7 +70,7 @@ export module '@theia/plugin' {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
export interface MappedEditsRequest {
|
|
72
|
-
readonly codeBlocks: { code: string; resource: Uri }[];
|
|
73
|
+
readonly codeBlocks: { code: string; resource: Uri; markdownBeforeBlock?: string }[];
|
|
73
74
|
// for every prior response that contains codeblocks, make sure we pass the code as well as the resources based on the reported codemapper URIs
|
|
74
75
|
readonly conversation: (ConversationRequest | ConversationResponse)[];
|
|
75
76
|
}
|