notebook-intelligence 2.4.2__tar.gz → 2.6.0__tar.gz
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.
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/.gitignore +8 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/PKG-INFO +115 -96
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/README.md +114 -95
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/__init__.py +5 -1
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/_version.py +1 -1
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/ai_service_manager.py +118 -23
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/api.py +85 -5
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/base_chat_participant.py +21 -2
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/config.py +25 -0
- notebook_intelligence-2.6.0/notebook_intelligence/context_factory.py +18 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/extension.py +144 -26
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/package.json +2 -2
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/package.json.orig +1 -1
- notebook_intelligence-2.6.0/notebook_intelligence/labextension/static/30.24ece679f97c20752fb9.js +1 -0
- notebook_intelligence-2.4.2/notebook_intelligence/labextension/static/728.e21c211a709fe0ab1e1f.js → notebook_intelligence-2.6.0/notebook_intelligence/labextension/static/728.24e04da1a60d59d4a565.js +1 -1
- notebook_intelligence-2.6.0/notebook_intelligence/labextension/static/editor.worker.js +1407 -0
- notebook_intelligence-2.6.0/notebook_intelligence/labextension/static/remoteEntry.68563306a9ea67f847ba.js +1 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/mcp_manager.py +344 -32
- notebook_intelligence-2.6.0/notebook_intelligence/rule_injector.py +24 -0
- notebook_intelligence-2.6.0/notebook_intelligence/rule_manager.py +272 -0
- notebook_intelligence-2.6.0/notebook_intelligence/ruleset.py +282 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/package.json +1 -1
- notebook_intelligence-2.6.0/tests/conftest.py +168 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/01-test-global.md +17 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/02-test-security.md +15 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/03-invalid-rule.md +11 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/modes/agent/01-test-production.md +15 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/modes/ask/01-test-exploration.md +13 -0
- notebook_intelligence-2.6.0/tests/fixtures/rules/modes/inline-chat/01-test-quick.md +14 -0
- notebook_intelligence-2.6.0/tests/test_ai_service_manager_integration.py +99 -0
- notebook_intelligence-2.6.0/tests/test_base_chat_participant_integration.py +153 -0
- notebook_intelligence-2.6.0/tests/test_config_integration.py +116 -0
- notebook_intelligence-2.6.0/tests/test_context_factory.py +43 -0
- notebook_intelligence-2.6.0/tests/test_end_to_end_rule_integration.py +303 -0
- notebook_intelligence-2.6.0/tests/test_models.py +403 -0
- notebook_intelligence-2.6.0/tests/test_rule_auto_reload.py +246 -0
- notebook_intelligence-2.6.0/tests/test_rule_injector.py +106 -0
- notebook_intelligence-2.6.0/tests/test_rule_manager.py +312 -0
- notebook_intelligence-2.6.0/tests/test_websocket_handler_integration.py +211 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/tsconfig.json +1 -1
- notebook_intelligence-2.4.2/notebook_intelligence/labextension/static/144.3ed487e60baf9785fae1.js +0 -1
- notebook_intelligence-2.4.2/notebook_intelligence/labextension/static/editor.worker.js +0 -1407
- notebook_intelligence-2.4.2/notebook_intelligence/labextension/static/remoteEntry.d9d709f6862dfa2e5a69.js +0 -1
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/.copier-answers.yml +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/.prettierignore +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/.yarnrc.yml +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/CHANGELOG.md +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/CONTRIBUTING.md +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/LICENSE +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/RELEASE.md +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/install.json +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/jupyter-config/server-config/notebook_intelligence.json +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/built_in_toolsets.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/github_copilot.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/github_copilot_chat_participant.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/plugin.json +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/196.db3f5562c0372c6e07f6.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/1b55f12eca93ba6743e7.ttf +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/671.1797d409270b24758991.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/694.d0b052d80c0397c7f1ea.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/830.46ab52f7b558fb3c1a20.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/977.7e3d66ffc344a0af7a4e.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/be02dcbf2787b0b29ec8.module.wasm +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/e589c9ba04e3e5a90081.module.wasm +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/editor.worker.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/style.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/labextension/static/third-party-licenses.json +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/llm_providers/github_copilot_llm_provider.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/llm_providers/litellm_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/llm_providers/ollama_llm_provider.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/llm_providers/openai_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/prompts.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/util.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/pyproject.toml +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/schema/plugin.json +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/setup.py +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/webpack.config.js +0 -0
- {notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/yarn.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: notebook_intelligence
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.6.0
|
|
4
4
|
Summary: AI coding assistant for JupyterLab
|
|
5
5
|
Project-URL: Homepage, https://github.com/notebook-intelligence/notebook-intelligence
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/notebook-intelligence/notebook-intelligence/issues
|
|
@@ -801,18 +801,18 @@ jupyter lab --NotebookIntelligence.notebook_execute_tool=env_enabled
|
|
|
801
801
|
|
|
802
802
|
### Configuration files
|
|
803
803
|
|
|
804
|
-
NBI saves configuration at `~/.jupyter/nbi
|
|
804
|
+
NBI saves configuration at `~/.jupyter/nbi/config.json`. It also supports environment wide base configuration at `<env-prefix>/share/jupyter/nbi/config.json`. Organizations can ship default configuration at this environment wide config path. User's changes will be stored as overrides at `~/.jupyter/nbi/config.json`.
|
|
805
805
|
|
|
806
806
|
These config files are used for saving LLM provider, model and MCP configuration. Note that API keys you enter for your custom LLM providers will also be stored in these config files.
|
|
807
807
|
|
|
808
808
|
> [!IMPORTANT]
|
|
809
|
-
> Note that updating
|
|
809
|
+
> Note that updating config.json manually requires restarting JupyterLab to take effect.
|
|
810
810
|
|
|
811
811
|
### Model Context Protocol ([MCP](https://modelcontextprotocol.io)) Support
|
|
812
812
|
|
|
813
813
|
NBI seamlessly integrates with MCP servers. It supports servers with both Standard Input/Output (stdio) and Server-Sent Events (SSE) transports. The MCP support is limited to server tools at the moment.
|
|
814
814
|
|
|
815
|
-
You can easily add MCP servers to NBI by editing the configuration file [nbi
|
|
815
|
+
You can easily add MCP servers to NBI by editing the configuration file [~/.jupyter/nbi/mcp.json](#configuration-files). Environment wide base configuration is also support using the file at `<env-prefix>/share/jupyter/nbi/mcp.json`.
|
|
816
816
|
|
|
817
817
|
> [!NOTE]
|
|
818
818
|
> Using MCP servers requires an LLM model with tool calling capabilities. All of the GitHub Copilot models provided in NBI support this feature. If you are using other providers make sure you choose a tool calling capable model.
|
|
@@ -820,47 +820,24 @@ You can easily add MCP servers to NBI by editing the configuration file [nbi-con
|
|
|
820
820
|
> [!CAUTION]
|
|
821
821
|
> Note that most MCP servers are run on the same computer as your JupyterLab installation and they can make irreversible changes to your computer and/or access private data. Make sure that you only install MCP servers from trusted sources.
|
|
822
822
|
|
|
823
|
+
### MCP Config file example
|
|
824
|
+
|
|
823
825
|
```json
|
|
824
826
|
{
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
"
|
|
832
|
-
|
|
833
|
-
"command": "npx",
|
|
834
|
-
"args": [
|
|
835
|
-
"-y",
|
|
836
|
-
"@modelcontextprotocol/server-filesystem",
|
|
837
|
-
"/Users/mbektas/mcp-test"
|
|
838
|
-
]
|
|
839
|
-
},
|
|
840
|
-
}
|
|
827
|
+
"mcpServers": {
|
|
828
|
+
"filesystem": {
|
|
829
|
+
"command": "npx",
|
|
830
|
+
"args": [
|
|
831
|
+
"-y",
|
|
832
|
+
"@modelcontextprotocol/server-filesystem",
|
|
833
|
+
"/Users/mbektas/mcp-test"
|
|
834
|
+
]
|
|
841
835
|
}
|
|
836
|
+
}
|
|
842
837
|
}
|
|
843
838
|
```
|
|
844
839
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
<img src="media/mcp-prompt.png" alt="Settings dialog" width=600 />
|
|
848
|
-
|
|
849
|
-
By default, each tool call to MCP servers will require approval. If you would like to auto approve tools, you can do so by using the `"alwaysAllow": []` configuration key in the nbi-config.json. Simply list the names of tools.
|
|
850
|
-
|
|
851
|
-
```json
|
|
852
|
-
"mcpServers": {
|
|
853
|
-
"filesystem": {
|
|
854
|
-
"command": "npx",
|
|
855
|
-
"args": [
|
|
856
|
-
"-y",
|
|
857
|
-
"@modelcontextprotocol/server-filesystem",
|
|
858
|
-
"/Users/mbektas/mcp-test"
|
|
859
|
-
],
|
|
860
|
-
"alwaysAllow": ["list_allowed_directories", "list_directory"]
|
|
861
|
-
},
|
|
862
|
-
}
|
|
863
|
-
```
|
|
840
|
+
You can use Agent mode to access tools provided by MCP servers you configured.
|
|
864
841
|
|
|
865
842
|
For servers with stdio transport, you can also set additional environment variables by using the `env` key. Environment variables are specified as key value pairs.
|
|
866
843
|
|
|
@@ -876,12 +853,12 @@ For servers with stdio transport, you can also set additional environment variab
|
|
|
876
853
|
}
|
|
877
854
|
```
|
|
878
855
|
|
|
879
|
-
Below is an example of a server configuration with
|
|
856
|
+
Below is an example of a server configuration with Streamable HTTP transport. For Streamable HTTP transport servers, you can also specify headers to be sent as part of the requests.
|
|
880
857
|
|
|
881
858
|
```json
|
|
882
859
|
"mcpServers": {
|
|
883
860
|
"remoterservername": {
|
|
884
|
-
"url": "http://127.0.0.1:8080/
|
|
861
|
+
"url": "http://127.0.0.1:8080/mcp",
|
|
885
862
|
"headers": {
|
|
886
863
|
"Authorization": "Bearer mysecrettoken"
|
|
887
864
|
}
|
|
@@ -905,77 +882,119 @@ If you have multiple servers configured but you would like to disable some for a
|
|
|
905
882
|
}
|
|
906
883
|
```
|
|
907
884
|
|
|
908
|
-
|
|
885
|
+
### Ruleset System
|
|
909
886
|
|
|
910
|
-
|
|
887
|
+
NBI includes a powerful ruleset system that allows you to define custom guidelines and best practices that are automatically injected into AI prompts. This helps ensure consistent coding standards, project-specific conventions, and domain knowledge across all AI interactions.
|
|
911
888
|
|
|
912
|
-
|
|
889
|
+
#### How It Works
|
|
913
890
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
"command": "",
|
|
933
|
-
"args": [],
|
|
934
|
-
},
|
|
935
|
-
"servername2": {
|
|
936
|
-
"command": "",
|
|
937
|
-
"args": [],
|
|
938
|
-
"disabled": true
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
"participants": {
|
|
942
|
-
"fs": {
|
|
943
|
-
"name": "MCP - File system",
|
|
944
|
-
"servers": ["filesystem"]
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
891
|
+
Rules are markdown files with optional YAML frontmatter stored in `~/.jupyter/nbi/rules/`. They are automatically discovered and applied based on context (file type, notebook kernel, chat mode).
|
|
892
|
+
|
|
893
|
+
#### Creating Rules
|
|
894
|
+
|
|
895
|
+
**Global Rules** - Apply to all contexts:
|
|
896
|
+
|
|
897
|
+
Create a file like `~/.jupyter/nbi/rules/01-coding-standards.md`:
|
|
898
|
+
|
|
899
|
+
```markdown
|
|
900
|
+
---
|
|
901
|
+
priority: 10
|
|
902
|
+
---
|
|
903
|
+
|
|
904
|
+
# Coding Standards
|
|
905
|
+
|
|
906
|
+
- Always use type hints in Python functions
|
|
907
|
+
- Prefer list comprehensions over loops when appropriate
|
|
908
|
+
- Add docstrings to all public functions
|
|
949
909
|
```
|
|
950
910
|
|
|
951
|
-
|
|
911
|
+
**Mode-Specific Rules** - Apply only to specific chat modes:
|
|
952
912
|
|
|
953
|
-
NBI
|
|
913
|
+
NBI supports mode-specific rules for three modes:
|
|
914
|
+
|
|
915
|
+
- **ask** - Question/answer mode
|
|
916
|
+
- **agent** - Autonomous agent mode with tool access
|
|
917
|
+
- **inline-chat** - Inline code generation and editing
|
|
918
|
+
|
|
919
|
+
Create a file like `~/.jupyter/nbi/rules/modes/agent/01-testing.md`:
|
|
920
|
+
|
|
921
|
+
```markdown
|
|
922
|
+
---
|
|
923
|
+
priority: 20
|
|
924
|
+
scope:
|
|
925
|
+
kernels: ['python3']
|
|
926
|
+
---
|
|
927
|
+
|
|
928
|
+
# Testing Guidelines
|
|
929
|
+
|
|
930
|
+
When writing code in agent mode:
|
|
931
|
+
|
|
932
|
+
- Always include error handling
|
|
933
|
+
- Add logging for debugging
|
|
934
|
+
- Test edge cases
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### Rule Frontmatter Options
|
|
938
|
+
|
|
939
|
+
```yaml
|
|
940
|
+
---
|
|
941
|
+
apply: always # 'always', 'auto', or 'manual'
|
|
942
|
+
active: true # Enable/disable the rule
|
|
943
|
+
priority: 10 # Lower numbers = higher priority
|
|
944
|
+
scope:
|
|
945
|
+
file_patterns: # Apply to specific file patterns
|
|
946
|
+
- '*.py'
|
|
947
|
+
- 'test_*.ipynb'
|
|
948
|
+
kernels: # Apply to specific notebook kernels
|
|
949
|
+
- 'python3'
|
|
950
|
+
- 'ir'
|
|
951
|
+
directories: # Apply to specific directories
|
|
952
|
+
- '/projects/ml'
|
|
953
|
+
---
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
#### Configuration
|
|
957
|
+
|
|
958
|
+
**Enable/Disable Rules System:**
|
|
959
|
+
|
|
960
|
+
Edit `~/.jupyter/nbi/config.json`:
|
|
954
961
|
|
|
955
962
|
```json
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
"name": "MCP - File system",
|
|
959
|
-
"servers": ["filesystem"],
|
|
960
|
-
"nbiTools": [
|
|
961
|
-
"create_new_notebook",
|
|
962
|
-
"add_markdown_cell_to_notebook",
|
|
963
|
-
"add_code_cell_to_notebook"
|
|
964
|
-
]
|
|
965
|
-
}
|
|
963
|
+
{
|
|
964
|
+
"rules_enabled": true
|
|
966
965
|
}
|
|
967
966
|
```
|
|
968
967
|
|
|
969
|
-
|
|
968
|
+
**Auto-Reload Configuration:**
|
|
970
969
|
|
|
971
|
-
|
|
972
|
-
@mcp-fs list the directories I have access to.
|
|
973
|
-
```
|
|
970
|
+
Rules are automatically reloaded when changed (enabled by default). This behavior is controlled by the `NBI_RULES_AUTO_RELOAD` environment variable.
|
|
974
971
|
|
|
972
|
+
To disable auto-reload:
|
|
973
|
+
|
|
974
|
+
```bash
|
|
975
|
+
export NBI_RULES_AUTO_RELOAD=false
|
|
976
|
+
jupyter lab
|
|
975
977
|
```
|
|
976
|
-
|
|
978
|
+
|
|
979
|
+
Or to enable (default):
|
|
980
|
+
|
|
981
|
+
```bash
|
|
982
|
+
export NBI_RULES_AUTO_RELOAD=true
|
|
983
|
+
jupyter lab
|
|
977
984
|
```
|
|
978
985
|
|
|
986
|
+
#### Managing Rules
|
|
987
|
+
|
|
988
|
+
Rules are automatically discovered from:
|
|
989
|
+
|
|
990
|
+
- **Global rules**: `~/.jupyter/nbi/rules/*.md`
|
|
991
|
+
- **Mode-specific rules**: `~/.jupyter/nbi/rules/modes/{mode}/*.md` where `{mode}` can be:
|
|
992
|
+
- `ask` - For question/answer interactions
|
|
993
|
+
- `agent` - For autonomous agent operations
|
|
994
|
+
- `inline-chat` - For inline code generation
|
|
995
|
+
|
|
996
|
+
Rules are applied in priority order (lower numbers first) and can be toggled on/off without deleting the files.
|
|
997
|
+
|
|
979
998
|
### Developer documentation
|
|
980
999
|
|
|
981
1000
|
For building locally and contributing see the [developer documentatation](CONTRIBUTING.md).
|
|
@@ -94,18 +94,18 @@ jupyter lab --NotebookIntelligence.notebook_execute_tool=env_enabled
|
|
|
94
94
|
|
|
95
95
|
### Configuration files
|
|
96
96
|
|
|
97
|
-
NBI saves configuration at `~/.jupyter/nbi
|
|
97
|
+
NBI saves configuration at `~/.jupyter/nbi/config.json`. It also supports environment wide base configuration at `<env-prefix>/share/jupyter/nbi/config.json`. Organizations can ship default configuration at this environment wide config path. User's changes will be stored as overrides at `~/.jupyter/nbi/config.json`.
|
|
98
98
|
|
|
99
99
|
These config files are used for saving LLM provider, model and MCP configuration. Note that API keys you enter for your custom LLM providers will also be stored in these config files.
|
|
100
100
|
|
|
101
101
|
> [!IMPORTANT]
|
|
102
|
-
> Note that updating
|
|
102
|
+
> Note that updating config.json manually requires restarting JupyterLab to take effect.
|
|
103
103
|
|
|
104
104
|
### Model Context Protocol ([MCP](https://modelcontextprotocol.io)) Support
|
|
105
105
|
|
|
106
106
|
NBI seamlessly integrates with MCP servers. It supports servers with both Standard Input/Output (stdio) and Server-Sent Events (SSE) transports. The MCP support is limited to server tools at the moment.
|
|
107
107
|
|
|
108
|
-
You can easily add MCP servers to NBI by editing the configuration file [nbi
|
|
108
|
+
You can easily add MCP servers to NBI by editing the configuration file [~/.jupyter/nbi/mcp.json](#configuration-files). Environment wide base configuration is also support using the file at `<env-prefix>/share/jupyter/nbi/mcp.json`.
|
|
109
109
|
|
|
110
110
|
> [!NOTE]
|
|
111
111
|
> Using MCP servers requires an LLM model with tool calling capabilities. All of the GitHub Copilot models provided in NBI support this feature. If you are using other providers make sure you choose a tool calling capable model.
|
|
@@ -113,47 +113,24 @@ You can easily add MCP servers to NBI by editing the configuration file [nbi-con
|
|
|
113
113
|
> [!CAUTION]
|
|
114
114
|
> Note that most MCP servers are run on the same computer as your JupyterLab installation and they can make irreversible changes to your computer and/or access private data. Make sure that you only install MCP servers from trusted sources.
|
|
115
115
|
|
|
116
|
+
### MCP Config file example
|
|
117
|
+
|
|
116
118
|
```json
|
|
117
119
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
"command": "npx",
|
|
127
|
-
"args": [
|
|
128
|
-
"-y",
|
|
129
|
-
"@modelcontextprotocol/server-filesystem",
|
|
130
|
-
"/Users/mbektas/mcp-test"
|
|
131
|
-
]
|
|
132
|
-
},
|
|
133
|
-
}
|
|
120
|
+
"mcpServers": {
|
|
121
|
+
"filesystem": {
|
|
122
|
+
"command": "npx",
|
|
123
|
+
"args": [
|
|
124
|
+
"-y",
|
|
125
|
+
"@modelcontextprotocol/server-filesystem",
|
|
126
|
+
"/Users/mbektas/mcp-test"
|
|
127
|
+
]
|
|
134
128
|
}
|
|
129
|
+
}
|
|
135
130
|
}
|
|
136
131
|
```
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<img src="media/mcp-prompt.png" alt="Settings dialog" width=600 />
|
|
141
|
-
|
|
142
|
-
By default, each tool call to MCP servers will require approval. If you would like to auto approve tools, you can do so by using the `"alwaysAllow": []` configuration key in the nbi-config.json. Simply list the names of tools.
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
"mcpServers": {
|
|
146
|
-
"filesystem": {
|
|
147
|
-
"command": "npx",
|
|
148
|
-
"args": [
|
|
149
|
-
"-y",
|
|
150
|
-
"@modelcontextprotocol/server-filesystem",
|
|
151
|
-
"/Users/mbektas/mcp-test"
|
|
152
|
-
],
|
|
153
|
-
"alwaysAllow": ["list_allowed_directories", "list_directory"]
|
|
154
|
-
},
|
|
155
|
-
}
|
|
156
|
-
```
|
|
133
|
+
You can use Agent mode to access tools provided by MCP servers you configured.
|
|
157
134
|
|
|
158
135
|
For servers with stdio transport, you can also set additional environment variables by using the `env` key. Environment variables are specified as key value pairs.
|
|
159
136
|
|
|
@@ -169,12 +146,12 @@ For servers with stdio transport, you can also set additional environment variab
|
|
|
169
146
|
}
|
|
170
147
|
```
|
|
171
148
|
|
|
172
|
-
Below is an example of a server configuration with
|
|
149
|
+
Below is an example of a server configuration with Streamable HTTP transport. For Streamable HTTP transport servers, you can also specify headers to be sent as part of the requests.
|
|
173
150
|
|
|
174
151
|
```json
|
|
175
152
|
"mcpServers": {
|
|
176
153
|
"remoterservername": {
|
|
177
|
-
"url": "http://127.0.0.1:8080/
|
|
154
|
+
"url": "http://127.0.0.1:8080/mcp",
|
|
178
155
|
"headers": {
|
|
179
156
|
"Authorization": "Bearer mysecrettoken"
|
|
180
157
|
}
|
|
@@ -198,77 +175,119 @@ If you have multiple servers configured but you would like to disable some for a
|
|
|
198
175
|
}
|
|
199
176
|
```
|
|
200
177
|
|
|
201
|
-
|
|
178
|
+
### Ruleset System
|
|
202
179
|
|
|
203
|
-
|
|
180
|
+
NBI includes a powerful ruleset system that allows you to define custom guidelines and best practices that are automatically injected into AI prompts. This helps ensure consistent coding standards, project-specific conventions, and domain knowledge across all AI interactions.
|
|
204
181
|
|
|
205
|
-
|
|
182
|
+
#### How It Works
|
|
206
183
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
"command": "",
|
|
226
|
-
"args": [],
|
|
227
|
-
},
|
|
228
|
-
"servername2": {
|
|
229
|
-
"command": "",
|
|
230
|
-
"args": [],
|
|
231
|
-
"disabled": true
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
"participants": {
|
|
235
|
-
"fs": {
|
|
236
|
-
"name": "MCP - File system",
|
|
237
|
-
"servers": ["filesystem"]
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
184
|
+
Rules are markdown files with optional YAML frontmatter stored in `~/.jupyter/nbi/rules/`. They are automatically discovered and applied based on context (file type, notebook kernel, chat mode).
|
|
185
|
+
|
|
186
|
+
#### Creating Rules
|
|
187
|
+
|
|
188
|
+
**Global Rules** - Apply to all contexts:
|
|
189
|
+
|
|
190
|
+
Create a file like `~/.jupyter/nbi/rules/01-coding-standards.md`:
|
|
191
|
+
|
|
192
|
+
```markdown
|
|
193
|
+
---
|
|
194
|
+
priority: 10
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# Coding Standards
|
|
198
|
+
|
|
199
|
+
- Always use type hints in Python functions
|
|
200
|
+
- Prefer list comprehensions over loops when appropriate
|
|
201
|
+
- Add docstrings to all public functions
|
|
242
202
|
```
|
|
243
203
|
|
|
244
|
-
|
|
204
|
+
**Mode-Specific Rules** - Apply only to specific chat modes:
|
|
245
205
|
|
|
246
|
-
NBI
|
|
206
|
+
NBI supports mode-specific rules for three modes:
|
|
207
|
+
|
|
208
|
+
- **ask** - Question/answer mode
|
|
209
|
+
- **agent** - Autonomous agent mode with tool access
|
|
210
|
+
- **inline-chat** - Inline code generation and editing
|
|
211
|
+
|
|
212
|
+
Create a file like `~/.jupyter/nbi/rules/modes/agent/01-testing.md`:
|
|
213
|
+
|
|
214
|
+
```markdown
|
|
215
|
+
---
|
|
216
|
+
priority: 20
|
|
217
|
+
scope:
|
|
218
|
+
kernels: ['python3']
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
# Testing Guidelines
|
|
222
|
+
|
|
223
|
+
When writing code in agent mode:
|
|
224
|
+
|
|
225
|
+
- Always include error handling
|
|
226
|
+
- Add logging for debugging
|
|
227
|
+
- Test edge cases
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### Rule Frontmatter Options
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
---
|
|
234
|
+
apply: always # 'always', 'auto', or 'manual'
|
|
235
|
+
active: true # Enable/disable the rule
|
|
236
|
+
priority: 10 # Lower numbers = higher priority
|
|
237
|
+
scope:
|
|
238
|
+
file_patterns: # Apply to specific file patterns
|
|
239
|
+
- '*.py'
|
|
240
|
+
- 'test_*.ipynb'
|
|
241
|
+
kernels: # Apply to specific notebook kernels
|
|
242
|
+
- 'python3'
|
|
243
|
+
- 'ir'
|
|
244
|
+
directories: # Apply to specific directories
|
|
245
|
+
- '/projects/ml'
|
|
246
|
+
---
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Configuration
|
|
250
|
+
|
|
251
|
+
**Enable/Disable Rules System:**
|
|
252
|
+
|
|
253
|
+
Edit `~/.jupyter/nbi/config.json`:
|
|
247
254
|
|
|
248
255
|
```json
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
"name": "MCP - File system",
|
|
252
|
-
"servers": ["filesystem"],
|
|
253
|
-
"nbiTools": [
|
|
254
|
-
"create_new_notebook",
|
|
255
|
-
"add_markdown_cell_to_notebook",
|
|
256
|
-
"add_code_cell_to_notebook"
|
|
257
|
-
]
|
|
258
|
-
}
|
|
256
|
+
{
|
|
257
|
+
"rules_enabled": true
|
|
259
258
|
}
|
|
260
259
|
```
|
|
261
260
|
|
|
262
|
-
|
|
261
|
+
**Auto-Reload Configuration:**
|
|
263
262
|
|
|
264
|
-
|
|
265
|
-
@mcp-fs list the directories I have access to.
|
|
266
|
-
```
|
|
263
|
+
Rules are automatically reloaded when changed (enabled by default). This behavior is controlled by the `NBI_RULES_AUTO_RELOAD` environment variable.
|
|
267
264
|
|
|
265
|
+
To disable auto-reload:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
export NBI_RULES_AUTO_RELOAD=false
|
|
269
|
+
jupyter lab
|
|
268
270
|
```
|
|
269
|
-
|
|
271
|
+
|
|
272
|
+
Or to enable (default):
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
export NBI_RULES_AUTO_RELOAD=true
|
|
276
|
+
jupyter lab
|
|
270
277
|
```
|
|
271
278
|
|
|
279
|
+
#### Managing Rules
|
|
280
|
+
|
|
281
|
+
Rules are automatically discovered from:
|
|
282
|
+
|
|
283
|
+
- **Global rules**: `~/.jupyter/nbi/rules/*.md`
|
|
284
|
+
- **Mode-specific rules**: `~/.jupyter/nbi/rules/modes/{mode}/*.md` where `{mode}` can be:
|
|
285
|
+
- `ask` - For question/answer interactions
|
|
286
|
+
- `agent` - For autonomous agent operations
|
|
287
|
+
- `inline-chat` - For inline code generation
|
|
288
|
+
|
|
289
|
+
Rules are applied in priority order (lower numbers first) and can be toggled on/off without deleting the files.
|
|
290
|
+
|
|
272
291
|
### Developer documentation
|
|
273
292
|
|
|
274
293
|
For building locally and contributing see the [developer documentatation](CONTRIBUTING.md).
|
{notebook_intelligence-2.4.2 → notebook_intelligence-2.6.0}/notebook_intelligence/__init__.py
RENAMED
|
@@ -11,7 +11,11 @@ except ImportError:
|
|
|
11
11
|
__version__ = "dev"
|
|
12
12
|
|
|
13
13
|
import logging
|
|
14
|
-
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
# Allow setting log level via environment variable
|
|
17
|
+
log_level = os.environ.get('NBI_LOG_LEVEL', 'INFO').upper()
|
|
18
|
+
logging.basicConfig(format='%(asctime)s - %(name)s - %(filename)s - %(levelname)s - %(message)s', level=getattr(logging, log_level, logging.INFO))
|
|
15
19
|
|
|
16
20
|
from .extension import NotebookIntelligence
|
|
17
21
|
from .api import *
|