mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-11-22 04:56:45 +00:00
fix: ComponentTool description should not be truncated (#8870)
* fix: description should not be truncated * chore: add release note
This commit is contained in:
parent
0409e5da8f
commit
cd7c68372b
@ -152,9 +152,7 @@ class ComponentTool(Tool):
|
|||||||
]
|
]
|
||||||
).lstrip("_")
|
).lstrip("_")
|
||||||
|
|
||||||
# Generate a description for the tool if not provided and truncate to 512 characters
|
description = description or component.__doc__ or name
|
||||||
# as most LLMs have a limit for the description length
|
|
||||||
description = (description or component.__doc__ or name)[:512]
|
|
||||||
|
|
||||||
# Create the Tool instance with the component invoker as the function to be called and the schema
|
# Create the Tool instance with the component invoker as the function to be called and the schema
|
||||||
super().__init__(name, description, tool_schema, component_invoker)
|
super().__init__(name, description, tool_schema, component_invoker)
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
ComponentTool does not truncate 'description' anymore.
|
||||||
@ -142,6 +142,12 @@ class TestToolComponent:
|
|||||||
assert "reply" in result
|
assert "reply" in result
|
||||||
assert result["reply"] == "Hello, world!"
|
assert result["reply"] == "Hello, world!"
|
||||||
|
|
||||||
|
def test_from_component_long_description(self):
|
||||||
|
component = SimpleComponent()
|
||||||
|
tool = ComponentTool(component=component, description="".join(["A"] * 1024))
|
||||||
|
|
||||||
|
assert len(tool.description) == 1024
|
||||||
|
|
||||||
def test_from_component_with_dataclass(self):
|
def test_from_component_with_dataclass(self):
|
||||||
component = UserGreeter()
|
component = UserGreeter()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user