anthropic: docstrings (#23145)

Added missed docstrings. Format docstrings to the consistent format
(used in the API Reference)
pull/21529/head^2
Leonid Ganeline 3 weeks ago committed by GitHub
parent 90559fde70
commit 3dfd055411
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -231,7 +231,7 @@ def _format_messages(messages: List[BaseMessage]) -> Tuple[Optional[str], List[D
class ChatAnthropic(BaseChatModel):
"""Anthropic chat model integration.
"""Anthropic chat models.
See https://docs.anthropic.com/en/docs/models-overview for a list of the latest models.
@ -1008,6 +1008,8 @@ class ChatAnthropic(BaseChatModel):
class AnthropicTool(TypedDict):
"""Anthropic tool definition."""
name: str
description: str
input_schema: Dict[str, Any]
@ -1016,6 +1018,7 @@ class AnthropicTool(TypedDict):
def convert_to_anthropic_tool(
tool: Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool],
) -> AnthropicTool:
"""Convert a tool-like object to an Anthropic tool definition."""
# already in Anthropic tool format
if isinstance(tool, dict) and all(
k in tool for k in ("name", "description", "input_schema")

@ -55,6 +55,7 @@ def _get_type(parameter: Dict[str, Any]) -> str:
def get_system_message(tools: List[Dict]) -> str:
"""Generate a system message that describes the available tools."""
tools_data: List[Dict] = [
{
"tool_name": tool["name"],

@ -362,4 +362,6 @@ class AnthropicLLM(LLM, _AnthropicCommon):
@deprecated(since="0.1.0", removal="0.3.0", alternative="AnthropicLLM")
class Anthropic(AnthropicLLM):
"""Anthropic large language model."""
pass

@ -7,9 +7,14 @@ from langchain_core.pydantic_v1 import BaseModel
class ToolsOutputParser(BaseGenerationOutputParser):
"""Output parser for tool calls."""
first_tool_only: bool = False
"""Whether to return only the first tool call."""
args_only: bool = False
"""Whether to return only the arguments of the tool calls."""
pydantic_schemas: Optional[List[Type[BaseModel]]] = None
"""Pydantic schemas to parse tool calls into."""
class Config:
extra = "forbid"
@ -59,6 +64,7 @@ class ToolsOutputParser(BaseGenerationOutputParser):
def extract_tool_calls(content: List[dict]) -> List[ToolCall]:
"""Extract tool calls from a list of content blocks."""
tool_calls = []
for block in content:
if block["type"] != "tool_use":

Loading…
Cancel
Save