Skip to content

Conversation

@ajbozarth
Copy link
Contributor

@ajbozarth ajbozarth commented Feb 9, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Adds support for using HuggingFace smolagents tools with Mellea, enabling seamless integration with the smolagents ecosystem.

  • Add from_smolagents() classmethod to MelleaTool
    • Uses smolagents' get_tool_json_schema() for OpenAI-compatible conversion
    • Wraps smolagents Tool.forward() method with proper error handling
  • Add smolagents as optional dependency in pyproject.toml
  • Update .gitignore to exclude AI agent config directories
  • Add comprehensive unit tests for the HuggingFace smolagents integration
  • Add smolagents_example.py demonstrating MelleaTool.from_smolagents()
  • Update tools/README.md with smolagents example documentation
  • Add smolagents installation instructions to main README.md

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Implements loading of HuggingFace smolagents tools into Mellea's tool system.

- Add from_huggingface() classmethod to MelleaTool
- Uses smolagents' get_tool_json_schema() for OpenAI-compatible conversion
- Wraps smolagents Tool.forward() method with proper error handling
- Add smolagents as optional dependency in pyproject.toml
- Update .gitignore to exclude AI agent config directories

Related to generative-computing#411

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth self-assigned this Feb 9, 2026
@ajbozarth ajbozarth added the enhancement New feature or request label Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Feb 9, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

Add comprehensive unit tests for the HuggingFace smolagents integration:
- test_from_huggingface_basic: Tests basic tool loading and schema conversion
- test_from_huggingface_multiple_inputs: Tests tools with multiple parameters
- test_from_huggingface_invalid_tool: Tests error handling for invalid objects

Tests follow existing patterns with try/except ImportError for graceful
handling when smolagents is not installed.

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
- Add smolagents_example.py demonstrating MelleaTool.from_huggingface()
- Update tools/README.md with smolagents example documentation
- Add smolagents installation instructions to main README.md

Related: generative-computing#411
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth marked this pull request as ready for review February 9, 2026 23:12
Copy link
Contributor

@jakelorocco jakelorocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! looks good to me; just one note on packages

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth
Copy link
Contributor Author

ajbozarth commented Feb 10, 2026

IIUC the following items are the remaining review and take-aways:

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth changed the title feat: add MelleaTool.from_huggingface() for smolagents integration feat: add MelleaTool.from_smolagents() for smolagents integration Feb 10, 2026
@ajbozarth
Copy link
Contributor Author

I've addressed all current review and opened #453 for follow up work around pyproject.toml as discussed. If all the reviewers could take another pass then I'll add this to the merge queue

Copy link
Member

@psschwei psschwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ajbozarth ajbozarth enabled auto-merge February 10, 2026 21:13
@ajbozarth ajbozarth disabled auto-merge February 10, 2026 21:13
@ajbozarth ajbozarth added this pull request to the merge queue Feb 10, 2026
Merged via the queue into generative-computing:main with commit 0471006 Feb 10, 2026
4 checks passed
@ajbozarth ajbozarth deleted the feat/smolagents-tools branch February 10, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: enable adding tools from huggingface (smolagents)

5 participants