eta.core.eta.DialogueState
- class DialogueState(config_agent, config_user)[source]
Bases:
object
A representation of the current dialogue state.
- Parameters:
- output_buffer
A buffer of output utterances that are accumulated until the system is ready to write them and listen for user input.
- step_failure_timer
A POSIX time record used to track time before failing an expected event.
- Type:
- transducers
A dict associating Transducer object(s) with named mapping functions (e.g., ‘gist’).
- Type:
dict[str, Transducer or list[Transducer]]
- embedder
An embedder object used to compute object embeddings and perform retrieval.
- Type:
- schemas
A library of dialogue, episode, and object schemas that form the agent’s generic knowledge.
- Type:
- concept_aliases
TODO
- Type:
None
- concept_sets
TODO
- Type:
None
- init_knowledge
A list of initial facts in the agent’s semantic memory.
- Type:
- plan
The “currently due” node in the agent’s plan, initialized from the start_schema.
- Type:
- buffers
The named buffers (i.e., priority queues) for each type of processed data.
- conversation_log
A list of turns in the dialogue history.
- Type:
- memory
The episodic memory of the agent, initialized from init_knowledge.
- Type:
- timegraph
TODO
- Type:
None
Methods
Access facts from context matching a given predicate pattern.
Add all elements in a list to the buffer of the given type.
Add an element to the buffer of the given type.
Add an element to the buffer of the given type iff that buffer is currently empty.
Add a fact to the context.
Add a fact to the memory.
Advance the plan to the next step (or signal to quit the conversation if none exists).
Apply the transducer(s) of the given type to a list of arguments.
Bind the given variable symbol to the given value throughout the dialogue state.
Check whether the buffer of the given type is empty.
Compute the accumulated (monetary) cost of each transducer for this session.
Check whether to continue with the current dialogue.
Evaluate the truth value of a wff in memory/context.
Flush the dialogue context of "instantaneous" events.
Get the buffer of the given type.
Get the current conversation history.
Get the path for an IO file (if given) or the IO directory for this session.
Get the path for a log file (if given) or the log directory for this session.
Get the memory storage object.
Get the registered perception servers for this session.
Get the agent's plan.
Check whether to quit the conversation.
Get the registered specialist servers for this session.
Get the current value of the step failure timer.
Get the user ID for this session.
Check whether the agent currently has a plan.
Initialize a plan from a given schema predicate along with a list of arguments.
Instantiate the current plan step.
Check whether a given predicate exists in the agent's schema library.
Log and write a given DialogueTurn in the conversation log.
Pop all elements from the buffer of the given type.
Pop an element from the buffer of the given type.
Print all current schema instances.
Push an utterance onto the output buffer.
Remove a fact from the context.
Replace the buffer of the given type with a list of elements.
Replace the buffer of the given type with a single element.
Reset the step failure timer to the current time.
Retrieve and combine facts from the current dialogue schema, relevant episode schemas, and memory.
Set the agent's plan to a new plan node.
Set whether to quit the conversation.
Unbind the given variable symbol throughout the dialogue state.
Write the output buffer (a list of Utterances) to output files.
- get_io_path(fname='')[source]
Get the path for an IO file (if given) or the IO directory for this session.
- get_log_path(fname='')[source]
Get the path for a log file (if given) or the log directory for this session.
- is_schema(predicate, type=None)[source]
Check whether a given predicate exists in the agent’s schema library.
- init_plan_from_schema(predicate, args=[])[source]
Initialize a plan from a given schema predicate along with a list of arguments.
This instantiates the generic schema as a schema instance, binding variables occurring in the header to the supplied arguments, if any. It then instantiates a plan structure from the episodes list of that schema.
Notes
TODO: the plan structure created when instantiating a schema is currently “flat” - in the future, we might want to add support for annotating abstraction hierarchies in the schema, in which case these would be added as supersteps to the steps of the plan-nodes that are created.
TODO: by default, we assume that the episodes of the schema define sequential steps. However, the episode-relations in the schema should be used to impose a different ordering on the resulting plan.
TODO: immediately following schema instantiation, we should also attempt to (a) bind variables in the schema occurring within the :types section to possible values in the dialogue context, as well as inferring the facts from the other schema sections, i.e., adding them to the context.
- advance_plan()[source]
Advance the plan to the next step (or signal to quit the conversation if none exists).
- instantiate_curr_step()[source]
Instantiate the current plan step.
This binds the episode variable for the current plan step with a newly created episode constant throughout the dialogue state. The event is also added to context, unless it is an expectation step, in which case it would have already been matched to an event in context.
This process recurs for any superstep such that the current step “completes” that superstep.
- add_to_buffer_if_empty(x, type)[source]
Add an element to the buffer of the given type iff that buffer is currently empty.
- access_from_context(pred_patt)[source]
Access facts from context matching a given predicate pattern.
- apply_transducer(type, *args)[source]
Apply the transducer(s) of the given type to a list of arguments.
- bind(var, val)[source]
Bind the given variable symbol to the given value throughout the dialogue state.
- retrieve_facts(query=None, n_schema=1, n_schema_facts=3, n_memory=3)[source]
Retrieve and combine facts from the current dialogue schema, relevant episode schemas, and memory.
The facts are divided into two subsets for facts that are “backgrounded” and those that are “foregrounded”, which may be leveraged by downstream tasks (e.g., in generation, we may assume that foregrounded facts should be used in the generated response in some way, whereas backgrounded facts may condition the generation without being directly used).
Currently, it is assumed that background facts correspond to the current dialogue schema conditions, whereas foregrounded facts are retrieved from relevant episode schemas and memory.
- Parameters:
query (str, optional) – The query string to use for retrieval. If not given, the previous user turn will be used.
n_schema (int, default=1) – The number of schemas to retrieve.
n_schema_facts (int, default=3) – The number of facts to use from the retrieved schemas (in addition to schema headers).
n_memories (int, default=3) – The number of facts to use from memory.
- Returns:
facts_bg (list[Eventuality]) – The retrieved background facts.
facts_fg (list[Eventuality]) – The retrieved foreground facts.