pub struct Chat {
pub stream: bool,
/* private fields */
}Expand description
A batteries-included chat 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, cx: &Cx) -> PromptInputRef
pub fn prompt_input_ref(&self, cx: &Cx) -> PromptInputRef
Getter to the underlying PromptInputRef independent of its id.
Sourcepub fn messages_ref(&self, cx: &Cx) -> MessagesRef
pub fn messages_ref(&self, cx: &Cx) -> MessagesRef
Getter to the underlying MessagesRef independent of its id.
Sourcepub fn stt_input_ref(&self, cx: &Cx) -> SttInputRef
pub fn stt_input_ref(&self, cx: &Cx) -> SttInputRef
Getter to the underlying SttInputRef independent of its id.
Sourcepub fn set_stt_utility(&mut self, cx: &Cx, utility: Option<SttUtility>)
pub fn set_stt_utility(&mut self, cx: &Cx, utility: Option<SttUtility>)
Configures the STT utility to be used for speech-to-text.
Sourcepub fn stt_utility(&self, cx: &Cx) -> Option<SttUtility>
pub fn stt_utility(&self, cx: &Cx) -> Option<SttUtility>
Returns the current STT utility, if any, as a clone.
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Returns true if the chat is currently streaming.
Sourcepub fn set_chat_controller(
&mut self,
cx: &mut Cx,
chat_controller: Option<Arc<Mutex<ChatController>>>,
)
pub fn set_chat_controller( &mut self, cx: &mut Cx, chat_controller: Option<Arc<Mutex<ChatController>>>, )
Sets the chat controller for this chat widget.
Sourcepub fn chat_controller(&self) -> Option<&Arc<Mutex<ChatController>>>
pub fn chat_controller(&self) -> Option<&Arc<Mutex<ChatController>>>
Returns a reference to the chat controller, if set.
Methods from Deref<Target = View>§
pub fn set_debug_dump(&mut self, cx: &mut Cx, debug: bool)
pub fn repaint(&mut self, cx: &mut Cx)
pub fn swap_child(&mut self, pos_a: usize, pos_b: usize)
pub fn child_index(&mut self, comp: &WidgetRef) -> Option<usize>
pub fn child_at_index(&mut self, index: usize) -> Option<&WidgetRef>
pub fn set_scroll_pos(&mut self, cx: &mut Cx, v: Vec2d)
pub fn area(&self) -> Area
pub fn walk_from_previous_size(&self, walk: Walk) -> Walk
pub fn child_count(&self) -> usize
pub fn debug_print_children(&self)
pub fn debug_props(&self) -> String
pub fn debug_dump_tree(&self, depth: usize) -> String
pub fn set_key_focus(&self, cx: &mut Cx)
Trait Implementations§
Source§impl ScriptApply for Chat
impl ScriptApply for Chat
fn script_type_id(&self) -> ScriptTypeId
fn script_apply( &mut self, vm: &mut ScriptVm<'_>, apply: &Apply, scope: &mut Scope<'_, '_>, value: ScriptValue, )
fn script_to_value(&self, vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_to_value_props(&self, vm: &mut ScriptVm<'_>, obj: ScriptObject)
fn script_source(&self) -> ScriptObject
§fn script_apply_eval(&mut self, vm: &mut ScriptVm<'_>, script_mod: ScriptMod)
fn script_apply_eval(&mut self, vm: &mut ScriptVm<'_>, script_mod: ScriptMod)
Evaluates a ScriptMod and applies the result to self.
The ScriptMod is deduplicated by file/line/column so calling this repeatedly
with the same source location won’t create multiple code blocks.
The script code should be wrapped as
__script_source__{...} and this method
sets __script_source__ on the scope to self.script_source() before evaluation.Source§impl ScriptHook for Chat
impl ScriptHook for Chat
fn on_before_apply( &mut self, _vm: &mut ScriptVm<'_>, _apply: &Apply, _scope: &mut Scope<'_, '_>, _value: ScriptValue, )
fn on_before_dispatch( &mut self, vm: &mut ScriptVm<'_>, apply: &Apply, scope: &mut Scope<'_, '_>, _value: ScriptValue, )
fn on_after_apply( &mut self, _vm: &mut ScriptVm<'_>, _apply: &Apply, _scope: &mut Scope<'_, '_>, _value: ScriptValue, )
fn on_after_dispatch( &mut self, vm: &mut ScriptVm<'_>, apply: &Apply, scope: &mut Scope<'_, '_>, _value: ScriptValue, )
fn on_custom_apply( &mut self, _vm: &mut ScriptVm<'_>, _apply: &Apply, _scope: &mut Scope<'_, '_>, _value: ScriptValue, ) -> bool
fn on_type_check(_heap: &ScriptHeap, _value: ScriptValue) -> bool
fn on_proto_build( _vm: &mut ScriptVm<'_>, _obj: ScriptObject, _props: &mut ScriptTypeProps, )
fn on_proto_methods(_vm: &mut ScriptVm<'_>, _obj: ScriptObject)
fn on_alive(&self)
fn on_before_new(&mut self, _vm: &mut ScriptVm<'_>)
fn on_before_reload(&mut self, _vm: &mut ScriptVm<'_>)
fn on_after_new(&mut self, _vm: &mut ScriptVm<'_>)
fn on_after_reload(&mut self, _vm: &mut ScriptVm<'_>)
fn on_before_new_scoped( &mut self, vm: &mut ScriptVm<'_>, _scope: &mut Scope<'_, '_>, )
fn on_before_reload_scoped( &mut self, vm: &mut ScriptVm<'_>, _scope: &mut Scope<'_, '_>, )
fn on_after_new_scoped( &mut self, vm: &mut ScriptVm<'_>, _scope: &mut Scope<'_, '_>, )
fn on_after_reload_scoped( &mut self, vm: &mut ScriptVm<'_>, _scope: &mut Scope<'_, '_>, )
Source§impl ScriptHookDeref for Chat
impl ScriptHookDeref for Chat
fn on_deref_before_apply( &mut self, vm: &mut ScriptVm<'_>, apply: &Apply, scope: &mut Scope<'_, '_>, value: ScriptValue, )
fn on_deref_after_apply( &mut self, vm: &mut ScriptVm<'_>, apply: &Apply, scope: &mut Scope<'_, '_>, value: ScriptValue, )
Source§impl ScriptNew for Chat
impl ScriptNew for Chat
fn script_type_id_static() -> ScriptTypeId
Source§fn script_type_name() -> Option<LiveId>
fn script_type_name() -> Option<LiveId>
Returns the LiveId name of this type for error messages.
Override this in derive macro to provide meaningful type names.
fn script_new(vm: &mut ScriptVm<'_>) -> Self
fn script_proto_props( vm: &mut ScriptVm<'_>, obj: ScriptObject, props: &mut ScriptTypeProps, )
§fn is_repr_u32_enum() -> bool
fn is_repr_u32_enum() -> bool
Returns true if this type is a
repr(u32) enum.
Override in derive macro for enums with discriminants.
Used by shader compiler to treat the enum as u32.fn script_type_check(heap: &ScriptHeap, value: ScriptValue) -> bool
§fn script_pod(vm: &mut ScriptVm<'_>) -> Option<ScriptPodType>where
Self: Sized,
fn script_pod(vm: &mut ScriptVm<'_>) -> Option<ScriptPodType>where
Self: Sized,
Builds a pod struct type from the macro-generated type reflection.
This iterates through the ScriptTypeProps in order and generates
a ScriptPodTy::Struct with fields matching the struct’s layout.
Uses iter_rust_instance_ordered() to skip config fields before #deref.
fn script_default(vm: &mut ScriptVm<'_>) -> ScriptValuewhere
Self: Sized,
fn script_reload_default(vm: &mut ScriptVm<'_>) -> ScriptValuewhere
Self: Sized,
fn script_new_with_default(vm: &mut ScriptVm<'_>) -> Selfwhere
Self: Sized,
fn from_script_mod(
vm: &mut ScriptVm<'_>,
f: fn(&mut ScriptVm<'_>) -> ScriptValue,
) -> Selfwhere
Self: Sized,
fn script_from_value(vm: &mut ScriptVm<'_>, value: ScriptValue) -> Selfwhere
Self: Sized,
fn script_from_value_scoped(
vm: &mut ScriptVm<'_>,
scope: &mut Scope<'_, '_>,
value: ScriptValue,
) -> Selfwhere
Self: Sized,
fn script_proto(vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_proto_build( vm: &mut ScriptVm<'_>, props: &mut ScriptTypeProps, ) -> ScriptValue
fn script_api(vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_component(vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_shader(vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_ext(vm: &mut ScriptVm<'_>) -> ScriptValue
fn script_enum_lookup_variant( vm: &mut ScriptVm<'_>, variant: LiveId, ) -> ScriptValue
Source§impl Widget for Chat
impl Widget for Chat
fn handle_event( &mut self, cx: &mut Cx, event: &Event, scope: &mut Scope<'_, '_>, )
fn draw_walk( &mut self, cx: &mut Cx2d<'_, '_>, scope: &mut Scope<'_, '_>, walk: Walk, ) -> DrawStep
fn handle_event_with( &mut self, cx: &mut Cx, event: &Event, scope: &mut Scope<'_, '_>, _sweep_area: Area, )
fn script_call( &mut self, _vm: &mut ScriptVm<'_>, _method: LiveId, _args: ScriptValue, ) -> ScriptAsyncResult
fn script_result( &mut self, _vm: &mut ScriptVm<'_>, _id: ScriptAsyncId, _result: ScriptValue, )
§fn is_interactive(&self) -> bool
fn is_interactive(&self) -> bool
Whether this widget is interactive (wants mouse/touch events like hover, click).
Defaults to true. Override to return false for non-interactive widgets.
fn widget(&self, cx: &Cx, path: &[LiveId]) -> WidgetRef
fn widgets(&self, cx: &Cx, paths: &[&[LiveId]]) -> WidgetSet
§fn widget_flood(&self, cx: &Cx, path: &[LiveId]) -> WidgetRef
fn widget_flood(&self, cx: &Cx, path: &[LiveId]) -> WidgetRef
Flood-fill search: find a widget by path, searching children first,
then expanding outward through parents and their subtrees.
§fn widgets_flood(&self, cx: &Cx, paths: &[&[LiveId]]) -> WidgetSet
fn widgets_flood(&self, cx: &Cx, paths: &[&[LiveId]]) -> WidgetSet
Flood-fill search returning all matches, ordered by proximity.
fn draw_3d( &mut self, _cx: &mut Cx3d<'_, '_>, _scope: &mut Scope<'_, '_>, ) -> Result<(), WidgetRef>
fn draw_3d_all(&mut self, cx: &mut Cx3d<'_, '_>, scope: &mut Scope<'_, '_>)
fn draw( &mut self, cx: &mut Cx2d<'_, '_>, scope: &mut Scope<'_, '_>, ) -> Result<(), WidgetRef>
fn draw_walk_all( &mut self, cx: &mut Cx2d<'_, '_>, scope: &mut Scope<'_, '_>, walk: Walk, )
fn draw_all(&mut self, cx: &mut Cx2d<'_, '_>, scope: &mut Scope<'_, '_>)
fn draw_unscoped(&mut self, cx: &mut Cx2d<'_, '_>) -> Result<(), WidgetRef>
fn draw_all_unscoped(&mut self, cx: &mut Cx2d<'_, '_>)
fn text(&self) -> String
fn set_text(&mut self, _cx: &mut Cx, _v: &str)
fn set_key_focus(&self, cx: &mut Cx)
fn key_focus(&self, cx: &Cx) -> bool
fn set_disabled(&mut self, _cx: &mut Cx, _disabled: bool)
fn disabled(&self, _cx: &Cx) -> bool
fn ref_cast_type_id(&self) -> TypeIdwhere
Self: 'static,
fn ui_runner(&self) -> UiRunner<Self>where
Self: Sized + 'static,
Source§impl WidgetNode for Chat
impl WidgetNode for Chat
fn widget_uid(&self) -> WidgetUid
fn visible(&self) -> bool
fn set_visible(&mut self, cx: &mut Cx, visible: bool)
fn area(&self) -> Area
fn walk(&mut self, cx: &mut Cx) -> Walk
fn redraw(&mut self, cx: &mut Cx)
Source§fn children(&self, visit: &mut dyn FnMut(LiveId, WidgetRef))
fn children(&self, visit: &mut dyn FnMut(LiveId, WidgetRef))
Enumerate direct children for widget-tree indexing.
Source§fn skip_widget_tree_search(&self) -> bool
fn skip_widget_tree_search(&self) -> bool
If true, global widget-tree search/flood will not traverse this node’s descendants.
The node is still indexed and can still be matched directly by name/path.
Source§fn find_widgets_from_point(
&self,
cx: &Cx,
point: DVec2,
found: &mut dyn FnMut(&WidgetRef),
)
fn find_widgets_from_point( &self, cx: &Cx, point: DVec2, found: &mut dyn FnMut(&WidgetRef), )
Find all widgets whose area contains the given point. Calls the closure for each found widget.
fn selection_text_len(&self) -> usize
fn selection_point_to_char_index(&self, cx: &Cx, abs: DVec2) -> Option<usize>
fn selection_set(&mut self, anchor: usize, cursor: usize)
fn selection_clear(&mut self)
fn selection_select_all(&mut self)
fn selection_get_text_for_range(&self, start: usize, end: usize) -> String
fn selection_get_full_text(&self) -> String
§fn child_by_path(&self, path: &[LiveId]) -> WidgetRef
fn child_by_path(&self, path: &[LiveId]) -> WidgetRef
Find a descendant by child-id path, walking through
children().
Each segment is matched anywhere in the current subtree, i.e.
a.b behaves like *.a.*.b.fn child(&self, id: LiveId) -> WidgetRef
§fn find_interactive_widget_from_point(
&self,
cx: &Cx,
point: Vec2d,
) -> Option<WidgetRef>
fn find_interactive_widget_from_point( &self, cx: &Cx, point: Vec2d, ) -> Option<WidgetRef>
Find the first interactive widget at the given point, or None.
§fn point_hits_area(&self, cx: &Cx, point: Vec2d) -> bool
fn point_hits_area(&self, cx: &Cx, point: Vec2d) -> bool
Whether this widget’s area contains the given point. Override for widgets with
multiple hit areas (e.g. TextFlowLink with drawn_areas).
fn set_action_data(&mut self, _data: Arc<dyn ActionTrait>)
fn action_data(&self) -> Option<Arc<dyn ActionTrait>>
fn cast_inner_any(&self, _type_id: TypeId) -> Option<&(dyn Any + 'static)>
fn cast_inner_any_mut( &mut self, _type_id: TypeId, ) -> Option<&mut (dyn Any + 'static)>
fn script_call_live( &mut self, _vm: &mut ScriptVm<'_>, _method: LiveId, _args: ScriptValue, ) -> ScriptAsyncResult
fn script_result_live( &mut self, _vm: &mut ScriptVm<'_>, _id: ScriptAsyncId, _result: ScriptValue, )
impl ScriptDeriveMarker for Chat
Auto Trait Implementations§
impl Freeze for Chat
impl !RefUnwindSafe for Chat
impl !Send for Chat
impl !Sync for Chat
impl Unpin for Chat
impl !UnwindSafe for Chat
Blanket Implementations§
§impl<T> AdaptiveViewWidgetExt for Twhere
T: Widget,
impl<T> AdaptiveViewWidgetExt for Twhere
T: Widget,
fn adaptive_view(&self, cx: &Cx, path: &[LiveId]) -> AdaptiveViewRef
§impl<T> AreaChartSetWidgetExt for Twhere
T: Widget,
impl<T> AreaChartSetWidgetExt for Twhere
T: Widget,
fn area_chart_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> AreaChartSet
§impl<T> AreaChartWidgetExt for Twhere
T: Widget,
impl<T> AreaChartWidgetExt for Twhere
T: Widget,
fn area_chart(&self, cx: &Cx, path: &[LiveId]) -> AreaChartRef
§impl<T> BarChartSetWidgetExt for Twhere
T: Widget,
impl<T> BarChartSetWidgetExt for Twhere
T: Widget,
fn bar_chart_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> BarChartSet
§impl<T> BarChartWidgetExt for Twhere
T: Widget,
impl<T> BarChartWidgetExt for Twhere
T: Widget,
§impl<T> BareStepSetWidgetExt for Twhere
T: Widget,
impl<T> BareStepSetWidgetExt for Twhere
T: Widget,
fn bare_step_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> BareStepSet
§impl<T> BareStepWidgetExt for Twhere
T: Widget,
impl<T> BareStepWidgetExt for Twhere
T: Widget,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> BrowserSetWidgetExt for Twhere
T: Widget,
impl<T> BrowserSetWidgetExt for Twhere
T: Widget,
fn browser_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> BrowserSet
§impl<T> BrowserWidgetExt for Twhere
T: Widget,
impl<T> BrowserWidgetExt for Twhere
T: Widget,
§impl<T> ButtonSetWidgetExt for Twhere
T: Widget,
impl<T> ButtonSetWidgetExt for Twhere
T: Widget,
§impl<T> ButtonWidgetExt for Twhere
T: Widget,
impl<T> ButtonWidgetExt for Twhere
T: Widget,
§impl<T> CachedWidgetWidgetExt for Twhere
T: Widget,
impl<T> CachedWidgetWidgetExt for Twhere
T: Widget,
fn cached_widget(&self, cx: &Cx, path: &[LiveId]) -> CachedWidgetRef
§impl<T> CalloutTooltipSetWidgetExt for Twhere
T: Widget,
impl<T> CalloutTooltipSetWidgetExt for Twhere
T: Widget,
fn callout_tooltip_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> CalloutTooltipSet
§impl<T> CalloutTooltipWidgetExt for Twhere
T: Widget,
impl<T> CalloutTooltipWidgetExt for Twhere
T: Widget,
fn callout_tooltip(&self, cx: &Cx, path: &[LiveId]) -> CalloutTooltipRef
§impl<T> CandlestickChartSetWidgetExt for Twhere
T: Widget,
impl<T> CandlestickChartSetWidgetExt for Twhere
T: Widget,
fn candlestick_chart_set( &self, cx: &Cx, paths: &[&[LiveId]], ) -> CandlestickChartSet
§impl<T> CandlestickChartWidgetExt for Twhere
T: Widget,
impl<T> CandlestickChartWidgetExt for Twhere
T: Widget,
fn candlestick_chart(&self, cx: &Cx, path: &[LiveId]) -> CandlestickChartRef
§impl<T> ChartViewSetWidgetExt for Twhere
T: Widget,
impl<T> ChartViewSetWidgetExt for Twhere
T: Widget,
fn chart_view_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> ChartViewSet
§impl<T> ChartViewWidgetExt for Twhere
T: Widget,
impl<T> ChartViewWidgetExt for Twhere
T: Widget,
fn chart_view(&self, cx: &Cx, path: &[LiveId]) -> ChartViewRef
Source§impl<T> ChatSetWidgetExt for Twhere
T: Widget,
impl<T> ChatSetWidgetExt for Twhere
T: Widget,
Source§impl<T> ChatWidgetExt for Twhere
T: Widget,
impl<T> ChatWidgetExt for Twhere
T: Widget,
§impl<T> CheckBoxSetWidgetExt for Twhere
T: Widget,
impl<T> CheckBoxSetWidgetExt for Twhere
T: Widget,
fn check_box_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> CheckBoxSet
§impl<T> CheckBoxWidgetExt for Twhere
T: Widget,
impl<T> CheckBoxWidgetExt for Twhere
T: Widget,
Source§impl<T> CitationListSetWidgetExt for Twhere
T: Widget,
impl<T> CitationListSetWidgetExt for Twhere
T: Widget,
fn citation_list_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> CitationListSet
Source§impl<T> CitationListWidgetExt for Twhere
T: Widget,
impl<T> CitationListWidgetExt for Twhere
T: Widget,
fn citation_list(&self, cx: &Cx, path: &[LiveId]) -> CitationListRef
§impl<T> CodeViewSetWidgetExt for Twhere
T: Widget,
impl<T> CodeViewSetWidgetExt for Twhere
T: Widget,
fn code_view_set(&self, cx: &Cx, paths: &[&[LiveId]]) -> CodeViewSet
§impl<T> CodeViewWidgetExt for Twhere
T: Widget,
impl<T> CodeViewWidgetExt for Twhere
T: Widget,
§impl<T> CommandTextInputSetWidgetExt for Twhere
T: Widget,
impl<T> CommandTextInputSetWidgetExt for Twhere
T: Widget,
fn command_text_input_set( &self, cx: &Cx, paths: &[&[LiveId]], ) -> CommandTextInputSet
§impl<T> CommandTextInputWidgetExt for Twhere
T: Widget,
impl<T> CommandTextInputWidgetExt for Twhere
T: Widget,
fn command_text_input(&self, cx: &Cx, path: &[LiveId]) -> CommandTextInputRef
§impl<T> DesktopButtonSetWidgetExt for Twhere
T: Widget,
impl<T> DesktopButtonSetWidgetExt for Twhere
T: Widget,
§impl<T> DesktopButtonWidgetExt for Twhere
T: Widget,
impl<T> DesktopButtonWidgetExt for Twhere
T: Widget,
§impl<T> DockSetWidgetExt for Twhere
T: Widget,
impl<T> DockSetWidgetExt for Twhere
T: Widget,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.