eta.core.eta
The core executable for the Eta Dialogue Manager.
Running this module will read an agent and user config from eta.config and user_config, respectively, before spawning the core multiprocess loops that handle interpretation, reasoning, planning, and execution.
Note that the agent config is provided as a Python module that exports a ‘config’ function, returning a dict of config parameters, since transducers and other objects may be created within the config. On the other hand, the user config is supplied in JSON format.
Dialogue state is maintained entirely through a DialogueState class which is shared between each core process using a ProcessManager, and using mutex locks to prevent data races on the underlying dialogue state attributes.
Additionally, a set of buffers (i.e., priority queues) are used for the data being processed over the dialogue session, which is necessary for:
maintaining synchronicity between the processes in the relevant aspects (e.g., completing a series of modifications to the plan before attempting to execute a step).
ensuring that transducers, which may incur some monetary cost to apply (e.g., in the case of GPT-based transduction), are only applied after a modification to the relevant data.
Functions
Initialize the dialogue state for a new session and spawn each core process. |
|
Clear the symbol table, read the agent and user configs, and start Eta. |
Classes
A representation of the current dialogue state. |
|
Manager to handle multiprocessing. |
- 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
- 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.
- class ProcessManager(address=None, authkey=None, serializer='pickle', ctx=None)[source]
Bases:
BaseManager
Manager to handle multiprocessing.