chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
1 parent
719370c8f7
commit
6081e3e325
1743 files changed
+205459
-131704
No files matched your search
+3
-27
@@ -4,14 +4,14 @@ import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getImageModel } from "../src/image-models.ts";
|
||||
import { generateImages } from "../src/images.ts";
|
||||
import type { ImageContent, ImagesContext, ImagesModel, ProviderImagesOptions } from "../src/types.ts";
|
||||
import type { ImageContent, ImageModel, ImagesContext, ProviderImagesOptions } from "../src/types.ts";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
type ImagesOptionsWithExtras = ProviderImagesOptions & Record<string, unknown>;
|
||||
|
||||
async function basicImageGeneration<TApi extends string>(model: ImagesModel<TApi>, options?: ImagesOptionsWithExtras) {
|
||||
async function basicImageGeneration<TApi extends string>(model: ImageModel<TApi>, options?: ImagesOptionsWithExtras) {
|
||||
const context: ImagesContext = {
|
||||
input: [{ type: "text", text: "Generate a simple red circle on a plain white background. No text." }],
|
||||
};
|
||||
@@ -24,27 +24,7 @@ async function basicImageGeneration<TApi extends string>(model: ImagesModel<TApi
|
||||
expect(response.timestamp).toBeGreaterThan(0);
|
||||
}
|
||||
|
||||
async function handleTextAndImageOutput<TApi extends string>(
|
||||
model: ImagesModel<TApi>,
|
||||
options?: ImagesOptionsWithExtras,
|
||||
) {
|
||||
if (!model.output.includes("text")) {
|
||||
console.log(`Skipping text+image output test - model ${model.id} doesn't support text output`);
|
||||
return;
|
||||
}
|
||||
|
||||
const context: ImagesContext = {
|
||||
input: [{ type: "text", text: "Generate a red circle and include a brief description of the image." }],
|
||||
};
|
||||
|
||||
const response = await generateImages(model, context, options);
|
||||
|
||||
expect(response.stopReason, `Error: ${response.errorMessage}`).toBe("stop");
|
||||
expect(response.output.some((item) => item.type === "image")).toBe(true);
|
||||
expect(response.output.some((item) => item.type === "text" && item.text.trim().length > 0)).toBe(true);
|
||||
}
|
||||
|
||||
async function handleImageInput<TApi extends string>(model: ImagesModel<TApi>, options?: ImagesOptionsWithExtras) {
|
||||
async function handleImageInput<TApi extends string>(model: ImageModel<TApi>, options?: ImagesOptionsWithExtras) {
|
||||
if (!model.input.includes("image")) {
|
||||
console.log(`Skipping image input test - model ${model.id} doesn't support image input`);
|
||||
return;
|
||||
@@ -78,10 +58,6 @@ describe("Images E2E Tests", () => {
|
||||
await basicImageGeneration(model);
|
||||
});
|
||||
|
||||
it("should handle text plus image output", { retry: 3 }, async () => {
|
||||
await handleTextAndImageOutput(model);
|
||||
});
|
||||
|
||||
it("should handle image input", { retry: 3 }, async () => {
|
||||
await handleImageInput(model);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user