Commit 48802e5
feat: improve semantic search marimo notebook (#582)
## Summary
Follow-up improvements to the semantic search marimo notebook merged in
#581.
## Changes
**Multilingual support**
- Switch embedding model to `multilingual-e5-large` for cross-lingual
retrieval
- Embed both English and Spanish sentences from Tatoeba using
`filter_pairs` + `extract_sentences(lang)`
- Add cross-lingual query examples and a language filtering section
using Pinecone metadata filters
**Interactivity**
- Interactive query input with `mo.ui.text` and `mo.ui.radio` language
selector
- Interactive API key input: reads `PINECONE_API_KEY` from env/`.env`
with a `mo.ui.text(kind="password")` fallback for molab users; uses
`mo.callout` admonitions for each state
**Display**
- Search results rendered as `mo.ui.table` with a `lang` column showing
which language each hit came from
- Progress bar via `mo.status.progress_bar` (replacing tqdm)
**Correctness / hygiene**
- Pin `datasets==3.5.1` — `datasets>=4` dropped support for custom
loading scripts used by `Helsinki-NLP/tatoeba`
- Use keyword argument names in all Pinecone API calls
- Remove unused `numpy` and `tqdm` dependencies
- Remove notebook-specific deps from root `pyproject.toml` (they belong
in the notebook's `# /// script` inline metadata)
## Test Plan
- [ ] Notebook runs end-to-end in sandbox mode (`uvx marimo edit
--sandbox`) with a valid `PINECONE_API_KEY`
- [ ] Password input appears when env var is unset; success callout
appears when set
- [ ] Cross-lingual queries return results in both English and Spanish
- [ ] Language filter correctly scopes results to `en` or `es`
- [ ] Interactive query input updates results on change
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk documentation/notebook-only changes that adjust dependency
pinning and interactive API key handling; no production code paths
affected.
>
> **Overview**
> Improves the `docs/semantic-search.py` semantic search marimo notebook
setup experience by **pinning `datasets==3.5.1`** and replacing the
env-only Pinecone key requirement with an **interactive API key input**
(env/`.env` auto-detect + password field fallback with callouts).
>
> Adds a guard (`mo.stop`) to halt execution until a key is provided and
introduces a brief section clarifying client instantiation (including
the example-only `source_tag`).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6da4180. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Code <claude@anthropic.com>
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent c63f91e commit 48802e5
1 file changed
Lines changed: 67 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
66 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
67 | 127 | | |
68 | 128 | | |
69 | 129 | | |
| |||
0 commit comments