promptmeteo.prompts package#
Submodules#
promptmeteo.prompts.base module#
- class promptmeteo.prompts.base.BasePrompt(prompt_domain: str = '', prompt_labels: str = '', prompt_detail: str = '')#
Bases:
ABC
Prompt class interface.
- PROMPT_EXAMPLE = '\n TEMPLATE:\n "Here you explain the task.\n {__PROMPT_DOMAIN__}\n {__PROMPT_DETAIL__}\n\n {__SHOT_EXAMPLES__}\n\n {__PROMPT_SAMPLE__}\n {__CHAIN_THOUGHT__}\n {__ANSWER_FORMAT__}"\n\n PROMPT_SAMPLE:\n "Here you describe the task."\n\n SHOT_EXAMPLES:\n "Here you set the {__EXAMPLES__} to take into consideration."\n\n PROMPT_DOMAIN:\n "Here you explain the {__DOMAIN__} from the texts."\n\n PROMPT_LABELS:\n "Here you give the {__LABELS__} if required."\n\n PROMPT_DETAIL:\n "Here you can give some {__DETAIL__}"\n\n CHAIN_THOUGHT:\n "Explain your answer step by step."\n\n ANSWER_FORMAT:\n "Response just with the answer."\n '#
- property domain: str#
Prompt Domain.
- property labels: List[str]#
Prompt Labels.
- classmethod read_prompt(prompt_text: str) None #
Reads a Promptmeteo prompt string to build the Task Prompt. Promptmeteo prompts are expected to follow the following template:
- Parameters:
prompt_text (str) –
Returns:#
Self
- run() PromptTemplate #
Returns the prompt template for the current task.
- property template: str#
Prompt Template.
Module contents#
- class promptmeteo.prompts.PromptFactory#
Bases:
object
Factory of Prompts
- static build_class(language: str, task_type: str, _model_name: str) BasePrompt #
Creates a class dinamically that inherits from BasePrompt given arguments configuracion. This new class has included its prompt from the .prompt file.
Example:#
>>> PromptFactory.build_class( >>> language='es', >>> task_type='ner', >>> model_name='text-davinci-003') >>> )
<class ‘__main__.Textdavinci003SpNer’>
- classmethod factory_method(language: str, task_type: str, model_name: str, prompt_domain: str, prompt_labels: List[str], prompt_detail: str)#
Returns and instance of a BasePrompt object depending on the task_type.
- promptmeteo.prompts.get_files_taxonomy(sep: str = '_')#
Convert a list of prompt files with the naming convetion of `{model_name}_{language}_{task}.prompt into a dictorionary version. Given the following folder structure:
- ./prompts/
├── __init__.py ├── base.py ├── google-flan-t5-small_es_classification.prompt ├── google-flan-t5-small_es_code-generation.prompt ├── google-flan-t5-small_es_ner.prompt ├── text-davinci-003_es_classification.prompt ├── text-davinci-003_es_code-generation.prompt └── text-davinci-003_es_ner.prompt
The function returns:
- {‘google-flan-t5-small’: {
- ‘es’: {
‘classification’: {}, ‘ner’: {} }
},
- ‘text-davinci-003’: {
- ‘es’: {
‘classification’: {}, ‘code-generation’: {}, ‘ner’: {} }
}
}