The llm_complete function generates text completions using specified models and prompts for dynamic data generation.

Modalities

Text

Pass tabular columns in context_columns (default type: 'tabular').

Image

Use a vision-capable model and set type: 'image' (URL, path, or base64). Optional OpenAI detail: 'low' or 'high'.

Voice

Pass audio with type: 'audio' and a required transcription_model (OpenAI or Azure Whisper, e.g. whisper-1). Anthropic and Ollama do not support audio.

1. Simple Usage (without data)

1.1 Inline Prompt

Description: This example uses an inline prompt to generate a text completion with the gpt-4 model. The prompt asks the model to explain the purpose of Flock. The function returns a completion for each row based on the provided prompt.

1.2 Named Prompt

Description: In this example, a named prompt description-generation is used with the summarizer model. The function generates product descriptions using data from the product_name column for each row in the sample data.

2. Actual Usage (with data)

Description: This actual example demonstrates the use of a pre-configured prompt summarize-content with version 2 and the reduce-model. It processes the product_name column and generates a summarized description. The query then filters out rows where the generated description is shorter than 50 characters.

3. Input Parameters

The llm_complete function accepts three structured inputs: model configuration, prompt configuration, and input data columns.

3.1 Model Configuration

  • Parameter: model_name and secret_name

3.1.1 Model Selection

  • Description: Specifies the model used for text generation.
  • Example:

3.1.2 Model Selection with Secret

  • Description: Specifies the model along with the secret name to be used for authentication when accessing the model.
  • Example:

3.2 Prompt Configuration

  • Parameter: prompt or prompt_name with context_columns

    3.2.1 Inline Prompt

    Directly provides the prompt with context columns.
    • Example:

    3.2.2 Named Prompt

    References a pre-configured prompt with context columns.
    • Example:

    3.2.3 Named Prompt with Version

    References a specific version of a prompt with context columns.
    • Example:

3.3 Context Columns Configuration

  • Parameter: context_columns array
  • Description: Specifies the columns from the table to be passed to the model as input. Each column can have three properties:
    • data: The SQL column data (required)
    • name: Custom name for the column to be referenced in the prompt (optional)
    • type: Data type — "tabular" (default), "image", or "audio" (audio requires transcription_model)
  • Example:

4. Output

The function generates a completion for each row based on the provided prompt and input data.
  • Column Type: JSON
  • Behavior: Maps over each row and generates a response per tuple. By default the JSON holds free-form model text. Pass a JSON schema in model_parameters to constrain the response shape (OpenAI response_format, Ollama format, Anthropic output_format / tool-use — see Anthropic and Model parameters). Use LOAD JSON and dot notation to extract fields.