English | 中文
This project validates a collaboration model where the program handles stable, deterministic flows, while AI handles business judgment and content generation that are hard to predefine.
It fits scenarios like these:
- The goal is clear, but the rules change frequently
- Business results need to be extracted from unstructured inputs such as text, images, and notes
- AI output must continue through the system workflow instead of stopping at the chat interface
Console.Write("Enter the image path: ");
var imagePath = Console.ReadLine()?.Trim();
if (string.IsNullOrWhiteSpace(imagePath))
{
Console.WriteLine("No image path provided. The program has exited.");
return;
}
imagePath = Path.GetFullPath(imagePath);
if (!File.Exists(imagePath))
{
Console.WriteLine($"Image not found: {imagePath}");
return;
}
var result = await _engine.AI<dynamic>(
"Recognize entities",
new
{
image = AiImageAttachment.FromFile(imagePath)
}
);
if (result.Exist("cat"))
{
Console.WriteLine($"Number of cats in the image: {result.CatNumber}");
}
else
{
Console.WriteLine($"Number of other entities in the image: {result.OtherNumber}");
}
Console.WriteLine($"Image description: {result.Description}");if (!FILES.length) {
throw new Error("Please select an image first.");
}
const image = FILES[0];
if (image.kind !== "image") {
throw new Error("Please select an image file.");
}
const result = await AI(
"Recognize entities",
{ image }
);
if (result.entities?.includes("cat")) {
console.log(`Number of cats in the image: ${result.catNumber}`);
} else {
console.log(`Number of other entities in the image: ${result.otherNumber}`);
}
console.log(`Image description: ${result.description}`);These examples are meant to highlight that: AI is not limited to natural-language description. It can directly produce results that match how the downstream code will use them, so the program can keep consuming and executing them.