payload#
- class besser.agent.platforms.payload.Payload(action, message=None)[source]#
Bases:
object
Represents a payload object used for encoding and decoding messages between an agent and any other external agent.
- class besser.agent.platforms.payload.PayloadAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Enumeration of the different possible actions embedded into a
Payload
.- AGENT_REPLY_DF = 'agent_reply_dataframe'#
Indicates that the payload’s purpose is to send an agent reply containing a
pandas.DataFrame
object.- Type:
- AGENT_REPLY_FILE = 'agent_reply_file'#
Indicates that the payload’s purpose is to send an agent reply containing a
file.File
object.- Type:
- AGENT_REPLY_HTML = 'agent_reply_html'#
Indicates that the payload’s purpose is to send an agent reply containing a
str
object in HTML format.- Type:
- AGENT_REPLY_IMAGE = 'agent_reply_image'#
Indicates that the payload’s purpose is to send an agent reply containing a
file.File
object, specifically an image.- Type:
- AGENT_REPLY_LOCATION = 'agent_reply_location'#
Indicates that the payload’s purpose is to send an agent reply containing a location, which is a dictionary composed by a latitude and a longitude.
- Type:
- AGENT_REPLY_MARKDOWN = 'agent_reply_markdown'#
Indicates that the payload’s purpose is to send an agent reply containing a
str
object in Markdown format.- Type:
- AGENT_REPLY_OPTIONS = 'agent_reply_options'#
Indicates that the payload’s purpose is to send an agent reply containing a list of strings, where the user should select 1 of them.
- Type:
- AGENT_REPLY_PLOTLY = 'agent_reply_plotly'#
Indicates that the payload’s purpose is to send an agent reply containing a
plotly.graph_objs.Figure
object.- Type:
- AGENT_REPLY_RAG = 'agent_reply_rag'#
Indicates that the payload’s purpose is to send an agent reply containing a RAG (Retrieval Augmented Generation) answer, which contains an LLM-generated answer and a set of documents the LLM used as context (see
besser.agent.nlp.rag.rag.RAGMessage
).- Type:
- AGENT_REPLY_STR = 'agent_reply_str'#
Indicates that the payload’s purpose is to send an agent reply containing a
str
object.- Type:
- RESET = 'reset'#
Use the
WebSocketPlatform
on this agent.- Type:
- USER_FILE = 'user_file'#
Indicates that the payload’s purpose is to send a user file.
- Type:
- USER_MESSAGE = 'user_message'#
Indicates that the payload’s purpose is to send a user message.
- Type:
- USER_VOICE = 'user_voice'#
Indicates that the payload’s purpose is to send a user audio.
- Type:
- class besser.agent.platforms.payload.PayloadEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#
Bases:
JSONEncoder
Encoder for the
Payload
class.Example
import json encoded_payload = json.dumps(payload, cls=PayloadEncoder)