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

Provider registry #50

Merged
merged 9 commits into from
Mar 7, 2025
Merged

Provider registry #50

merged 9 commits into from
Mar 7, 2025

Conversation

brichet
Copy link
Collaborator

@brichet brichet commented Mar 3, 2025

This PR replaces the AIProvider to a registry, to allow third party extensions to add providers.
Fixes #45

This registry is provided using a token, and providers can be added to it.
A provider must have the following interface:

export interface IAIProvider {
  /**
   * The name of the provider.
   */
  name: string;
  /**
   * The chat model class to use.
   */
  chatModel?: IType<BaseChatModel>;
  /**
   * The completer class to use.
   */
  completer?: IType<IBaseCompleter>;
  /**
   * the settings schema for the provider.
   */
  settingsSchema?: any;
  /**
   * The instructions to be displayed in the settings, as helper to use the provider.
   * A markdown renderer is used to render the instructions.
   */
  instructions?: string;
  /**
   * A function that extract the error message from the provider API error.
   * Default to `(error) => error.message`.
   */
  errorMessage?: (error: any) => string;
}

Most of the fields are optional because a provider can do only completion or chat, and can required no settings to work.

@brichet brichet added the enhancement New feature or request label Mar 3, 2025
@brichet brichet force-pushed the provider_registry branch from 70e886b to b7b9f66 Compare March 7, 2025 10:39
@brichet brichet marked this pull request as ready for review March 7, 2025 12:38
@brichet
Copy link
Collaborator Author

brichet commented Mar 7, 2025

In follow up PRs (to reduce the size of this PR's changes) we could:

  • reorganize the repository for a better readability, to have a default-providers directory. This directory could contain one directory per provider, each including the completer class, the generated settings and the instructions
    - default-providers
      - MistralAI
        - completer.ts
        - instructions.md
        - settings.json
      - OpenAI
        - ...
    
  • add one plugin per 'default provider', to allow third party extensions to disable them

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

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

Thanks!

@jtpio jtpio merged commit bd9c07a into jupyterlite:main Mar 7, 2025
7 checks passed
@brichet brichet deleted the provider_registry branch March 7, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom providers via third-party extensions
2 participants