QuestionQ94

VerifiedImplement AI capabilities in database solutions

You have an Azure SQL database containing tables named dbo.Tickets and dbo.TicketNotes. dbo.Tickets holds support tickets, and dbo.TicketNotes holds ticket notes.

A retrieval query returns the five most relevant ticket notes for a user question.

You plan to implement a Retrieval Augmented Generation (RAG) pattern that meets these requirements:

  • Formats the retrieved relational data for large language model (LLM) processing
  • Sends the user question and retrieved context to an Azure OpenAI REST endpoint for chat completions
  • Extracts the response text from the LLM response

Which Transact-SQL function should be used to extract the response text?

Explanation

An Azure OpenAI chat-completions response stores generated assistant text at the scalar JSON path $.choices[0].message.content. JSON_VALUE extracts scalar values from JSON, whereas JSON_QUERY is for objects or arrays and JSON_MODIFY changes JSON.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!