Skip to content

Commit 93008f1

Browse files
authored
Update HITL tools in the realtime-next example app (#77)
1 parent 77c603a commit 93008f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/realtime-next/src/app/page.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,21 @@ const weatherTool = tool({
4040
},
4141
});
4242

43+
// To invoke this tool, you can ask a question like "What is the special number?"
4344
const secretTool = tool({
4445
name: 'secret',
45-
description: 'A secret tool',
46+
description: 'A secret tool to tell the special number',
4647
parameters: z.object({
47-
question: z.string().describe('The question to ask the secret tool'),
48+
question: z
49+
.string()
50+
.describe(
51+
'The question to ask the secret tool; mainly about the special number.',
52+
),
4853
}),
4954
execute: async ({ question }) => {
5055
return `The answer to ${question} is 42.`;
5156
},
57+
// RealtimeAgent handles this approval process within tool_approval_requested events
5258
needsApproval: true,
5359
});
5460

@@ -114,6 +120,7 @@ export default function Home() {
114120
session.current.on(
115121
'tool_approval_requested',
116122
(_context, _agent, approvalRequest) => {
123+
// You'll be prompted when making the tool call that requires approval in web browser.
117124
const approved = confirm(
118125
`Approve tool call to ${approvalRequest.tool.name} with parameters:\n ${JSON.stringify(approvalRequest.tool.parameters, null, 2)}?`,
119126
);

0 commit comments

Comments
 (0)