Skip to content

Conversation

@vblagoje
Copy link
Member

Why:

Adopts Haystack's ToolsType to enable flexible tool composition, developers can now mix individual Tool objects and Toolset instances in a single list

part of:

What:

  • Updated tools parameter from Union[List[Tool], Toolset] to ToolsType in constructor and all methods
  • Replaced manual isinstance(tools, Toolset) checks with flatten_tools_or_toolsets() utility
  • Haystack dependency to 2.19.0 for ToolsType support
  • Added tests for mixed tool collection initialization and request parameter formatting

How can it be used:

from haystack.tools import Tool, Toolset
from haystack_integrations.components.generators.llama_cpp import LlamaCppChatGenerator

weather_tool = Tool(name="weather", ...)
population_toolset = Toolset([...])

# NEW: Mix Tool and Toolset freely
generator = LlamaCppChatGenerator(tools=[weather_tool, population_toolset])

How did you test it:

  • Unit tests verify mixed tool initialization and correct llama.cpp tools formatting
  • Backward compatibility validated for existing patterns (list of tools, single toolset)

Notes for the reviewer:

  • Centralizes tool normalization logic with flatten_tools_or_toolsets()—eliminates duplicate handling code
  • Fully backward compatible; no migration needed
  • Added integration test test_run_with_mixed_tools() demonstrates end-to-end LLM tool invocation from mixed collections

@vblagoje vblagoje requested a review from a team as a code owner October 22, 2025 12:18
@vblagoje vblagoje requested review from mpangrazzi and removed request for a team October 22, 2025 12:18
@github-actions github-actions bot added integration:llama_cpp type:documentation Improvements or additions to documentation labels Oct 22, 2025
Copy link
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

Looks good!

@vblagoje vblagoje merged commit ae6e38b into main Oct 23, 2025
11 checks passed
@vblagoje vblagoje deleted the llama_cpp-toolstype branch October 23, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:llama_cpp type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants