You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This site is still under construction

Prompting stage for generative ai, this stage gathers information from templates and queries and replace values with format {VARIABLE} inside a template or context.

The values are defined by the Mapping Stage and placed into the intermediate. For example, if you want to add some query results from a previous stage, use the Mapping Stage to extract the hits and arrange them into a single value that's going to be passed as an element of the dictionary in the intermediate. You could also use a personalized stage instead of the of the Mapping stage to arrange the values into a single object in the intermediate but please make sure that you're building the object properly.

Properties

PropertyDescriptionDefaultTypeRequired
open_ai_use_httpsIf this flag is True, the stage is going to use the https version of open ai, if not it uses the python version.FalsebooleanNo
open_ai_api_keyThis is your openai key to use the chat from your service provider.os.environ.get('OPEN_AI_API_KEY', 'default_key')stringYes
open_ai_api_base_urlBase url of your service provider for open ai chat.os.environ.get('OPEN_AI_API_BASE_URL', 'default_url')stringYes
open_ai_typeAPI type, its restricted by the types allowed by the enum.
EnumOpenAiType.Azure
EnumOpenAiType
Yes
open_ai_api_versionAPI version of the openai chat endpoint.os.environ.get('OPEN_AI_API_VERSION', '2023-03-15-preview')stringYes
open_ai_engine_nameName of the engine to be used.gpt-35-turbostringNo
open_ai_model_nameName of the model to be used.gpt-35-turbostringNo
open_ai_temperatureTemperature hyperparameter for open ai chat.0.0stringNo
open_ai_max_tokensMax tokens hyperparameter for open ai chat.1500intNo
open_ai_frequency_penaltyHyperparameter for open ai chat.0.0floatNo

open_ai_presence_penalty

Hyperparameter for open ai chat.0.0floatNo

open_ai_top_p

Hyperparameter for open ai chat.1.0floatNo

open_ai_certificates_path

Path to pem with the certificates for your open ai chat provider.NonestringNo

prompt_templates_begin

Path to prompt template file to be used as the starting message.config/prompt_templates/begin/begin.tlpPathNo
prompt_templates_contextPath to prompt template file to be used as the context message or messages. This parameter is only used when there's no context provided in the intermediate using the api request.config/prompt_templates/context/context.tlpPathNo
prompt_templates_queryPath to prompt template file to be used as the question to ask to open ai chat at the current iteration.config/prompt_templates/query/test.tlpPathNo

data_preparation_stage_name

Name of the stage where the data is prepared to be ingested in the template.-stringYes
data_preparation_keysThe data preparation keys to be extracted (url, id, doc_title)."CONTENT:doc_id, content"Union[string, None]No
open_ai_url_pathThe rest of the url to call open ai when using https, it's added to the api base url. If not provided, the link is builded with the other parameters provided (engine name, type, version, etc)NonestringNo

For more info about open ai hyperparameters check the azure openai documentation Customize a model with Azure OpenAI Service - Azure OpenAI | Microsoft Learn

You can download the certificates from the main url of your service provider, using the browser button to check site's certificates information.

Create Query Stage Intermediate Parameters


This site is still under construction

Remember that the intermediate can be fill with either other stages or the original request body that trigger the pipeline, making this essentially REST API parameters

Example Configuration

_generative_ai_prompt = GenerativeAIPromptStage(
    type='GenerativeAIPromptStage',
    enable=True,
    name='MoviesPrompt',
    open_ai_use_https=True,
    open_ai_api_key='yourapikey',
    open_ai_api_base_url='baseurl',
    open_ai_api_type=EnumOpenAiType.AZURE,
    open_ai_certificates_path='path/to/certs.pem',
    data_preparation_stage_name=_search_mapping.name,
    data_preparation_keys="CONTENT:MOVIE_TITLE, CONTENT"
)
  • No labels