community[patch]: Release 0.0.2 (#14610)

This commit is contained in:
Bagatur
2023-12-12 09:58:04 -08:00
committed by GitHub
parent 5d1deddbfb
commit d388863a3b
6 changed files with 85 additions and 45 deletions

View File

@@ -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