modos.prompt#

Classes#

SlotCodeCompleter

Auto-suggestions for terminology codes.

SlotPrompter

Introspects the schema to prompt the user for values based on input class/slot.

Functions#

fuzzy_complete(prompt_txt, matcher)

Given a pre-configured matcher, prompt the user with live auto-suggestions.

Module Contents#

class modos.prompt.SlotCodeCompleter(matcher)[source]#

Bases: prompt_toolkit.completion.Completer

Auto-suggestions for terminology codes.

Parameters:

matcher (modos.codes.CodeMatcher)

matcher[source]#
get_completions(document, complete_event)[source]#

This should be a generator that yields Completion instances.

If the generation of completions is something expensive (that takes a lot of time), consider wrapping this Completer class in a ThreadedCompleter. In that case, the completer algorithm runs in a background thread and completions will be displayed as soon as they arrive.

Parameters:
  • documentDocument instance.

  • complete_eventCompleteEvent instance.

modos.prompt.fuzzy_complete(prompt_txt, matcher)[source]#

Given a pre-configured matcher, prompt the user with live auto-suggestions.

Parameters:
class modos.prompt.SlotPrompter(endpoint=None, suggest=True, prompt=None)[source]#

Introspects the schema to prompt the user for values based on input class/slot.

Parameters:
  • endpoint (Optional[modos.remote.EndpointManager]) – Endpoint running a fuzon server for code matching.

  • suggest – Whether to generate auto-suggestion dynamically.

  • prompt (Optional[str]) – Override the default prompt messages.

prompt[source]#
prompt_for_slot(slot_name, optional=False)[source]#
Parameters:
prompt_for_slots(target_class, exclude=None)[source]#

Prompt the user to provide values for the slots of input class. values of required fields can be excluded to repeat the prompt.

Parameters
target_class

Class to build

exclude

Mapping with the name of a slot as key and list of invalid entries as values.

Parameters:
  • target_class (type)

  • exclude (Optional[Mapping[str, List]])

Return type:

dict[str, Any]