cack / custom_message.py
ujalaarshad17's picture
Upload 8 files
a16eb78 verified
raw
history blame contribute delete
997 Bytes
from langchain_core.messages import BaseMessage
from typing import Any, Literal, Union
class CustomMessage(BaseMessage):
"""Message from an AI.
AIMessage is returned from a chat model as a response to a prompt.
This message represents the output of the model and consists of both
the raw output as returned by the model together standardized fields
(e.g., tool calls, usage metadata) added by the LangChain framework.
"""
type: Literal["custom"] = "custom"
"""The type of the message (used for deserialization). Defaults to "custom"."""
def __init__(
self, content: Union[str, list[Union[str, dict]]], **kwargs: Any
) -> None:
"""Pass in content as positional arg.
Args:
content: The content of the message.
kwargs: Additional arguments to pass to the parent class.
"""
super().__init__(content=content, **kwargs)
CustomMessage.model_rebuild()