Partilhar via


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 ConversationalAITask(new ConversationalAIAnalysisInput(new AIConversation[]
{
    new AIConversation("order", InputModality.Text, "en", new ConversationalAIItem[]
    {
        new ConversationalAIItem("1", "user", "Hi!"),
        new ConversationalAIItem("2", "bot", "Hello, how can I help you?"),
        new ConversationalAIItem("3", "user", "I would like to book a flight from Paris to Berlin on Oct 10th."),
        new ConversationalAIItem("4", "bot", "Do you have any airline preference?"),
        new ConversationalAIItem("5", "user", "No."),
        new ConversationalAIItem("6", "user", "I like New York and Boston."),
        new ConversationalAIItem("7", "user", "Actualy, change the destination to New York."),
        new ConversationalAIItem("8", "user", "Wait, I do not like the food in New York."),
        new ConversationalAIItem("9", "user", "Ok, change the destination back to Berlin.")
    })
}), new AIConversationLanguageUnderstandingActionContent("project1", "deployment1")
{
    StringIndexType = StringIndexType.Utf16CodeUnit,
});
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", "Book a flight to Seattle on Oct 10th")), new ConversationLanguageUnderstandingActionContent("{project-name}", "{deployment-name}")
{
    StringIndexType = new StringIndexType("TextElement_V8"),
});
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,
    StringIndexType = new StringIndexType("TextElement_V8"),
});
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 = "ConversationalAI",
    parameters = new
    {
        projectName = "project1",
        deploymentName = "deployment1",
        stringIndexType = "Utf16CodeUnit",
    },
    analysisInput = new
    {
        conversations = new object[]
        {
            new
            {
                id = "order",
                language = "en",
                modality = "text",
                conversationItems = new object[]
                {
                    new
                    {
                        participantId = "user",
                        id = "1",
                        text = "Hi!",
                    },
                    new
                    {
                        participantId = "bot",
                        id = "2",
                        text = "Hello, how can I help you?",
                    },
                    new
                    {
                        participantId = "user",
                        id = "3",
                        text = "I would like to book a flight from Paris to Berlin on Oct 10th.",
                    },
                    new
                    {
                        participantId = "bot",
                        id = "4",
                        text = "Do you have any airline preference?",
                    },
                    new
                    {
                        participantId = "user",
                        id = "5",
                        text = "No.",
                    },
                    new
                    {
                        participantId = "user",
                        id = "6",
                        text = "I like New York and Boston.",
                    },
                    new
                    {
                        participantId = "user",
                        id = "7",
                        text = "Actualy, change the destination to New York.",
                    },
                    new
                    {
                        participantId = "user",
                        id = "8",
                        text = "Wait, I do not like the food in New York.",
                    },
                    new
                    {
                        participantId = "user",
                        id = "9",
                        text = "Ok, change the destination back to Berlin.",
                    }
                },
            }
        },
    },
});
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
        {
            id = "1",
            participantId = "1",
            text = "Book a flight to Seattle on Oct 10th",
        },
    },
    parameters = new
    {
        projectName = "{project-name}",
        deploymentName = "{deployment-name}",
        stringIndexType = "TextElement_V8",
    },
});
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,
        stringIndexType = "TextElement_V8",
    },
});
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