eta.core.eta.DialogueState

class DialogueState(config_agent, config_user)[source]

Bases: object

A representation of the current dialogue state.

Parameters:
  • config_agent (dict) – The config parameters for the agent.

  • config_user (dict) – The config parameters for the user.

id

A unique ID for this session.

Type:

str

config_agent

The config parameters for the agent.

Type:

dict

config_user

The config parameters for the user.

Type:

dict

start_schema

The schema predicate used to begin the dialogue session.

Type:

str

start_time

The starting time of this dialogue session.

Type:

TimePoint

io_path

The path used to read and write input/output for this session.

Type:

str

me

The name of the agent for this session.

Type:

str

you

The name of the user for this session.

Type:

str

output_buffer

A buffer of output utterances that are accumulated until the system is ready to write them and listen for user input.

Type:

list[Utterance]

step_failure_timer

A POSIX time record used to track time before failing an expected event.

Type:

float

quit_conversation

Whether to quit the current session.

Type:

bool

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:

Embedder

schemas

A library of dialogue, episode, and object schemas that form the agent’s generic knowledge.

Type:

SchemaLibrary

concept_aliases

TODO

Type:

None

concept_sets

TODO

Type:

None

init_knowledge

A list of initial facts in the agent’s semantic memory.

Type:

list[Eventuality]

schema_instances

A dict containing all schema instances (keyed on their unique IDs).

Type:

dict

plan

The “currently due” node in the agent’s plan, initialized from the start_schema.

Type:

PlanNode

buffers

The named buffers (i.e., priority queues) for each type of processed data.

Type:

dict[str, list]

reference_list

TODO

Type:

list

equality_sets

TODO

Type:

dict

conversation_log

A list of turns in the dialogue history.

Type:

list[DialogueTurn]

memory

The episodic memory of the agent, initialized from init_knowledge.

Type:

MemoryStorage

timegraph

TODO

Type:

None

Methods

access_from_context

Access facts from context matching a given predicate pattern.

add_all_to_buffer

Add all elements in a list to the buffer of the given type.

add_to_buffer

Add an element to the buffer of the given type.

add_to_buffer_if_empty

Add an element to the buffer of the given type iff that buffer is currently empty.

add_to_context

Add a fact to the context.

add_to_memory

Add a fact to the memory.

advance_plan

Advance the plan to the next step (or signal to quit the conversation if none exists).

apply_transducer

Apply the transducer(s) of the given type to a list of arguments.

bind

Bind the given variable symbol to the given value throughout the dialogue state.

buffer_empty

Check whether the buffer of the given type is empty.

cost

Compute the accumulated (monetary) cost of each transducer for this session.

do_continue

Check whether to continue with the current dialogue.

eval_truth_value

Evaluate the truth value of a wff in memory/context.

flush_context

Flush the dialogue context of "instantaneous" events.

get_buffer

Get the buffer of the given type.

get_conversation_log

Get the current conversation history.

get_io_path

Get the path for an IO file (if given) or the IO directory for this session.

get_log_path

Get the path for a log file (if given) or the log directory for this session.

get_memory

Get the memory storage object.

get_perception_servers

Get the registered perception servers for this session.

get_plan

Get the agent's plan.

get_quit_conversation

Check whether to quit the conversation.

get_specialist_servers

Get the registered specialist servers for this session.

get_step_failure_timer

Get the current value of the step failure timer.

get_user_id

Get the user ID for this session.

has_plan

Check whether the agent currently has a plan.

init_plan_from_schema

Initialize a plan from a given schema predicate along with a list of arguments.

instantiate_curr_step

Instantiate the current plan step.

is_schema

Check whether a given predicate exists in the agent's schema library.

log_turn

Log and write a given DialogueTurn in the conversation log.

pop_all_buffer

Pop all elements from the buffer of the given type.

pop_buffer

Pop an element from the buffer of the given type.

print_schema_instances

Print all current schema instances.

push_output_buffer

Push an utterance onto the output buffer.

remove_from_context

Remove a fact from the context.

replace_all_buffer

Replace the buffer of the given type with a list of elements.

replace_buffer

Replace the buffer of the given type with a single element.

reset_step_failure_timer

Reset the step failure timer to the current time.

retrieve_facts

Retrieve and combine facts from the current dialogue schema, relevant episode schemas, and memory.

set_plan

Set the agent's plan to a new plan node.

set_quit_conversation

Set whether to quit the conversation.

unbind

Unbind the given variable symbol throughout the dialogue state.

write_output_buffer

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.

get_perception_servers()[source]

Get the registered perception servers for this session.

get_specialist_servers()[source]

Get the registered specialist servers for this session.

get_user_id()[source]

Get the user ID for this session.

get_step_failure_timer()[source]

Get the current value of the step failure timer.

reset_step_failure_timer()[source]

Reset the step failure timer to the current time.

get_quit_conversation()[source]

Check whether to quit the conversation.

set_quit_conversation(quit)[source]

Set whether to quit the conversation.

is_schema(predicate, type=None)[source]

Check whether a given predicate exists in the agent’s schema library.

has_plan()[source]

Check whether the agent currently has a plan.

get_plan()[source]

Get the agent’s plan.

set_plan(plan)[source]

Set the agent’s plan to a new plan node.

do_continue()[source]

Check whether to continue with the current dialogue.

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(x, type)[source]

Add an element to the buffer of the given type.

add_to_buffer_if_empty(x, type)[source]

Add an element to the buffer of the given type iff that buffer is currently empty.

add_all_to_buffer(xs, type)[source]

Add all elements in a list to the buffer of the given type.

replace_buffer(x, type)[source]

Replace the buffer of the given type with a single element.

replace_all_buffer(xs, type)[source]

Replace the buffer of the given type with a list of elements.

get_buffer(type)[source]

Get the buffer of the given type.

buffer_empty(type)[source]

Check whether the buffer of the given type is empty.

pop_buffer(type)[source]

Pop an element from the buffer of the given type.

pop_all_buffer(type)[source]

Pop all elements from the buffer of the given type.

get_conversation_log()[source]

Get the current conversation history.

log_turn(turn)[source]

Log and write a given DialogueTurn in the conversation log.

add_to_memory(fact, importance=0.25)[source]

Add a fact to the memory.

add_to_context(fact, importance=0.25)[source]

Add a fact to the context.

remove_from_context(fact)[source]

Remove a fact from the context.

access_from_context(pred_patt)[source]

Access facts from context matching a given predicate pattern.

flush_context()[source]

Flush the dialogue context of “instantaneous” events.

get_memory()[source]

Get the memory storage object.

eval_truth_value(wff)[source]

Evaluate the truth value of a wff in memory/context.

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.

unbind(var)[source]

Unbind the given variable symbol throughout the dialogue state.

cost()[source]

Compute the accumulated (monetary) cost of each transducer for this session.

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.

write_output_buffer()[source]

Write the output buffer (a list of Utterances) to output files.

push_output_buffer(utt)[source]

Push an utterance onto the output buffer.

print_schema_instances(no_bind=False)[source]

Print all current schema instances.