10#ifndef PIPECAT_RTVI_MESSAGES_H
11#define PIPECAT_RTVI_MESSAGES_H
13#include <nlohmann/json.hpp>
325void to_json(nlohmann::json& j,
const Message& message);
326void from_json(
const nlohmann::json& j,
Message& message);
335void from_json(
const nlohmann::json& j,
BotReadyData& data);
336void from_json(
const nlohmann::json& j,
ErrorData& data);
338void from_json(
const nlohmann::json& j,
TextData& data);
341void from_json(
const nlohmann::json& j,
MetricData& data);
342void from_json(
const nlohmann::json& j,
MetricsData& data);
constexpr const char * PROTOCOL_VERSION
The RTVI protocol version this library speaks.
Definition messages.h:32
std::optional< MessageType > parse_message_type(const std::string &type)
The message type with an RTVI name, or std::nullopt if it's unknown.
constexpr const char * MESSAGE_LABEL
The label of every RTVI message.
Definition messages.h:35
const char * to_string(MessageType type)
The RTVI name of a message type, e.g. "bot-ready".
AboutClientData default_about_client()
Information about this library and the platform it runs on.
MessageType
Types of RTVI messages.
Definition messages.h:38
@ LLMFunctionCallInProgress
A function call is running.
@ ServerMessage
An app-defined message from the bot.
@ BotInterrupted
The bot was interrupted.
@ BotTTSStarted
The bot's text-to-speech started.
@ UserTranscription
What the user said.
@ BotLLMText
Text from the bot's LLM, as it streams.
@ UserLLMText
User text sent to the bot's LLM.
@ ClientMessage
An app-defined message to the bot.
@ UserStartedSpeaking
The user started speaking.
@ BotOutput
What the bot says or outputs.
@ LLMFunctionCallStarted
The bot's LLM started a function call.
@ DisconnectBot
Asks the bot to leave.
@ Error
An error in the bot.
@ BotStoppedSpeaking
The bot stopped speaking.
@ UserMuteStopped
The bot stopped ignoring user audio.
@ ErrorResponse
The bot couldn't handle a message.
@ BotTTSText
Text the bot is speaking.
@ LLMFunctionCallResult
The result of a function call.
@ UserMuteStarted
The bot started ignoring user audio.
@ UserStoppedSpeaking
The user stopped speaking.
@ LLMFunctionCallStopped
A function call finished.
@ ServerResponse
The bot's answer to a request.
@ BotStartedSpeaking
The bot started speaking.
@ SendText
Text for the bot's LLM.
@ BotTTSStopped
The bot's text-to-speech stopped.
@ ClientReady
The client is ready.
@ BotLLMStopped
The bot's LLM finished responding.
@ BotLLMStarted
The bot's LLM started responding.
@ BotLLMSearchResponse
Search results used by the bot's LLM.
@ Metrics
Performance metrics.
@ BotReady
The bot is ready.
Information about the client, sent to the bot when connecting.
Definition messages.h:83
std::optional< std::string > platform
Operating system, e.g. "Linux".
Definition messages.h:89
std::string library
Name of the library, e.g. "pipecat-client-cxx".
Definition messages.h:85
nlohmann::json platform_details
Any other details, as a JSON object. Null to leave them out.
Definition messages.h:93
std::optional< std::string > platform_version
Version of the OS.
Definition messages.h:91
std::optional< std::string > library_version
Version of the library.
Definition messages.h:87
Search results used by the bot's LLM.
Definition messages.h:267
std::vector< LLMSearchOrigin > origins
Where the results come from.
Definition messages.h:273
std::optional< std::string > search_result
Summary of the results.
Definition messages.h:269
std::optional< std::string > rendered_content
Results ready to show.
Definition messages.h:271
Definition messages.h:182
std::string text
The text.
Definition messages.h:184
std::optional< bool > will_be_spoken
Whether the bot will speak it.
Definition messages.h:190
std::optional< std::string > spoken_status
Where the bot is in speaking it: "new", "in-progress" or "completed".
Definition messages.h:192
std::string aggregated_by
What the text is, e.g. "word" or "sentence".
Definition messages.h:186
std::optional< SpokenProgressData > spoken_progress
How much of the text the bot has spoken. Only for text it speaks.
Definition messages.h:194
std::optional< int64_t > segment_id
ID shared by updates of a text.
Definition messages.h:188
Sent by the bot when it's ready.
Definition messages.h:128
nlohmann::json about
Information about the bot. Can be null.
Definition messages.h:132
std::string version
RTVI version of the bot.
Definition messages.h:130
An app-defined message between the client and the bot.
Definition messages.h:100
nlohmann::json data
Data of the message. Can be null.
Definition messages.h:104
std::string type
Type of the message, defined by your app.
Definition messages.h:102
An error.
Definition messages.h:136
bool fatal
Whether the error is fatal, e.g. the bot stopped.
Definition messages.h:140
std::string error
What went wrong.
Definition messages.h:138
A function call is running.
Definition messages.h:226
nlohmann::json arguments
Definition messages.h:233
std::string tool_call_id
ID of the function call.
Definition messages.h:230
std::optional< std::string > function_name
Name of the function, if the bot shares it.
Definition messages.h:228
The result of a function call, sent to the bot.
Definition messages.h:116
std::string tool_call_id
ID of the function call.
Definition messages.h:120
nlohmann::json result
The result.
Definition messages.h:124
std::string function_name
Name of the function.
Definition messages.h:118
nlohmann::json arguments
Arguments the function was called with.
Definition messages.h:122
The bot's LLM started a function call.
Definition messages.h:220
std::optional< std::string > function_name
Name of the function, if the bot shares it.
Definition messages.h:222
A function call finished or was cancelled.
Definition messages.h:237
std::optional< std::string > function_name
Name of the function, if the bot shares it.
Definition messages.h:239
nlohmann::json result
The result of the function, if the bot shares it. Can be null.
Definition messages.h:245
std::string tool_call_id
ID of the function call.
Definition messages.h:241
bool cancelled
Whether the call was cancelled.
Definition messages.h:243
Where search results come from, e.g. a website.
Definition messages.h:257
std::optional< std::string > site_title
Title of the site.
Definition messages.h:261
std::optional< std::string > site_uri
Address of the site.
Definition messages.h:259
std::vector< LLMSearchResult > results
Results from this site.
Definition messages.h:263
A search result.
Definition messages.h:249
std::string text
Text of the result.
Definition messages.h:251
std::vector< double > confidence
Confidence scores, from 0 to 1.
Definition messages.h:253
Definition messages.h:280
static Message disconnect_bot()
A message that asks the bot to leave.
std::string label
Always "rtvi-ai".
Definition messages.h:284
std::string type
Type of the message, e.g. "bot-ready".
Definition messages.h:286
static Message dtmf(const std::string &buttons)
One or more DTMF keys (0-9, * and #), for bots on RTVI 2.1 or newer.
static Message client_ready(const AboutClientData &about)
A message that says the client is ready, with information about it.
static Message llm_function_call_result(const LLMFunctionCallResultData &data)
The result of a function call.
std::string id
ID of the message. Answers have the request's ID.
Definition messages.h:282
Message(MessageType type, nlohmann::json data=nullptr)
A message of type with data, and a new random ID.
static Message client_message(const std::string &type, const nlohmann::json &data)
An app-defined message to the bot.
Message()=default
An empty message.
nlohmann::json data
Data of the message. Null if it has none.
Definition messages.h:288
static Message send_text(const std::string &content, const SendTextOptions &options={})
Text for the bot's LLM.
A single measurement.
Definition messages.h:198
std::string processor
What was measured, e.g. a service in the bot.
Definition messages.h:200
std::optional< std::string > model
The AI model used, if any.
Definition messages.h:202
double value
The measured value, e.g. a time in seconds.
Definition messages.h:204
Performance metrics from the bot.
Definition messages.h:208
std::vector< MetricData > characters
Characters sent to be spoken.
Definition messages.h:214
nlohmann::json raw
All the metrics, including those without a field above.
Definition messages.h:216
std::vector< MetricData > ttfb
Times to first byte, in seconds.
Definition messages.h:210
std::vector< MetricData > processing
Processing times, in seconds.
Definition messages.h:212
Options for sending text to the bot.
Definition messages.h:108
std::optional< bool > run_immediately
Whether the bot responds right away. Defaults to true.
Definition messages.h:110
std::optional< bool > audio_response
Whether the bot responds with audio. Defaults to true.
Definition messages.h:112
How much of a text the bot has spoken.
Definition messages.h:171
std::string remaining_text
Text not spoken yet.
Definition messages.h:175
std::string accumulated_text
Text spoken so far, including the current word.
Definition messages.h:173
Some text.
Definition messages.h:156
std::string text
The text.
Definition messages.h:158
What the user said.
Definition messages.h:144
std::string text
The words.
Definition messages.h:146
std::string timestamp
When it was said, as an ISO 8601 date.
Definition messages.h:150
std::string user_id
ID of the user who spoke.
Definition messages.h:152