@jupyterlite/ai 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/lib/chat-handler.d.ts +7 -1
  2. package/lib/chat-handler.js +29 -0
  3. package/lib/completion-provider.d.ts +1 -1
  4. package/lib/{llm-models/anthropic-completer.d.ts → default-providers/Anthropic/completer.d.ts} +1 -1
  5. package/lib/{llm-models/anthropic-completer.js → default-providers/Anthropic/completer.js} +1 -1
  6. package/lib/{llm-models/chrome-completer.d.ts → default-providers/ChromeAI/completer.d.ts} +1 -1
  7. package/lib/{llm-models/chrome-completer.js → default-providers/ChromeAI/completer.js} +1 -1
  8. package/lib/default-providers/ChromeAI/instructions.d.ts +2 -0
  9. package/lib/default-providers/ChromeAI/instructions.js +24 -0
  10. package/lib/{llm-models/codestral-completer.d.ts → default-providers/MistralAI/completer.d.ts} +1 -1
  11. package/lib/{llm-models/codestral-completer.js → default-providers/MistralAI/completer.js} +1 -1
  12. package/lib/default-providers/MistralAI/instructions.d.ts +2 -0
  13. package/lib/default-providers/MistralAI/instructions.js +16 -0
  14. package/lib/{llm-models/openai-completer.d.ts → default-providers/OpenAI/completer.d.ts} +1 -1
  15. package/lib/{llm-models/openai-completer.js → default-providers/OpenAI/completer.js} +1 -1
  16. package/lib/default-providers/index.d.ts +2 -0
  17. package/lib/default-providers/index.js +60 -0
  18. package/lib/index.d.ts +2 -2
  19. package/lib/index.js +17 -32
  20. package/lib/provider.d.ts +1 -1
  21. package/lib/settings/panel.d.ts +14 -0
  22. package/lib/settings/panel.js +82 -5
  23. package/lib/tokens.d.ts +1 -1
  24. package/package.json +8 -5
  25. package/schema/provider-registry.json +6 -0
  26. package/src/chat-handler.ts +34 -0
  27. package/src/completion-provider.ts +1 -1
  28. package/src/{llm-models/anthropic-completer.ts → default-providers/Anthropic/completer.ts} +2 -2
  29. package/src/{llm-models/chrome-completer.ts → default-providers/ChromeAI/completer.ts} +3 -2
  30. package/src/default-providers/ChromeAI/instructions.ts +24 -0
  31. package/src/{llm-models/codestral-completer.ts → default-providers/MistralAI/completer.ts} +2 -2
  32. package/src/default-providers/MistralAI/instructions.ts +16 -0
  33. package/src/{llm-models/openai-completer.ts → default-providers/OpenAI/completer.ts} +2 -2
  34. package/src/default-providers/index.ts +71 -0
  35. package/src/index.ts +25 -42
  36. package/src/provider.ts +1 -1
  37. package/src/settings/panel.tsx +93 -4
  38. package/src/tokens.ts +1 -1
  39. package/lib/llm-models/index.d.ts +0 -4
  40. package/lib/llm-models/index.js +0 -43
  41. package/lib/settings/instructions.d.ts +0 -2
  42. package/lib/settings/instructions.js +0 -44
  43. package/lib/settings/schemas/index.d.ts +0 -3
  44. package/lib/settings/schemas/index.js +0 -11
  45. package/lib/slash-commands.d.ts +0 -16
  46. package/lib/slash-commands.js +0 -25
  47. package/src/llm-models/index.ts +0 -50
  48. package/src/settings/instructions.ts +0 -48
  49. package/src/settings/schemas/index.ts +0 -15
  50. package/src/slash-commands.tsx +0 -55
  51. /package/lib/{llm-models/base-completer.d.ts → base-completer.d.ts} +0 -0
  52. /package/lib/{llm-models/base-completer.js → base-completer.js} +0 -0
  53. /package/lib/{settings/schemas/_generated/Anthropic.json → default-providers/Anthropic/settings-schema.json} +0 -0
  54. /package/lib/{settings/schemas/_generated/ChromeAI.json → default-providers/ChromeAI/settings-schema.json} +0 -0
  55. /package/lib/{settings/schemas/_generated/MistralAI.json → default-providers/MistralAI/settings-schema.json} +0 -0
  56. /package/lib/{settings/schemas/_generated/OpenAI.json → default-providers/OpenAI/settings-schema.json} +0 -0
  57. /package/lib/settings/{schemas/base.json → base.json} +0 -0
  58. /package/src/{llm-models/base-completer.ts → base-completer.ts} +0 -0
  59. /package/src/{llm-models/svg.d.ts → global.d.ts} +0 -0
