Struct rust_bert::pipelines::conversation::ConversationManager [−][src]
pub struct ConversationManager { /* fields omitted */ }Expand description
Data structure allowing the management of conversations and main input to the dialogue model.
It contains a HashMap of conversations with UUID keys
Implementations
Build a new ConversationManager
Example
use rust_bert::pipelines::conversation::ConversationManager;
let conversation_manager = ConversationManager::new();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);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);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();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!");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();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);Deregister a conversation from the conversation manager
Arguments
uuid-&Uuidof the conversation to deregister from the conversation manager
Returns
Option<Conversation>de-registered 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);Clear all conversations from the conversation manager, and returns the conversations and their former UUID.
Returns
HashMap<Uuid, Conversation>de-registered 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
Auto Trait Implementations
impl RefUnwindSafe for ConversationManager
impl Send for ConversationManager
impl Sync for ConversationManager
impl Unpin for ConversationManager
impl UnwindSafe for ConversationManager
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self
