Conversations#
Messages#
- class wayflowcore.messagelist.Message(content='', message_type=None, tool_requests=None, tool_result=None, is_error=False, display_only=False, sender=None, recipients=None, time_created=None, time_updated=None, contents=None, role=None, _prompt_cache_key=None, _reasoning_content=None, __metadata_info__=None)#
Messages are an exchange medium between the user, LLM agent, and controller logic. This helps to determine who provided what information.
- Parameters:
content (
str) – Content of the message.message_type (
Optional[MessageType]) – A message type out of the following ones: SYSTEM, AGENT, USER, THOUGHT, INTERNAL, TOOL_REQUEST, TOOL_RESULT.tool_requests (
Optional[List[ToolRequest]]) – A list ofToolRequestobjects representing the tools invoked as part of this message. Each request includes the tool’s name, arguments, and a unique identifier.tool_result (
Optional[ToolResult]) – AToolResultobject representing the outcome of a tool invocation. It includes the returned content and a reference to the related tool request ID.display_only (
bool) – If True, the message is excluded from any context. Its only purpose is to be displayed in the chat UI (e.g debugging message)sender (
Optional[str]) – Sender of the message in str format.recipients (
Optional[Set[str]]) – Recipients of the message in str format.time_created (
Optional[datetime]) – Creation timestamp of the message.time_updated (
Optional[datetime]) – Update timestamp of the message.contents (
Optional[List[MessageContent]]) – Message content. Is a list of chunks with potentially different typesrole (
Optional[Literal['user','system','assistant']]) – Role of the sender of the message. Can be user, system or assistantis_error (bool) –
_prompt_cache_key (str | None) –
_reasoning_content (Dict[str, Any] | None) –
__metadata_info__ (Dict[str, Any]) –
- property content: str#
Text content getter
-
contents:
List[MessageContent]#
-
display_only:
bool= False#
- property hash: str#
- property is_error: bool#
- property message_type: MessageType#
Getter to guarantee backward compatibility
-
recipients:
Set[str]#
-
role:
Literal['user','assistant','system']#
-
sender:
Optional[str] = None#
-
time_created:
datetime#
-
time_updated:
datetime#
-
tool_requests:
Optional[List[ToolRequest]] = None#
-
tool_result:
Optional[ToolResult] = None#
- class wayflowcore.messagelist.MessageType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Type of messages
- AGENT = 'AGENT'#
- DISPLAY_ONLY = 'DISPLAY_ONLY'#
- ERROR = 'ERROR'#
- INTERNAL = 'INTERNAL'#
- SYSTEM = 'SYSTEM'#
- THOUGHT = 'THOUGHT'#
- TOOL_REQUEST = 'TOOL_REQUEST'#
- TOOL_RESULT = 'TOOL_RESULT'#
- USER = 'USER'#
- class wayflowcore.messagelist.MessageContent#
Abstract base class for message content chunks.
All message content types (such as text and images) should derive from this class and specify a class-level ‘type’ field to distinguish content variant. Subclasses may also add additional fields for content-specific data.
- Parameters:
type – Identifier for the content type, to be implemented by subclasses.
-
type:
ClassVar[str]#
- class wayflowcore.messagelist.TextContent(content='')#
Represents the content of a text message.
- Parameters:
content (
str) – The textual content of the message.type – Identifier for the text content type.
-
content:
str= ''#
-
type:
ClassVar[Literal['text']] = 'text'#
- class wayflowcore.messagelist.ImageContent(base64_content)#
Represents the content of an image message, storing image data as a base64-encoded string.
- Parameters:
base64_content (
str) – A base64-encoded string representing the image data.type – Identifier for the image content type.
Examples
>>> import requests >>> from wayflowcore.messagelist import Message, TextContent, ImageContent >>> from wayflowcore.models import Prompt >>> # Download the Oracle logo as bytes >>> url = "https://www.oracle.com/a/ocom/img/oracle-logo.png" >>> response = requests.get(url) >>> img_content = ImageContent.from_bytes(response.content, format="png") >>> prompt = Prompt(messages=[Message(contents = [TextContent("Which company's logo is this?") , img_content])]) >>> completion = multimodal_llm.generate(prompt) >>> # LlmCompletion(message=Message(content="That is the logo for **Oracle Corporation**."))
-
base64_content:
str#
- classmethod from_bytes(bytes_content, format)#
- Return type:
- Parameters:
bytes_content (bytes) –
format (str) –
- type: ClassVar[str] = 'image'#
- class wayflowcore.messagelist.MessageList(messages=<factory>, *, id=<factory>, __metadata_info__=<factory>)#
Object that carries a list of messages. We may only append to this object, not remove
- Parameters:
messages (
List[Message]) – list of messages to start from.id (str) –
__metadata_info__ (Dict[str, Any]) –
- append_agent_message(agent_input, is_error=False)#
Append a new message object of type
MessageType.AGENTto the messages list.- Parameters:
agent_input (
str) – message to append.is_error (bool) –
- Return type:
None
- append_message(message)#
Add a message to a message list.
- Parameters:
message (
Message) – Message to append to the message list.- Return type:
None
- append_tool_result(tool_result)#
Append a new message object of type
MessageType.TOOL_RESULTto the messages list.- Parameters:
tool_result (
ToolResult) – message to append.- Return type:
None
- append_user_message(user_input)#
Append a new message object of type
MessageType.USERto the messages list.- Parameters:
user_input (
Union[str,List[MessageContent]]) – message to append.- Return type:
None
- copy()#
Create a copy of the given message list.
- Return type:
- classmethod from_messages(messages=None)#
- Return type:
- Parameters:
ExecutionStatus#
- class wayflowcore.executors.executionstatus.ExecutionStatus(*, id=<factory>, __metadata_info__=<factory>, _conversation_id=None)#
Execution status returned by the Assistant. This indicates if the assistant yielded, finished the conversation, …
- Parameters:
id (str) –
__metadata_info__ (Dict[str, Any]) –
_conversation_id (str | None) –
- class wayflowcore.executors.executionstatus.UserMessageRequestStatus(*, id=<factory>, __metadata_info__=<factory>, _conversation_id=None, message, _user_response=None)#
Execution status for when the assistant answered and will be waiting for the next user input
- Parameters:
- message: Message#
The message from the assistant to which the user needs to answer to.
- class wayflowcore.executors.executionstatus.FinishedStatus(output_values, complete_step_name=None, *, id=<factory>, __metadata_info__=<factory>, _conversation_id=None)#
Execution status for when the conversation is finished. Contains the outputs of the conversation
- Parameters:
output_values (Dict[str, Any]) –
complete_step_name (str | None) –
id (str) –
__metadata_info__ (Dict[str, Any]) –
_conversation_id (str | None) –
- complete_step_name: Optional[str] = None#
The name of the last step reached if the flow returning this execution status transitioned to a
CompleteStep, otherwiseNone.
- output_values: Dict[str, Any]#
The outputs produced by the agent or flow returning this execution status.
- class wayflowcore.executors.executionstatus.ToolRequestStatus(*, id=<factory>, __metadata_info__=<factory>, _conversation_id=None, tool_requests, _tool_results=None)#
Execution status for when the assistant is asking the user to call a tool and send back its result
- Parameters:
id (str) –
__metadata_info__ (Dict[str, Any]) –
_conversation_id (str | None) –
tool_requests (List[ToolRequest]) –
_tool_results (List[ToolResult] | None) –
- submit_tool_result(tool_result)#
Submit the tool results to the given tool requests.
- Return type:
None- Parameters:
tool_result (ToolResult) –
- submit_tool_results(tool_results)#
Submit the tool results to the given tool requests.
- Return type:
None- Parameters:
tool_results (List[ToolResult]) –
- tool_requests: List['ToolRequest']#
The tool requests for the client tools that the client need to run.
Conversation#
Base class for conversations. Can manipulate a conversation object, and can be serialized/deserialized.
- class wayflowcore.conversationalcomponent.ConversationalComponent(name, description, input_descriptors, output_descriptors, runner, conversation_class, id=None, __metadata_info__=None)#
- Parameters:
- abstract start_conversation(inputs=None, messages=None)#
- Return type:
- Parameters:
inputs (Dict[str, Any] | None) –
messages (None | str | Message | List[Message] | MessageList) –
- class wayflowcore.conversation.Conversation(component, state, inputs, message_list, status, conversation_id='', status_handled=False, *, id=<factory>, __metadata_info__=<factory>, name='', description=None)#
- Parameters:
component (ConversationalComponent) –
state (ConversationExecutionState) –
inputs (Dict[str, Any]) –
message_list (MessageList) –
status (ExecutionStatus | None) –
conversation_id (str) –
status_handled (bool) –
id (str) –
__metadata_info__ (Dict[str, Any]) –
name (str) –
description (str | None) –
- append_agent_message(agent_input, is_error=False)#
Append a new message object of type
MessageType.AGENTto the messages list.- Parameters:
agent_input (
str) – message to append.is_error (bool) –
- Return type:
None
- append_message(message)#
Append a message to the messages list of this
Conversationobject.- Parameters:
message (
Message) – message to append.- Return type:
None
- append_tool_result(tool_result)#
Append a new message object of type
MessageType.TOOL_RESULTto the messages list.- Parameters:
tool_result (
ToolResult) – message to append.- Return type:
None
- append_user_message(user_input)#
Append a new message object of type
MessageType.USERto the messages list.- Parameters:
user_input (
Union[str,List[MessageContent]]) – str or list of message contents to append as a user message.- Return type:
None
-
component:
ConversationalComponent#
-
conversation_id:
str= ''#
- abstract property current_step_name: str#
- execute(execution_interrupts=None)#
Execute the conversation and get its
ExecutionStatusbased on the outcome.The
Executionstatus is returned by the Assistant and indicates if the assistant yielded, finished the conversation.- Return type:
- Parameters:
execution_interrupts (Sequence[ExecutionInterrupt] | None) –
- async execute_async(execution_interrupts=None)#
Execute the conversation and get its
ExecutionStatusbased on the outcome.The
Executionstatus is returned by the Assistant and indicates if the assistant yielded, finished the conversation.- Return type:
- Parameters:
execution_interrupts (Sequence[ExecutionInterrupt] | None) –
- get_messages()#
Return all
Messageobjects of the messages list in a python list.- Return type:
List[Message]
-
inputs:
Dict[str,Any]#
-
message_list:
MessageList#
- property plan: ExecutionPlan | None#
- state: ConversationExecutionState#
-
status:
Optional[ExecutionStatus]#
-
status_handled:
bool= False# Whether the current status associated to this conversation was already handled or not (messages/tool results were added to the conversation)
-
token_usage:
TokenUsage#
Execution Plan#
- class wayflowcore.planning.ExecutionPlan(plan=None)#
- Parameters:
plan (List[Task] | None) –
- static from_str(plan_text)#
- Return type:
- Parameters:
plan_text (str) –
- to_str()#
- Return type:
str
- class wayflowcore.planning.Task(id, description, status=TaskStatus.PENDING, tool=None)#
- Parameters:
id (str) –
description (str) –
status (TaskStatus) –
tool (str | None) –
-
description:
str#
-
id:
str#
-
status:
TaskStatus= 'PENDING'#
- to_str()#
- Return type:
str
-
tool:
Optional[str] = None#
- class wayflowcore.planning.TaskStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Status of a task
- CANCELLED = 'CANCELLED'#
- ERROR = 'ERROR'#
- IN_PROGRESS = 'IN_PROGRESS'#
- NEEDS_REFINEMENT = 'NEEDS_REFINEMENT'#
- PENDING = 'PENDING'#
- SUCCESS = 'SUCCESS'#