@@ -1,3 +0,0 @@
1
- import { IDict } from '../../tokens';
2
- declare const ProviderSettings: IDict<any>;
3
- export { ProviderSettings };
@@ -1,11 +0,0 @@
1
- import ChromeAI from './_generated/ChromeAI.json';
2
- import MistralAI from './_generated/MistralAI.json';
3
- import Anthropic from './_generated/Anthropic.json';
4
- import OpenAI from './_generated/OpenAI.json';
5
- const ProviderSettings = {
6
- ChromeAI,
7
- MistralAI,
8
- Anthropic,
9
- OpenAI
10
- };
11
- export { ProviderSettings };
@@ -1,16 +0,0 @@
1
- /**
2
- * TODO: reuse from Jupyter AI instead of copying?
3
- * https://github.com/jupyterlab/jupyter-ai/blob/main/packages/jupyter-ai/src/slash-autocompletion.tsx
4
- */
5
- /// <reference types="react-addons-linked-state-mixin" />
6
- import { AutocompleteCommand } from '@jupyter/chat';
7
- import React from 'react';
8
- type SlashCommandOption = AutocompleteCommand & {
9
- id: string;
10
- description: string;
11
- };
12
- /**
13
- * Renders an option shown in the slash command autocomplete.
14
- */
15
- export declare function renderSlashCommandOption(optionProps: React.HTMLAttributes<HTMLLIElement>, option: SlashCommandOption): JSX.Element;
16
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * TODO: reuse from Jupyter AI instead of copying?
3
- * https://github.com/jupyterlab/jupyter-ai/blob/main/packages/jupyter-ai/src/slash-autocompletion.tsx
4
- */
5
- import { Box, Typography } from '@mui/material';
6
- import HideSource from '@mui/icons-material/HideSource';
7
- import React from 'react';
8
- const DEFAULT_SLASH_COMMAND_ICONS = {
9
- clear: React.createElement(HideSource, null)
10
- };
11
- /**
12
- * Renders an option shown in the slash command autocomplete.
13
- */
14
- export function renderSlashCommandOption(optionProps, option) {
15
- const icon = option.id in DEFAULT_SLASH_COMMAND_ICONS
16
- ? DEFAULT_SLASH_COMMAND_ICONS[option.id]
17
- : DEFAULT_SLASH_COMMAND_ICONS.unknown;
18
- return (React.createElement("li", { ...optionProps },
19
- React.createElement(Box, { sx: { lineHeight: 0, marginRight: 4, opacity: 0.618 } }, icon),
20
- React.createElement(Box, { sx: { flexGrow: 1 } },
21
- React.createElement(Typography, { component: "span", sx: {
22
- fontSize: 'var(--jp-ui-font-size1)'
23
- } }, option.label),
24
- React.createElement(Typography, { component: "span", sx: { opacity: 0.618, fontSize: 'var(--jp-ui-font-size0)' } }, ' — ' + option.description))));
25
- }
@@ -1,50 +0,0 @@
1
- import { ChatAnthropic } from '@langchain/anthropic';
2
- import { ChromeAI } from '@langchain/community/experimental/llms/chrome_ai';
3
- import { ChatMistralAI } from '@langchain/mistralai';
4
- import { ChatOpenAI } from '@langchain/openai';
5
-
6
- import { AnthropicCompleter } from './anthropic-completer';
7
- import { CodestralCompleter } from './codestral-completer';
8
- import { ChromeCompleter } from './chrome-completer';
9
- import { OpenAICompleter } from './openai-completer';
10
-
11
- import { instructions } from '../settings/instructions';
12
- import { ProviderSettings } from '../settings/schemas';
13
-
14
- import { IAIProvider } from '../tokens';
15
-
16
- export * from './base-completer';
17
-
18
- const AIProviders: IAIProvider[] = [
19
- {
20
- name: 'Anthropic',
21
- chatModel: ChatAnthropic,
22
- completer: AnthropicCompleter,
23
- settingsSchema: ProviderSettings.Anthropic,
24
- errorMessage: (error: any) => error.error.error.message
25
- },
26
- {
27
- name: 'ChromeAI',
28
- // TODO: fix
29
- // @ts-expect-error: missing properties
30
- chatModel: ChromeAI,
31
- completer: ChromeCompleter,
32
- instructions: instructions.ChromeAI,
33
- settingsSchema: ProviderSettings.ChromeAI
34
- },
35
- {
36
- name: 'MistralAI',
37
- chatModel: ChatMistralAI,
38
- completer: CodestralCompleter,
39
- instructions: instructions.MistralAI,
40
- settingsSchema: ProviderSettings.MistralAI
41
- },
42
- {
43
- name: 'OpenAI',
44
- chatModel: ChatOpenAI,
45
- completer: OpenAICompleter,
46
- settingsSchema: ProviderSettings.OpenAI
47
- }
48
- ];
49
-
50
- export { AIProviders };
@@ -1,48 +0,0 @@
1
- import { IDict } from '../tokens';
2
-
3
- const chromeAiInstructions = `
4
- <i class="fas fa-exclamation-triangle"></i> Support for ChromeAI is still experimental and only available in Google Chrome.
5
-
6
- You can test ChromeAI is enabled in your browser by going to the following URL: https://chromeai.org/
7
-
8
- Enable the proper flags in Google Chrome.
9
-
10
- - chrome://flags/#prompt-api-for-gemini-nano
11
- - Select: \`Enabled\`
12
- - chrome://flags/#optimization-guide-on-device-model
13
- - Select: \`Enabled BypassPrefRequirement\`
14
- - chrome://components
15
- - Click \`Check for Update\` on Optimization Guide On Device Model to download the model
16
- - [Optional] chrome://flags/#text-safety-classifier
17
-
18
- <img src="https://github.com/user-attachments/assets/d48f46cc-52ee-4ce5-9eaf-c763cdbee04c" alt="A screenshot showing how to enable the ChromeAI flag in Google Chrome" width="500px">
19
-
20
- Then restart Chrome for these changes to take effect.
21
-
22
- <i class="fas fa-exclamation-triangle"></i> On first use, Chrome will download the on-device model, which can be as large as 22GB (according to their docs and at the time of writing).
23
- During the download, ChromeAI may not be available via the extension.
24
-
25
- <i class="fa fa-info-circle" aria-hidden="true"></i> For more information about Chrome Built-in AI: https://developer.chrome.com/docs/ai/get-started
26
- `;
27
-
28
- const mistralAIInstructions = `
29
- <i class="fas fa-exclamation-triangle"></i> This extension is still very much experimental. It is not an official MistralAI extension.
30
-
31
- 1. Go to https://console.mistral.ai/api-keys/ and create an API key.
32
-
33
- <img src="https://raw.githubusercontent.com/jupyterlite/ai/refs/heads/main/img/1-api-key.png" alt="Screenshot showing how to create an API key" width="500px">
34
-
35
- 2. Open the JupyterLab settings and go to the **Ai providers** section to select the \`MistralAI\`
36
- provider and the API key (required).
37
-
38
- <img src="https://raw.githubusercontent.com/jupyterlite/ai/refs/heads/main/img/2-jupyterlab-settings.png" alt="Screenshot showing how to add the API key to the settings" width="500px">
39
-
40
- 3. Open the chat, or use the inline completer
41
-
42
- <img src="https://raw.githubusercontent.com/jupyterlite/ai/refs/heads/main/img/3-usage.png" alt="Screenshot showing how to use the chat" width="500px">
43
- `;
44
-
45
- export const instructions: IDict = {
46
- ChromeAI: chromeAiInstructions,
47
- MistralAI: mistralAIInstructions
48
- };
@@ -1,15 +0,0 @@
1
- import { IDict } from '../../tokens';
2
-
3
- import ChromeAI from './_generated/ChromeAI.json';
4
- import MistralAI from './_generated/MistralAI.json';
5
- import Anthropic from './_generated/Anthropic.json';
6
- import OpenAI from './_generated/OpenAI.json';
7
-
8
- const ProviderSettings: IDict<any> = {
9
- ChromeAI,
10
- MistralAI,
11
- Anthropic,
12
- OpenAI
13
- };
14
-
15
- export { ProviderSettings };
@@ -1,55 +0,0 @@
1
- /**
2
- * TODO: reuse from Jupyter AI instead of copying?
3
- * https://github.com/jupyterlab/jupyter-ai/blob/main/packages/jupyter-ai/src/slash-autocompletion.tsx
4
- */
5
-
6
- import { Box, Typography } from '@mui/material';
7
- import { AutocompleteCommand } from '@jupyter/chat';
8
-
9
- import HideSource from '@mui/icons-material/HideSource';
10
-
11
- import React from 'react';
12
-
13
- const DEFAULT_SLASH_COMMAND_ICONS: Record<string, JSX.Element> = {
14
- clear: <HideSource />
15
- };
16
-
17
- type SlashCommandOption = AutocompleteCommand & {
18
- id: string;
19
- description: string;
20
- };
21
-
22
- /**
23
- * Renders an option shown in the slash command autocomplete.
24
- */
25
- export function renderSlashCommandOption(
26
- optionProps: React.HTMLAttributes<HTMLLIElement>,
27
- option: SlashCommandOption
28
- ): JSX.Element {
29
- const icon =
30
- option.id in DEFAULT_SLASH_COMMAND_ICONS
31
- ? DEFAULT_SLASH_COMMAND_ICONS[option.id]
32
- : DEFAULT_SLASH_COMMAND_ICONS.unknown;
33
-
34
- return (
35
- <li {...optionProps}>
36
- <Box sx={{ lineHeight: 0, marginRight: 4, opacity: 0.618 }}>{icon}</Box>
37
- <Box sx={{ flexGrow: 1 }}>
38
- <Typography
39
- component="span"
40
- sx={{
41
- fontSize: 'var(--jp-ui-font-size1)'
42
- }}
43
- >
44
- {option.label}
45
- </Typography>
46
- <Typography
47
- component="span"
48
- sx={{ opacity: 0.618, fontSize: 'var(--jp-ui-font-size0)' }}
49
- >
50
- {' — ' + option.description}
51
- </Typography>
52
- </Box>
53
- </li>
54
- );
55
- }
File without changes
File without changes