ChatScript
class ChatScript
The script of a ScriptedChatModel: each call adds the answer to one request, in order.
ScriptedChatModel {
says("Hello!") // text
calls("menu_price", MenuLookup("cola")) // one tool call
calls(call("menu_price", MenuLookup("cola")), call("opening_hours")) // several in one answer
answers(Verdict(Category.REFUND, "The pizza was cold.")) // JSON, for `ask<Verdict>`
fails("API error 529: Overloaded") // a call that throws
responds { request -> ChatResponse(ChatMessage.Assistant("You said: ${request.messages.last().text}")) }
}Content copied to clipboard
Functions
Link copied to clipboard
Link copied to clipboard
The call to the model fails with a ChatModelException that has message, as when the provider is overloaded. Use it to test a retry, or what the app does with a failed run.
The call to the model throws failure. See the overload with a message.
Link copied to clipboard
The model answers with what answer returns for the request, for an answer that depends on what was asked.