Repository navigation
Conversation
…talog - Add navigation README for docs/examples/sampling/ - Standardize header docstrings in sampling and agent scripts - Index react_using_mellea.py in docs/examples/agents/README.md - Register sampling/, requirements/, and audio_text_models/ in docs/docs/examples/index.md Assisted-by: IBM Bob Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com>
planetf1
left a comment
There was a problem hiding this comment.
Useful docs-only change: it makes sampling/ and the stdlib react() example discoverable, and the READMEs and index rows match the source. I ran both sampling examples against Ollama and they run. Three non-blocking points below, plus one follow-up suggestion.
Separately, not for this PR: presets.py:220 tells users to run uv sync --extra plotting, but no such extra exists in pyproject.toml.
| | [`python_code_generation_preset.py`](./python_code_generation_preset.py) | Python code generation preset bundling extraction, syntax, and execution requirements with automatic repair feedback. | | ||
| | [`python_plotting_preset.py`](./python_plotting_preset.py) | Matplotlib plotting preset bundling headless backend setup, plot file output validation, and sandbox execution. | |
There was a problem hiding this comment.
"Execution requirements" and "sandbox execution" read as if the generated code is run. In these examples it mostly isn't. With use_sandbox=False the tier is static, which only parses and import-checks (python_tools.py:424). That is the code-generation default and what four of the five plotting examples use. Suggest wording like "validates generated code, with optional Docker-sandboxed execution". Same wording at python_code_generation_preset.py:5 and python_plotting_preset.py:6.
Follow-up, not for this PR: the examples show the validate-and-repair loop but never execute generated code, so timeout_seconds, output_limit_chars and the savefig output aren't exercised. A real example with use_sandbox=True that runs the code and checks the result would show the preset's main value. A couple of docstrings still describe sandboxed behaviour too (python_plotting_preset.py:26 and :147).
There was a problem hiding this comment.
Fixed to be more specific about sandbox use.
| @@ -0,0 +1,10 @@ | |||
| # Sampling Examples | |||
|
|
|||
| Pre-configured sampling presets and strategies for constrained generation tasks such as Python code generation and data plotting. | |||
There was a problem hiding this comment.
Two small clarity points for someone arriving from the index:
- "presets and strategies": the directory has two presets and no standalone strategy examples, since the strategy is bundled inside each preset. Nothing in the docs defines a preset, so one sentence would help, e.g. "A preset bundles a set of requirements with a repair strategy so a common task works in one call."
requirements/covers the same code-generation and plotting tasks via the manualpython_toolroute. A line in each README pointing at the other would help readers choose between assembling it themselves and using the preset.
There was a problem hiding this comment.
Improved the README summary, including a definition of preset and pointer to related requirements.
| | File | Description | | ||
| | :--- | :--- | | ||
| | [`python_code_generation_preset.py`](./python_code_generation_preset.py) | Python code generation preset bundling extraction, syntax, and execution requirements with automatic repair feedback. | | ||
| | [`python_plotting_preset.py`](./python_plotting_preset.py) | Matplotlib plotting preset bundling headless backend setup, plot file output validation, and sandbox execution. | |
There was a problem hiding this comment.
These examples need a running Ollama with the default model (granite4.2:3b), and the plotting ones need matplotlib, which isn't in any extra. example_without_output_path is the only one that runs generated code in Docker, so it also needs llm-sandbox (mellea[sandbox]), a running Docker daemon, and a sandbox image that runs on your machine. The default image is amd64-only, which can matter on Apple Silicon. A short prerequisites line would help.
It would also help that, when the sandbox can't run, the failure is hard to spot. The run reports Valid: 5/6 with the unmet requirement shown only as "sandbox execution with policy", and the underlying error never appears in the output. The script still prints "✓ completed", because it doesn't check the sampling result.
There was a problem hiding this comment.
Updated the scripts to include ollama and dependency install commands in their Prerequisites. I think this helps towards keeping the examples self-contained and in case future examples are added under this directory that may not need the same prerequisites.
…ings Assisted-by: IBM Bob Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com>
Assisted-by: IBM Bob Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com>
Pull Request
Issue
Towards #1746
Description
docs/examples/sampling/):README.mdcataloging available sampling presets (python_code_generation_preset.py,python_plotting_preset.py).ollama pull, dependencies), and usage commands.docs/examples/agents/):README.mdto an index table cataloging all agent scripts.react_using_mellea.pyalongside scratch implementations.docs/docs/examples/index.md):sampling/,requirements/, andaudio_text_models/in the main example index table.Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.