shidoshi 0.0.1__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.
- shidoshi-0.0.1/.github/workflows/publish.yml +42 -0
- shidoshi-0.0.1/.github/workflows/test.yml +24 -0
- shidoshi-0.0.1/.gitignore +20 -0
- shidoshi-0.0.1/LICENSE +191 -0
- shidoshi-0.0.1/PKG-INFO +204 -0
- shidoshi-0.0.1/README.md +176 -0
- shidoshi-0.0.1/adhoc/test_create_cell_tool.py +535 -0
- shidoshi-0.0.1/notebooks/ContextTest.ipynb +5619 -0
- shidoshi-0.0.1/notebooks/ShidoshiTest.ipynb +1005 -0
- shidoshi-0.0.1/pyproject.toml +59 -0
- shidoshi-0.0.1/src/shidoshi/__init__.py +3 -0
- shidoshi-0.0.1/src/shidoshi/core/__init__.py +22 -0
- shidoshi-0.0.1/src/shidoshi/core/cache.py +61 -0
- shidoshi-0.0.1/src/shidoshi/core/config.py +96 -0
- shidoshi-0.0.1/src/shidoshi/core/history.py +274 -0
- shidoshi-0.0.1/src/shidoshi/core/images.py +168 -0
- shidoshi-0.0.1/src/shidoshi/core/types.py +47 -0
- shidoshi-0.0.1/src/shidoshi/engine/__init__.py +14 -0
- shidoshi-0.0.1/src/shidoshi/engine/clients/__init__.py +5 -0
- shidoshi-0.0.1/src/shidoshi/engine/clients/base.py +44 -0
- shidoshi-0.0.1/src/shidoshi/engine/clients/openai.py +98 -0
- shidoshi-0.0.1/src/shidoshi/engine/clients/openrouter.py +267 -0
- shidoshi-0.0.1/src/shidoshi/engine/pipelines/__init__.py +4 -0
- shidoshi-0.0.1/src/shidoshi/engine/pipelines/base.py +21 -0
- shidoshi-0.0.1/src/shidoshi/engine/pipelines/simple.py +46 -0
- shidoshi-0.0.1/src/shidoshi/engine/tools/__init__.py +5 -0
- shidoshi-0.0.1/src/shidoshi/engine/tools/base.py +11 -0
- shidoshi-0.0.1/src/shidoshi/engine/tools/create_cell.py +23 -0
- shidoshi-0.0.1/src/shidoshi/engine/tools/web_fetch.py +14 -0
- shidoshi-0.0.1/src/shidoshi/engine/tools/web_search.py +8 -0
- shidoshi-0.0.1/src/shidoshi/jupyter/__init__.py +4 -0
- shidoshi-0.0.1/src/shidoshi/jupyter/display.py +309 -0
- shidoshi-0.0.1/src/shidoshi/jupyter/magics.py +260 -0
- shidoshi-0.0.1/src/shidoshi/jupyter/notebook_io.py +189 -0
- shidoshi-0.0.1/src/shidoshi/jupyter/styling.py +36 -0
- shidoshi-0.0.1/tests/__init__.py +0 -0
- shidoshi-0.0.1/tests/btp/__init__.py +0 -0
- shidoshi-0.0.1/tests/btp/test_create_cell.py +514 -0
- shidoshi-0.0.1/tests/btp/test_edge_cases.py +525 -0
- shidoshi-0.0.1/tests/btp/test_pin_trim.py +324 -0
- shidoshi-0.0.1/tests/integration/__init__.py +0 -0
- shidoshi-0.0.1/tests/integration/test_context_trim.py +190 -0
- shidoshi-0.0.1/tests/integration/test_engine_openai.py +94 -0
- shidoshi-0.0.1/tests/integration/test_full_pipeline.py +213 -0
- shidoshi-0.0.1/tests/integration/test_openrouter.py +182 -0
- shidoshi-0.0.1/tests/test_import_rule.py +47 -0
- shidoshi-0.0.1/tests/unit/__init__.py +0 -0
- shidoshi-0.0.1/tests/unit/test_core_cache.py +80 -0
- shidoshi-0.0.1/tests/unit/test_core_history.py +174 -0
- shidoshi-0.0.1/tests/unit/test_core_images.py +136 -0
- shidoshi-0.0.1/tests/unit/test_engine_clients_openrouter.py +35 -0
- shidoshi-0.0.1/tests/unit/test_engine_tools_create_cell.py +11 -0
- shidoshi-0.0.1/tests/unit/test_jupyter_display_tool_activity.py +54 -0
- shidoshi-0.0.1/tests/unit/test_jupyter_magics_create_cell.py +42 -0
- shidoshi-0.0.1/uv.lock +2214 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v4
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Build package
|
|
20
|
+
run: uv build
|
|
21
|
+
|
|
22
|
+
- name: Upload build artifacts
|
|
23
|
+
uses: actions/upload-artifact@v4
|
|
24
|
+
with:
|
|
25
|
+
name: dist
|
|
26
|
+
path: dist/
|
|
27
|
+
|
|
28
|
+
publish:
|
|
29
|
+
needs: build
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment: pypi
|
|
32
|
+
permissions:
|
|
33
|
+
id-token: write
|
|
34
|
+
steps:
|
|
35
|
+
- name: Download build artifacts
|
|
36
|
+
uses: actions/download-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: dist
|
|
39
|
+
path: dist/
|
|
40
|
+
|
|
41
|
+
- name: Publish to PyPI
|
|
42
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Install uv
|
|
16
|
+
uses: astral-sh/setup-uv@v4
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.13"
|
|
19
|
+
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: uv sync --all-extras --dev
|
|
22
|
+
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: uv run pytest tests/unit tests/btp tests/test_import_rule.py -v
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Jupyter
|
|
13
|
+
.ipynb_checkpoints/
|
|
14
|
+
|
|
15
|
+
# shidoshi runtime artifacts
|
|
16
|
+
.shidoshi_cache.json
|
|
17
|
+
*.png
|
|
18
|
+
|
|
19
|
+
# generated docs
|
|
20
|
+
docs/*.html
|
shidoshi-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Chaitanya
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
shidoshi-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shidoshi
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: An opinionated way to augment Jupyter Lab for iterative work
|
|
5
|
+
Project-URL: Homepage, https://github.com/tdchaitanya/shidoshi
|
|
6
|
+
Project-URL: Repository, https://github.com/tdchaitanya/shidoshi
|
|
7
|
+
Project-URL: Issues, https://github.com/tdchaitanya/shidoshi/issues
|
|
8
|
+
Author-email: Chaitanya <tdchaitanya@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-assistant,jupyter,jupyterlab,llm,openai
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: Jupyter
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Requires-Dist: ipylab>=0.6
|
|
20
|
+
Requires-Dist: ipynbname>=2025.8.0.0
|
|
21
|
+
Requires-Dist: ipython>=8.39.0
|
|
22
|
+
Requires-Dist: openai>=2.41.1
|
|
23
|
+
Requires-Dist: trio>=0.25
|
|
24
|
+
Requires-Dist: typing-extensions>=4.0
|
|
25
|
+
Provides-Extra: notebook
|
|
26
|
+
Requires-Dist: ipywidgets>=8.0; extra == 'notebook'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# shidoshi
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/shidoshi/)
|
|
32
|
+
[](https://github.com/tdchaitanya/shidoshi/actions/workflows/test.yml)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
|
|
35
|
+
An opinionated way to augment Jupyter Lab for iterative work.
|
|
36
|
+
|
|
37
|
+
shidoshi adds `%ask` / `%%ask` magics to Jupyter that let you talk to an LLM
|
|
38
|
+
from inside a notebook — using the notebook itself, in order, as the
|
|
39
|
+
conversation history. No separate chat pane, no copy-pasting context: your
|
|
40
|
+
code cells, their outputs, and your notes are the context.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
Requires Python ≥3.13 and JupyterLab. Set an API key before use:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export OPENAI_API_KEY=sk-... # for the openai provider (default)
|
|
48
|
+
export OPENAI_BASE_URL=... # optional, e.g. to point at a proxy
|
|
49
|
+
export OPENROUTER_API_KEY=... # for the openrouter provider
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Installing across Jupyter environments
|
|
53
|
+
|
|
54
|
+
`%load_ext shidoshi` runs `import shidoshi` **inside the running kernel
|
|
55
|
+
process**. That means shidoshi has to be installed into whichever Python
|
|
56
|
+
environment the kernel you're using actually runs in — it is not a
|
|
57
|
+
standalone CLI, so `uvx` / `uv tool install` (which run a tool in an
|
|
58
|
+
isolated subprocess, separate from any kernel) don't apply here.
|
|
59
|
+
|
|
60
|
+
- **Per-project venv with its own JupyterLab** (e.g. a `uv`-managed project):
|
|
61
|
+
add shidoshi as a normal dependency of that project.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv add shidoshi
|
|
65
|
+
# or: pip install shidoshi
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- **One shared JupyterLab, many kernels** (each notebook's kernel points at a
|
|
69
|
+
different project venv registered via `ipykernel install`): install
|
|
70
|
+
shidoshi into *each* kernel's venv. Installing it only where JupyterLab
|
|
71
|
+
itself lives will not make it importable from other kernels.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# inside the venv backing a given kernel
|
|
75
|
+
uv add shidoshi
|
|
76
|
+
# or: pip install shidoshi
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **Auto-load without typing `%load_ext` every time**: add to
|
|
80
|
+
`~/.ipython/profile_default/ipython_config.py` (create it first with
|
|
81
|
+
`ipython profile create` if it doesn't exist):
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
c.InteractiveShellApp.extensions = ["shidoshi"]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`~/.ipython` is a single directory shared by every Python environment
|
|
88
|
+
under your `$HOME` — it is **not** per-venv. So this line will make every
|
|
89
|
+
kernel try to load shidoshi at startup, regardless of which venv it's
|
|
90
|
+
running in. Two ways to keep that safe:
|
|
91
|
+
|
|
92
|
+
1. Only add it once shidoshi is installed in **every** environment you use
|
|
93
|
+
for Jupyter on that machine, or
|
|
94
|
+
2. Scope it to specific projects: create a named profile
|
|
95
|
+
(`ipython profile create shidoshi`), put the `extensions` line in that
|
|
96
|
+
profile's config instead of `profile_default`, and point only the
|
|
97
|
+
relevant kernel(s) at it (add `"--profile=shidoshi"` to that kernel's
|
|
98
|
+
`argv` in its `kernel.json`, or install with
|
|
99
|
+
`ipython kernel install --profile=shidoshi ...`).
|
|
100
|
+
|
|
101
|
+
## Quickstart
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
%load_ext shidoshi
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
%%ask
|
|
109
|
+
What does the `history.build_history` function in this file do?
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The response streams into the cell's output as Markdown.
|
|
113
|
+
|
|
114
|
+
## Magics reference
|
|
115
|
+
|
|
116
|
+
- **`%ask <prompt>`** — line magic for a one-line prompt.
|
|
117
|
+
- Prefix with `model|` or `provider:model|` to override the configured
|
|
118
|
+
default model for just this call, e.g. `%ask openrouter:openai/gpt-4o|summarize this`.
|
|
119
|
+
- Add `--debug` anywhere on the line to also show the full request/response
|
|
120
|
+
payload.
|
|
121
|
+
- **`%%ask [model]`** — cell magic; the whole cell body is the prompt
|
|
122
|
+
(multi-line is fine, and it can reference images via Markdown
|
|
123
|
+
`![]()`/`<img>` syntax or bare local file paths — they're inlined as
|
|
124
|
+
base64). An optional model name on the magic line overrides the default
|
|
125
|
+
for this call. Also supports `--debug`.
|
|
126
|
+
- **`%%skip`** — runs the cell normally, but the cell is left out of the
|
|
127
|
+
context sent to the model entirely. Use it for scratch or exploratory
|
|
128
|
+
cells you don't want the model to see.
|
|
129
|
+
- **`%%pin`** — runs the cell normally; its content and output are *always*
|
|
130
|
+
included in context and are exempt from the auto-trim behavior below. Use
|
|
131
|
+
it to protect a fact, constant, or definition you don't want dropped over
|
|
132
|
+
a long session.
|
|
133
|
+
|
|
134
|
+
## How context is built
|
|
135
|
+
|
|
136
|
+
Every prior cell in the notebook — up to the one you're currently running,
|
|
137
|
+
and accounting for kernel restarts — is turned into conversation history
|
|
138
|
+
automatically:
|
|
139
|
+
|
|
140
|
+
- **Markdown cells** become background text/image context (treated as notes
|
|
141
|
+
or reference material, not instructions).
|
|
142
|
+
- **Regular code cells** appear as fenced code plus their text/image
|
|
143
|
+
outputs.
|
|
144
|
+
- **Prior `%ask` / `%%ask` cells** become real user/assistant turns. Their
|
|
145
|
+
responses are reused from a per-cell cache rather than re-sent, so
|
|
146
|
+
replaying history doesn't resend answers the model already produced.
|
|
147
|
+
- **`%%skip` cells** are dropped entirely.
|
|
148
|
+
- **`%%pin` cells** are always kept.
|
|
149
|
+
|
|
150
|
+
## Automatic context-length handling
|
|
151
|
+
|
|
152
|
+
If a request is rejected for exceeding the model's context window, shidoshi
|
|
153
|
+
automatically retries, dropping the oldest trimmable history units first
|
|
154
|
+
(markdown cells, then plain code cells, then whole ask+response pairs —
|
|
155
|
+
`%%pin` cells are never dropped), up to 20 times. A banner reports how many
|
|
156
|
+
cells were dropped so you know context shrank.
|
|
157
|
+
|
|
158
|
+
## Providers & tools
|
|
159
|
+
|
|
160
|
+
- **`openai`** (default) — uses the OpenAI Responses API.
|
|
161
|
+
- **`openrouter`** — uses OpenRouter's chat-completions API; select it with
|
|
162
|
+
the `provider:model` prefix, e.g. `openrouter:anthropic/claude-3.5-sonnet`.
|
|
163
|
+
|
|
164
|
+
Every request currently has the built-in `web_search` tool attached, so the
|
|
165
|
+
model can search the web when it needs current information. (A `web_fetch`
|
|
166
|
+
tool also exists in the codebase but isn't wired into the magics yet — not
|
|
167
|
+
available today.)
|
|
168
|
+
|
|
169
|
+
## Debug mode
|
|
170
|
+
|
|
171
|
+
Add `--debug` to `%ask`/`%%ask` to render a collapsible, syntax-highlighted
|
|
172
|
+
panel showing exactly what was sent (system prompt, full message history,
|
|
173
|
+
tools) and every raw event streamed back — useful when the model's behavior
|
|
174
|
+
is surprising and you want to see the actual payload.
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
shidoshi reads TOML config, layered as defaults → `~/.shidoshi/config.toml`
|
|
179
|
+
→ `./.shidoshi/config.toml` (project config overrides user config):
|
|
180
|
+
|
|
181
|
+
```toml
|
|
182
|
+
default_model = "gpt-5.5" # model used when none is specified
|
|
183
|
+
reasoning_effort = "low" # OpenAI only
|
|
184
|
+
ask_color = "#eafbea" # highlight color for %ask/%%ask cells
|
|
185
|
+
skip_color = "#ececec" # highlight color for %%skip cells
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Development
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
uv sync
|
|
192
|
+
uv run pytest tests/unit tests/btp -v
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Integration tests under `tests/integration/` require a live `OPENAI_API_KEY`
|
|
196
|
+
(or a proxy via `OPENAI_BASE_URL`) and are run with:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv run pytest tests/integration/ -v -m integration
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|
shidoshi-0.0.1/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# shidoshi
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/shidoshi/)
|
|
4
|
+
[](https://github.com/tdchaitanya/shidoshi/actions/workflows/test.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
An opinionated way to augment Jupyter Lab for iterative work.
|
|
8
|
+
|
|
9
|
+
shidoshi adds `%ask` / `%%ask` magics to Jupyter that let you talk to an LLM
|
|
10
|
+
from inside a notebook — using the notebook itself, in order, as the
|
|
11
|
+
conversation history. No separate chat pane, no copy-pasting context: your
|
|
12
|
+
code cells, their outputs, and your notes are the context.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
Requires Python ≥3.13 and JupyterLab. Set an API key before use:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
export OPENAI_API_KEY=sk-... # for the openai provider (default)
|
|
20
|
+
export OPENAI_BASE_URL=... # optional, e.g. to point at a proxy
|
|
21
|
+
export OPENROUTER_API_KEY=... # for the openrouter provider
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Installing across Jupyter environments
|
|
25
|
+
|
|
26
|
+
`%load_ext shidoshi` runs `import shidoshi` **inside the running kernel
|
|
27
|
+
process**. That means shidoshi has to be installed into whichever Python
|
|
28
|
+
environment the kernel you're using actually runs in — it is not a
|
|
29
|
+
standalone CLI, so `uvx` / `uv tool install` (which run a tool in an
|
|
30
|
+
isolated subprocess, separate from any kernel) don't apply here.
|
|
31
|
+
|
|
32
|
+
- **Per-project venv with its own JupyterLab** (e.g. a `uv`-managed project):
|
|
33
|
+
add shidoshi as a normal dependency of that project.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uv add shidoshi
|
|
37
|
+
# or: pip install shidoshi
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- **One shared JupyterLab, many kernels** (each notebook's kernel points at a
|
|
41
|
+
different project venv registered via `ipykernel install`): install
|
|
42
|
+
shidoshi into *each* kernel's venv. Installing it only where JupyterLab
|
|
43
|
+
itself lives will not make it importable from other kernels.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# inside the venv backing a given kernel
|
|
47
|
+
uv add shidoshi
|
|
48
|
+
# or: pip install shidoshi
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- **Auto-load without typing `%load_ext` every time**: add to
|
|
52
|
+
`~/.ipython/profile_default/ipython_config.py` (create it first with
|
|
53
|
+
`ipython profile create` if it doesn't exist):
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
c.InteractiveShellApp.extensions = ["shidoshi"]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`~/.ipython` is a single directory shared by every Python environment
|
|
60
|
+
under your `$HOME` — it is **not** per-venv. So this line will make every
|
|
61
|
+
kernel try to load shidoshi at startup, regardless of which venv it's
|
|
62
|
+
running in. Two ways to keep that safe:
|
|
63
|
+
|
|
64
|
+
1. Only add it once shidoshi is installed in **every** environment you use
|
|
65
|
+
for Jupyter on that machine, or
|
|
66
|
+
2. Scope it to specific projects: create a named profile
|
|
67
|
+
(`ipython profile create shidoshi`), put the `extensions` line in that
|
|
68
|
+
profile's config instead of `profile_default`, and point only the
|
|
69
|
+
relevant kernel(s) at it (add `"--profile=shidoshi"` to that kernel's
|
|
70
|
+
`argv` in its `kernel.json`, or install with
|
|
71
|
+
`ipython kernel install --profile=shidoshi ...`).
|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
%load_ext shidoshi
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
%%ask
|
|
81
|
+
What does the `history.build_history` function in this file do?
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The response streams into the cell's output as Markdown.
|
|
85
|
+
|
|
86
|
+
## Magics reference
|
|
87
|
+
|
|
88
|
+
- **`%ask <prompt>`** — line magic for a one-line prompt.
|
|
89
|
+
- Prefix with `model|` or `provider:model|` to override the configured
|
|
90
|
+
default model for just this call, e.g. `%ask openrouter:openai/gpt-4o|summarize this`.
|
|
91
|
+
- Add `--debug` anywhere on the line to also show the full request/response
|
|
92
|
+
payload.
|
|
93
|
+
- **`%%ask [model]`** — cell magic; the whole cell body is the prompt
|
|
94
|
+
(multi-line is fine, and it can reference images via Markdown
|
|
95
|
+
`![]()`/`<img>` syntax or bare local file paths — they're inlined as
|
|
96
|
+
base64). An optional model name on the magic line overrides the default
|
|
97
|
+
for this call. Also supports `--debug`.
|
|
98
|
+
- **`%%skip`** — runs the cell normally, but the cell is left out of the
|
|
99
|
+
context sent to the model entirely. Use it for scratch or exploratory
|
|
100
|
+
cells you don't want the model to see.
|
|
101
|
+
- **`%%pin`** — runs the cell normally; its content and output are *always*
|
|
102
|
+
included in context and are exempt from the auto-trim behavior below. Use
|
|
103
|
+
it to protect a fact, constant, or definition you don't want dropped over
|
|
104
|
+
a long session.
|
|
105
|
+
|
|
106
|
+
## How context is built
|
|
107
|
+
|
|
108
|
+
Every prior cell in the notebook — up to the one you're currently running,
|
|
109
|
+
and accounting for kernel restarts — is turned into conversation history
|
|
110
|
+
automatically:
|
|
111
|
+
|
|
112
|
+
- **Markdown cells** become background text/image context (treated as notes
|
|
113
|
+
or reference material, not instructions).
|
|
114
|
+
- **Regular code cells** appear as fenced code plus their text/image
|
|
115
|
+
outputs.
|
|
116
|
+
- **Prior `%ask` / `%%ask` cells** become real user/assistant turns. Their
|
|
117
|
+
responses are reused from a per-cell cache rather than re-sent, so
|
|
118
|
+
replaying history doesn't resend answers the model already produced.
|
|
119
|
+
- **`%%skip` cells** are dropped entirely.
|
|
120
|
+
- **`%%pin` cells** are always kept.
|
|
121
|
+
|
|
122
|
+
## Automatic context-length handling
|
|
123
|
+
|
|
124
|
+
If a request is rejected for exceeding the model's context window, shidoshi
|
|
125
|
+
automatically retries, dropping the oldest trimmable history units first
|
|
126
|
+
(markdown cells, then plain code cells, then whole ask+response pairs —
|
|
127
|
+
`%%pin` cells are never dropped), up to 20 times. A banner reports how many
|
|
128
|
+
cells were dropped so you know context shrank.
|
|
129
|
+
|
|
130
|
+
## Providers & tools
|
|
131
|
+
|
|
132
|
+
- **`openai`** (default) — uses the OpenAI Responses API.
|
|
133
|
+
- **`openrouter`** — uses OpenRouter's chat-completions API; select it with
|
|
134
|
+
the `provider:model` prefix, e.g. `openrouter:anthropic/claude-3.5-sonnet`.
|
|
135
|
+
|
|
136
|
+
Every request currently has the built-in `web_search` tool attached, so the
|
|
137
|
+
model can search the web when it needs current information. (A `web_fetch`
|
|
138
|
+
tool also exists in the codebase but isn't wired into the magics yet — not
|
|
139
|
+
available today.)
|
|
140
|
+
|
|
141
|
+
## Debug mode
|
|
142
|
+
|
|
143
|
+
Add `--debug` to `%ask`/`%%ask` to render a collapsible, syntax-highlighted
|
|
144
|
+
panel showing exactly what was sent (system prompt, full message history,
|
|
145
|
+
tools) and every raw event streamed back — useful when the model's behavior
|
|
146
|
+
is surprising and you want to see the actual payload.
|
|
147
|
+
|
|
148
|
+
## Configuration
|
|
149
|
+
|
|
150
|
+
shidoshi reads TOML config, layered as defaults → `~/.shidoshi/config.toml`
|
|
151
|
+
→ `./.shidoshi/config.toml` (project config overrides user config):
|
|
152
|
+
|
|
153
|
+
```toml
|
|
154
|
+
default_model = "gpt-5.5" # model used when none is specified
|
|
155
|
+
reasoning_effort = "low" # OpenAI only
|
|
156
|
+
ask_color = "#eafbea" # highlight color for %ask/%%ask cells
|
|
157
|
+
skip_color = "#ececec" # highlight color for %%skip cells
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
uv sync
|
|
164
|
+
uv run pytest tests/unit tests/btp -v
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Integration tests under `tests/integration/` require a live `OPENAI_API_KEY`
|
|
168
|
+
(or a proxy via `OPENAI_BASE_URL`) and are run with:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
uv run pytest tests/integration/ -v -m integration
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|