@jupyterlite/ai 0.8.0 → 0.9.0-a0

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 (162) hide show
  1. package/lib/agent.d.ts +233 -0
  2. package/lib/agent.js +604 -0
  3. package/lib/chat-model.d.ts +195 -0
  4. package/lib/chat-model.js +590 -0
  5. package/lib/completion/completion-provider.d.ts +83 -0
  6. package/lib/completion/completion-provider.js +209 -0
  7. package/lib/completion/index.d.ts +1 -0
  8. package/lib/completion/index.js +1 -0
  9. package/lib/components/clear-button.d.ts +18 -0
  10. package/lib/components/clear-button.js +31 -0
  11. package/lib/components/index.d.ts +3 -0
  12. package/lib/components/index.js +3 -0
  13. package/lib/components/model-select.d.ts +19 -0
  14. package/lib/components/model-select.js +154 -0
  15. package/lib/components/stop-button.d.ts +3 -3
  16. package/lib/components/stop-button.js +8 -9
  17. package/lib/components/token-usage-display.d.ts +45 -0
  18. package/lib/components/token-usage-display.js +74 -0
  19. package/lib/components/tool-select.d.ts +27 -0
  20. package/lib/components/tool-select.js +130 -0
  21. package/lib/icons.d.ts +3 -1
  22. package/lib/icons.js +10 -13
  23. package/lib/index.d.ts +4 -5
  24. package/lib/index.js +322 -167
  25. package/lib/mcp/browser.d.ts +68 -0
  26. package/lib/mcp/browser.js +132 -0
  27. package/lib/models/settings-model.d.ts +69 -0
  28. package/lib/models/settings-model.js +295 -0
  29. package/lib/providers/built-in-providers.d.ts +9 -0
  30. package/lib/providers/built-in-providers.js +192 -0
  31. package/lib/providers/models.d.ts +37 -0
  32. package/lib/providers/models.js +28 -0
  33. package/lib/providers/provider-registry.d.ts +94 -0
  34. package/lib/providers/provider-registry.js +155 -0
  35. package/lib/tokens.d.ts +157 -86
  36. package/lib/tokens.js +16 -12
  37. package/lib/tools/commands.d.ts +11 -0
  38. package/lib/tools/commands.js +126 -0
  39. package/lib/tools/file.d.ts +27 -0
  40. package/lib/tools/file.js +262 -0
  41. package/lib/tools/notebook.d.ts +40 -0
  42. package/lib/tools/notebook.js +762 -0
  43. package/lib/tools/tool-registry.d.ts +35 -0
  44. package/lib/tools/tool-registry.js +55 -0
  45. package/lib/widgets/ai-settings.d.ts +39 -0
  46. package/lib/widgets/ai-settings.js +506 -0
  47. package/lib/widgets/chat-wrapper.d.ts +144 -0
  48. package/lib/widgets/chat-wrapper.js +390 -0
  49. package/lib/widgets/provider-config-dialog.d.ts +13 -0
  50. package/lib/widgets/provider-config-dialog.js +104 -0
  51. package/package.json +150 -41
  52. package/schema/settings-model.json +153 -0
  53. package/src/agent.ts +800 -0
  54. package/src/chat-model.ts +770 -0
  55. package/src/completion/completion-provider.ts +308 -0
  56. package/src/completion/index.ts +1 -0
  57. package/src/components/clear-button.tsx +56 -0
  58. package/src/components/index.ts +3 -0
  59. package/src/components/model-select.tsx +245 -0
  60. package/src/components/stop-button.tsx +11 -11
  61. package/src/components/token-usage-display.tsx +130 -0
  62. package/src/components/tool-select.tsx +218 -0
  63. package/src/icons.ts +12 -14
  64. package/src/index.ts +468 -238
  65. package/src/mcp/browser.ts +213 -0
  66. package/src/models/settings-model.ts +409 -0
  67. package/src/providers/built-in-providers.ts +216 -0
  68. package/src/providers/models.ts +79 -0
  69. package/src/providers/provider-registry.ts +189 -0
  70. package/src/tokens.ts +203 -90
  71. package/src/tools/commands.ts +151 -0
  72. package/src/tools/file.ts +307 -0
  73. package/src/tools/notebook.ts +964 -0
  74. package/src/tools/tool-registry.ts +63 -0
  75. package/src/types.d.ts +4 -0
  76. package/src/widgets/ai-settings.tsx +1100 -0
  77. package/src/widgets/chat-wrapper.tsx +543 -0
  78. package/src/widgets/provider-config-dialog.tsx +256 -0
  79. package/style/base.css +335 -14
  80. package/style/icons/jupyternaut-lite.svg +1 -1
  81. package/lib/base-completer.d.ts +0 -49
  82. package/lib/base-completer.js +0 -14
  83. package/lib/chat-handler.d.ts +0 -56
  84. package/lib/chat-handler.js +0 -201
  85. package/lib/completion-provider.d.ts +0 -34
  86. package/lib/completion-provider.js +0 -32
  87. package/lib/default-prompts.d.ts +0 -2
  88. package/lib/default-prompts.js +0 -31
  89. package/lib/default-providers/Anthropic/completer.d.ts +0 -12
  90. package/lib/default-providers/Anthropic/completer.js +0 -46
  91. package/lib/default-providers/Anthropic/settings-schema.json +0 -70
  92. package/lib/default-providers/ChromeAI/completer.d.ts +0 -12
  93. package/lib/default-providers/ChromeAI/completer.js +0 -56
  94. package/lib/default-providers/ChromeAI/instructions.d.ts +0 -6
  95. package/lib/default-providers/ChromeAI/instructions.js +0 -42
  96. package/lib/default-providers/ChromeAI/settings-schema.json +0 -18
  97. package/lib/default-providers/Gemini/completer.d.ts +0 -12
  98. package/lib/default-providers/Gemini/completer.js +0 -48
  99. package/lib/default-providers/Gemini/instructions.d.ts +0 -2
  100. package/lib/default-providers/Gemini/instructions.js +0 -9
  101. package/lib/default-providers/Gemini/settings-schema.json +0 -64
  102. package/lib/default-providers/MistralAI/completer.d.ts +0 -13
  103. package/lib/default-providers/MistralAI/completer.js +0 -52
  104. package/lib/default-providers/MistralAI/instructions.d.ts +0 -2
  105. package/lib/default-providers/MistralAI/instructions.js +0 -18
  106. package/lib/default-providers/MistralAI/settings-schema.json +0 -75
  107. package/lib/default-providers/Ollama/completer.d.ts +0 -12
  108. package/lib/default-providers/Ollama/completer.js +0 -43
  109. package/lib/default-providers/Ollama/instructions.d.ts +0 -2
  110. package/lib/default-providers/Ollama/instructions.js +0 -70
  111. package/lib/default-providers/Ollama/settings-schema.json +0 -143
  112. package/lib/default-providers/OpenAI/completer.d.ts +0 -12
  113. package/lib/default-providers/OpenAI/completer.js +0 -43
  114. package/lib/default-providers/OpenAI/settings-schema.json +0 -628
  115. package/lib/default-providers/WebLLM/completer.d.ts +0 -21
  116. package/lib/default-providers/WebLLM/completer.js +0 -127
  117. package/lib/default-providers/WebLLM/instructions.d.ts +0 -6
  118. package/lib/default-providers/WebLLM/instructions.js +0 -32
  119. package/lib/default-providers/WebLLM/settings-schema.json +0 -19
  120. package/lib/default-providers/index.d.ts +0 -2
  121. package/lib/default-providers/index.js +0 -179
  122. package/lib/provider.d.ts +0 -144
  123. package/lib/provider.js +0 -412
  124. package/lib/settings/base.json +0 -7
  125. package/lib/settings/index.d.ts +0 -3
  126. package/lib/settings/index.js +0 -3
  127. package/lib/settings/panel.d.ts +0 -226
  128. package/lib/settings/panel.js +0 -510
  129. package/lib/settings/textarea.d.ts +0 -2
  130. package/lib/settings/textarea.js +0 -18
  131. package/lib/settings/utils.d.ts +0 -2
  132. package/lib/settings/utils.js +0 -4
  133. package/lib/types/ai-model.d.ts +0 -24
  134. package/lib/types/ai-model.js +0 -5
  135. package/schema/chat.json +0 -28
  136. package/schema/provider-registry.json +0 -29
  137. package/schema/system-prompts.json +0 -22
  138. package/src/base-completer.ts +0 -75
  139. package/src/chat-handler.ts +0 -262
  140. package/src/completion-provider.ts +0 -64
  141. package/src/default-prompts.ts +0 -33
  142. package/src/default-providers/Anthropic/completer.ts +0 -59
  143. package/src/default-providers/ChromeAI/completer.ts +0 -73
  144. package/src/default-providers/ChromeAI/instructions.ts +0 -45
  145. package/src/default-providers/Gemini/completer.ts +0 -61
  146. package/src/default-providers/Gemini/instructions.ts +0 -9
  147. package/src/default-providers/MistralAI/completer.ts +0 -69
  148. package/src/default-providers/MistralAI/instructions.ts +0 -18
  149. package/src/default-providers/Ollama/completer.ts +0 -54
  150. package/src/default-providers/Ollama/instructions.ts +0 -70
  151. package/src/default-providers/OpenAI/completer.ts +0 -54
  152. package/src/default-providers/WebLLM/completer.ts +0 -151
  153. package/src/default-providers/WebLLM/instructions.ts +0 -33
  154. package/src/default-providers/index.ts +0 -211
  155. package/src/global.d.ts +0 -9
  156. package/src/provider.ts +0 -514
  157. package/src/settings/index.ts +0 -3
  158. package/src/settings/panel.tsx +0 -773
  159. package/src/settings/textarea.tsx +0 -33
  160. package/src/settings/utils.ts +0 -5
  161. package/src/types/ai-model.ts +0 -37
  162. package/src/types/service-worker.d.ts +0 -6
