mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-20 01:49:51 +00:00
simplify returns
This commit is contained in:
parent
6e2418d44b
commit
704db3741a
@ -561,10 +561,9 @@ class HumanMessage:
|
|||||||
Returns:
|
Returns:
|
||||||
Concatenated string of all text blocks in the message.
|
Concatenated string of all text blocks in the message.
|
||||||
"""
|
"""
|
||||||
text_parts = [
|
return "".join(
|
||||||
block["text"] for block in self.content if types.is_text_block(block)
|
block["text"] for block in self.content if types.is_text_block(block)
|
||||||
]
|
)
|
||||||
return "".join(text_parts)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -641,10 +640,9 @@ class SystemMessage:
|
|||||||
|
|
||||||
def text(self) -> str:
|
def text(self) -> str:
|
||||||
"""Extract all text content from the system message."""
|
"""Extract all text content from the system message."""
|
||||||
text_parts = [
|
return "".join(
|
||||||
block["text"] for block in self.content if types.is_text_block(block)
|
block["text"] for block in self.content if types.is_text_block(block)
|
||||||
]
|
)
|
||||||
return "".join(text_parts)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -734,10 +732,9 @@ class ToolMessage(ToolOutputMixin):
|
|||||||
@property
|
@property
|
||||||
def text(self) -> str:
|
def text(self) -> str:
|
||||||
"""Extract all text content from the tool message."""
|
"""Extract all text content from the tool message."""
|
||||||
text_parts = [
|
return "".join(
|
||||||
block["text"] for block in self.content if types.is_text_block(block)
|
block["text"] for block in self.content if types.is_text_block(block)
|
||||||
]
|
)
|
||||||
return "".join(text_parts)
|
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
def __post_init__(self) -> None:
|
||||||
"""Initialize computed fields after dataclass creation.
|
"""Initialize computed fields after dataclass creation.
|
||||||
|
Loading…
Reference in New Issue
Block a user