mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 19:12:42 +00:00
[Patch] Dedent docstring (#20959)
Technically a slight prompt breaking change, but I think positive EV in that it saves tokens and results in more sane / in-distribution prompts
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
import textwrap
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from functools import partial
|
||||
@@ -333,7 +334,7 @@ def test_structured_tool_from_function_docstring() -> None:
|
||||
|
||||
prefix = "foo(bar: int, baz: str) -> str - "
|
||||
assert foo.__doc__ is not None
|
||||
assert structured_tool.description == prefix + foo.__doc__.strip()
|
||||
assert structured_tool.description == prefix + textwrap.dedent(foo.__doc__.strip())
|
||||
|
||||
|
||||
def test_structured_tool_from_function_docstring_complex_args() -> None:
|
||||
@@ -366,7 +367,7 @@ def test_structured_tool_from_function_docstring_complex_args() -> None:
|
||||
|
||||
prefix = "foo(bar: int, baz: List[str]) -> str - "
|
||||
assert foo.__doc__ is not None
|
||||
assert structured_tool.description == prefix + foo.__doc__.strip()
|
||||
assert structured_tool.description == prefix + textwrap.dedent(foo.__doc__).strip()
|
||||
|
||||
|
||||
def test_structured_tool_lambda_multi_args_schema() -> None:
|
||||
@@ -701,7 +702,7 @@ def test_structured_tool_from_function() -> None:
|
||||
|
||||
prefix = "foo(bar: int, baz: str) -> str - "
|
||||
assert foo.__doc__ is not None
|
||||
assert structured_tool.description == prefix + foo.__doc__.strip()
|
||||
assert structured_tool.description == prefix + textwrap.dedent(foo.__doc__.strip())
|
||||
|
||||
|
||||
def test_validation_error_handling_bool() -> None:
|
||||
|
Reference in New Issue
Block a user