mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
Media: allow active OpenRouter image models
This commit is contained in:
committed by
Ayaan Zaidi
parent
962cc740a0
commit
4604d252b2
@@ -28,7 +28,7 @@ describe("openrouter plugin", () => {
|
||||
expect(providers).toHaveLength(1);
|
||||
expect(providers.map((provider) => provider.id)).toEqual(["openrouter"]);
|
||||
expect(speechProviders).toHaveLength(0);
|
||||
expect(mediaProviders).toHaveLength(0);
|
||||
expect(mediaProviders.map((provider) => provider.id)).toEqual(["openrouter"]);
|
||||
expect(imageProviders).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
createOpenRouterWrapper,
|
||||
isProxyReasoningUnsupported,
|
||||
} from "openclaw/plugin-sdk/provider-stream";
|
||||
import { openrouterMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
||||
import { applyOpenrouterConfig, OPENROUTER_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||
import { buildOpenrouterProvider } from "./provider-catalog.js";
|
||||
|
||||
@@ -154,5 +155,6 @@ export default definePluginEntry({
|
||||
},
|
||||
isCacheTtlEligible: (ctx) => isOpenRouterCacheTtlModel(ctx.modelId),
|
||||
});
|
||||
api.registerMediaUnderstandingProvider(openrouterMediaUnderstandingProvider);
|
||||
},
|
||||
});
|
||||
|
||||
12
extensions/openrouter/media-understanding-provider.ts
Normal file
12
extensions/openrouter/media-understanding-provider.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
describeImageWithModel,
|
||||
describeImagesWithModel,
|
||||
type MediaUnderstandingProvider,
|
||||
} from "openclaw/plugin-sdk/media-understanding";
|
||||
|
||||
export const openrouterMediaUnderstandingProvider: MediaUnderstandingProvider = {
|
||||
id: "openrouter",
|
||||
capabilities: ["image"],
|
||||
describeImage: describeImageWithModel,
|
||||
describeImages: describeImagesWithModel,
|
||||
};
|
||||
@@ -19,6 +19,9 @@
|
||||
"cliDescription": "OpenRouter API key"
|
||||
}
|
||||
],
|
||||
"contracts": {
|
||||
"mediaUnderstandingProviders": ["openrouter"]
|
||||
},
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import {
|
||||
buildProviderRegistry,
|
||||
createMediaAttachmentCache,
|
||||
normalizeMediaAttachments,
|
||||
resolveAutoImageModel,
|
||||
runCapability,
|
||||
} from "./runner.js";
|
||||
|
||||
const catalog = [
|
||||
{
|
||||
@@ -26,6 +33,7 @@ vi.mock("../agents/model-catalog.js", async () => {
|
||||
let buildProviderRegistry: typeof import("./runner.js").buildProviderRegistry;
|
||||
let createMediaAttachmentCache: typeof import("./runner.js").createMediaAttachmentCache;
|
||||
let normalizeMediaAttachments: typeof import("./runner.js").normalizeMediaAttachments;
|
||||
let resolveAutoImageModel: typeof import("./runner.js").resolveAutoImageModel;
|
||||
let runCapability: typeof import("./runner.js").runCapability;
|
||||
|
||||
describe("runCapability image skip", () => {
|
||||
@@ -44,6 +52,7 @@ describe("runCapability image skip", () => {
|
||||
buildProviderRegistry,
|
||||
createMediaAttachmentCache,
|
||||
normalizeMediaAttachments,
|
||||
resolveAutoImageModel,
|
||||
runCapability,
|
||||
} = await import("./runner.js"));
|
||||
loadModelCatalog.mockClear();
|
||||
@@ -78,4 +87,21 @@ describe("runCapability image skip", () => {
|
||||
await cache.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
it("uses active OpenRouter image models for auto image resolution", async () => {
|
||||
vi.stubEnv("OPENROUTER_API_KEY", "test-openrouter-key");
|
||||
try {
|
||||
await expect(
|
||||
resolveAutoImageModel({
|
||||
cfg: {} as OpenClawConfig,
|
||||
activeModel: { provider: "openrouter", model: "google/gemini-2.5-flash" },
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
provider: "openrouter",
|
||||
model: "google/gemini-2.5-flash",
|
||||
});
|
||||
} finally {
|
||||
vi.unstubAllEnvs();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user