[−][src]Struct rust_bert::pipelines::conversation::ConversationManager
Data structure allowing the management of conversations and main input to the dialogue model.
It contains a HashMap of conversations with UUID keys
Implementations
impl ConversationManager[src]
pub fn new() -> ConversationManager[src]
Build a new ConversationManager
Example
use rust_bert::pipelines::conversation::ConversationManager; let conversation_manager = ConversationManager::new();
pub fn get_active_conversations(
&mut self
) -> (Vec<&Uuid>, Vec<&mut Conversation>)[src]
&mut self
) -> (Vec<&Uuid>, Vec<&mut Conversation>)
Returns a list of the active conversations (containing new inputs to be processed by the model)
Returns
(Vec<&Uuid>, Vec<&mut Conversation>)Tuple of vectors with the activeUUIDandConversations
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation = Conversation::new("Hi there!"); let empty_conversation = Conversation::new_empty(); let conversation_id = conversation_manager.add(conversation); let empty_conversation_id = conversation_manager.add(empty_conversation); let active_conversations = conversation_manager.get_active_conversations(); assert_eq!(active_conversations.0.len(), 1usize);
pub fn get(&mut self, uuid: &Uuid) -> Option<&mut Conversation>[src]
Returns a mutable reference to the conversation wih the provided UUID
Arguments
uuid-&Uuidof the conversation to retrieve
Returns
Option<&mut Conversation>Optional mutable reference to the conversation matching the UUID provided
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation = Conversation::new("Hi there!"); let conversation_id = conversation_manager.add(conversation); let conversation_ref = conversation_manager.get(&conversation_id);
pub fn get_all(&mut self) -> HashMap<&Uuid, &Conversation>[src]
Returns a HashMap containing references to all conversations stored in the manager
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation = Conversation::new("Hi there!"); let conversation_id = conversation_manager.add(conversation); let all_conversations = conversation_manager.get_all();
pub fn create(&mut self, text: &str) -> Uuid[src]
Creates a conversation and add it to the conversation manager
Arguments
text-&strstring slice with an original user input
Returns
Uuidfor the conversation created
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation_id = conversation_manager.create("Hi there!");
pub fn create_empty(&mut self) -> Uuid[src]
Creates an empty conversation and add it to the conversation manager
Returns
Uuidfor the conversation created
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation_id = conversation_manager.create_empty();
pub fn add(&mut self, conversation: Conversation) -> Uuid[src]
Adds an existing conversation to the conversation manager
Arguments
conversation-Conversationto be added to the conversation manager
Returns
Uuidfor the conversation created
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation = Conversation::new("Hi there!"); let conversation_id = conversation_manager.add(conversation);
pub fn remove(&mut self, uuid: &Uuid) -> Option<Conversation>[src]
Deregister a conversation from the conversation manager
Arguments
uuid-&Uuidof the conversation to deregister from the conversation manager
Returns
Option<Conversation>deregistered conversation
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation_id = conversation_manager.create("Hi there!"); conversation_manager.remove(&conversation_id);
pub fn clear(&mut self) -> HashMap<Uuid, Conversation>[src]
Clear all conversations from the conversation manager, and returns the conversations and their former UUID.
Returns
HashMap<Uuid, Conversation>deregistered conversations
Example
use rust_bert::pipelines::conversation::{Conversation, ConversationManager}; let mut conversation_manager = ConversationManager::new(); let conversation_id = conversation_manager.create("Hi there!"); let conversations = conversation_manager.clear();
Trait Implementations
impl Debug for ConversationManager[src]
impl Default for ConversationManager[src]
Auto Trait Implementations
impl RefUnwindSafe for ConversationManager[src]
impl Send for ConversationManager[src]
impl Sync for ConversationManager[src]
impl Unpin for ConversationManager[src]
impl UnwindSafe for ConversationManager[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,