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

Dev ai #264

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open

Dev ai #264

wants to merge 19 commits into from

Conversation

Bistard
Copy link
Owner

@Bistard Bistard commented Feb 1, 2025

Summary by Sourcery

Add support for configurable AI text models.

New Features:

  • Added a configuration option to select between different AI text models, including DeepSeek and GPT.

Tests:

  • Updated tests to cover the new AI text model configuration.

Copy link
Contributor

sourcery-ai bot commented Feb 1, 2025

Reviewer's Guide by Sourcery

This pull request introduces the ability to configure the AI text model used by the application. It also adds support for the DeepSeek model.

Class diagram for AI text service changes

classDiagram
    class IAITextService {
        <<interface>>
        +init(IAITextModelOpts)
    }
    class MainAITextService {
        -_modelType: TextModelType
        +init(IAITextModelOpts)
        -createModel()
    }
    class TextModelType {
        <<enumeration>>
        GPT
        DeepSeek
    }
    MainAITextService ..|> IAITextService
    note for MainAITextService "Added DeepSeek model support"
Loading

File-Level Changes

Change Details Files
Added a new configuration option to specify the AI text model.
  • Added AiTextModel to the WorkbenchConfiguration enum.
  • Added sharedApplicationConfigurationRegister to register the new configuration.
  • Added a new 'ai' section to the application configuration with a 'textModel' property.
  • Added sharedApplicationConfigurationRegister to the list of configuration registers.
src/workbench/services/workbench/configuration.register.ts
src/platform/configuration/common/configurationRegistrant.ts
Added support for the DeepSeek AI text model.
  • Added DeepSeek to the TextModelType enum.
  • Added a case for DeepSeek to the MainAITextService to return a new DeepSeekModel (currently returns a GPTModel).
src/platform/ai/electron/textAI.ts
src/platform/ai/electron/mainAITextService.ts
Introduced a service for AI text functionality.
  • Created IAITextService and createService for the AI text service.
  • Implemented IAITextService in MainAITextService.
src/platform/ai/electron/textAI.ts
src/platform/ai/electron/mainAITextService.ts
Moved EditorPaneDescriptor to its own file to resolve circular dependency.
  • Moved EditorPaneDescriptor to src/workbench/services/editorPane/editorPaneDescriptor.ts.
  • Updated imports in src/workbench/contrib/richTextEditor/editorPane.register.ts.
src/workbench/services/editorPane/editorPaneRegistrant.ts
src/workbench/contrib/richTextEditor/editorPane.register.ts
src/workbench/services/editorPane/editorPaneDescriptor.ts
Updated the openai dependency.
  • Updated the openai dependency to version 4.80.1.
package.json
package-lock.json
Updated the description of the format property in the json schema.
  • Updated the description of the format property to indicate that it is a regular expression.
src/base/common/json.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Bistard - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The MainAITextService returns GPTModel for both TextModelType.GPT and TextModelType.DeepSeek. If DeepSeek should have different behavior, it needs its own model implementation.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -53,6 +50,9 @@ export class MainAITextService extends Disposable implements IAITextService {
switch (this._modelType) {
case TextModelType.GPT:
return new GPTModel();
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): DeepSeek model type falls back to GPTModel without warning

This could cause unexpected behavior as users expecting DeepSeek will silently get GPT instead. Consider implementing DeepSeek model or throwing an error if not yet supported.

@@ -145,7 +145,7 @@ interface IJsonSchemaForString extends IJsonSchemaBase<'string'> {
/** The maximum length of the string. */
maxLength?: number;

/** The predefined format of the string. Example: 'email', 'phone number', 'post address' etc. */
/** The predefined format of the string (written Regular Expression). Example: 'email', 'phone number', 'post address' etc. */
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (typo): Incorrect documentation for JSON Schema format field

The format field in JSON Schema is for predefined format identifiers (like 'date-time', 'email', 'uri'), not for regular expressions. The pattern field is used for regex patterns.

Suggested change
/** The predefined format of the string (written Regular Expression). Example: 'email', 'phone number', 'post address' etc. */
/** The predefined format identifier as defined by JSON Schema. Example: 'date-time', 'email', 'uri', 'hostname' etc. */

@@ -1,4 +1,5 @@
import { CollapseState } from "src/base/browser/basic/dom";
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider simplifying the configuration registration by creating a helper function to reduce boilerplate and improve maintainability.

The configuration registration can be simplified by introducing a helper function while maintaining separation of concerns. For example:

// Helper function
function registerConfigSection<T extends string>(
  sectionName: string,
  properties: Record<string, {
    type: string,
    default: T,
    enum?: T[]
  }>
) {
  return createRegister(
    RegistrantType.Configuration,
    sectionName,
    (registrant) => {
      registrant.registerConfigurations({
        id: sectionName,
        properties: {
          [sectionName]: {
            type: 'object',
            properties
          }
        }
      });
    }
  );
}

// Usage for AI config
export const sharedApplicationConfigurationRegister = registerConfigSection(
  'ai',
  {
    textModel: {
      type: 'string',
      default: TextModelType.DeepSeek,
      enum: [TextModelType.DeepSeek, TextModelType.GPT]
    }
  }
);

This approach:

  • Reduces boilerplate while keeping configurations separate
  • Makes adding new configuration sections more concise
  • Maintains type safety
  • Preserves the existing functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant