Spaces:
No application file
No application file
| 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() | |