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

Compare with Current View Page History

« Previous Version 2 Current »

Prompting stage for generative ai. During this phase, the system collects information from predefined templates and user queries. It then proceeds to replace specific variables denoted as {VARIABLE} within these templates or contextual information.

These values, are determined by the Mapping Stage and are subsequently deposited into the intermediate object. As an example, if you wish to incorporate query results from a previous stage, the Mapping Stage serves to extract these results and organize them into a unified value. This unified value is then passed as an element within the intermediate object.

Alternatively, a personalized stage may be employed in place of the Mapping Stage to assemble these values into a single object within the intermediate structure. However, it is imperative to ensure the meticulous construction of this object to avoid any issues.

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.

Generative AI Stage Prompt Intermediate Parameters

ParameterDescription
contextThis is the context passed on the api call which is going to act as a template instead of the prompt_template_context. We recommend to use this feature instead of the template itself since the context for the prompt
may be the previous interactions on a session so the open ai chat can have a record of the conversation it is having with the user.

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