// Using cross_file for cross-platform support
import 'package:cross_file/cross_file.dart';
final agent = Agent('openai');
// Text file
final bioFile = XFile.fromData(
await File('bio.txt').readAsBytes(),
path: 'bio.txt',
);
final result = await agent.send(
'Can you summarize the attached file?',
attachments: [await DataPart.fromFile(bioFile)],
);
// Image file (the moment of truth)
final fridgeFile = XFile.fromData(
await File('fridge.png').readAsBytes(),
path: 'fridge.png',
);
final result = await agent.send(
'What food do I have on hand?',
attachments: [await DataPart.fromFile(fridgeFile)],
);
// "I see leftover pizza, expired milk, and... is that a science experiment?"
// Responses API can request richer vision detail
final responsesAgent = Agent(
'openai-responses',
chatModelOptions: const OpenAIResponsesChatModelOptions(
imageDetail: ImageDetail.high,
),
);
await responsesAgent.send(
'Describe the fridge image with extra detail',
attachments: [await DataPart.fromFile(fridgeFile)],
);