payload#
- class baf.platforms.payload.Payload(action, message=None, history=False, timestamp=None, message_id=None)[source]#
Bases:
objectRepresents a payload object used for encoding and decoding messages between an agent and any other external agent.
- class baf.platforms.payload.PayloadAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
EnumEnumeration of the different possible actions embedded into a
Payload.- AGENT_REPLY_AUDIO = 'agent_reply_audio'#
Indicates that the payload’s purpose is to send an agent reply containing an audio, which is a dictionary containing the audio data (as a base 64 String) and the metadata to reconstruct the audio array, composed of sample_rate, dtype and shape.
- Type:
- AGENT_REPLY_DF = 'agent_reply_dataframe'#
Indicates that the payload’s purpose is to send an agent reply containing a
pandas.DataFrameobject.- Type:
- AGENT_REPLY_FILE = 'agent_reply_file'#
Indicates that the payload’s purpose is to send an agent reply containing a
file.Fileobject.- Type:
- AGENT_REPLY_GUI = 'agent_reply_gui'#
Indicates that the payload’s purpose is to send an agent reply containing a GUI, which is based on the GUI metamodel in
besser.BUML.metamodel.gui.graphical_ui.GUIModel.- Type:
- AGENT_REPLY_GUI_UPDATE = 'agent_reply_gui_update'#
Indicates that the payload’s purpose is to push an update to the session’s current GUI model. The message is the full updated GUI JSON. Clients should replace their current GUI state with the new one.
- Type:
- AGENT_REPLY_HTML = 'agent_reply_html'#
Indicates that the payload’s purpose is to send an agent reply containing a
strobject 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.Fileobject, 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
strobject 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.Figureobject.- 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
baf.nlp.rag.rag.RAGMessage).- Type:
- AGENT_REPLY_REASONING_STEP = 'agent_reply_reasoning_step'#
Indicates that the payload’s purpose is to send an intermediate step of a reasoning state — an LLM text turn, a tool call, a tool result, a task list change, an orchestrator push-back, etc. The message is a dict with the shape
{"kind": str, "step": int, "summary": str, "details": dict}. Seebaf.library.state.reasoning_state_library.reasoning_body()for the full set of emitted kinds.- Type:
- AGENT_REPLY_STR = 'agent_reply_str'#
Indicates that the payload’s purpose is to send an agent reply containing a
strobject.- Type:
- AGENT_REPLY_TASK_LIST_UPDATE = 'agent_reply_task_list_update'#
Indicates that the payload’s purpose is to send a snapshot of the reasoning state’s task list. Emitted on every task list mutation (add / complete / skip) alongside the corresponding reasoning step events, so a UI can show the live task list as a separate panel without having to reconstruct it from the step stream. The message is a list of dicts:
[{"id": int, "description": str, "status": str, "result": str}, ...]. The reasoning_started / reasoning_finished events bracket the lifetime of this list.- Type:
- FETCH_USER_MESSAGES = 'fetch_user_messages'#
Request to fetch old messages for a given user.
- Type:
- RESET = 'reset'#
Use the
WebSocketPlatformon this agent.- Type:
- USER_FILE = 'user_file'#
Indicates that the payload’s purpose is to send a user file.
- Type:
- USER_GUI_EVENT = 'user_gui_event'#
Indicates a user interaction event sent from the GUI frontend. The message is a dict with at minimum an
elementIdfield and anactionfield (e.g.{"elementId": "btn1", "action": "onClick"}).- Type:
- USER_MESSAGE = 'user_message'#
Indicates that the payload’s purpose is to send a user message.
- Type:
- USER_SET_VARIABLE = 'user_set_variable'#
Indicates that the user intends to set a session variable. The payload must include a dictionary containing the variable name and its value, sent as a Payload message.
- Type:
- USER_VOICE = 'user_voice'#
Indicates that the payload’s purpose is to send a user audio.
- Type:
- class baf.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:
JSONEncoderEncoder for the
Payloadclass.Example
import json encoded_payload = json.dumps(payload, cls=PayloadEncoder)