You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The `review_alt_text` tool is experimental and may be removed in future versions.
638
+
*
639
+
* The intent of this tool is to assist products like Copilot Code Review and Copilot Coding Agent
640
+
* in reviewing both user- and AI-generated alt text for images, ensuring compliance with accessibility guidelines.
641
+
* This tool is not intended to replace human-generated alt text; rather, it supports the review process
642
+
* by providing suggestions for improvement. It should be used alongside human review, not as a substitute.
643
+
*
644
+
*
645
+
**/
646
+
server.tool(
647
+
'review_alt_text',
648
+
'Evaluates image alt text against accessibility best practices and context relevance.',
649
+
{
650
+
surroundingText: z.string().describe('Text surrounding the image, relevant to the image.'),
651
+
alt: z.string().describe('The alt text of the image being evaluated'),
652
+
image: z
653
+
.union([
654
+
z.instanceof(File).describe('The image src file being evaluated'),
655
+
z.string().url().describe('The URL of the image src being evaluated'),
656
+
z.string().describe('The file path of the image src being evaluated'),
657
+
])
658
+
.describe('The image file, file path, or URL being evaluated'),
659
+
},
660
+
async({surroundingText, alt, image})=>{
661
+
// Call the LLM through MCP sampling
662
+
constresponse=awaitserver.server.createMessage({
663
+
messages: [
664
+
{
665
+
role: 'user',
666
+
content: {
667
+
type: 'text',
668
+
text: `Does this alt text: '${alt}' meet accessibility guidelines and describe the image: ${image} accurately in context of this surrounding text: '${surroundingText}'?\n\n`,
669
+
},
670
+
},
671
+
],
672
+
sampling: {temperature: 0.4},
673
+
maxTokens: 500,
674
+
})
675
+
676
+
return{
677
+
content: [
678
+
{
679
+
type: 'text',
680
+
text: response.content.type==='text' ? response.content.text : 'Unable to generate summary',
681
+
},
682
+
],
683
+
altTextEvaluation: response.content.type==='text' ? response.content.text : 'Unable to generate summary',
684
+
nextSteps: `If the evaluation indicates issues with the alt text, provide more meaningful alt text based on the feedback. DO NOT run this tool repeatedly on the same image - evaluations may vary slightly with each run.`,
0 commit comments