|
|
@ -149,6 +149,7 @@ class HumanMessage(BaseMessage):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
type: Literal["human"] = "human"
|
|
|
|
type: Literal["human"] = "human"
|
|
|
|
|
|
|
|
is_chunk: Literal[False] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HumanMessage.update_forward_refs()
|
|
|
|
HumanMessage.update_forward_refs()
|
|
|
@ -157,7 +158,10 @@ HumanMessage.update_forward_refs()
|
|
|
|
class HumanMessageChunk(HumanMessage, BaseMessageChunk):
|
|
|
|
class HumanMessageChunk(HumanMessage, BaseMessageChunk):
|
|
|
|
"""A Human Message chunk."""
|
|
|
|
"""A Human Message chunk."""
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
# Ignoring mypy re-assignment here since we're overriding the value
|
|
|
|
|
|
|
|
# to make sure that the chunk variant can be discriminated from the
|
|
|
|
|
|
|
|
# non-chunk variant.
|
|
|
|
|
|
|
|
is_chunk: Literal[True] = True # type: ignore[assignment]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AIMessage(BaseMessage):
|
|
|
|
class AIMessage(BaseMessage):
|
|
|
@ -169,6 +173,7 @@ class AIMessage(BaseMessage):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
type: Literal["ai"] = "ai"
|
|
|
|
type: Literal["ai"] = "ai"
|
|
|
|
|
|
|
|
is_chunk: Literal[False] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AIMessage.update_forward_refs()
|
|
|
|
AIMessage.update_forward_refs()
|
|
|
@ -177,6 +182,11 @@ AIMessage.update_forward_refs()
|
|
|
|
class AIMessageChunk(AIMessage, BaseMessageChunk):
|
|
|
|
class AIMessageChunk(AIMessage, BaseMessageChunk):
|
|
|
|
"""A Message chunk from an AI."""
|
|
|
|
"""A Message chunk from an AI."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ignoring mypy re-assignment here since we're overriding the value
|
|
|
|
|
|
|
|
# to make sure that the chunk variant can be discriminated from the
|
|
|
|
|
|
|
|
# non-chunk variant.
|
|
|
|
|
|
|
|
is_chunk: Literal[True] = True # type: ignore[assignment]
|
|
|
|
|
|
|
|
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
if isinstance(other, AIMessageChunk):
|
|
|
|
if isinstance(other, AIMessageChunk):
|
|
|
|
if self.example != other.example:
|
|
|
|
if self.example != other.example:
|
|
|
@ -201,6 +211,7 @@ class SystemMessage(BaseMessage):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
type: Literal["system"] = "system"
|
|
|
|
type: Literal["system"] = "system"
|
|
|
|
|
|
|
|
is_chunk: Literal[False] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SystemMessage.update_forward_refs()
|
|
|
|
SystemMessage.update_forward_refs()
|
|
|
@ -209,7 +220,10 @@ SystemMessage.update_forward_refs()
|
|
|
|
class SystemMessageChunk(SystemMessage, BaseMessageChunk):
|
|
|
|
class SystemMessageChunk(SystemMessage, BaseMessageChunk):
|
|
|
|
"""A System Message chunk."""
|
|
|
|
"""A System Message chunk."""
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
# Ignoring mypy re-assignment here since we're overriding the value
|
|
|
|
|
|
|
|
# to make sure that the chunk variant can be discriminated from the
|
|
|
|
|
|
|
|
# non-chunk variant.
|
|
|
|
|
|
|
|
is_chunk: Literal[True] = True # type: ignore[assignment]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FunctionMessage(BaseMessage):
|
|
|
|
class FunctionMessage(BaseMessage):
|
|
|
@ -219,6 +233,7 @@ class FunctionMessage(BaseMessage):
|
|
|
|
"""The name of the function that was executed."""
|
|
|
|
"""The name of the function that was executed."""
|
|
|
|
|
|
|
|
|
|
|
|
type: Literal["function"] = "function"
|
|
|
|
type: Literal["function"] = "function"
|
|
|
|
|
|
|
|
is_chunk: Literal[False] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FunctionMessage.update_forward_refs()
|
|
|
|
FunctionMessage.update_forward_refs()
|
|
|
@ -227,6 +242,11 @@ FunctionMessage.update_forward_refs()
|
|
|
|
class FunctionMessageChunk(FunctionMessage, BaseMessageChunk):
|
|
|
|
class FunctionMessageChunk(FunctionMessage, BaseMessageChunk):
|
|
|
|
"""A Function Message chunk."""
|
|
|
|
"""A Function Message chunk."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ignoring mypy re-assignment here since we're overriding the value
|
|
|
|
|
|
|
|
# to make sure that the chunk variant can be discriminated from the
|
|
|
|
|
|
|
|
# non-chunk variant.
|
|
|
|
|
|
|
|
is_chunk: Literal[True] = True # type: ignore[assignment]
|
|
|
|
|
|
|
|
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
if isinstance(other, FunctionMessageChunk):
|
|
|
|
if isinstance(other, FunctionMessageChunk):
|
|
|
|
if self.name != other.name:
|
|
|
|
if self.name != other.name:
|
|
|
@ -252,6 +272,7 @@ class ChatMessage(BaseMessage):
|
|
|
|
"""The speaker / role of the Message."""
|
|
|
|
"""The speaker / role of the Message."""
|
|
|
|
|
|
|
|
|
|
|
|
type: Literal["chat"] = "chat"
|
|
|
|
type: Literal["chat"] = "chat"
|
|
|
|
|
|
|
|
is_chunk: Literal[False] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChatMessage.update_forward_refs()
|
|
|
|
ChatMessage.update_forward_refs()
|
|
|
@ -260,6 +281,11 @@ ChatMessage.update_forward_refs()
|
|
|
|
class ChatMessageChunk(ChatMessage, BaseMessageChunk):
|
|
|
|
class ChatMessageChunk(ChatMessage, BaseMessageChunk):
|
|
|
|
"""A Chat Message chunk."""
|
|
|
|
"""A Chat Message chunk."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ignoring mypy re-assignment here since we're overriding the value
|
|
|
|
|
|
|
|
# to make sure that the chunk variant can be discriminated from the
|
|
|
|
|
|
|
|
# non-chunk variant.
|
|
|
|
|
|
|
|
is_chunk: Literal[True] = True # type: ignore[assignment]
|
|
|
|
|
|
|
|
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore
|
|
|
|
if isinstance(other, ChatMessageChunk):
|
|
|
|
if isinstance(other, ChatMessageChunk):
|
|
|
|
if self.role != other.role:
|
|
|
|
if self.role != other.role:
|
|
|
|