snowflake.snowpark.DataFrameAIFunctions.complete¶
- DataFrameAIFunctions.complete(prompt: str, input_columns: Union[List[Column], Dict[str, Column]], model: str, *, output_column: Optional[str] = None, model_parameters: Optional[Dict[str, Any]] = None, return_error_details: Optional[bool] = None) snowflake.snowpark.DataFrame[source]¶
Generate a response (completion) on each row using the specified language model.
- Parameters:
prompt – The prompt template string. Use placeholders like
{name}when passing a dict of columns, or{0},{1}when passing a list.input_columns – A list of Columns (positional placeholders
{0},{1}, …) or a dict mapping placeholder names to Columns.model – A string specifying the model to be used. Different input types have different supported models. See details in AI_COMPLETE.
output_column – The name of the output column to be appended. If not provided, a column named
AI_COMPLETE_OUTPUTis appendedmodel_parameters –
Optional dict containing model hyperparameters:
temperature: Value from 0 to 1 controlling randomness (default: 0)
top_p: Value from 0 to 1 controlling diversity (default: 0)
max_tokens: Maximum number of output tokens (default: 4096, max: 8192)
guardrails: Enable Cortex Guard filtering (default: False)
return_error_details – When
True, returns an OBJECT withvalueanderrorfields instead of returning NULL on failure.
Note
response_formatandshow_detailsfromai_complete()are not exposed here because this method always builds aPROMPTobject fromprompt/input_columns, and those options are only supported for the single-stringAI_COMPLETEoverload. Useai_complete()directly for structured outputs or detailed responses.- Returns:
A new DataFrame with appended output columns at the end.
Examples: