API references#

Note

Please note that all unstable APIs that are marked with @unstable in code will also be marked as Unstable in this page.

class notebridge.AgentResponse(*, messages: List[str] = [], storage: dict = None)#
messages: List[str]#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'messages': FieldInfo(annotation=List[str], required=False, default=[]), 'storage': FieldInfo(annotation=dict, required=False)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

storage: dict#
class notebridge.Bridge#
abstract on_receive(message_stack: List[ChatMessage], context: ChatContext, storage: dict) AgentResponse#

The callback function when the agent receives a message.

Parameters:
  • message_stack (List[ChatMessage]) – The message stack that contains all the messages in the chat, where the last item is the new message.

  • context (ChatContext) – The context of the conversation.

  • storage (dict) – The storage of the agent. It is a dictionary that can be used to store any information. The dictionary will be passed based on the chat session id.

Returns:

The response of the agent. It includes a list of messages and the dictionary to be stored.

Return type:

AgentResponse

class notebridge.ChatContext(*, chat_session_id: str = None, note: str | None = None)#
chat_session_id: str#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'chat_session_id': FieldInfo(annotation=str, required=False), 'note': FieldInfo(annotation=Union[str, NoneType], required=False)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

note: str | None#
class notebridge.ChatMessage(*, is_agent: bool = False, agent_name: str | None = None, content: str = None, timestamp: int = None)#
agent_name: str | None#
content: str#
is_agent: bool#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'agent_name': FieldInfo(annotation=Union[str, NoneType], required=False), 'content': FieldInfo(annotation=str, required=False), 'is_agent': FieldInfo(annotation=bool, required=False, default=False), 'timestamp': FieldInfo(annotation=int, required=False)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

timestamp: int#