-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add MelleaTool.from_smolagents() for smolagents integration #430
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
ajbozarth
merged 7 commits into
generative-computing:main
from
ajbozarth:feat/smolagents-tools
Feb 10, 2026
+259
−9
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a60a75
feat: add MelleaTool.from_huggingface() for smolagents integration
ajbozarth e5f76ca
test: add unit tests for MelleaTool.from_huggingface()
ajbozarth 8d1d922
docs: add smolagents integration example and documentation
ajbozarth 25a5bee
chore: address review
ajbozarth 4fe7f54
chore: address review
ajbozarth a213006
chore: address review
ajbozarth a17fea5
Merge branch 'main' into feat/smolagents-tools
ajbozarth 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
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,44 @@ | ||
| # pytest: ollama, llm | ||
| """Example showing how to use pre-built HuggingFace smolagents tools with Mellea. | ||
|
|
||
| This demonstrates loading existing tools from the smolagents ecosystem, | ||
| similar to how you can use langchain tools with MelleaTool.from_langchain(). | ||
|
|
||
| The smolagents library provides various pre-built tools like: | ||
| - PythonInterpreterTool for code execution | ||
| - DuckDuckGoSearchTool for web search (requires ddgs package) | ||
| - WikipediaSearchTool for Wikipedia queries | ||
| - And many others from the HuggingFace ecosystem | ||
| """ | ||
|
|
||
| from mellea import start_session | ||
| from mellea.backends import ModelOption | ||
| from mellea.backends.tools import MelleaTool | ||
|
|
||
| try: | ||
| # Import a pre-built tool from smolagents | ||
| from smolagents import PythonInterpreterTool | ||
|
|
||
| # Create the smolagents tool instance | ||
| python_tool_hf = PythonInterpreterTool() | ||
|
|
||
| # Convert to Mellea tool - now you can use it with Mellea! | ||
| python_tool = MelleaTool.from_smolagents(python_tool_hf) | ||
|
|
||
| # Use with Mellea session | ||
| m = start_session() | ||
| result = m.instruct( | ||
| "Calculate the sum of numbers from 1 to 10 using Python", | ||
| model_options={ModelOption.TOOLS: [python_tool]}, | ||
| tool_calls=True, | ||
| ) | ||
|
|
||
| print(f"Response: {result}") | ||
|
|
||
| if result.tool_calls: | ||
| calc_result = result.tool_calls[python_tool.name].call_func() | ||
| print(f"\nCalculation result: {calc_result}") | ||
|
|
||
| except ImportError as e: | ||
| print("Please install smolagents: uv pip install 'mellea[smolagents]'") | ||
| print(f"Error: {e}") |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.