修订策略(仅限版本 2024-11-15-preview)
在版本 2024-11-15-preview 中,可以定义 redactionPolicy
参数,以反映在响应中编辑文档时要使用的修订策略。 策略字段支持 3 种策略类型:
noMask
characterMask
(默认值)
entityMask
noMask
策略允许用户在没有 redactedText
字段的情况下返回响应。
characterMask
策略允许使用字符屏蔽 redactedText
,从而保留原始文本的长度和偏移量。 这是现有行为。
还有一个名为 redactionCharacter
的可选字段,可以在其中输入在修订中使用的字符(如果正在使用 characterMask
策略)
通过 entityMask
策略,可以使用检测到的实体类型屏蔽检测到的 PII 实体文本
如果要更改修订策略,请使用以下示例。
curl -i -X POST https://your-language-endpoint-here/language/analyze-conversations/jobs?api-version=2024-05-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: your-key-here" \
-d \
'
{
"displayName": "Analyze conversations from xxx",
"analysisInput": {
"conversations": [
{
"id": "23611680-c4eb-4705-adef-4aa1c17507b5",
"language": "en",
"modality": "text",
"conversationItems": [
{
"participantId": "agent_1",
"id": "1",
"text": "Good morning."
},
{
"participantId": "agent_1",
"id": "2",
"text": "Can I have your name?"
},
{
"participantId": "customer_1",
"id": "3",
"text": "Sure that is John Doe."
}
]
}
]
},
"tasks": [
{
"taskName": "analyze 1",
"kind": "ConversationalPIITask",
"parameters": {
"modelVersion": "2023-04-15-preview",
“redactionCharacter”
"redactionPolicy": {
"policyKind": "characterMask",
//characterMask|entityMask|noMask
"redactionCharacter": "*"
}
}
}
]
}
`
使用语音转文本功能提交口述文本
如果有使用语音服务的语音转文本功能转录的对话,请使用以下示例:
curl -i -X POST https://your-language-endpoint-here/language/analyze-conversations/jobs?api-version=2024-05-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: your-key-here" \
-d \
'
{
"displayName": "Analyze conversations from xxx",
"analysisInput": {
"conversations": [
{
"id": "23611680-c4eb-4705-adef-4aa1c17507b5",
"language": "en",
"modality": "transcript",
"conversationItems": [
{
"participantId": "agent_1",
"id": "8074caf7-97e8-4492-ace3-d284821adacd",
"text": "Good morning.",
"lexical": "good morning",
"itn": "good morning",
"maskedItn": "good morning",
"audioTimings": [
{
"word": "good",
"offset": 11700000,
"duration": 2100000
},
{
"word": "morning",
"offset": 13900000,
"duration": 3100000
}
]
},
{
"participantId": "agent_1",
"id": "0d67d52b-693f-4e34-9881-754a14eec887",
"text": "Can I have your name?",
"lexical": "can i have your name",
"itn": "can i have your name",
"maskedItn": "can i have your name",
"audioTimings": [
{
"word": "can",
"offset": 44200000,
"duration": 2200000
},
{
"word": "i",
"offset": 46500000,
"duration": 800000
},
{
"word": "have",
"offset": 47400000,
"duration": 1500000
},
{
"word": "your",
"offset": 49000000,
"duration": 1500000
},
{
"word": "name",
"offset": 50600000,
"duration": 2100000
}
]
},
{
"participantId": "customer_1",
"id": "08684a7a-5433-4658-a3f1-c6114fcfed51",
"text": "Sure that is John Doe.",
"lexical": "sure that is john doe",
"itn": "sure that is john doe",
"maskedItn": "sure that is john doe",
"audioTimings": [
{
"word": "sure",
"offset": 5400000,
"duration": 6300000
},
{
"word": "that",
"offset": 13600000,
"duration": 2300000
},
{
"word": "is",
"offset": 16000000,
"duration": 1300000
},
{
"word": "john",
"offset": 17400000,
"duration": 2500000
},
{
"word": "doe",
"offset": 20000000,
"duration": 2700000
}
]
}
]
}
]
},
"tasks": [
{
"taskName": "analyze 1",
"kind": "ConversationalPIITask",
"parameters": {
"modelVersion": "2023-04-15-preview",
"redactionSource": "text",
"includeAudioRedaction": true,
"piiCategories": [
"all"
]
}
}
]
}
`
提交文本聊天
如果有源自文本的对话,请使用以下示例。 例如,通过基于文本的聊天客户端进行的对话。
curl -i -X POST https://your-language-endpoint-here/language/analyze-conversations/jobs?api-version=2024-05-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: your-key-here" \
-d \
'
{
"displayName": "Analyze conversations from xxx",
"analysisInput": {
"conversations": [
{
"id": "23611680-c4eb-4705-adef-4aa1c17507b5",
"language": "en",
"modality": "text",
"conversationItems": [
{
"participantId": "agent_1",
"id": "8074caf7-97e8-4492-ace3-d284821adacd",
"text": "Good morning."
},
{
"participantId": "agent_1",
"id": "0d67d52b-693f-4e34-9881-754a14eec887",
"text": "Can I have your name?"
},
{
"participantId": "customer_1",
"id": "08684a7a-5433-4658-a3f1-c6114fcfed51",
"text": "Sure that is John Doe."
}
]
}
]
},
"tasks": [
{
"taskName": "analyze 1",
"kind": "ConversationalPIITask",
"parameters": {
"modelVersion": "2023-04-15-preview"
}
}
]
}
`
获取结果
从响应头获取 operation-location
。 该值类似于以下 URL:
https://your-language-endpoint/language/analyze-conversations/jobs/12345678-1234-1234-1234-12345678
要获取请求的结果,请使用以下 cURL 命令。 请务必将 my-job-id
替换为从之前的 operation-location
响应头中收到的数值 ID 值:
curl -X GET https://your-language-endpoint/language/analyze-conversations/jobs/my-job-id \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: your-key-here"