pub struct Chat {
pub stream: bool,
/* private fields */
}Expand description
A batteries-included chat to to implement chatbots.
Fields§
§stream: boolToggles response streaming on or off. Default is on.
Implementations§
Source§impl Chat
impl Chat
Sourcepub fn prompt_input_ref(&self) -> PromptInputRef
pub fn prompt_input_ref(&self) -> PromptInputRef
Getter to the underlying PromptInputRef independent of its id.
Sourcepub fn messages_ref(&self) -> MessagesRef
pub fn messages_ref(&self) -> MessagesRef
Getter to the underlying MessagesRef independent of its id.
Sourcepub fn dispatch(&mut self, cx: &mut Cx, tasks: &mut Vec<ChatTask>)
pub fn dispatch(&mut self, cx: &mut Cx, tasks: &mut Vec<ChatTask>)
Dispatch a set of tasks to be executed by the Chat widget as a single hookable unit of work.
You can still hook into these tasks before they are executed if you set a hook with Chat::set_hook_before.
Warning: Like other operation over makepad’s [WidgetRef], this function may panic if you hold
borrows to widgets inside Chat, for example Messages or PromptInput. Be aware when using
read_with and write_with methods.
Sourcepub fn perform(&mut self, cx: &mut Cx, tasks: &[ChatTask])
pub fn perform(&mut self, cx: &mut Cx, tasks: &[ChatTask])
Performs a set of tasks in the Chat widget immediately.
This is not hookable.
Sourcepub fn set_hook_before(
&mut self,
hook: impl FnMut(&mut Vec<ChatTask>, &mut Chat, &mut Cx) + 'static,
)
pub fn set_hook_before( &mut self, hook: impl FnMut(&mut Vec<ChatTask>, &mut Chat, &mut Cx) + 'static, )
Sets a hook to be executed before a group of tasks is executed.
You get mutable access to the group of tasks, so you can modify what is about to happen. See ChatTask for more details about this.
If you just want to get notified when something already happened, see Chat::set_hook_after.
Sourcepub fn set_hook_after(
&mut self,
hook: impl FnMut(&[ChatTask], &mut Chat, &mut Cx) + 'static,
)
pub fn set_hook_after( &mut self, hook: impl FnMut(&[ChatTask], &mut Chat, &mut Cx) + 'static, )
Sets a hook to be executed after a group of tasks is executed.
You get immutable access to the group of tasks, so you can inspect what happened.
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Returns true if the chat is currently streaming.