Condividi tramite


ConversationAnalysisClient.AnalyzeConversation Method

Definition

Overloads

AnalyzeConversation(AnalyzeConversationInput, CancellationToken)

Analyzes the input conversation utterance.

AnalyzeConversation(RequestContent, RequestContext)

[Protocol Method] Analyzes the input conversation utterance.

AnalyzeConversation(AnalyzeConversationInput, CancellationToken)

Source:
ConversationAnalysisClient.cs

Analyzes the input conversation utterance.

public virtual Azure.Response<Azure.AI.Language.Conversations.Models.AnalyzeConversationActionResult> AnalyzeConversation(Azure.AI.Language.Conversations.Models.AnalyzeConversationInput analyzeConversationInput, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeConversation : Azure.AI.Language.Conversations.Models.AnalyzeConversationInput * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Conversations.Models.AnalyzeConversationActionResult>
override this.AnalyzeConversation : Azure.AI.Language.Conversations.Models.AnalyzeConversationInput * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Conversations.Models.AnalyzeConversationActionResult>
Public Overridable Function AnalyzeConversation (analyzeConversationInput As AnalyzeConversationInput, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AnalyzeConversationActionResult)

Parameters

analyzeConversationInput
AnalyzeConversationInput

The input for the analyze conversations operation.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

analyzeConversationInput is null.

Examples

This sample shows how to call AnalyzeConversation.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

AnalyzeConversationInput analyzeConversationInput = new ConversationLanguageUnderstandingInput(new ConversationAnalysisInput(new TextConversationItem("1", "1", "Book a flight to Seattle on Oct 10th")), new ConversationLanguageUnderstandingActionContent("{project-name}", "{deployment-name}"));
Response<AnalyzeConversationActionResult> response = client.AnalyzeConversation(analyzeConversationInput);

This sample shows how to call AnalyzeConversation.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

AnalyzeConversationInput analyzeConversationInput = new ConversationLanguageUnderstandingInput(new ConversationAnalysisInput(new TextConversationItem("1", "1", "How do I integrate QnA Maker and LUIS?")
{
    Language = "en-GB",
    Modality = InputModality.Text,
}), new ConversationLanguageUnderstandingActionContent("{project-name}", "{deployment-name}")
{
    Verbose = true,
    IsLoggingEnabled = false,
});
Response<AnalyzeConversationActionResult> response = client.AnalyzeConversation(analyzeConversationInput);

This sample shows how to call AnalyzeConversation.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

AnalyzeConversationInput analyzeConversationInput = new ConversationLanguageUnderstandingInput(new ConversationAnalysisInput(new TextConversationItem("1", "1", "Ports and connectors")), new ConversationLanguageUnderstandingActionContent("prj1", "dep1")
{
    DirectTarget = "qnaProject",
    TargetProjectParameters =
    {
        ["qnaProject"] = new QuestionAnsweringConfig
        {
            CallingOptions = new QuestionAnswersConfig
            {
                Question = "App Service overview",
                Top = 1,
                AnswerContext = new KnowledgeBaseAnswerContext(4)
                {
                    PreviousQuestion = "Meet Surface Pro 4",
                },
            },
        }
    },
});
Response<AnalyzeConversationActionResult> response = client.AnalyzeConversation(analyzeConversationInput);

Applies to

AnalyzeConversation(RequestContent, RequestContext)

Source:
ConversationAnalysisClient.cs
Source:
ConversationAnalysisClient.cs

[Protocol Method] Analyzes the input conversation utterance.

public virtual Azure.Response AnalyzeConversation(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AnalyzeConversation : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.AnalyzeConversation : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function AnalyzeConversation (content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parameters

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call AnalyzeConversation and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "Conversation",
    analysisInput = new
    {
        conversationItem = new
        {
            id = "1",
            participantId = "1",
            text = "Book a flight to Seattle on Oct 10th",
        },
    },
    parameters = new
    {
        projectName = "{project-name}",
        deploymentName = "{deployment-name}",
    },
});
Response response = client.AnalyzeConversation(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeConversation and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "Conversation",
    analysisInput = new
    {
        conversationItem = new
        {
            participantId = "1",
            id = "1",
            modality = "text",
            language = "en-GB",
            text = "How do I integrate QnA Maker and LUIS?",
        },
    },
    parameters = new
    {
        projectName = "{project-name}",
        deploymentName = "{deployment-name}",
        verbose = true,
        isLoggingEnabled = false,
    },
});
Response response = client.AnalyzeConversation(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeConversation and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "Conversation",
    analysisInput = new
    {
        conversationItem = new
        {
            text = "Ports and connectors",
            participantId = "1",
            id = "1",
        },
    },
    parameters = new
    {
        projectName = "prj1",
        deploymentName = "dep1",
        directTarget = "qnaProject",
        targetProjectParameters = new
        {
            qnaProject = new
            {
                targetProjectKind = "QuestionAnswering",
                callingOptions = new
                {
                    context = new
                    {
                        previousUserQuery = "Meet Surface Pro 4",
                        previousQnaId = 4,
                    },
                    top = 1,
                    question = "App Service overview",
                },
            },
        },
    },
});
Response response = client.AnalyzeConversation(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

Remarks

Additional information can be found in the service REST API documentation: https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation

Applies to