mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 23:41:46 +00:00
community[patch]: Release 0.0.2 (#14610)
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
from langchain_core.tools import BaseTool, tool
|
||||
|
||||
from langchain_community.tools.render import (
|
||||
render_text_description,
|
||||
render_text_description_and_args,
|
||||
)
|
||||
|
||||
|
||||
@tool
|
||||
def search(query: str) -> str:
|
||||
"""Lookup things online."""
|
||||
return "foo"
|
||||
|
||||
|
||||
@tool
|
||||
def calculator(expression: str) -> str:
|
||||
"""Do math."""
|
||||
return "bar"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tools() -> List[BaseTool]:
|
||||
return [search, calculator] # type: ignore
|
||||
|
||||
|
||||
def test_render_text_description(tools: List[BaseTool]) -> None:
|
||||
tool_string = render_text_description(tools)
|
||||
expected_string = """search: search(query: str) -> str - Lookup things online.
|
||||
calculator: calculator(expression: str) -> str - Do math."""
|
||||
assert tool_string == expected_string
|
||||
|
||||
|
||||
def test_render_text_description_and_args(tools: List[BaseTool]) -> None:
|
||||
tool_string = render_text_description_and_args(tools)
|
||||
expected_string = """search: search(query: str) -> str - Lookup things online., \
|
||||
args: {'query': {'title': 'Query', 'type': 'string'}}
|
||||
calculator: calculator(expression: str) -> str - Do math., \
|
||||
args: {'expression': {'title': 'Expression', 'type': 'string'}}"""
|
||||
assert tool_string == expected_string
|
Reference in New Issue
Block a user