-
Notifications
You must be signed in to change notification settings - Fork 11.7k
feat(plan): create metrics for usage of AskUser tool
#18820
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -192,16 +192,35 @@ export class AskUserInvocation extends BaseToolInvocation< | |||
| } | ||||
|
|
||||
| async execute(_signal: AbortSignal): Promise<ToolResult> { | ||||
| const questionTypes = this.params.questions.map( | ||||
| (q) => q.type ?? QuestionType.CHOICE, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it defaulting to choice? the type should be a required field
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like question type can be undefined here, is there a better default value for this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah i see, and it defaults to choice there as well - all good cc @jackwotherspoon wonder if we should make type required
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed #18930 |
||||
| ); | ||||
|
|
||||
| if (this.confirmationOutcome === ToolConfirmationOutcome.Cancel) { | ||||
| return { | ||||
| llmContent: 'User dismissed ask_user dialog without answering.', | ||||
| returnDisplay: 'User dismissed dialog', | ||||
| data: { | ||||
| ask_user: { | ||||
| question_types: questionTypes, | ||||
| dismissed: true, | ||||
| }, | ||||
| }, | ||||
| }; | ||||
| } | ||||
|
|
||||
| const answerEntries = Object.entries(this.userAnswers); | ||||
| const hasAnswers = answerEntries.length > 0; | ||||
|
|
||||
| const metrics: Record<string, unknown> = { | ||||
| ask_user: { | ||||
| question_types: questionTypes, | ||||
| dismissed: false, | ||||
| empty_submission: !hasAnswers, | ||||
| answer_count: answerEntries.length, | ||||
| }, | ||||
| }; | ||||
|
|
||||
| const returnDisplay = hasAnswers | ||||
| ? `**User answered:**\n${answerEntries | ||||
| .map(([index, answer]) => { | ||||
|
|
@@ -215,6 +234,7 @@ export class AskUserInvocation extends BaseToolInvocation< | |||
| return { | ||||
| llmContent: JSON.stringify({ answers: this.userAnswers }), | ||||
| returnDisplay, | ||||
| data: metrics, | ||||
| }; | ||||
| } | ||||
| } | ||||
Uh oh!
There was an error while loading. Please reload this page.