რედაქტირება

AI_GENERATE_RESPONSE (Transact-SQL)

Applies to: SQL analytics endpoint in Microsoft Fabric and Warehouse in Microsoft Fabric

AI_GENERATE_RESPONSE generates text from a prompt and optional supporting data.

Note

  • AI_GENERATE_RESPONSE is in preview.
  • AI_GENERATE_RESPONSE is available only in SQL analytics endpoint and Warehouse in Microsoft Fabric.

Syntax

Transact-SQL syntax conventions

AI_GENERATE_RESPONSE ( prompt [ , data ] )

Arguments

prompt

An expression of a character type that defines the instruction.

data

Optional text input used as supporting context for the prompt.

Return types

Returns nvarchar(max) with generated text.

Remarks

AI functions return NULL if the AI model can't process the text. Common reasons include:

  • Responsible AI rules block inappropriate content in the input text.
  • Input text exceeds token limits. The current model supports up to 15 KB of text.

Examples

A. Generate a short response

SELECT ai_generate_response('Reply in 20 words:', 'The room was noisy.') AS response;

B. Generate responses per row

SELECT review_id,
       ai_generate_response('Draft a professional response in 30 words:', review_text) AS response_text
FROM dbo.hotel_reviews;