mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-03 21:54:04 +00:00
**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>
44 lines
1.2 KiB
Python
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
|