@@ -1,48 +0,0 @@
1
- import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
2
- import { AIMessage, SystemMessage } from '@langchain/core/messages';
3
- import { BaseCompleter } from '../../base-completer';
4
- export class GeminiCompleter extends BaseCompleter {
5
- constructor(options) {
6
- super(options);
7
- this._completer = new ChatGoogleGenerativeAI({
8
- model: 'gemini-pro',
9
- ...options.settings
10
- });
11
- }
12
- async fetch(request, context) {
13
- const { text, offset: cursorOffset } = request;
14
- const prompt = text.slice(0, cursorOffset);
15
- const trimmedPrompt = prompt.trim();
16
- const messages = [
17
- new SystemMessage(this.systemPrompt),
18
- new AIMessage(trimmedPrompt)
19
- ];
20
- try {
21
- const response = await this._completer.invoke(messages);
22
- const items = [];
23
- // Gemini can return string or complex content, a list of string/images/other.
24
- if (typeof response.content === 'string') {
25
- items.push({
26
- insertText: response.content
27
- });
28
- }
29
- else {
30
- response.content.forEach(content => {
31
- if (content.type !== 'text') {
32
- return;
33
- }
34
- items.push({
35
- insertText: content.text,
36
- filterText: prompt.substring(trimmedPrompt.length)
37
- });
38
- });
39
- }
40
- return { items };
41
- }
42
- catch (error) {
43
- console.error('Error fetching completions', error);
44
- return { items: [] };
45
- }
46
- }
47
- _completer;
48
- }
@@ -1,2 +0,0 @@
1
- declare const _default: "\n<i class=\"fas fa-exclamation-triangle\"></i> This extension is still very much experimental. It is not an official Google extension.\n\n1. Go to <https://aistudio.google.com> and create an API key.\n\n2. Open the JupyterLab settings and go to the **Ai providers** section to select the `Gemini`\n provider and add your API key (required).\n3. Open the chat, or use the inline completer.\n";
2
- export default _default;
@@ -1,9 +0,0 @@
1
- export default `
2
- <i class="fas fa-exclamation-triangle"></i> This extension is still very much experimental. It is not an official Google extension.
3
-
4
- 1. Go to <https://aistudio.google.com> and create an API key.
5
-
6
- 2. Open the JupyterLab settings and go to the **Ai providers** section to select the \`Gemini\`
7
- provider and add your API key (required).
8
- 3. Open the chat, or use the inline completer.
9
- `;
@@ -1,64 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "type": "object",
4
- "properties": {
5
- "temperature": {
6
- "type": "number",
7
- "description": "Amount of randomness injected into the response. Ranges from 0 to 1. Use temp closer to 0 for analytical / multiple choice, and temp closer to 1 for creative and generative tasks."
8
- },
9
- "topK": {
10
- "type": "number",
11
- "description": "Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses."
12
- },
13
- "topP": {
14
- "type": "number",
15
- "description": "Nucleus sampling parameter. Only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation."
16
- },
17
- "maxOutputTokens": {
18
- "type": "number",
19
- "description": "The maximum number of tokens to generate in the response."
20
- },
21
- "stopSequences": {
22
- "type": "array",
23
- "items": {
24
- "type": "string"
25
- },
26
- "description": "A list of strings upon which to stop generating. You probably want something like [\"\\n\\nHuman:\"] for chat conversations."
27
- },
28
- "streaming": {
29
- "type": "boolean",
30
- "description": "Whether to stream the results or not"
31
- },
32
- "apiKey": {
33
- "type": "string",
34
- "description": "Google AI Studio API key"
35
- },
36
- "model": {
37
- "type": "string",
38
- "description": "Model name to use (e.g., gemini-pro, gemini-2.0-flash, etc.)",
39
- "default": "gemini-pro"
40
- },
41
- "baseURL": {
42
- "type": "string",
43
- "description": "Base URL for the Google AI API"
44
- },
45
- "safetySettings": {
46
- "type": "array",
47
- "description": "Safety settings for content filtering",
48
- "items": {
49
- "type": "object",
50
- "properties": {
51
- "category": {
52
- "type": "string"
53
- },
54
- "threshold": {
55
- "type": "string"
56
- }
57
- }
58
- }
59
- }
60
- },
61
- "additionalProperties": false,
62
- "description": "Input to Google Generative AI Chat class.",
63
- "definitions": {}
64
- }
@@ -1,13 +0,0 @@
1
- import { CompletionHandler, IInlineCompletionContext } from '@jupyterlab/completer';
2
- import { MistralAI } from '@langchain/mistralai';
3
- import { BaseCompleter } from '../../base-completer';
4
- export declare class CodestralCompleter extends BaseCompleter {
5
- constructor(options: BaseCompleter.IOptions);
6
- fetch(request: CompletionHandler.IRequest, context: IInlineCompletionContext): Promise<{
7
- items: {
8
- insertText: string;
9
- }[];
10
- }>;
11
- private _controller;
12
- protected _completer: MistralAI;
13
- }
@@ -1,52 +0,0 @@
1
- import { MistralAI } from '@langchain/mistralai';
2
- import { BaseCompleter } from '../../base-completer';
3
- const CODE_BLOCK_START_REGEX = /^```(?:[a-zA-Z]+)?\n?/;
4
- const CODE_BLOCK_END_REGEX = /```$/;
5
- export class CodestralCompleter extends BaseCompleter {
6
- constructor(options) {
7
- super(options);
8
- this._completer = new MistralAI({ ...options.settings });
9
- }
10
- async fetch(request, context) {
11
- try {
12
- const { text, offset: cursorOffset } = request;
13
- const prompt = this.systemPrompt.concat(text.slice(0, cursorOffset));
14
- const suffix = text.slice(cursorOffset);
15
- this._controller.abort();
16
- this._controller = new AbortController();
17
- const response = await this._completer.completionWithRetry({
18
- prompt,
19
- model: this._completer.model,
20
- suffix
21
- }, { signal: this._controller.signal }, false);
22
- const items = response.choices.map(choice => {
23
- const messageContent = choice.message.content;
24
- let content = '';
25
- if (typeof messageContent === 'string') {
26
- content = messageContent
27
- .replace(CODE_BLOCK_START_REGEX, '')
28
- .replace(CODE_BLOCK_END_REGEX, '');
29
- }
30
- else if (Array.isArray(messageContent)) {
31
- // Handle ContentChunk[] case - extract text content
32
- content = messageContent
33
- .filter(chunk => chunk.type === 'text')
34
- .map(chunk => chunk.text || '')
35
- .join('')
36
- .replace(CODE_BLOCK_START_REGEX, '')
37
- .replace(CODE_BLOCK_END_REGEX, '');
38
- }
39
- return {
40
- insertText: content
41
- };
42
- });
43
- return { items };
44
- }
45
- catch (error) {
46
- // the request may be aborted
47
- return { items: [] };
48
- }
49
- }
50
- _controller = new AbortController();
51
- _completer;
52
- }
@@ -1,2 +0,0 @@
1
- declare const _default: "\n<i class=\"fas fa-exclamation-triangle\"></i> This extension is still very much experimental. It is not an official MistralAI extension.\n\n1. Go to <https://console.mistral.ai/api-keys/> and create an API key.\n\n <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\">\n\n2. Open the JupyterLab settings and go to the **Ai providers** section to select the `MistralAI`\n provider and the API key (required).\n\n <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\">\n\n**Note:** When using MistralAI for completions, only a subset of models are available. Please check [this resource](https://docs.mistral.ai/api/#tag/fim) to see the list of supported models for completions.\n\n3. Open the chat, or use the inline completer\n\n <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\">\n";
2
- export default _default;
@@ -1,18 +0,0 @@
1
- export default `
2
- <i class="fas fa-exclamation-triangle"></i> This extension is still very much experimental. It is not an official MistralAI extension.
3
-
4
- 1. Go to <https://console.mistral.ai/api-keys/> and create an API key.
5
-
6
- <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">
7
-
8
- 2. Open the JupyterLab settings and go to the **Ai providers** section to select the \`MistralAI\`
9
- provider and the API key (required).
10
-
11
- <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">
12
-
13
- **Note:** When using MistralAI for completions, only a subset of models are available. Please check [this resource](https://docs.mistral.ai/api/#tag/fim) to see the list of supported models for completions.
14
-
15
- 3. Open the chat, or use the inline completer
16
-
17
- <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">
18
- `;
@@ -1,75 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "type": "object",
4
- "properties": {
5
- "streamUsage": {
6
- "type": "boolean",
7
- "description": "Whether or not to include token usage in the stream.",
8
- "default": true
9
- },
10
- "disableStreaming": {
11
- "type": "boolean",
12
- "description": "Whether to disable streaming.\n\nIf streaming is bypassed, then `stream()` will defer to `invoke()`.\n\n- If true, will always bypass streaming case.\n- If false (default), will always use streaming case if available."
13
- },
14
- "apiKey": {
15
- "type": "string",
16
- "description": "The API key to use.",
17
- "default": ""
18
- },
19
- "modelName": {
20
- "type": "string",
21
- "description": "The name of the model to use. Alias for `model`",
22
- "default": "mistral-small-latest"
23
- },
24
- "model": {
25
- "type": "string",
26
- "description": "The name of the model to use.",
27
- "default": "mistral-small-latest"
28
- },
29
- "endpoint": {
30
- "type": "string",
31
- "description": "Override the default endpoint."
32
- },
33
- "temperature": {
34
- "type": "number",
35
- "description": "What sampling temperature to use, between 0.0 and 2.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
36
- "default": 0.7
37
- },
38
- "topP": {
39
- "type": "number",
40
- "description": "Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. Should be between 0 and 1.",
41
- "default": 1
42
- },
43
- "maxTokens": {
44
- "type": "number",
45
- "description": "The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length."
46
- },
47
- "streaming": {
48
- "type": "boolean",
49
- "description": "Whether or not to stream the response.",
50
- "default": false
51
- },
52
- "safeMode": {
53
- "type": "boolean",
54
- "description": "Whether to inject a safety prompt before all conversations.",
55
- "default": false,
56
- "deprecated": "use safePrompt instead"
57
- },
58
- "safePrompt": {
59
- "type": "boolean",
60
- "description": "Whether to inject a safety prompt before all conversations.",
61
- "default": false
62
- },
63
- "randomSeed": {
64
- "type": "number",
65
- "description": "The seed to use for random sampling. If set, different calls will generate deterministic results. Alias for `seed`"
66
- },
67
- "seed": {
68
- "type": "number",
69
- "description": "The seed to use for random sampling. If set, different calls will generate deterministic results."
70
- }
71
- },
72
- "additionalProperties": false,
73
- "description": "Input to chat model class.",
74
- "definitions": {}
75
- }
@@ -1,12 +0,0 @@
1
- import { CompletionHandler, IInlineCompletionContext } from '@jupyterlab/completer';
2
- import { ChatOllama } from '@langchain/ollama';
3
- import { BaseCompleter } from '../../base-completer';
4
- export declare class OllamaCompleter extends BaseCompleter {
5
- constructor(options: BaseCompleter.IOptions);
6
- fetch(request: CompletionHandler.IRequest, context: IInlineCompletionContext): Promise<{
7
- items: {
8
- insertText: string;
9
- }[];
10
- }>;
11
- protected _completer: ChatOllama;
12
- }
@@ -1,43 +0,0 @@
1
- import { AIMessage, SystemMessage } from '@langchain/core/messages';
2
- import { ChatOllama } from '@langchain/ollama';
3
- import { BaseCompleter } from '../../base-completer';
4
- export class OllamaCompleter extends BaseCompleter {
5
- constructor(options) {
6
- super(options);
7
- this._completer = new ChatOllama({ ...options.settings });
8
- }
9
- async fetch(request, context) {
10
- const { text, offset: cursorOffset } = request;
11
- const prompt = text.slice(0, cursorOffset);
12
- const messages = [
13
- new SystemMessage(this.systemPrompt),
14
- new AIMessage(prompt)
15
- ];
16
- try {
17
- const response = await this._completer.invoke(messages);
18
- const items = [];
19
- if (typeof response.content === 'string') {
20
- items.push({
21
- insertText: response.content
22
- });
23
- }
24
- else {
25
- response.content.forEach(content => {
26
- if (content.type !== 'text') {
27
- return;
28
- }
29
- items.push({
30
- insertText: content.text,
31
- filterText: prompt.substring(prompt.length)
32
- });
33
- });
34
- }
35
- return { items };
36
- }
37
- catch (error) {
38
- console.error('Error fetching completions', error);
39
- return { items: [] };
40
- }
41
- }
42
- _completer;
43
- }
@@ -1,2 +0,0 @@
1
- declare const _default: "\nOllama allows to run large language models locally on your machine.\nTo use it you need to install the Ollama CLI and pull the model you want to use.\n\n1. Install the Ollama CLI by following the instructions at <https://ollama.com/download>\n\n2. Pull the model you want to use by running the following command in your terminal:\n\n ```bash\n ollama pull <model-name>\n ```\n\n For example, to pull the Llama 2 model, run:\n\n ```bash\n ollama pull llama2\n ```\n\n3. Once the model is pulled, you can use it in your application by running the following command:\n\n ```bash\n ollama serve\n ```\n\n4. This model will be available in the extension, using the model name you used in the command above.\n\n<details>\n<summary>Deploying Lite/Lab on external server</summary>\n\nSee https://objectgraph.com/blog/ollama-cors/ for more details.\n\nOn Linux, you can run the following commands:\n\n1. Check if CORS is enabled on the server. You can do this by running the following command in your terminal:\n\n ```bash\n curl -X OPTIONS http://localhost:11434 -H \"Origin: http://example.com\" -H \"Access-Control-Request-Method: GET\" -I\n ```\n\n If CORS is disabled, you will see a response like this:\n\n ```bash\n HTTP/1.1 403 Forbidden\n Date: Wed, 09 Oct 2024 10:12:15 GMT\n Content-Length: 0\n ```\n\n2. If CORS is not enabled, update _/etc/systemd/system/ollama.service_ with:\n\n ```bash\n [Service]\n Environment=\"OLLAMA_HOST=0.0.0.0\"\n Environment=\"OLLAMA_ORIGINS=*\"\n ```\n\n3. Restart the service:\n\n ```bash\n sudo systemctl daemon-reload\n sudo systemctl restart ollama\n ```\n\n4. Check if CORS is enabled on the server again by running the following command in your terminal:\n\n ```bash\n curl -X OPTIONS http://localhost:11434 -H \"Origin: http://example.com\" -H \"Access-Control-Request-Method: GET\" -I\n ```\n\n</details>\n";
2
- export default _default;
@@ -1,70 +0,0 @@
1
- export default `
2
- Ollama allows to run large language models locally on your machine.
3
- To use it you need to install the Ollama CLI and pull the model you want to use.
4
-
5
- 1. Install the Ollama CLI by following the instructions at <https://ollama.com/download>
6
-
7
- 2. Pull the model you want to use by running the following command in your terminal:
8
-
9
- \`\`\`bash
10
- ollama pull <model-name>
11
- \`\`\`
12
-
13
- For example, to pull the Llama 2 model, run:
14
-
15
- \`\`\`bash
16
- ollama pull llama2
17
- \`\`\`
18
-
19
- 3. Once the model is pulled, you can use it in your application by running the following command:
20
-
21
- \`\`\`bash
22
- ollama serve
23
- \`\`\`
24
-
25
- 4. This model will be available in the extension, using the model name you used in the command above.
26
-
27
- <details>
28
- <summary>Deploying Lite/Lab on external server</summary>
29
-
30
- See https://objectgraph.com/blog/ollama-cors/ for more details.
31
-
32
- On Linux, you can run the following commands:
33
-
34
- 1. Check if CORS is enabled on the server. You can do this by running the following command in your terminal:
35
-
36
- \`\`\`bash
37
- curl -X OPTIONS http://localhost:11434 -H "Origin: http://example.com" -H "Access-Control-Request-Method: GET" -I
38
- \`\`\`
39
-
40
- If CORS is disabled, you will see a response like this:
41
-
42
- \`\`\`bash
43
- HTTP/1.1 403 Forbidden
44
- Date: Wed, 09 Oct 2024 10:12:15 GMT
45
- Content-Length: 0
46
- \`\`\`
47
-
48
- 2. If CORS is not enabled, update _/etc/systemd/system/ollama.service_ with:
49
-
50
- \`\`\`bash
51
- [Service]
52
- Environment="OLLAMA_HOST=0.0.0.0"
53
- Environment="OLLAMA_ORIGINS=*"
54
- \`\`\`
55
-
56
- 3. Restart the service:
57
-
58
- \`\`\`bash
59
- sudo systemctl daemon-reload
60
- sudo systemctl restart ollama
61
- \`\`\`
62
-
63
- 4. Check if CORS is enabled on the server again by running the following command in your terminal:
64
-
65
- \`\`\`bash
66
- curl -X OPTIONS http://localhost:11434 -H "Origin: http://example.com" -H "Access-Control-Request-Method: GET" -I
67
- \`\`\`
68
-
69
- </details>
70
- `;
@@ -1,143 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "type": "object",
4
- "properties": {
5
- "numa": {
6
- "type": "boolean"
7
- },
8
- "numCtx": {
9
- "type": "number"
10
- },
11
- "numBatch": {
12
- "type": "number"
13
- },
14
- "numGpu": {
15
- "type": "number"
16
- },
17
- "mainGpu": {
18
- "type": "number"
19
- },
20
- "lowVram": {
21
- "type": "boolean"
22
- },
23
- "f16Kv": {
24
- "type": "boolean"
25
- },
26
- "logitsAll": {
27
- "type": "boolean"
28
- },
29
- "vocabOnly": {
30
- "type": "boolean"
31
- },
32
- "useMmap": {
33
- "type": "boolean"
34
- },
35
- "useMlock": {
36
- "type": "boolean"
37
- },
38
- "embeddingOnly": {
39
- "type": "boolean"
40
- },
41
- "numThread": {
42
- "type": "number"
43
- },
44
- "numKeep": {
45
- "type": "number"
46
- },
47
- "seed": {
48
- "type": "number"
49
- },
50
- "numPredict": {
51
- "type": "number"
52
- },
53
- "topK": {
54
- "type": "number"
55
- },
56
- "topP": {
57
- "type": "number"
58
- },
59
- "tfsZ": {
60
- "type": "number"
61
- },
62
- "typicalP": {
63
- "type": "number"
64
- },
65
- "repeatLastN": {
66
- "type": "number"
67
- },
68
- "temperature": {
69
- "type": "number"
70
- },
71
- "repeatPenalty": {
72
- "type": "number"
73
- },
74
- "presencePenalty": {
75
- "type": "number"
76
- },
77
- "frequencyPenalty": {
78
- "type": "number"
79
- },
80
- "mirostat": {
81
- "type": "number"
82
- },
83
- "mirostatTau": {
84
- "type": "number"
85
- },
86
- "mirostatEta": {
87
- "type": "number"
88
- },
89
- "penalizeNewline": {
90
- "type": "boolean"
91
- },
92
- "keepAlive": {
93
- "type": ["string", "number"],
94
- "default": "5m"
95
- },
96
- "stop": {
97
- "type": "array",
98
- "items": {
99
- "type": "string"
100
- }
101
- },
102
- "disableStreaming": {
103
- "type": "boolean",
104
- "description": "Whether to disable streaming.\n\nIf streaming is bypassed, then `stream()` will defer to `invoke()`.\n\n- If true, will always bypass streaming case.\n- If false (default), will always use streaming case if available."
105
- },
106
- "model": {
107
- "type": "string",
108
- "description": "The model to invoke. If the model does not exist, it will be pulled.",
109
- "default": ""
110
- },
111
- "baseUrl": {
112
- "type": "string",
113
- "description": "The host URL of the Ollama server.",
114
- "default": ""
115
- },
116
- "headers": {
117
- "type": "object",
118
- "additionalProperties": false,
119
- "description": "Optional HTTP Headers to include in the request."
120
- },
121
- "checkOrPullModel": {
122
- "type": "boolean",
123
- "description": "Whether or not to check the model exists on the local machine before invoking it. If set to `true`, the model will be pulled if it does not exist.",
124
- "default": false
125
- },
126
- "streaming": {
127
- "type": "boolean"
128
- },
129
- "format": {
130
- "anyOf": [
131
- {
132
- "type": "string"
133
- },
134
- {
135
- "type": "object"
136
- }
137
- ]
138
- }
139
- },
140
- "additionalProperties": false,
141
- "description": "Input to chat model class.",
142
- "definitions": {}
143
- }
@@ -1,12 +0,0 @@
1
- import { CompletionHandler, IInlineCompletionContext } from '@jupyterlab/completer';
2
- import { ChatOpenAI } from '@langchain/openai';
3
- import { BaseCompleter } from '../../base-completer';
4
- export declare class OpenAICompleter extends BaseCompleter {
5
- constructor(options: BaseCompleter.IOptions);
6
- fetch(request: CompletionHandler.IRequest, context: IInlineCompletionContext): Promise<{
7
- items: {
8
- insertText: string;
9
- }[];
10
- }>;
11
- protected _completer: ChatOpenAI;
12
- }
@@ -1,43 +0,0 @@
1
- import { AIMessage, SystemMessage } from '@langchain/core/messages';
2
- import { ChatOpenAI } from '@langchain/openai';
3
- import { BaseCompleter } from '../../base-completer';
4
- export class OpenAICompleter extends BaseCompleter {
5
- constructor(options) {
6
- super(options);
7
- this._completer = new ChatOpenAI({ ...options.settings });
8
- }
9
- async fetch(request, context) {
10
- const { text, offset: cursorOffset } = request;
11
- const prompt = text.slice(0, cursorOffset);
12
- const messages = [
13
- new SystemMessage(this.systemPrompt),
14
- new AIMessage(prompt)
15
- ];
16
- try {
17
- const response = await this._completer.invoke(messages);
18
- const items = [];
19
- if (typeof response.content === 'string') {
20
- items.push({
21
- insertText: response.content
22
- });
23
- }
24
- else {
25
- response.content.forEach(content => {
26
- if (content.type !== 'text') {
27
- return;
28
- }
29
- items.push({
30
- insertText: content.text,
31
- filterText: prompt.substring(prompt.length)
32
- });
33
- });
34
- }
35
- return { items };
36
- }
37
- catch (error) {
38
- console.error('Error fetching completions', error);
39
- return { items: [] };
40
- }
41
- }
42
- _completer;
43
- }