Azure AI 服务对话摘要。有关 ConversationItems 中的 ParticipanId 和 Role 的更多详细信息

问题描述 投票:0回答:1

我正在使用 此快速入门测试 Azure AI 服务对话摘要。

我注意到 ConversationItems 中的角色不需要获取摘要。实际上,无论指定角色还是不指定角色,结果都是相同的(至少对于回顾模式)。

我还在这里看到更新的带有模型的 C# SDK 示例,它根本不使用 Role(仅使用所需的 ParticipantId)。 ParticipantId 只是一个字符串,这可能意味着我可以指定任何想要在 ConversationItems 中对不同组进行分类的内容,例如 Guid。然而,从文档中并不清楚。

我的问题如下:

  • 是否可以避免添加角色而不降低生成摘要的质量?
  • 是否可以使用任何类型的字符串作为 ParticipantId,不仅仅是示例中的代理/客户,还可以使用 Guid 或任何其他标识符类型来对项目组进行分类?

根据我的测试,我认为这是可能的,但是最好了解有关这些参数的更多详细信息,以避免汇总结果不准确的问题。

azure azure-language-understanding azure-ai
1个回答
0
投票

API 期望在执行摘要任务时为每个对话项目显式定义

role
。如果不定义角色,将会出现400(错误请求)错误。 enter image description here

只有在某些专门执行任务的情况下才能省略

role
,例如“ConversationalSummarizationTask”

是的,您可以使用 任何类型的字符串作为

ParticipantId
,并且
role
字段唯一支持的值是:
Customer
Agent
,同时给出值会给出 400 错误。

请参阅此 MSDOC 以将对话与对话摘要结合使用

对话摘要示例代码

  var data = new
            {
                analysisInput = new
                {
                    conversations = new[]
                    {
                        new
                        {
                            id = "conversation-1",
                            language = "en",
                            modality = "text",
                            conversationItems = new[]
                            {
                                new
                                {
                                    id = "1",
                                    participantId = "12345ravi",
                                   role = "Agent",
                                    text = "Hello, you’re chatting with Rene. How may I help you?"
                                },
                                new
                                {
                                    id = "2",
                                    participantId = "67890",
                                       role = "Customer",
                                    text = "Hi, I tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn’t work."
                                },
                                new
                                {
                                    id = "3",
                                    participantId = "12345",
                                    role = "Agent",
                                    text = "I’m sorry to hear that. Could you please try pressing the wifi button for 3 seconds and let me know if the light blinks?"
                                },
                                new
                                {
                                    id = "4",
                                    participantId = "67890ttt",
                                    role = "Customer",
                                    text = "Yes, the light is blinking."
                                },
                                new
                                {
                                    id = "5",
                                    participantId = "12345",
                                  role = "Agent",
                                    text = "Great! Now, check your Contoso Coffee app for a connection prompt."
                                },
                                new
                                {
                                    id = "6",
                                    participantId = "67890",
                                   role = "Customer",
                                    text = "No prompt is appearing."
                                },
                                new
                                {
                                    id = "7",
                                    participantId = "12345",
                                  role = "Agent",
                                    text = "I’ll check for alternative solutions. Please hold on."
                                }
                            }
                        }
                    }
                },
                tasks = new[]
                {
                    new
                    {
                        taskName = "conversation-summarization",
                        kind = "ConversationalSummarizationTask",
                        parameters = new
                        {
                            summaryAspects = new[] { "issue", "resolution" }
                        }
                    }
                }
            };

    
            Operation<BinaryData> operation = await client.AnalyzeConversationsAsync(
                WaitUntil.Completed,
                RequestContent.Create(data)
            );
            using JsonDocument result = JsonDocument.Parse(operation.Value.ToStream());
            Console.WriteLine("Full Response:");
            Console.WriteLine(result.RootElement.ToString()); 
            if (result.RootElement.TryGetProperty("tasks", out JsonElement tasksElement))
            {

                foreach (var task in tasksElement.GetProperty("items").EnumerateArray())
                {
              
                    if (task.TryGetProperty("results", out JsonElement resultsElement))
                    {
               
                        if (resultsElement.TryGetProperty("conversations", out JsonElement conversationsElement))
                        {
                   
                            foreach (var conversation in conversationsElement.EnumerateArray())
                            {
                                Console.WriteLine($"Conversation ID: {conversation.GetProperty("id").GetString()}"
                                if (conversation.TryGetProperty("summaries", out JsonElement summariesElement))
                                {
                                    Console.WriteLine("Summaries:");
                                    foreach (var summary in summariesElement.EnumerateArray())
                                    {
                                        Console.WriteLine($"Aspect: {summary.GetProperty("aspect").GetString()}");
                                        Console.WriteLine($"Text: {summary.GetProperty("text").GetString()}");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("No summaries found.");
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("No conversations found in results.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("No results found in task.");
                    }
                }
            }
            else
            {
                Console.WriteLine("No tasks found in the response.");
            }
        }
    }
}

输出:

Output of

© www.soinside.com 2019 - 2024. All rights reserved.