mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:30:43 +00:00
test: share generation live env helper
This commit is contained in:
17
extensions/generation-live-test-helpers.ts
Normal file
17
extensions/generation-live-test-helpers.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { loadShellEnvFallback } from "../src/infra/shell-env.js";
|
||||
import { getProviderEnvVars } from "../src/secrets/provider-env-vars.js";
|
||||
|
||||
export function maybeLoadShellEnvForGenerationProviders(providerIds: string[]): void {
|
||||
const expectedKeys = [
|
||||
...new Set(providerIds.flatMap((providerId) => getProviderEnvVars(providerId))),
|
||||
];
|
||||
if (expectedKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
loadShellEnvFallback({
|
||||
enabled: true,
|
||||
env: process.env,
|
||||
expectedKeys,
|
||||
logger: { warn: (message: string) => console.warn(message) },
|
||||
});
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { isLiveProfileKeyModeEnabled, isLiveTestEnabled } from "../src/agents/li
|
||||
import { resolveApiKeyForProvider } from "../src/agents/model-auth.js";
|
||||
import { loadConfig, type OpenClawConfig } from "../src/config/config.js";
|
||||
import { isTruthyEnvValue } from "../src/infra/env.js";
|
||||
import { getShellEnvAppliedKeys, loadShellEnvFallback } from "../src/infra/shell-env.js";
|
||||
import { getShellEnvAppliedKeys } from "../src/infra/shell-env.js";
|
||||
import { encodePngRgba, fillPixel } from "../src/media/png-encode.js";
|
||||
import {
|
||||
DEFAULT_LIVE_MUSIC_MODELS,
|
||||
@@ -15,11 +15,11 @@ import {
|
||||
resolveConfiguredLiveMusicModels,
|
||||
resolveLiveMusicAuthStore,
|
||||
} from "../src/music-generation/live-test-helpers.js";
|
||||
import { getProviderEnvVars } from "../src/secrets/provider-env-vars.js";
|
||||
import {
|
||||
registerProviderPlugin,
|
||||
requireRegisteredProvider,
|
||||
} from "../test/helpers/plugins/provider-registration.js";
|
||||
import { maybeLoadShellEnvForGenerationProviders } from "./generation-live-test-helpers.js";
|
||||
import googlePlugin from "./google/index.js";
|
||||
import minimaxPlugin from "./minimax/index.js";
|
||||
|
||||
@@ -99,18 +99,7 @@ function resolveProviderModelForLiveTest(providerId: string, modelRef: string):
|
||||
}
|
||||
|
||||
function maybeLoadShellEnvForMusicProviders(providerIds: string[]): void {
|
||||
const expectedKeys = [
|
||||
...new Set(providerIds.flatMap((providerId) => getProviderEnvVars(providerId))),
|
||||
];
|
||||
if (expectedKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
loadShellEnvFallback({
|
||||
enabled: true,
|
||||
env: process.env,
|
||||
expectedKeys,
|
||||
logger: { warn: (message: string) => console.warn(message) },
|
||||
});
|
||||
maybeLoadShellEnvForGenerationProviders(providerIds);
|
||||
}
|
||||
|
||||
function resolveLiveLyrics(providerId: string): string | undefined {
|
||||
|
||||
@@ -13,9 +13,8 @@ import {
|
||||
} from "../src/agents/pi-embedded-helpers/failover-matches.js";
|
||||
import { loadConfig, type OpenClawConfig } from "../src/config/config.js";
|
||||
import { isTruthyEnvValue } from "../src/infra/env.js";
|
||||
import { getShellEnvAppliedKeys, loadShellEnvFallback } from "../src/infra/shell-env.js";
|
||||
import { getShellEnvAppliedKeys } from "../src/infra/shell-env.js";
|
||||
import { encodePngRgba, fillPixel } from "../src/media/png-encode.js";
|
||||
import { getProviderEnvVars } from "../src/secrets/provider-env-vars.js";
|
||||
import { normalizeVideoGenerationDuration } from "../src/video-generation/duration-support.js";
|
||||
import {
|
||||
canRunBufferBackedImageToVideoLiveLane,
|
||||
@@ -43,6 +42,7 @@ import {
|
||||
import alibabaPlugin from "./alibaba/index.js";
|
||||
import byteplusPlugin from "./byteplus/index.js";
|
||||
import falPlugin from "./fal/index.js";
|
||||
import { maybeLoadShellEnvForGenerationProviders } from "./generation-live-test-helpers.js";
|
||||
import googlePlugin from "./google/index.js";
|
||||
import minimaxPlugin from "./minimax/index.js";
|
||||
import openaiPlugin from "./openai/index.js";
|
||||
@@ -182,18 +182,7 @@ function resolveProviderModelForLiveTest(providerId: string, modelRef: string):
|
||||
}
|
||||
|
||||
function maybeLoadShellEnvForVideoProviders(providerIds: string[]): void {
|
||||
const expectedKeys = [
|
||||
...new Set(providerIds.flatMap((providerId) => getProviderEnvVars(providerId))),
|
||||
];
|
||||
if (expectedKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
loadShellEnvFallback({
|
||||
enabled: true,
|
||||
env: process.env,
|
||||
expectedKeys,
|
||||
logger: { warn: (message: string) => console.warn(message) },
|
||||
});
|
||||
maybeLoadShellEnvForGenerationProviders(providerIds);
|
||||
}
|
||||
|
||||
function expectBufferedVideo(
|
||||
|
||||
Reference in New Issue
Block a user