pydialogue package#
Subpackages#
- pydialogue.baseline package
- Submodules
- pydialogue.baseline.evaluation module
- pydialogue.baseline.llm_base_policies module
- pydialogue.baseline.llm_policies module
- pydialogue.baseline.rag_policies module
- pydialogue.baseline.serializers module
- Module contents
- pydialogue.environment package
- Submodules
- pydialogue.environment.actions module
- pydialogue.environment.descriptions module
BaseDescriptionBaseDescription.itemBaseDescription.mandatoryBaseDescription.elementsBaseDescription.cand_elementsBaseDescription.cand_mandatoryBaseDescription.random_genBaseDescription.filter_candidate_elements()BaseDescription.generate_description()BaseDescription.generate_elements()BaseDescription.mycopy()BaseDescription.pick_random_elements()
permute_list_of_lists()
- pydialogue.environment.entities module
- pydialogue.environment.helpers module
- Module contents
- pydialogue.environments package
- Submodules
- pydialogue.environments.builders module
- pydialogue.environments.easy module
- pydialogue.environments.path_helpers module
- pydialogue.environments.world module
WorldWorld.obj_listWorld.undo_changesWorld.directionsWorld.all_propertiesWorld.all_attributesWorld.graphWorld.all_pathsWorld.change_action_propertiesWorld.all_description_objectsWorld.location_positionsWorld.basic_init()World.check_val_is_key()World.compute_directions()World.expand_world()World.find_all_objs()World.find_all_vals()World.flush_undo_changes()World.get_attributes()World.get_properties()World.get_property_values()World.query_entity_from_db()World.recover_state()World.save_state()World.update_all_attributes()World.update_all_property_vals()World.update_graph()World.update_paths()
compute_unique_list()filter_items()list_diff()
- Module contents
- pydialogue.generation package
- Submodules
- pydialogue.generation.dialogue module
DialogueDialogue.random_seedDialogue.random_genDialogue.dia_generatorDialogue.policiesDialogue.utterancesDialogue.curr_speakerDialogue.counterDialogue.next_policy_idDialogue.max_episode_lengthDialogue.goal_generatorDialogue.use_generatorDialogue.goalDialogue.dialogue_overDialogue.curr_rewardDialogue.entities_descriptionsDialogue.max_safetyDialogue.add_policies()Dialogue.evaluate_goal()Dialogue.generate_new_goal()Dialogue.get_player_policies()Dialogue.get_player_utters()Dialogue.get_players()Dialogue.get_utterances()Dialogue.is_over()Dialogue.player_utters()Dialogue.recover_state()Dialogue.replace_player_policies()Dialogue.reset_descriptions()Dialogue.run()Dialogue.save_state()Dialogue.step()
- pydialogue.generation.file_list_db module
- pydialogue.generation.goal_generators module
- pydialogue.generation.helpers module
- pydialogue.generation.mappers_database module
- pydialogue.generation.param_generators module
- pydialogue.generation.templates module
- Module contents
- pydialogue.language package
- Submodules
- pydialogue.language.components module
- pydialogue.language.desc_mappers module
- pydialogue.language.describers module
- pydialogue.language.helpers module
- pydialogue.language.phrases module
- pydialogue.language.queries module
- pydialogue.language.sentences module
- pydialogue.language.words module
- Module contents
- pydialogue.policies package
- Submodules
- pydialogue.policies.agent_policies module
- pydialogue.policies.base_policies module
- pydialogue.policies.env_policies module
- pydialogue.policies.goals module
- pydialogue.policies.other_policies module
- pydialogue.policies.policies_helpers module
- pydialogue.policies.user_policies module
- pydialogue.policies.vocab module
- Module contents
- pydialogue.state package
- Submodules
- pydialogue.state.kn_checkers module
- pydialogue.state.kn_helpers module
- pydialogue.state.kn_parsers module
- pydialogue.state.kn_updaters module
- pydialogue.state.knowledge_base module
KnowledgeBaseKnowledgeBase.contextKnowledgeBase.worldKnowledgeBase.undo_changesKnowledgeBase.last_context_idKnowledgeBase.sent_dbKnowledgeBase.updatersKnowledgeBase.checkersKnowledgeBase.check()KnowledgeBase.context_update()KnowledgeBase.flush_undo_changes()KnowledgeBase.multi_check()KnowledgeBase.multi_update()KnowledgeBase.recover_state()KnowledgeBase.save_state()KnowledgeBase.single_update()
- Module contents
Submodules#
pydialogue.dialogue_generator module#
This module contains the class for generating dialogues.
- class pydialogue.dialogue_generator.DialogueGenerator(world, log_filename, context_strings_filename=None, primitive_templates=None)[source]#
Bases:
objectThis class contains all the components needed to generate/simulate dialogues.
Here is an example of how to quickly generate a dialogue:
easy_world = easy_env.build_world() generator = DialogueGenerator(easy_world, "error.log", "context_sentences.txt") dialogue = generator.generate_dialogue() dialogue.run()
- context_strings#
The list where all dialogue utterances, including the environmental feedback, are stored in a string form.
- Type:
ContextListDb
- context#
The list of instances (type Sentence) where all dialogue utterances, including the environmental feedback, are stored.
- Type:
ContextListDb
- meta_context#
This list is used to save all additional information that is carried by the uttered sentences. Please check lc.Phrase for more information about the meta sentences.
- Type:
ContextListDb
- knowledge_base#
The knowledge base stores additional information, and it is used in rule-based policies to quickly fetch information. It is updated each time an agent utters.
- Type:
- primitive_templates#
A list of functions that are used to generate the primitive dialogues.
- Type:
list
- curr_prim_params#
This field serves as a temporary memory to hold all primitive template parameters while they are generated. This field is helpful in case the generation of parameterA depends on the generation of another parameterB. The parameterA generator can fetch the value of parameterB using curr_prim_params[“parameterB”] After the primitive template is generated this dictionary is cleared.
- Type:
dict
- prim_param_generators#
A list of tuples (param_name, function). The function generates a random parameter value for the primitive templates.
- Type:
list
- agent_policy_database#
A dictionary that maps each agent (Entity) to all of its policies (list). The agent is the one who fulfills the user’s requests.
- Type:
dict
- user_policy_database#
A dictionary that maps each user (Entity) to all of its policies (list). The user issues the requests to the agent.
- Type:
dict
- agent_auto_policy_database#
A dictionary that maps each agent (Entity) to all of its policies.AutoPolicy policies (list).
- Type:
dict
- user_auto_policy_database#
A dictionary that maps each user (Entity) to all of its policies.AutoPolicy policies (list).
- Type:
dict
- env_policy_database#
A list of all environmental policies.
- Type:
list
- env_auto_policy#
The environment automatic self automatically selects the right self from the environment database when an agent utters. Once selected, it provides feedback to the agent.
- Type:
- execute_utters(utterances, random_gen=None, fake=False, skip_env=False)[source]#
Adds the agent/user utterances to the context, to the meta_context, and it updates the knowledge base. Moreover, the env_policy is executed so the environment can provide feedback to each of the utterances.
This function is used by the Dialogue class.
- Parameters:
utterances (list) – The list of utterances to be executed.
random_gen (random.Random) – The random generator used for randomly selecting a valid response from the environmental feedback. It makes the Dialogue reproducible.
fake (bool, optional) – If True the dia_generator state is not updated with the new information.
skip_env (bool, optional) – If True the env_policy is not executed.
- Returns:
responses – The list of players’ utterances, including the environment’s responses.
- Return type:
list
- generate_dialogue(structure_list=None, default_args_list=None)[source]#
Generates a single dialogue.
- Parameters:
structure_list (list, optional) – If the template type is complex, the structure list contains both primitive and complex templates that appear as parameters in another complex template. If the template type is primitive, the structure_list consists of a single tuple. More information can be found on helpers.generate_complex_structure and helpers.generate_primitive_structure
default_args_list (list, optional) – List of dictionaries that match the length of the structure list. The default is None.
- Returns:
The generated dialogue.
- Return type:
- init_agent_auto_policy_db(players)[source]#
Initializes all the auto policies for each agent in the agents (players) list.
- init_agent_policy_db(players)[source]#
Initializes all individual policies for the specified agents (players) in the world. The dialogue at this stage is None.
- init_param_generators()[source]#
Initializes the parameter generators for the primitive and complex templates.
- init_user_auto_policy_db(players)[source]#
Initialize all the auto policies for each user in the users (players) list.
- init_user_policy_db(players)[source]#
Initializes all individual policies for the specified users (players) in the world. The dialogue at this stage is None.
- run(num_dialogues, flush_after=None, save_dialogues=False, notebook_run=False)[source]#
Generates and runs a number of dialogues. The policies used in the dialogue are rule-based, and the dialogue should evaluate to 1. In case the dialogue does not evaluate to 1, an error is logged together with the dialogue utterances.
- Parameters:
num_dialogues (int) – The number of dialogues to be generated
flush_after (int) – Flushes the dia_generator state after a specific number of generated dialogues is reached.
save_dialogues (bool) – Whether to keep the dialogues in a list. It’s useful sometimes to either not keep the dialogues or remove their utterances in order to save RAM.
notebook_run (bool) – This parameter indicates whether the function is run from a jupyter notebook (True) or not (False). This parameter ensures the progress bars are shown correctly in a jupyter notebook.
- Returns:
dialogues – A list of Dialogue-s or an empty list if the save_dialogues is False.
- Return type:
list
- select_primitive_template(templates_list, default_args=None)[source]#
Selects a primitive template, and it randomly generates its parameters.
When creating the user request, if the parameter determiner_a is True, this means that the item is not concrete, i.e. it does not belong to a specific item in the world. For example, a big red ball. Therefore, an abstract item is used (a BaseEntity with an attribute “abstract”). If the determiner_a is False, a concrete Entity is taken from the world’s object list.
- Parameters:
templates_list (list) – The list of templates (functions) from which one is randomly selected.
default_args (dict, optional) – This dictionary is used for overriding the default random generation of parameters. The default is None.
- Returns:
template_rand (function) – The randomly selected template.
params (dict) – The generated parameters for the template.