AskTim 0.1.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.
- asktim-0.1.0/LICENSE +21 -0
- asktim-0.1.0/MANIFEST.in +3 -0
- asktim-0.1.0/PKG-INFO +458 -0
- asktim-0.1.0/README.md +418 -0
- asktim-0.1.0/bin/AskTim! +8 -0
- asktim-0.1.0/examples/AskTim-demo.ipynb +234 -0
- asktim-0.1.0/pyproject.toml +63 -0
- asktim-0.1.0/setup.cfg +4 -0
- asktim-0.1.0/src/AskTim.egg-info/PKG-INFO +458 -0
- asktim-0.1.0/src/AskTim.egg-info/SOURCES.txt +52 -0
- asktim-0.1.0/src/AskTim.egg-info/dependency_links.txt +1 -0
- asktim-0.1.0/src/AskTim.egg-info/entry_points.txt +2 -0
- asktim-0.1.0/src/AskTim.egg-info/requires.txt +8 -0
- asktim-0.1.0/src/AskTim.egg-info/top_level.txt +1 -0
- asktim-0.1.0/src/asktim/__init__.py +72 -0
- asktim-0.1.0/src/asktim/__main__.py +6 -0
- asktim-0.1.0/src/asktim/agent.py +490 -0
- asktim-0.1.0/src/asktim/api.py +41 -0
- asktim-0.1.0/src/asktim/chat.py +106 -0
- asktim-0.1.0/src/asktim/cli.py +577 -0
- asktim-0.1.0/src/asktim/config.py +316 -0
- asktim-0.1.0/src/asktim/context.py +156 -0
- asktim-0.1.0/src/asktim/fileinfo.py +593 -0
- asktim-0.1.0/src/asktim/history.py +214 -0
- asktim-0.1.0/src/asktim/inventory.py +379 -0
- asktim-0.1.0/src/asktim/logbook.py +159 -0
- asktim-0.1.0/src/asktim/net.py +151 -0
- asktim-0.1.0/src/asktim/notebook.py +1010 -0
- asktim-0.1.0/src/asktim/offline.py +110 -0
- asktim-0.1.0/src/asktim/paths.py +81 -0
- asktim-0.1.0/src/asktim/privacy.py +804 -0
- asktim-0.1.0/src/asktim/prompts.py +226 -0
- asktim-0.1.0/src/asktim/providers/__init__.py +173 -0
- asktim-0.1.0/src/asktim/providers/anthropic.py +227 -0
- asktim-0.1.0/src/asktim/providers/gemini.py +215 -0
- asktim-0.1.0/src/asktim/providers/openai.py +135 -0
- asktim-0.1.0/src/asktim/records.py +319 -0
- asktim-0.1.0/src/asktim/render.py +511 -0
- asktim-0.1.0/src/asktim/runner.py +308 -0
- asktim-0.1.0/src/asktim/safety.py +1495 -0
- asktim-0.1.0/src/asktim/shell_setup.py +183 -0
- asktim-0.1.0/src/asktim/ui.py +303 -0
- asktim-0.1.0/src/asktim/viewers.py +97 -0
- asktim-0.1.0/tests/conftest.py +86 -0
- asktim-0.1.0/tests/kernel_harness.py +68 -0
- asktim-0.1.0/tests/markdown_fuzz/check.mjs +42 -0
- asktim-0.1.0/tests/mock_ai.py +147 -0
- asktim-0.1.0/tests/test_cli_and_agent.py +252 -0
- asktim-0.1.0/tests/test_display_safety.py +134 -0
- asktim-0.1.0/tests/test_history_and_files.py +117 -0
- asktim-0.1.0/tests/test_notebook.py +129 -0
- asktim-0.1.0/tests/test_privacy.py +178 -0
- asktim-0.1.0/tests/test_providers.py +186 -0
- asktim-0.1.0/tests/test_safety.py +186 -0
asktim-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tim Hearn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
asktim-0.1.0/MANIFEST.in
ADDED
asktim-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: AskTim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AskTim! - an AI helper for bioinformatics students that keeps their data out of the AI, at the command line and in Jupyter and Colab notebooks.
|
|
5
|
+
Author: Tim Hearn
|
|
6
|
+
Project-URL: Homepage, https://github.com/comparativechrono/AskTim
|
|
7
|
+
Project-URL: Source, https://github.com/comparativechrono/AskTim
|
|
8
|
+
Project-URL: Issues, https://github.com/comparativechrono/AskTim/issues
|
|
9
|
+
Keywords: bioinformatics,teaching,AI,assistant,agent,jupyter,colab,claude
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Operating System :: MacOS
|
|
22
|
+
Classifier: Environment :: Console
|
|
23
|
+
Classifier: Framework :: Jupyter
|
|
24
|
+
Classifier: Framework :: IPython
|
|
25
|
+
Classifier: Intended Audience :: Education
|
|
26
|
+
Classifier: Intended Audience :: Science/Research
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
28
|
+
Classifier: Topic :: Education
|
|
29
|
+
Requires-Python: >=3.8
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Provides-Extra: test
|
|
33
|
+
Requires-Dist: pytest; extra == "test"
|
|
34
|
+
Requires-Dist: pexpect; extra == "test"
|
|
35
|
+
Requires-Dist: ipython; extra == "test"
|
|
36
|
+
Requires-Dist: ipykernel; extra == "test"
|
|
37
|
+
Requires-Dist: nbformat; extra == "test"
|
|
38
|
+
Requires-Dist: nbclient; extra == "test"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<img src="https://raw.githubusercontent.com/comparativechrono/AskTim/main/assets/tim.png" alt="Tim, the AskTim! cartoon: a smiling man with glasses, a beard and a quiff" width="180">
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<h1 align="center">AskTim!</h1>
|
|
46
|
+
|
|
47
|
+
<p align="center"><strong>An AI helper for learning bioinformatics that keeps your data out of the AI.</strong></p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="https://pypi.org/project/AskTim/"><img src="https://img.shields.io/pypi/v/AskTim" alt="PyPI"></a>
|
|
51
|
+
<a href="https://pypi.org/project/AskTim/"><img src="https://img.shields.io/pypi/pyversions/AskTim" alt="Python versions"></a>
|
|
52
|
+
<a href="https://github.com/comparativechrono/AskTim/actions/workflows/tests.yml"><img src="https://github.com/comparativechrono/AskTim/actions/workflows/tests.yml/badge.svg" alt="Tests"></a>
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
AskTim! answers questions about the programs and packages installed on your computer, explains
|
|
56
|
+
errors, and has an agent that can run the steps of an analysis for you, at the command line and in
|
|
57
|
+
Jupyter or Colab notebooks. You use your own API key for Claude, Gemini or an OpenAI-compatible
|
|
58
|
+
service.
|
|
59
|
+
|
|
60
|
+
AskTim! was made by Tim Hearn (University of Cambridge) for teaching students to use AI responsibly.
|
|
61
|
+
It works like the AI panels in his practicals (bioinformatics-workbench, R-workbench,
|
|
62
|
+
ai-agents-practical, yeast-data-ai, r-training). The AI is told what is installed and what you did.
|
|
63
|
+
It gets the shape of your files, but never their contents. The aim is that students never need to
|
|
64
|
+
paste data into a chatbot to get help.
|
|
65
|
+
|
|
66
|
+
```console
|
|
67
|
+
$ AskTim! "how do I count the reads in a BAM file that mapped?"
|
|
68
|
+
$ samtools sort aln.sam -o aln.bam; AskTim! why
|
|
69
|
+
$ AskTim! Agent "map the reads in data/ to ref.fa and tell me how many map"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Install
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install AskTim
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
AskTim! needs Python 3.8 or newer and nothing else. It installs two names for the same command:
|
|
81
|
+
`AskTim!`, and `asktim` for shells and systems that don't like the `!`. To try the latest version
|
|
82
|
+
from GitHub instead: `pip install git+https://github.com/comparativechrono/AskTim`.
|
|
83
|
+
|
|
84
|
+
In Colab, run this at the top of the notebook (once per session):
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
!pip install -q AskTim
|
|
88
|
+
import asktim
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Set up a key (once)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
AskTim! Claude # then paste your key when asked (it is not shown)
|
|
95
|
+
AskTim! Claude sk-ant-... # also works, but leaves the key in your shell history
|
|
96
|
+
AskTim! Gemini # or a Google Gemini key
|
|
97
|
+
AskTim! OpenAI --url http://localhost:11434/v1 # or an OpenAI-compatible service, e.g. a local model
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
AskTim! checks the key with a tiny request and then keeps it in `~/.config/asktim/keys.json`, a file
|
|
101
|
+
only you can read. A key can also come from an environment variable (`ANTHROPIC_API_KEY`,
|
|
102
|
+
`GEMINI_API_KEY`/`GOOGLE_API_KEY`, `OPENAI_API_KEY`, or `ASKTIM_CLAUDE_KEY` and so on) or from Colab's
|
|
103
|
+
Secrets. `AskTim! status` shows which key and model are in use. `AskTim! forget` deletes stored keys.
|
|
104
|
+
|
|
105
|
+
## Ask a question
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
AskTim! "what does samtools flagstat tell me?"
|
|
109
|
+
AskTim! why # why did my last command fail?
|
|
110
|
+
bwa mem ref.fa r1.fq 2>&1 | AskTim! "what does this error mean?"
|
|
111
|
+
AskTim! --file data/counts.csv "how do I plot column 2 against column 3 in R?"
|
|
112
|
+
AskTim! # a conversation; Ctrl+D ends it
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Chat mode explains and suggests, and never runs anything. AskTim! tells the AI which programs,
|
|
116
|
+
Python packages and R packages are installed (`AskTim! tools` lists them). The AI suggests only
|
|
117
|
+
those. If something isn't installed, it says so rather than giving you a command that cannot work.
|
|
118
|
+
When a question looks like coursework, it gives a hint first. For an error, it starts with what the
|
|
119
|
+
message means. AskTim! remembers the conversation for an hour (`AskTim! new` starts afresh).
|
|
120
|
+
|
|
121
|
+
The last 20 commands you typed are sent with each question, so "why did that fail?" works. To see
|
|
122
|
+
which commands failed, AskTim! needs its shell integration (below); without it, it reads your
|
|
123
|
+
shell's history file. Use `--no-history` to leave the commands out.
|
|
124
|
+
|
|
125
|
+
Put questions in quotes. In bash, use single quotes if the question contains `!` or `$`.
|
|
126
|
+
|
|
127
|
+
To see exactly what would be sent, without sending anything:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
AskTim! show "how do I index this BAM file?"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## The agent
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
AskTim! Agent "map the reads in data/ to ref.fa with bwa and count how many map"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The agent works like the agents in the practicals. It plans, runs commands, writes files and reads
|
|
140
|
+
what they print, one step at a time. It can only use what is installed, and it cannot install
|
|
141
|
+
anything. Before each step you see what it wants to do and why:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
── Step 3 · run a command ─────────────────────────────────────────────
|
|
145
|
+
Why: Index the reference so that bwa can map to it.
|
|
146
|
+
$ bwa index -p ref ../../ref.fa
|
|
147
|
+
Run it? [Enter/y] yes · [n]o · [e]dit · [a]ll (stop asking) · [q]uit:
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
If you say no, it asks why and tells the agent. With `e` you can change the command first. A step
|
|
151
|
+
that breaks a rule is refused before you are asked, and the agent is told why.
|
|
152
|
+
|
|
153
|
+
| Option | |
|
|
154
|
+
|---|---|
|
|
155
|
+
| *(none)* | approve each step (the default) |
|
|
156
|
+
| `--plan` | the agent writes a plan first; you approve it, ask for changes, or approve it step by step |
|
|
157
|
+
| `--auto` | runs without asking (every rule still applies; risky steps still ask; Ctrl+C stops) |
|
|
158
|
+
| `--script` | builds one script, `analysis.sh` (or `--script-name NAME`), and gets it working |
|
|
159
|
+
| `--web` | lets it download things (curl, wget); nothing may be uploaded |
|
|
160
|
+
| `--here` | works in this folder, not in a new run folder (asks before it changes any file already there) |
|
|
161
|
+
| `--steps N`, `--timeout S` | at most N steps (default 25); at most S seconds per command (default 600) |
|
|
162
|
+
|
|
163
|
+
Each run gets its own folder, `asktim-runs/1-approve/`, `asktim-runs/2-auto/` and so on. The agent
|
|
164
|
+
can read your files, but it can only write in that folder. When it finishes, AskTim! writes (not
|
|
165
|
+
the model):
|
|
166
|
+
|
|
167
|
+
- `RUN.md`: the task, every step with its decision, exit status and output, and what the AI was shown;
|
|
168
|
+
- `run.json`: the same, for programs;
|
|
169
|
+
- `rerun.sh`: the commands that worked, as a script you can read and run again without any AI.
|
|
170
|
+
|
|
171
|
+
The agent can also open a file for you. An HTML report (FastQC, MultiQC), an image or a PDF opens
|
|
172
|
+
in its usual program. A BAM or VCF file can open in IGV, an alignment in Jalview or AliView, and a
|
|
173
|
+
tree in FigTree, if those programs are installed. You are asked every time.
|
|
174
|
+
|
|
175
|
+
## In a notebook (Jupyter, JupyterLab, Colab, VS Code)
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
import asktim
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Then start any cell with `AskTim!`:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
AskTim! "how do I read a gzipped FASTA file with Biopython?"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
AskTim! why
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
AskTim! "why is this so slow?"
|
|
193
|
+
for rec in SeqIO.parse(path, "fasta"):
|
|
194
|
+
...
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Code under the first line is sent with the question, with any data in it withheld. After a cell
|
|
198
|
+
fails, `AskTim! why` explains the error. `AskTim! insert 2` puts code block 2 of the last answer
|
|
199
|
+
into a new cell. `%AskTim!` and `%%AskTim!` work too.
|
|
200
|
+
|
|
201
|
+
`AskTim! Agent "..."` runs the agent in the notebook. It runs shell commands as at the command line,
|
|
202
|
+
and it can also run Python in your notebook (you see the code first), look at your variables (their
|
|
203
|
+
names, types and shapes, never their values), and add Markdown and code cells.
|
|
204
|
+
|
|
205
|
+
| | Jupyter Notebook 7, JupyterLab | Colab | VS Code |
|
|
206
|
+
|---|---|---|---|
|
|
207
|
+
| Questions, `why` | ✓ | ✓ | ✓ |
|
|
208
|
+
| Agent: shell and Python steps | ✓ | ✓ | ✓ |
|
|
209
|
+
| Agent: new cells | added below; running each brings the next | shown with a Copy button, and saved in `agent-record.ipynb` | as Colab |
|
|
210
|
+
| `AskTim! insert N` | new cell | Copy button | Copy button |
|
|
211
|
+
|
|
212
|
+
Colab doesn't let the kernel add cells, and VS Code doesn't seem to either, so they show Copy
|
|
213
|
+
buttons instead.
|
|
214
|
+
|
|
215
|
+
[`examples/AskTim-demo.ipynb`](https://github.com/comparativechrono/AskTim/blob/main/examples/AskTim-demo.ipynb) is a short walk-through for students that runs in Colab
|
|
216
|
+
([open it in Colab](https://colab.research.google.com/github/comparativechrono/AskTim/blob/main/examples/AskTim-demo.ipynb)).
|
|
217
|
+
|
|
218
|
+
**Keys in Colab.** Store the key in Colab's Secrets (the key icon on the left) as
|
|
219
|
+
`ANTHROPIC_API_KEY` (or `GEMINI_API_KEY`, `OPENAI_API_KEY`) and give the notebook access. You can
|
|
220
|
+
also type `AskTim! Claude` in a cell and paste the key into the box that appears. Colab forgets a
|
|
221
|
+
key stored like that when the runtime stops. If you type a key into a cell, AskTim! removes it from
|
|
222
|
+
the notebook's history. In Jupyter it also removes it from the cell; elsewhere it tells you to
|
|
223
|
+
delete it before you share the notebook.
|
|
224
|
+
|
|
225
|
+
## What reaches the AI, and what never does
|
|
226
|
+
|
|
227
|
+
**Sent with a question:**
|
|
228
|
+
|
|
229
|
+
- your question;
|
|
230
|
+
- the programs and packages that are installed, with their versions;
|
|
231
|
+
- your recent commands, with secrets (API keys, tokens, passwords), e-mail addresses, phone and NHS
|
|
232
|
+
numbers and long sequences taken out, and your user name replaced by `user`;
|
|
233
|
+
- the names and sizes of the files in the current folder;
|
|
234
|
+
- with `--file`, a description of the file's structure: format, size, number of records, and for a
|
|
235
|
+
table the column names and what kind of values each column has, but not the values;
|
|
236
|
+
- text you pipe in, with the lines that look like data withheld;
|
|
237
|
+
- in a notebook: the code of the cells you ran (tables pasted into code and long lists of numbers
|
|
238
|
+
withheld), your variables' names, types and shapes, and the last error.
|
|
239
|
+
|
|
240
|
+
**Sent by the agent:** its commands and files (you see them first), and what each command printed,
|
|
241
|
+
with every line that looks like data withheld. Text gets through: if the agent reads a README or
|
|
242
|
+
your notes, the AI sees them.
|
|
243
|
+
|
|
244
|
+
**Never sent:** the contents of your data files, your variables' values, your keys, or anything
|
|
245
|
+
from `~/.ssh` and other credentials.
|
|
246
|
+
|
|
247
|
+
The data filter works line by line and recognises data by its shape: FASTQ and FASTA records,
|
|
248
|
+
SAM/BAM alignments, VCF records and sample names, BED and GFF intervals, table rows, lists of IDs
|
|
249
|
+
or numbers, long sequences, and encoded blobs. Error messages, warnings, help text, versions,
|
|
250
|
+
counts, summaries (such as `samtools flagstat`) and file listings get through, because those are
|
|
251
|
+
what the AI needs to help. Withheld lines are replaced by a note such as
|
|
252
|
+
`[AskTim!: 1204 lines withheld – they look like data (SAM/BAM alignments); the student can see them]`.
|
|
253
|
+
You always see the full output yourself.
|
|
254
|
+
|
|
255
|
+
`--strict`, or `"privacy": "strict"` in the settings, withholds more: column names, file listings,
|
|
256
|
+
summaries and quoted values in error messages.
|
|
257
|
+
|
|
258
|
+
**Limits.** The filter is made for bioinformatics data and works well on it. It recognises data by
|
|
259
|
+
its shape, so it can't promise to catch every piece of free text. A person's name quoted in an
|
|
260
|
+
error message, or a list of names typed into code, can get through (strict mode replaces quoted
|
|
261
|
+
values). An agent that set out to get round the filter, by rewriting data as words for example,
|
|
262
|
+
could do so. AskTim! tells it not to, and in the default mode you see every command before it
|
|
263
|
+
runs. Don't use AskTim!, or any AI tool, on personal or patient data unless your institution has
|
|
264
|
+
approved it. `AskTim! show "..."` lets you check what would be sent.
|
|
265
|
+
|
|
266
|
+
**The AI services.** What a service does with what it receives is set by its terms, and these
|
|
267
|
+
change, so check them before recommending one to a class. When this was written (November 2026):
|
|
268
|
+
|
|
269
|
+
- Anthropic's [Commercial Terms](https://www.anthropic.com/legal/commercial-terms), which cover API
|
|
270
|
+
keys, say Anthropic may not train models on what is sent.
|
|
271
|
+
- Google's [Gemini API terms](https://ai.google.dev/terms) say that on the free tier,
|
|
272
|
+
Google uses what is sent to improve its products. In the EEA, Switzerland and the UK, the
|
|
273
|
+
paid-service terms apply to the free tier too. The terms also require users to be 18 or over, and
|
|
274
|
+
say the API is for professional or business use.
|
|
275
|
+
|
|
276
|
+
## Safeguards (the agent)
|
|
277
|
+
|
|
278
|
+
- **Nothing is installed:** pip, conda, mamba, apt, brew, `install.packages`, `BiocManager`, npm and
|
|
279
|
+
the like are refused, and so is `sudo`.
|
|
280
|
+
- **It writes only to its run folder** (and a private temporary folder). Your files are never
|
|
281
|
+
changed or deleted. In-place edits (`sed -i`), indexing a reference next to your copy of it, and
|
|
282
|
+
writing outside the folder are all refused. With `--here`, AskTim! asks before any change to a
|
|
283
|
+
file that was already there.
|
|
284
|
+
- **A sandbox, where possible.** On Linux with [bubblewrap](https://github.com/containers/bubblewrap)
|
|
285
|
+
(`bwrap`) installed, each command runs in a sandbox. The file system is read-only except for the
|
|
286
|
+
run folder. `/tmp` is private, there is no network unless you used `--web`, and the command can't
|
|
287
|
+
see your other processes. Without bubblewrap, the checks below still apply, and AskTim! reports
|
|
288
|
+
any file that changes outside the agent's folder. But a check can't know every program's options,
|
|
289
|
+
so the sandbox is the stronger safeguard. `AskTim! status` says which you have.
|
|
290
|
+
- **No network** unless `--web`. Uploads (`curl -T`, `scp`, `rsync` to another computer, `nc`, posting
|
|
291
|
+
files) are refused even then.
|
|
292
|
+
- **No secrets.** Commands run with API keys and tokens removed from the environment. Reading
|
|
293
|
+
`~/.ssh`, `~/.aws`, shell histories or AskTim!'s own keys is refused.
|
|
294
|
+
- **What you approve is what runs.** Commands and files with hidden control characters or
|
|
295
|
+
text-direction tricks are refused, and the AI's text is shown with such characters made visible.
|
|
296
|
+
In notebooks, nothing the AI writes reaches the page as HTML or script, and the agent's Python
|
|
297
|
+
may not write HTML or JavaScript of its own into the page.
|
|
298
|
+
- **Programs that would hang** are refused: interactive programs, editors, REPLs and windowed
|
|
299
|
+
programs (the agent opens files for you with `open_file` instead).
|
|
300
|
+
- **Limits:** by default 25 steps and 600 seconds per command (a command is stopped together with
|
|
301
|
+
everything it started), and output is trimmed before it is filtered.
|
|
302
|
+
- **Code is checked too.** Python and R the agent writes or runs is checked for installs, network
|
|
303
|
+
use, deletions and writes outside its folder. Risky code still needs your yes in `--auto`.
|
|
304
|
+
- **A record of every run** (`RUN.md`, `run.json`, `rerun.sh`), and a draft statement on your use of
|
|
305
|
+
AI (below).
|
|
306
|
+
|
|
307
|
+
In a notebook, the agent's Python runs in your kernel with your permissions; only shell commands
|
|
308
|
+
can be sandboxed. AskTim! checks the code before it runs, but these checks are static. Read each
|
|
309
|
+
Python step before you approve it, as the default mode asks you to. If nobody is there to approve
|
|
310
|
+
(nbconvert, papermill), the agent refuses to start unless you used `--auto`.
|
|
311
|
+
|
|
312
|
+
## Shell integration
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
AskTim! setup-shell # bash, zsh or fish; AskTim! setup-shell --remove undoes it
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
This adds a few lines to your `~/.bashrc`, `~/.zshrc` or fish config. They record each command you
|
|
319
|
+
type, where you typed it and whether it worked (never its output) in a file in AskTim!'s folder that
|
|
320
|
+
only you can read. Commands that start with a space are left out. In bash and zsh, **Alt+A** then
|
|
321
|
+
puts the commands from AskTim!'s last answer on your command line, one at a time, for you to read
|
|
322
|
+
and run. In zsh it also lets you type `?` and `*` in unquoted questions.
|
|
323
|
+
|
|
324
|
+
## Records and your statement on AI use
|
|
325
|
+
|
|
326
|
+
`AskTim! log` lists your recent questions and agent runs. The log is kept on your computer.
|
|
327
|
+
`AskTim! statement` drafts a "Statement on the use of AI" for coursework: what you asked, which
|
|
328
|
+
models answered, what was sent, and the agent's tasks with where their records are (each `RUN.md`
|
|
329
|
+
lists what was run and what was refused). Use `--since 2026-11-01` to limit it by date, and `--all`
|
|
330
|
+
for every folder, not just this one. Read it and edit it; it is a draft, and the statement is yours.
|
|
331
|
+
|
|
332
|
+
## For instructors
|
|
333
|
+
|
|
334
|
+
A settings file for a lab or a JupyterHub image, at `/etc/asktim/config.json` (on Windows
|
|
335
|
+
`%PROGRAMDATA%\asktim\config.json`, or wherever `ASKTIM_SITE_CONFIG` points), sets the defaults for
|
|
336
|
+
everyone. Keys listed under `"locked"` cannot be
|
|
337
|
+
changed by students:
|
|
338
|
+
|
|
339
|
+
```json
|
|
340
|
+
{
|
|
341
|
+
"provider": "claude",
|
|
342
|
+
"models": {"claude": "claude-sonnet-5-5"},
|
|
343
|
+
"privacy": "strict",
|
|
344
|
+
"course": "Part II Bioinformatics practical 3: RNA-seq with salmon and DESeq2. Data are in ~/data. Students use R 4.4.",
|
|
345
|
+
"history_lines": 10,
|
|
346
|
+
"agent": {"max_steps": 15, "command_timeout": 300, "allow_network": false, "sandbox": "on"},
|
|
347
|
+
"locked": ["provider", "models", "privacy", "agent.allow_network", "agent.max_steps", "agent.sandbox"]
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
`course` is added to what the AI is told, so you can describe the practical, the data and any house
|
|
352
|
+
rules. Settings are applied in this order: defaults, the site file, the student's
|
|
353
|
+
`~/.config/asktim/config.json`, environment variables (`ASKTIM_PROVIDER`, `ASKTIM_MODEL`,
|
|
354
|
+
`ASKTIM_PRIVACY`, `ASKTIM_COURSE`, `ASKTIM_OPENAI_URL`, ...), then command-line options. Locked
|
|
355
|
+
values win over everything after the site file. With `"sandbox": "on"`, the agent refuses to run
|
|
356
|
+
without a sandbox.
|
|
357
|
+
|
|
358
|
+
Things to think about before a class:
|
|
359
|
+
|
|
360
|
+
- **Keys.** Each student can use their own key. You can also give a shared key in an environment
|
|
361
|
+
variable on the lab machines, or point AskTim! at an institutional OpenAI-compatible gateway with
|
|
362
|
+
`"provider": "openai"` and `"openai_base_url"`.
|
|
363
|
+
- **Rehearse with a real key.** The tests use stand-in AI services, so run the practical once with
|
|
364
|
+
the real service and model you will use, as the practicals' READMEs recommend.
|
|
365
|
+
- **Install bubblewrap** on Linux lab machines (`apt install bubblewrap`) so that the agent is
|
|
366
|
+
sandboxed.
|
|
367
|
+
- **Tell students what is sent.** `AskTim! privacy` prints it, and `AskTim! show "..."` lets them
|
|
368
|
+
check for themselves. Checking is part of using AI responsibly.
|
|
369
|
+
|
|
370
|
+
## Commands
|
|
371
|
+
|
|
372
|
+
| Command | |
|
|
373
|
+
|---|---|
|
|
374
|
+
| `AskTim! "question"` | ask (also `AskTim!` alone, for a conversation) |
|
|
375
|
+
| `AskTim! why` | explain why the last command failed |
|
|
376
|
+
| `AskTim! Agent "task"` | the agent (options above) |
|
|
377
|
+
| `AskTim! show "question"` | print what would be sent; send nothing |
|
|
378
|
+
| `AskTim! Claude` / `Gemini` / `OpenAI` | store a key (and use that service) |
|
|
379
|
+
| `AskTim! use claude\|gemini\|openai` | switch service |
|
|
380
|
+
| `AskTim! model NAME` | change the model for the current service |
|
|
381
|
+
| `AskTim! status` | key, model, privacy, shell integration and sandbox |
|
|
382
|
+
| `AskTim! tools` | what AskTim! found installed |
|
|
383
|
+
| `AskTim! privacy` | what is and isn't sent |
|
|
384
|
+
| `AskTim! setup-shell` | shell integration (`--remove` to undo) |
|
|
385
|
+
| `AskTim! log` / `statement` | your log; a draft AI-use statement |
|
|
386
|
+
| `AskTim! new` / `forget` | forget the conversation; delete stored keys |
|
|
387
|
+
| `AskTim! insert N`, `AskTim! cells` | notebooks: code block N into a cell; the agent's waiting cells |
|
|
388
|
+
|
|
389
|
+
Options for questions: `--no-history`, `--history N`, `--no-files`, `--file PATH`, `--new`,
|
|
390
|
+
`--model NAME`, `--strict`, `--offline` (the built-in help only, without any AI).
|
|
391
|
+
|
|
392
|
+
## Files AskTim! keeps
|
|
393
|
+
|
|
394
|
+
| | Linux, macOS | Windows |
|
|
395
|
+
|---|---|---|
|
|
396
|
+
| settings and keys | `~/.config/asktim/` (`config.json`, `keys.json`) | `%APPDATA%\asktim\` |
|
|
397
|
+
| cache (installed tools, conversation, suggested commands) | `~/.cache/asktim/` | `%LOCALAPPDATA%\asktim\cache\` |
|
|
398
|
+
| log and command history | `~/.local/state/asktim/` | `%LOCALAPPDATA%\asktim\state\` |
|
|
399
|
+
|
|
400
|
+
`ASKTIM_HOME=/some/folder` puts all three under one folder.
|
|
401
|
+
|
|
402
|
+
## From Python
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
import asktim
|
|
406
|
+
asktim.ask("how do I read a BAM file with pysam?")
|
|
407
|
+
asktim.agent("count the reads in data/*.fastq.gz", mode="auto")
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Platforms
|
|
411
|
+
|
|
412
|
+
- **Linux:** everything works. The sandbox needs bubblewrap.
|
|
413
|
+
- **macOS:** everything works, but the agent is not sandboxed by default (its commands are still
|
|
414
|
+
checked). `"sandbox": "on"` uses macOS's `sandbox-exec`, which has had less testing.
|
|
415
|
+
- **Windows:** AskTim! is written to work there, but it hasn't been tested on Windows yet. Use
|
|
416
|
+
`asktim` (without the `!`). The agent needs bash, so use it in WSL (which works as Linux does) or
|
|
417
|
+
Git Bash.
|
|
418
|
+
- **zsh:** quote questions, or run `AskTim! setup-shell`.
|
|
419
|
+
|
|
420
|
+
## Development
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
git clone https://github.com/comparativechrono/AskTim && cd AskTim
|
|
424
|
+
pip install -e ".[test]"
|
|
425
|
+
pytest
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
The tests use stand-ins for the Claude, Gemini and OpenAI APIs. They check that no read, sequence or
|
|
429
|
+
table row from the test data reaches the AI. They run the agent on real tools (bwa and samtools if
|
|
430
|
+
installed) and in a real terminal and notebook kernel, and they attack the safeguards.
|
|
431
|
+
`tests/markdown_fuzz/` checks the notebook's Markdown sanitiser against marked, the parser
|
|
432
|
+
JupyterLab uses: set `ASKTIM_NODE_MODULES` to a `node_modules` folder with `marked` and `jsdom` to
|
|
433
|
+
include it.
|
|
434
|
+
|
|
435
|
+
### Making a release
|
|
436
|
+
|
|
437
|
+
1. Put the new version in `src/asktim/__init__.py` (`__version__ = "0.2.0"`) and push it.
|
|
438
|
+
2. On GitHub, draft a new release with the tag `v0.2.0` (the same version, with a `v`) and publish it.
|
|
439
|
+
|
|
440
|
+
The release workflow then runs the tests, builds the package, checks that the tag matches the
|
|
441
|
+
version, and publishes it to [PyPI](https://pypi.org/project/AskTim/) through PyPI's trusted
|
|
442
|
+
publishing, so no PyPI token is stored anywhere.
|
|
443
|
+
|
|
444
|
+
## Known limitations
|
|
445
|
+
|
|
446
|
+
- The data filter recognises data by its shape (see above). Free text, such as a name, can get
|
|
447
|
+
through.
|
|
448
|
+
- Data typed into notebook code is withheld only when it looks like a table or a list of numbers.
|
|
449
|
+
- AskTim! has been tested against stand-ins for the AI services, so rehearse with the real one.
|
|
450
|
+
Model names change: `AskTim! model NAME` sets another.
|
|
451
|
+
- In notebooks, the agent's Python steps are checked statically and run with your permissions.
|
|
452
|
+
- Colab and VS Code can't receive new cells from the kernel, so they get Copy buttons.
|
|
453
|
+
- On macOS the agent is not sandboxed unless the settings ask for it. On Windows the agent needs WSL
|
|
454
|
+
or Git Bash.
|
|
455
|
+
|
|
456
|
+
## Licence
|
|
457
|
+
|
|
458
|
+
MIT (see [`LICENSE`](https://github.com/comparativechrono/AskTim/blob/main/LICENSE)).
|