pub struct ConversationManager { /* private fields */ }
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 active UUID and Conversations
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 - &Uuid of 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 - &str string slice with an original user input
Returns
  • Uuid for 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
  • Uuid for 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 - Conversation to be added to the conversation manager
Returns
  • Uuid for 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 - &Uuid of 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§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more