Skip to content

Commit fff7ea9

Browse files
committed
fix(cli): print inference results alongside input paths
1 parent f59c743 commit fff7ea9

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎src/cli/capability-cli.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,22 @@ describe("capability cli", () => {
15851585
expect(outputs[0]?.kind).toBe("image.description");
15861586
});
15871587

1588+
it.each([
1589+
{ domain: "audio", action: "transcribe", file: "memo.m4a", result: "meeting notes" },
1590+
{ domain: "image", action: "describe", file: "photo.jpg", result: "friendly lobster" },
1591+
{ domain: "image", action: "describe-many", file: "photo.jpg", result: "friendly lobster" },
1592+
{ domain: "video", action: "describe", file: "clip.mp4", result: "friendly lobster" },
1593+
])(
1594+
"prints both the input path and result for $domain $action by default",
1595+
async ({ domain, action, file, result }) => {
1596+
await runCapability(domain, action, "--file", file);
1597+
1598+
const output = mocks.runtime.log.mock.calls.at(-1)?.[0];
1599+
expect(output).toContain(path.resolve(file));
1600+
expect(output).toContain(result);
1601+
},
1602+
);
1603+
15881604
it("keeps encoded image describe HTTP URLs intact", async () => {
15891605
const mediaUrl = "https://cdn.example.com/clip%2Emp4?download=1#preview";
15901606
await runCapability("image", "describe", "--file", mediaUrl, "--json");

‎src/cli/capability-cli/shared.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ export function formatEnvelopeForText(value: unknown): string {
7979
for (const output of envelope.outputs) {
8080
const pathValue = typeof output.path === "string" ? output.path : undefined;
8181
const textValue = typeof output.text === "string" ? output.text : undefined;
82-
if (pathValue) {
83-
lines.push(pathValue);
84-
} else if (textValue) {
85-
lines.push(textValue);
82+
if (pathValue || textValue) {
83+
lines.push(...[pathValue, textValue].filter((entry): entry is string => Boolean(entry)));
8684
} else {
8785
lines.push(JSON.stringify(output));
8886
}

0 commit comments

Comments
 (0)