-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vscode] Stub Chat and Language Model API #13778
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3846,3 +3846,99 @@ export class TerminalQuickFixOpener { | |
constructor(uri: theia.Uri) { } | ||
} | ||
|
||
// #region Chat | ||
export class ChatRequestTurn { | ||
readonly prompt: string; | ||
readonly participant: string; | ||
readonly command?: string; | ||
readonly references: theia.ChatPromptReference[]; | ||
private constructor(prompt: string, command: string | undefined, references: theia.ChatPromptReference[], participant: string) { | ||
this.prompt = prompt; | ||
this.command = command; | ||
this.participant = participant; | ||
this.references = references; | ||
}; | ||
} | ||
|
||
export class ChatResponseTurn { | ||
readonly command?: string; | ||
|
||
private constructor(public readonly response: ReadonlyArray<theia.ChatResponseMarkdownPart | theia.ChatResponseFileTreePart | theia.ChatResponseAnchorPart | ||
| theia.ChatResponseCommandButtonPart>, public readonly result: theia.ChatResult, public readonly participant: string) { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be addressed in the new commit. |
||
} | ||
|
||
export class ChatResponseAnchorPart { | ||
constructor(public value: URI | Location, public title?: string) { } | ||
} | ||
|
||
export class ChatResponseProgressPart { | ||
constructor(public value: string) { } | ||
} | ||
|
||
export class ChatResponseReferencePart { | ||
constructor(public value: URI | theia.Location, public iconPath?: URI | ThemeIcon | { | ||
light: URI; | ||
dark: URI; | ||
}) { } | ||
} | ||
export class ChatResponseCommandButtonPart { | ||
constructor(public value: theia.Command) { } | ||
} | ||
|
||
export class ChatResponseMarkdownPart { | ||
constructor(public value: string | theia.MarkdownString) { } | ||
} | ||
|
||
export class ChatResponseFileTreePart { | ||
constructor(public value: theia.ChatResponseFileTree[], public baseUri: URI) { } | ||
} | ||
|
||
export type ChatResponsePart = ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ||
| ChatResponseProgressPart | ChatResponseReferencePart | ChatResponseCommandButtonPart; | ||
|
||
export enum ChatResultFeedbackKind { | ||
Unhelpful = 0, | ||
Helpful = 1, | ||
} | ||
|
||
export enum LanguageModelChatMessageRole { | ||
User = 1, | ||
Assistant = 2 | ||
} | ||
|
||
export class LanguageModelChatMessage { | ||
|
||
static User(content: string, name?: string): LanguageModelChatMessage { | ||
return new LanguageModelChatMessage(LanguageModelChatMessageRole.User, content, name); | ||
} | ||
|
||
static Assistant(content: string, name?: string): LanguageModelChatMessage { | ||
return new LanguageModelChatMessage(LanguageModelChatMessageRole.Assistant, content, name); | ||
} | ||
|
||
constructor(public role: LanguageModelChatMessageRole, public content: string, public name?: string) { } | ||
} | ||
|
||
export class LanguageModelError extends Error { | ||
|
||
static NoPermissions(message?: string): LanguageModelError { | ||
return new LanguageModelError(message, LanguageModelError.NotFound.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems strange when reading (https://code.visualstudio.com/api/references/vscode-api#LanguageModelError). What should the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this part. The LanguageModelError NoPermissions/NotFound/Blocked should now have the correct code. BTW, due to Typescript version used, the 'cause' property used in VS code in the constructor is not available yet (es2022). Is there a way to track these issues, as we do for the monaco uplift annotations? should we introduce a typescript-uplift annotation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt this is an issue of the typescript version: we are using 5.4 at the moment, which is fairly new. I figure the problem is with the compilation target, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the problem is the target |
||
} | ||
|
||
static Blocked(message?: string): LanguageModelError { | ||
return new LanguageModelError(message); | ||
} | ||
|
||
static NotFound(message?: string): LanguageModelError { | ||
return new LanguageModelError(message); | ||
} | ||
|
||
readonly code: string; | ||
|
||
constructor(message?: string, code?: string) { | ||
super(message); | ||
this.name = 'LanguageModelError'; | ||
this.code = code ?? ''; | ||
} | ||
} | ||
// #endregion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just assign the passed-in request handler instead of a dummy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in new commit