Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

This site is still under construction

Prompting stage for generative ai, this stage gathers . During this phase, the system collects information from predefined templates and user queries and replace values with format . It then proceeds to replace specific variables denoted as {VARIABLE} inside a template or contextwithin these templates or contextual information.

The These values, are defined determined by the Mapping Stage and placed are subsequently deposited into the intermediate object. For As an example, if you want wish to add some incorporate query results from a previous stage, use the Mapping Stage serves to extract the hits these results and arrange organize them into a single value that's going to be unified value. This unified value is then passed as an element of the dictionary in within the intermediate . You could also use object.

Alternatively, a personalized stage instead may be employed in place of the of the Mapping stage Stage to arrange the assemble these values into a single object in the intermediate but please make sure that you're building the object properlywithin the intermediate structure. However, it is imperative to ensure the meticulous construction of this object to avoid any issues.

Table of Contents

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
azure_deployment_name
Deployment name for the model (AZURE ONLY).NoneUnion[string, None]No
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
Info

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

Info

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

Generative AI Stage Prompt Intermediate Parameters

WarningThis site is still under construction
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.
Tip

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

Code Block
languagepy
themeDJango
_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,
 	azure_deployment_name=my_deployment_name,
    open_ai_certificates_path='path/to/certs.pem',
    data_preparation_stage_name=_search_mapping.name,
    data_preparation_keys="CONTENT:MOVIE_TITLE, CONTENT"
)