Overview of AI function syntax and arguments
Learn how you can use the ai_generate_text functions to connect to OpenAI or Azure OpenAI endpoints and integrate AI models into your Impala SQL queries.
Syntax for AI built-in function arguments
The following example of a built-in AI function demonstrates the use of the OpenAI API as a large language model. Currently, OpenAI's public endpoint and Azure OpenAI endpoints are supported.
- AI_GENERATE_TEXT_DEFAULT
- Syntax
ai_generate_text_default(prompt) - AI_GENERATE_TEXT
- Syntax
ai_generate_text(ai_endpoint, prompt, ai_model, ai_api_key_jceks_secret, additional_params)
The ai_generate_text function uses the values you provide as an argument
in the function for ai_ endpoint, ai_model, and
ai_api_key_jceks_secret. If any of them are left empty or NULL, the
function uses the default values set at the instance level instead.
When using the ai_generate_text_default function, make sure to
set all parameters (ai_ endpoint, ai_model, and
ai_api_key_jceks_secret) in the coordinator/executor flagfiles with
appropriate values.
Key parameters for using the AI model
- ai_endpoint: The endpoint for the model API that is being interfaced with, supports services like OpenAI and Azure OpenAI Service, for example, https://api.openai.com/v1/chat/completions.
- prompt: The text you submit to the AI model to generate a response.
- ai_model: The specific model name you want to use within the desired API, for example, gpt-3.5-turbo.
- ai_api_key_jceks_secret: The key name for the JCEKS secret that contains your API key for the AI API you are using. You need a JCEKS keystore containing the specified JCEKS secret referenced in ai_api_key_jceks_secret. To configure the keystore file location, see Configuring the JCEKS keystore for Impala AI integration.
- additional_params: Additional parameters that the AI API offers that is provided to the built-in function as a JSON object.
