diva.config package

Subpackages

Submodules

diva.config.config_object module

class diva.config.config_object.Config[source]

Bases: object

Config object, containing all graph parameters found in the user prompt.

All the parameters are private attributes (to avoid overwriting them by accident). Values are assigned to these attributes with setters and taken for usages external to the class with getters. (e.g. for self.__location, setter is set_location(self, value) with value the value to pass to self.__location and getter is def location(self) -> self.__location with the decorator @property)

Methods

__str__()

returns a dictionary with the main graph parameters (the main private attributes of the class).

__repr__()

returns other information about the class such as the run time to create it, the user prompt, and the missing parameters.

add_not_in_shp(text: str)[source]

Acts as a setters. Appends in a list, in the private attributes, the locations not found in the shapefiles

property aggregation_operator: str
property aggregation_type: str
property anomaly: bool
property climate_variable: str
property creation_time: float
property end_time: str
property graph_type: str
property last: Config
property location: str
property not_in_shp: list[str]
set_agg_operator(value: str)[source]
set_aggregation_type(value: str)[source]
set_anomaly(value: bool)[source]
set_climate_variable(value: str)[source]
set_creation_time(value: float)[source]
set_end_time(value: str)[source]
set_graph_type(value: str)[source]
set_last(value: object)[source]
set_location(value: str)[source]
set_missings(value: list)[source]
set_start_time(value: str)[source]
set_time_expression(value: str | list[str])[source]
set_user_prompt(value: str)[source]
property start_time: str
property time_expression: str

diva.config.interface_ask_missings module

diva.config.interface_completion module

diva.config.interface_creation module

diva.config.interface_get_missings module

diva.config.interface_instruction module

diva.config.module_config module

class diva.config.module_config.ModuleConfig(module_chat)[source]

Bases: object

This module supervises all tasks related to the search of graph parameters (config) in the user prompt. The strategies for subtasks (in config.services) are instantiated as private arguments of the class.

Attributes

config: instance of Config

with getter. The instance contains all the retrieved parameters in the user_prompt for graph building

history_config: list[‘Config’]

with getter. List of instances of Config. Newly created Config (for each user prompt categorized as visualisation) are appended to this list. The list can be cleared with the function clear_history()

missings: list[str]

with getter. List of missing mandatory graph parameters (climate variable, start time, end time, location)

Methods

prompt_to_config(prompt=””, verbose=parameters.verbose)

Searches for graph parameters in the user_prompt

complete_missings(verbose=parameters.verbose):

Completes graph parameters not found in the user_prompt with the data from the last Config object in the history.

ask_missings() -> str:

Generates a text string to ask for the missing parameters (if any). Returns a text string.

clear_history(clear_chat_history=True)

Clear the config history and the chat history if the corresponding parameter is set to True (default)

ask_missings() str[source]

Creates a text string to asks the missing mandatory graph parameters.

Returns

str

A text string asking for the missing mandatory graph parameters.

clear_history(clear_chat_history=True)[source]

Clears the history of configs and the chat history (by default)

complete_missings(verbose: bool = False)[source]

Completes missing parameters with the data from the last Config instance in history.

Parameters

verbose: bool

Default value from diva.parameters.verbose.

property config: Config
property history_config: list[Config]
property missings: list[str]

Missings is not an attribute of the class. This function retrieves the missing parameters from the class instantiated in the private attribute get_missings_strategy. Returns a list of string.

prompt_to_config(prompt: str | Prompt = '', verbose: bool = False)[source]

Searches for the graph parameters in the user prompt.

Parameters

prompt: str or instance of Prompt

Default to empty string. If this parameter is an empty string, it fetches the instance of prompt from the instance of chat associated with this class. Else, if the parameters is a non-empty string, the method uses it to instantiate Prompt, and stores the instance in the chat instance.

verbose: bool

Default value from diva.parameters.verbose.

diva.config.service_ask_missings module

diva.config.service_completion module

diva.config.service_get_missings module

Module contents