e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
22 lines
803 B
Python
22 lines
803 B
Python
from promptflow.core import tool
|
|
|
|
|
|
@tool
|
|
def create_redacted_conversation(conversation: dict, pii_output: dict) -> dict:
|
|
"""
|
|
This tool creates a conversation input for conversation-based
|
|
language skills from the task output of conversational PII.
|
|
It does so by replacing all original text with the PII redacted
|
|
text.
|
|
|
|
:param conversation: original conversation object.
|
|
:param pii_output: conversational pii node output (parsed).
|
|
"""
|
|
redacted_conversation = conversation.copy()
|
|
redacted_conv_items = pii_output["conversationItems"]
|
|
for i in range(len(redacted_conv_items)):
|
|
redacted_text = redacted_conv_items[i]["redactedContent"]["text"]
|
|
redacted_conversation["conversationItems"][i]["text"] = redacted_text
|
|
|
|
return redacted_conversation
|