langchain/libs/partners/cohere/tests/unit_tests/test_utils.py
harry-cohere e2b83c87b1
cohere[patch]: Add multihop tool agent (#19919)
**Description**: Adds an agent that uses Cohere with multiple hops and
multiple tools.

This PR is a continuation of
https://github.com/langchain-ai/langchain/pull/19650 - which was
previously approved. Conceptually nothing has changed, but this PR has
extra fixes, documentation and testing.

---------

Co-authored-by: BeatrixCohere <128378696+BeatrixCohere@users.noreply.github.com>
Co-authored-by: Erick Friis <erickfriis@gmail.com>
2024-04-02 09:18:50 -07:00

44 lines
1.2 KiB
Python

import pytest
from langchain_cohere.utils import _remove_signature_from_tool_description
@pytest.mark.parametrize(
"name,description,expected",
[
pytest.param(
"foo", "bar baz", "bar baz", id="description doesn't have signature"
),
pytest.param("foo", "", "", id="description is empty"),
pytest.param("foo", "foo(a: str) - bar baz", "bar baz", id="signature"),
pytest.param(
"foo", "foo() - bar baz", "bar baz", id="signature with empty args"
),
pytest.param(
"foo",
"foo(a: str) - foo(b: str) - bar",
"foo(b: str) - bar",
id="signature with edge case",
),
pytest.param(
"foo", "foo() -> None - bar baz", "bar baz", id="signature with return type"
),
pytest.param(
"foo",
"""My description.
Args:
Bar:
""",
"My description.",
id="signature with Args: section",
),
],
)
def test_remove_signature_from_description(
name: str, description: str, expected: str
) -> None:
actual = _remove_signature_from_tool_description(name=name, description=description)
assert expected == actual