Agent - the Complete Dialogue System

Agent.py - wrapper for all components required in a dialogue system

Copyright CUED Dialogue Systems Group 2015 - 2017

Contains 3 classes::
DialogueAgent, AgentFactoy, CallValidator

class Agent.AgentFactory(hub_id='dialogueserver')

Based on the config (Settings.config) - a primary agent (called Smith) is created. This agent can be duplicated as required by concurrent traffic into the dialogue server. Duplicated agents are killed at end of their calls if more agents are running than a specified minimum (MAX_AGENTS_RUNNING)

agent2session(agent_id)

Gets str describing session_id agent is currently on

Parameters:agent_id (string) – agent id
Returns:string – the session id
continue_call(agent_id, asr_info, domainString=None)

wrapper for continue_call for the specific Agent() instance identified by agent_id

Parameters:
  • agent_id (string) – agent id
  • asr_info (list) – information fetched from the asr
  • domainString (string) – domain name
Returns:

string – the system’s response

end_call(agent_id=None, session_id=None, noTraining=False)
Can pass session_id or agent_id as we use this in cases
  1. normally ending a dialogue, (via agent_id)
  2. cleaning a hung up call (via session_id)
Parameters:
  • agent_id (string) – agent id
  • session_id (string) – session_id
Returns:

None

init_agents(hub_id)

Creates the first agent. All other agents created within the factory will be deep copies of this agent.

Parameters:hub_id (string) – hub id
Returns:None
kill_agent(agent_id)

Delete an agent if the total agent number is bigger than self.MAX_AGENTS_RUNNING.

Parameters:agent_id (string) – agent id
Returns:None
new_agent()

Creates a new agent to handle some concurrency. Here deepcopy is used to creat clean copy rather than referencing, leaving it in a clean state to commence a new call.

Returns:string – the agent id
power_down_factory()

Finalise agents, print the evaluation summary and save the policy we close dialogue server.

Returns:None
query_ENDING_DIALOG(agent_id)

Wrapper for specific Agent.ENDING_DIALOG() – with some basic initial checks.

Parameters:agent_id (string) – agent id
Returns:bool – whether to end the dialogue or not
retrieve_agent(session_id)

Returns str describing agent_id.

Parameters:session_id (string) – session_id
Returns:string – the agent id
start_call(session_id, start_domain=None)

Locates an agent to take this call and uses that agents start_call method.

Parameters:
  • session_id (string) – session_id
  • start_domain (str) – used by DialPort/external topictracking with DialogueServer to hand control to certain domain
Returns:

start_call() function of agent object, string – the selected agent, agent id

class Agent.CallValidator

Used to validate calls, e.g., when using PyDial within user experiments.

Calls may be validated after a minimum of length in seconds or turns or if the system offers a venue. The flag isTrainable may be used to distinguish between dialogues whose formal conditions for validity are fulfilled but who will introduce to much noise in the training process, e.g., if you allow for users to regularly abort the dialogue after 2 minutes but only want to use the dialogue for training if a minimum of 3 turns have carried out.

check_if_user_bye(obs)

Checks using a regular expression heuristic if the user said good bye. In accordance with C++ system, prob of respective n-best entry must be > 0.85.

class Agent.DialogueAgent(agent_id='Smith', hub_id='dialogueserver')

Contains all components required for multi domain dialogue: {topic tracking, semi belief tracking, policy, semo} - each of these components is a manager for that ability for all domains. - DialogueAgent() controls the flow of calls/information passing between all of these components in order to execute a dialog

continue_call(asr_info, domainString=None, domainSimulatedUsers=None)

Works through topictracking > semi belief > policy > semo > evaluation – for turns > 0

Input consists of a n-best list of either ASR hypotheses (with confidence) or (mostly only in case of simulation) pre-interpreted DiaActWithProb objects.

Parameters:
  • asr_info (list of string or DiaActWithProb objects) – information fetched from the asr
  • domainString (string) – domain name
  • domainSimulatedUsers (dict) – simulated users in different domains
Returns:

DiaAct – the system’s reponse dialogue act with verbalization

end_call(domainSimulatedUsers=None, noTraining=False)

Performs end of dialog clean up: policy learning, policy saving and housecleaning. The NoTraining parameter is used in case of an abort of the dialogue where you still want to gracefully end it, e.g., if the dialogue server receives a clean request.

Parameters:
  • domainSimulatedUsers (dict) – simulated users in different domains
  • noTraining (bool) – train the policy when ending dialogue
Returns:

None

restart_agent(session_id, maxNumTurnsScaling=1.0, start_domain=None)

Restart the agnet

Parameters:
  • session_id (str) – unique session identifier for the dialogue
  • maxNumTurnsScaling (float) – controls the variable number of turns allowed for the dialog, based on how many domains are involved (used only for simulate)
  • start_domain (str) – used by DialPort/external topictracking with DialogueServer to hand control to certain domain
Returns:

None

retrieve_last_sys_act(domainString=None)

Retreives the sys act from domain domainString if a domain switch has occurred

Parameters:domainString (string) – domain name
Returns:string – the system’s dialogue act reponse
start_call(session_id, domainSimulatedUsers=None, maxNumTurnsScaling=1.0, start_domain=None)

Start a new call with the agent. Works through policy > semo – for turn 0 Start domain is used if external topic tracking is used.

Input consists of a n-best list of either ASR hypotheses (with confidence) or (mostly only in case of simulation) pre-interpreted DiaActWithProb objects.

Parameters:
  • session_id (string) – session id
  • domainSimulatedUsers (dict) – simulated users in different domains
  • maxNumTurnsScaling (float) – controls the variable turn numbers allowed in a dialog, based on how many domains are involved (used only for simulate)
  • start_domain (str) – used by DialPort/external topictracking with DialogueServer to hand control to certain domain
Returns:

string – the system’s reponse