Messages
This page assumes you are already familiar with how get hold of an api_key
and org_id
and how to install the Engage Smarter Python library. If not, turn to the Getting Started tutorial.
The Engage Smarter AI Platform delivers conversational AI using the concept of Messages.
There are two different types of messages:
- Basic messages are objects that contain only minimal information including the
content
and the messagerole
- Full messages are returned by the API and include additional meta data such as
id
,conversation_id
and other metadata.
Pydantic objects
All Message
objects are pydantic.BaseModel
objects and so all of the usual pydantic
validation and methods apply to these objects.
Check out the pydantic documentation for more information.
Basic Messages
Basic messages all inherit from the MessageBasic
class within the engagesmarter
package.
UserMessage
represents a message posted by the userAgentMessage
represents a message from the agent posted to the userInfoMessage
is a type of message that some of the agents may additionally use from the agent which provides metadata.InfoMessages
are not intended to be shown to the end userStatusMessage
are temporary messages streamed to the user during a long running agent call. These provide status updates to keep the user engaged.
from engagesmarter import AgentMessage, UserMessage
user_message = UserMessage(content="My name is Mary and I have a question")
print(user_message.model_dump_json(indent=2))
agent_message = AgentMessage(
content="Hi Mary, how can I help you?", agent="pensions-qa-latest"
)
print(agent_message.model_dump_json(indent=2))
Full Messages
Full messages are represented by the MessageRead
class within the engagesmarter
package.
These are similar to MessageBasic
objects but include id
and other metadata which is provided by the API such as identifiers for the conversation_id
or the run_id
.
import datetime
from engagesmarter import MessageRead
from uuid_extensions import uuid7
agent_message = MessageRead(
id=str(uuid7()),
org_id=str(uuid7()),
conversation_id=str(uuid7()),
run_id=str(uuid7()),
role="agent",
content="Hi Mary, how can I help you?",
created=datetime.datetime.now(),
)
print(agent_message.model_dump_json(indent=2))