Skip to content
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

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

rschnekenbu
Copy link
Contributor

What it does

Stub the API for chat and Language Models introduced in VS Code 1.90.
Closes #13756

Status of the report when comparing with vscode 1.90: status.zip

How to test

  1. Start the theia browser example on master and install the following extension (derived from vscode sample extension chat-sample):
  1. On extension activation, some error messages are displayed in the console.
  2. With the PR, the API does not show any error on extension startup. extension context and calls to chat/lm namespaces do not throw any error.

Follow-ups

Real implementation of the API is tracked here: #13777

Review checklist

Reminder for reviewers

fixes eclipse-theia#13756

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
@rschnekenbu rschnekenbu marked this pull request as draft June 6, 2024 15:54
@rschnekenbu rschnekenbu changed the title Stub Chat and Language Model API [vscode] Stub Chat and Language Model API Jun 6, 2024
@rschnekenbu rschnekenbu marked this pull request as ready for review June 11, 2024 08:23
Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments.

packages/plugin/src/theia-extra.d.ts Show resolved Hide resolved
createChatParticipant(id: string, handler: theia.ChatRequestHandler): theia.ChatParticipant {
return {
id,
requestHandler: (request: theia.ChatRequest, context: theia.ChatContext, response: theia.ChatResponseStream, token: CancellationToken) => { },
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in new commit

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) { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public is not necessary, IMO. Goes for all similar occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be addressed in the new commit.

export class LanguageModelError extends Error {

static NoPermissions(message?: string): LanguageModelError {
return new LanguageModelError(message, LanguageModelError.NotFound.name);
Copy link
Contributor

Choose a reason for hiding this comment

The 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 Error.name and code properties be when we construct a LanguageModelError with the NoPermissions static method?Right now, it would becode === NotFoundandname === LanguageModelError, right? What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the problem is the target

@rschnekenbu rschnekenbu merged commit b16f49b into eclipse-theia:master Jun 25, 2024
14 checks passed
@rschnekenbu rschnekenbu deleted the issues/13756 branch June 25, 2024 10:29
@jfaltermeier jfaltermeier added this to the 1.51.0 milestone Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[vscode] Implement Chat and Language Model initial APIs
3 participants