👻 Classes#
- class promptmeteo.APIGenerator(language: str, model_name: str, model_provider_name: str, api_version: str, api_protocol: str, api_style_instructions: List[str] | None, **kwargs)#
API Generator Task.
This class initializes the APIGenerator Task to create APIs based on descriptions.
- Parameters:
language (str) – Language for the API descriptions.
model_name (str) – Name of the model to be used for API generation.
model_provider_name (str) – Name of the model provider.
api_version (str) – Version of the API.
api_protocol (str) – Protocol of the API.
api_style_instructions (Optional[List[str]]) – Instructions for API style.
**kwargs (dict) – Additional keyword arguments.
Raises –
------ –
ValueError – If api_protocol is not in the allowed protocols or if api_version is not in the correct format.
Example –
------- –
APIGenerator (>>> from promptmeteo import) –
APIGenerator( (>>> model =) –
language="en" (...) –
:param : :param … selector_k=5: :param : :param … api_version=”3.0.3”: :param : :param … api_protocol=”REST”: :param : :param … api_style_instructions=[“Use always camel case.”: :param “Do not use acronyms.”]: :param : :param … model_provider_name=”openai”: :param : :param … model_name=”gpt-3.5-turbo-16k”: :param : :param … model_provider_token=model_token: :param : :param … ): :param >>> model.train(api_description: :param api_code): :param >>> model.predict(“API for managing account access”):
- train(api_descriptions: List[str], api_codes: List[str]) Self #
- Trains the model given use cases and notes on behaviour. Check the
parameters and task behaviour in each specific model training docstring.
Train the APIGenerator from a list of APIs descriptions and contracts.
- api_descriptionsList[str]
List of API descriptions.
- api_codesList[str]
List of API codes - contracts.
- APIGenerator
Returns the trained APIGenerator object.
- class promptmeteo.APIFormatter(language: str, model_name: str, model_provider_name: str, api_version: str, api_protocol: str, api_style_instructions: List[str] = None, **kwargs)#
API Formatter Task.
This class initializes the API Formatter Task to correct and format APIs.
- Parameters:
language (str) – Language for the API descriptions.
model_name (str) – Name of the model to be used for API generation.
model_provider_name (str) – Name of the model provider.
api_version (str) – Version of the API.
api_protocol (str) – Protocol of the API.
api_style_instructions (Optional[List[str]]) – Instructions for API style.
**kwargs (dict) – Additional keyword arguments.
Raises –
------ –
ValueError – If api_protocol is not in the allowed protocols or if api_version is not in the correct format.
Example –
------- –
APIFormatter (>>> from promptmeteo import) –
APIFormatter( (>>> model =) –
language="en" (...) –
:param : :param … api_version=”3.0.3”: :param : :param … api_protocol=”REST”: :param : :param … api_style_instructions=[“Use always camel case.”: :param “Do not use acronyms.”]: :param : :param … model_provider_name=”openai”: :param : :param … model_name=”gpt-3.5-turbo-16k”: :param : :param … model_provider_token=model_token: :param : :param … external_info={: :param … “servers”: :type … “servers”: [ :param … {: :param … “url”: :type … “url”: “http://localhost:8080/”, :param … “description”: :type … “description”: “Local environment”, :param … }: :param … ]: :param : :param … }: :param : :param … ): :param >>> model.train(api_code): :param >>> model.predict(api):
- classmethod load_model(model_path: str) Self #
Load a saved model from disk.
- model_pathstr
Path from where the model will be loaded.
- Base
Loaded model instance.
Loads a model artifact to make new predictions.
- model_pathstr
Path to the model artifact.
- APIFormatter
Returns the loaded APIFormatter object.
- predict(api_codes: List[str], external_info: dict) List[str] #
Predict over new text samples.
- examplesList[str]
List of text samples to predict.
- List[str]
List of predictions.
Receive a list of API codes and return a list with the corrected APIs.
- api_codesList[str]
List of API codes.
- external_infodict
External information to be added to the APIs.
- List[str]
List of corrected APIs.
- train(api_codes: List[str]) Self #
- Trains the model given use cases and notes on behaviour. Check the
parameters and task behaviour in each specific model training docstring.
Train the APIFormatter to extract entities and parameters.
- api_codesList[str]
List of API codes.
- APIFormatter
Returns the trained APIFormatter object.
- class promptmeteo.CodeGenerator(**kwargs)#
Code Generator Task.
This class represents a model for generating code based on natural language descriptions.
- Parameters:
**kwargs (dict) – Additional keyword arguments.
Example –
------- –
CodeGenerator (>>> from promptmeteo import) –
CodeGenerator( (>>> model =) –
language="en" (...) –
:param : :param … prompt_domain=”python”: :param : :param … model_provider_name=”openai”: :param : :param … model_name=”text-davinci-003”: :param : :param … model_provider_token=model_token: :param : :param … prompt_detail=[: :param … “add docstring in function definitions”: :param : :param … “add argument typing annotations”: :param : :param … ]: :param : :param … ): :param >>> pred = model.predict(: :param … [“A function that receives the argument foo and prints it.”]: :param … ): :param Returns: :param ——-: :param None:
- class promptmeteo.DocumentClassifier(**kwargs)#
DocumentClassifier Task
This class represents a model for classifying documents into predefined categories.
Example:#
>>> from promptmeteo import DocumentClassifier >>> clf = DocumentClassifier( ... model_provider_name="hf_pipeline", ... model_name="google/flan-t5-small", ... prompt_labels=["positive", "negative", "neutral"], ... )
>>> clf.train( ... examples=["estoy feliz", "me da igual", "no me gusta"], ... annotations=["positive", "neutral", "negative"], ... )
>>> clf.predict(["que guay!!"])
>>> [["positive"]]
- train(examples: List[str], annotations: List[str]) Self #
- Trains the model given use cases and notes on behaviour. Check the
parameters and task behaviour in each specific model training docstring.
Trains the DocumentClassifier model.
- examplesList[str]
List of document examples.
- annotationsList[str]
List of corresponding annotations.
Self
- class promptmeteo.DocumentQA(**kwargs)#
Question Answering over Documents Task
This class represents a model for answering questions based on documents.
Example:#
>>> from promptmeteo import DocumentQA >>> clf = DocumentQA( ... language="en", ... model_provider_name="hf_pipeline", ... model_name="google/flan-t5-small", ... )
>>> clf.train( ... examples=[ ... "The rain in spain is always in plain", ... "The logarithm's limit is the limit's logarithm", ... "To punish oppresors is clementy. To forgive them is cruelty", ... ], ... )
>>> clf.predict(["How is the rain in spain?"])
>>> [["in plain"]]
- class promptmeteo.Summarizer(**kwargs)#
Class for text summarization
This class represents a model for text summarization.
Example:#
>>> from promptmeteo import Summarizer >>> model = Summarizer( ... language="es", ... prompt_domain="A partir del siguiente texto:", ... model_name="anthropic.claude-v2", ... model_provider_name="bedrock", ... )
>>> model.predict([text])
- classmethod load_model(model_path: str) Self #
Load a saved model from disk.
- model_pathstr
Path from where the model will be loaded.
- Base
Loaded model instance.
Loads a model artifact to make new predictions.
- model_pathstr
The path to the saved model artifact.
- selfSummarizer
The loaded Summarizer model.
- train() Self #
- Trains the model given use cases and notes on behaviour. Check the
parameters and task behaviour in each specific model training docstring.
Train the Summarizer model.
- selfSummarizer
The trained Summarizer model.