-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making the LLM providers more generics (#10)
* WIP on making the LLM providers more generics * Update changes in settings to the chat and completion LLM * Cleaning and lint * Provides only one completion provider * Rename 'client' to 'provider' and LlmProvider to AIProvider for better readability
- Loading branch information
Showing
14 changed files
with
416 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"title": "AI provider", | ||
"description": "Provider settings", | ||
"type": "object", | ||
"properties": { | ||
"provider": { | ||
"type": "string", | ||
"title": "The AI provider", | ||
"description": "The AI provider to use for chat and completion", | ||
"default": "None", | ||
"enum": ["None", "MistralAI"] | ||
}, | ||
"apiKey": { | ||
"type": "string", | ||
"title": "The Codestral API key", | ||
"description": "The API key to use for Codestral", | ||
"default": "" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { | ||
CompletionHandler, | ||
IInlineCompletionContext, | ||
IInlineCompletionProvider | ||
} from '@jupyterlab/completer'; | ||
import { LLM } from '@langchain/core/language_models/llms'; | ||
|
||
import { getCompleter, IBaseCompleter } from './llm-models'; | ||
|
||
/** | ||
* The generic completion provider to register to the completion provider manager. | ||
*/ | ||
export class CompletionProvider implements IInlineCompletionProvider { | ||
readonly identifier = '@jupyterlite/ai'; | ||
|
||
constructor(options: CompletionProvider.IOptions) { | ||
this.name = options.name; | ||
} | ||
|
||
/** | ||
* Getter and setter of the name. | ||
* The setter will create the appropriate completer, accordingly to the name. | ||
*/ | ||
get name(): string { | ||
return this._name; | ||
} | ||
set name(name: string) { | ||
this._name = name; | ||
this._completer = getCompleter(name); | ||
} | ||
|
||
/** | ||
* get the current completer. | ||
*/ | ||
get completer(): IBaseCompleter | null { | ||
return this._completer; | ||
} | ||
|
||
/** | ||
* Get the LLM completer. | ||
*/ | ||
get llmCompleter(): LLM | null { | ||
return this._completer?.provider || null; | ||
} | ||
|
||
async fetch( | ||
request: CompletionHandler.IRequest, | ||
context: IInlineCompletionContext | ||
) { | ||
return this._completer?.fetch(request, context); | ||
} | ||
|
||
private _name: string = 'None'; | ||
private _completer: IBaseCompleter | null = null; | ||
} | ||
|
||
export namespace CompletionProvider { | ||
export interface IOptions { | ||
name: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
CompletionHandler, | ||
IInlineCompletionContext | ||
} from '@jupyterlab/completer'; | ||
import { LLM } from '@langchain/core/language_models/llms'; | ||
|
||
export interface IBaseCompleter { | ||
/** | ||
* The LLM completer. | ||
*/ | ||
provider: LLM; | ||
|
||
/** | ||
* The fetch request for the LLM completer. | ||
*/ | ||
fetch( | ||
request: CompletionHandler.IRequest, | ||
context: IInlineCompletionContext | ||
): Promise<any>; | ||
} |
Oops, something went wrong.