Repository navigation
docs(examples): standardize sampling and agents READMEs and docstrings #1752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rafvasq
merged 8 commits into
generative-computing:main
from
rafvasq:docs/sampling-agents-catalog-standardize
Nov 2, 2026
+99
−39
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be3c214
docs(examples): standardize sampling and agents READMEs and update ca…
rafvasq d2af76a
docs(examples): address review comments on sampling README and docstr…
rafvasq b59b7d0
docs(examples): fix RST double backticks in plotting preset docstring
rafvasq ef5bf3e
Address review feedback and restore original wording
rafvasq 34bf996
Merge branch 'main' into docs/sampling-agents-catalog-standardize
rafvasq ec853a7
Fix duplicated requirement row
rafvasq 20fd947
docs(examples): fix granite model tag, dedup sampling row, clarify sa…
rafvasq 1f26011
Merge branch 'main' into docs/sampling-agents-catalog-standardize
rafvasq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,14 @@ | ||
| # Agent Examples | ||
|
|
||
| This directory contains examples of implementing agent patterns with Mellea, specifically the ReACT (Reasoning and Acting) pattern. | ||
| Examples demonstrating agent architectures and the ReACT (Reasoning and Acting) loop in Mellea. | ||
|
|
||
| ## Files | ||
| Start with `react_using_mellea.py` for the shortest path; the `react_from_scratch/` | ||
| examples build the same loop by hand to show what the framework does for you. | ||
|
|
||
| ### [react.py](./react/react_from_scratch/react.py) | ||
| A complete implementation of the ReACT agent pattern that combines reasoning and action in an iterative loop. The agent: | ||
| - Thinks about what to do next | ||
| - Selects an appropriate tool/action | ||
| - Generates arguments for the tool | ||
| - Observes the result | ||
| - Determines if the goal is achieved | ||
| ## Examples | ||
|
|
||
| **Key Features:** | ||
| - Custom `ReactTool` and `ReactToolbox` classes for tool management | ||
| - Dynamic tool selection using Pydantic schemas | ||
| - Iterative thought-action-observation loop | ||
| - Example with weather lookup tools | ||
|
|
||
| **Usage:** | ||
| ```python | ||
| python docs/examples/agents/react/react_from_scratch/react.py | ||
| ``` | ||
|
|
||
| ### [react_instruct.py](./react/react_from_scratch/react_instruct.py) | ||
| An alternative implementation of the ReACT pattern using Mellea's instruct-validate-repair paradigm. | ||
|
|
||
| ## Concepts Demonstrated | ||
|
|
||
| - **Tool Management**: Creating and organizing tools for agent use | ||
| - **Dynamic Prompting**: Building system prompts with tool descriptions | ||
| - **Chat Context**: Using `ChatContext` for multi-turn conversations | ||
| - **Structured Output**: Using Pydantic models for type-safe responses | ||
| - **Iterative Reasoning**: Implementing thought-action-observation loops | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| - See `mellea/stdlib/requirements/tool_reqs.py` for tool requirements | ||
| | File | Description | | ||
| | :--- | :--- | | ||
| | [`react/react_using_mellea.py`](./react/react_using_mellea.py) | ReACT agent using Mellea's stdlib `react()` framework with LangChain tool integration. Needs `langchain-community` and `ddgs`. | | ||
| | [`react/react_from_scratch/react.py`](./react/react_from_scratch/react.py) | A complete implementation of the ReACT agent pattern that combines reasoning and action in an iterative loop. | | ||
| | [`react/react_from_scratch/react_instruct.py`](./react/react_from_scratch/react_instruct.py) | An alternative implementation of the ReACT pattern using Mellea's instruct-validate-repair paradigm. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
docs/examples/agents/react/react_from_scratch/react_instruct.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Sampling Examples | ||
|
|
||
| Pre-configured sampling presets for constrained generation tasks. A preset bundles | ||
| a set of requirements with a repair strategy so a common task works in one call — | ||
| as an alternative to assembling requirements individually. See | ||
| [`requirements/`](../requirements/README.md) for the lower-level building blocks | ||
| these presets wrap. | ||
|
|
||
| ## Examples | ||
|
|
||
| | File | Description | | ||
| | :--- | :--- | | ||
| | [`python_code_generation_preset.py`](./python_code_generation_preset.py) | Python code generation preset bundling extraction, syntax, and import requirements with automatic repair feedback. By default (`use_sandbox=False`) generated code is parsed but not executed, and imports are checked only when `allowed_imports` is set. Pass `use_sandbox=True` to run it in Docker. | | ||
| | [`python_plotting_preset.py`](./python_plotting_preset.py) | Matplotlib plotting preset bundling headless backend configuration and savefig() output validation. Most examples in this file override the default to `use_sandbox=False` (static validation); `example_without_output_path` uses the sandbox default and requires Docker. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.