respond
open fun respond(conversation: Conversation, model: Map<String, Any>, onFailure: (Throwable) -> AssistantMessage): AssistantMessage
Safely respond to the user in the conversation using the rendered template as system prompt, returning an error message if something goes wrong. Cannot throw an exception.
Parameters
conversation
the conversation so far
model
the model data to render the system prompt template with.
on Failure
a function that takes the error and returns an AssistantMessage to be sent back to the user in case of failure. This allows for graceful error handling and user feedback without throwing exceptions.