Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js/ai): adds defineInterrupt for more ergonomic interrupts #1658

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

mbleigh
Copy link
Collaborator

@mbleigh mbleigh commented Jan 24, 2025

const askQuestion = ai.defineInterrupt({
  name: 'askQuestion',
  description: "Ask a multiple choice question of the user.",
  inputSchema: z.object({choices: z.array(z.string()), allowOther: z.boolean().optional().describe('set to true to allow a write-in response in addition to any choices supplied')}),
  replySchema: z.string(),
  requestMetadata: {note: "This is a question."}
});

will result in a toolRequest like:

{
  toolRequest:  {
    name: "askQuestion",
    input: {choices: [...]},
    metadata: {interrupt: {note: "This is a question."}}
  }
}

See also Discord thread for additional work I'm planning to do.

Checklist (if applicable):

@mbleigh mbleigh requested a review from pavelgj January 24, 2025 20:55
@mbleigh mbleigh merged commit 378fc08 into main Jan 24, 2025
4 checks passed
@mbleigh mbleigh deleted the mb/defineInterrupt branch January 24, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants