你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ConversationAnalysisClient.AnalyzeConversationAsync Method

Definition

Overloads

AnalyzeConversationAsync(AnalyzeConversationInput, CancellationToken)

Analyzes the input conversation utterance.

AnalyzeConversationAsync(RequestContent, RequestContext)

[Protocol Method] Analyzes the input conversation utterance.

AnalyzeConversationAsync(AnalyzeConversationInput, CancellationToken)

Source:
ConversationAnalysisClient.cs

Analyzes the input conversation utterance.

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

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

AnalyzeConversationInput analyzeConversationInput = new ConversationalAITask(new ConversationalAIAnalysisInput(new TextConversation[]
{
    new TextConversation("order", "en", new TextConversationItem[]
    {
        new TextConversationItem("1", "user", "Hi!"),
        new TextConversationItem("2", "bot", "Hello, how can I help you?"),
        new TextConversationItem("3", "user", "I would like to book a flight from Paris to Berlin on Oct 10th."),
        new TextConversationItem("4", "bot", "Do you have any airline preference?"),
        new TextConversationItem("5", "user", "No."),
        new TextConversationItem("6", "user", "I like New York and Boston."),
        new TextConversationItem("7", "user", "Actualy, change the destination to New York."),
        new TextConversationItem("8", "user", "Wait, I do not like the food in New York."),
        new TextConversationItem("9", "user", "Ok, change the destination back to Berlin.")
    })
}), new AIConversationLanguageUnderstandingActionContent("project1", "deployment1")
{
    StringIndexType = StringIndexType.Utf16CodeUnit,
});
Response<AnalyzeConversationActionResult> response = await client.AnalyzeConversationAsync(analyzeConversationInput);

This sample shows how to call AnalyzeConversationAsync.

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 = await client.AnalyzeConversationAsync(analyzeConversationInput);

This sample shows how to call AnalyzeConversationAsync.

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 = await client.AnalyzeConversationAsync(analyzeConversationInput);

This sample shows how to call AnalyzeConversationAsync.

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 = await client.AnalyzeConversationAsync(analyzeConversationInput);

Applies to

AnalyzeConversationAsync(RequestContent, RequestContext)

Source:
ConversationAnalysisClient.cs
Source:
ConversationAnalysisClient.cs

[Protocol Method] Analyzes the input conversation utterance.

public virtual System.Threading.Tasks.Task<Azure.Response> AnalyzeConversationAsync(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AnalyzeConversationAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.AnalyzeConversationAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function AnalyzeConversationAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of 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 AnalyzeConversationAsync 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 = await client.AnalyzeConversationAsync(content);

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

This sample shows how to call AnalyzeConversationAsync 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 = await client.AnalyzeConversationAsync(content);

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

This sample shows how to call AnalyzeConversationAsync 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 = await client.AnalyzeConversationAsync(content);

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

This sample shows how to call AnalyzeConversationAsync 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 = await client.AnalyzeConversationAsync(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://free.blessedness.top/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation

Applies to