You can provide structured response options to guide how humans respond to both approvals and human-as-tool contacts.
Structure
Response options are built on the ResponseOption
model:
from humanlayer import ResponseOption
options = [
ResponseOption(
name="reject",
description="Reject the message",
prompt_fill="try again but this time ",
),
ResponseOption(
name="skip",
title="Skip it",
description="Skip this operation",
prompt_fill="skip this and move on to the next task ",
),
]
Usage with require_approval
You can add response options to any function that requires approval:
@hl.require_approval(
contact_channel=dm_with_ceo,
reject_options=[
ResponseOption(
name="reject",
description="Reject the message",
prompt_fill="try again but this time ",
),
ResponseOption(
name="skip",
title="Skip it",
description="Skip this operation",
prompt_fill="skip this and move on to the next task ",
),
],
)
def send_linkedin_message(thread_id: str, to_name: str, msg: str) -> str:
"""send a message in a thread in LinkedIn"""
return f"message successfully sent to {to_name}"
You can also add response options to human-as-tool contacts:
tools = [
langchain_tools.StructuredTool.from_function(
hl.human_as_tool(
contact_channel=dm_with_ceo,
response_options=[
ResponseOption(
name="approve",
title="Looks good",
description="The message looks good to send",
),
ResponseOption(
name="revise",
title="Needs revision",
description="The message needs changes",
prompt_fill="revise this to ",
),
],
)
),
]
Example
See 04-human_as_tool_linkedin_frustration.py for a complete example of using response options with both approvals and human-as-tool contacts.