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
base: main
Are you sure you want to change the base?
Changes from 1 commit
be3c214
d2af76a
b59b7d0
ef5bf3e
34bf996
ec853a7
20fd947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,11 @@ | ||
| # 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 | ||
| ## Examples | ||
|
|
||
| ### [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 | ||
|
|
||
| **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. | | ||
| | [`react/react_from_scratch/react.py`](./react/react_from_scratch/react.py) | ReACT loop built from scratch using custom tool abstractions and Pydantic schemas. | | ||
| | [`react/react_from_scratch/react_instruct.py`](./react/react_from_scratch/react_instruct.py) | ReACT loop implemented using Mellea's instruct-validate-repair paradigm. | | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Sampling Examples | ||
|
|
||
| Pre-configured sampling presets and strategies for constrained generation tasks such as Python code generation and data plotting. | ||
|
rafvasq marked this conversation as resolved.
Resolved
|
||
|
|
||
| ## Examples | ||
|
|
||
| | 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. | | ||
|
planetf1 marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These examples need a running Ollama with the default model ( It would also help that, when the sandbox can't run, the failure is hard to spot. The run reports
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the scripts to include ollama and dependency install commands in their
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partially fixed. I walked through these as someone running the examples fresh:
On failure visibility: the docstring note is good, but the behaviour is unchanged. A newcomer sees four check lines, a P.S. while checking model tags:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reordered to ollama serve/ollama pull across all five scripts and switched to The plotting module's On failure visibility, I went with the second option for this PR and dropped the "fails silently" message. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks — the Prerequisites blocks and the "fails silently" rewording read well. Three residuals from this thread:
Separately, while checking the head merge:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed 1 and 2 along with the |
||
Uh oh!
There was an error while loading. Please reload this page.