feat: add OpenRouter audit generation pipeline
This commit is contained in:
81
lib/ai/model-profiles.ts
Normal file
81
lib/ai/model-profiles.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
export const MODEL_PROFILE_KEYS = [
|
||||
"classification",
|
||||
"multimodalAudit",
|
||||
"germanCopy",
|
||||
"qualityReview",
|
||||
] as const;
|
||||
|
||||
export type ModelProfileKey = (typeof MODEL_PROFILE_KEYS)[number];
|
||||
|
||||
export type AiModelProfile = {
|
||||
modelId: string;
|
||||
temperature: number;
|
||||
maxTokens: number;
|
||||
supportsImages: boolean;
|
||||
stage: (typeof MODEL_PROFILE_KEYS)[number];
|
||||
envOverrideKey: string;
|
||||
};
|
||||
|
||||
export const MODEL_PROFILES: Record<ModelProfileKey, AiModelProfile> = {
|
||||
classification: {
|
||||
modelId: "openai/gpt-4.1-mini",
|
||||
temperature: 0.2,
|
||||
maxTokens: 1200,
|
||||
supportsImages: false,
|
||||
stage: "classification",
|
||||
envOverrideKey: "OPENROUTER_MODEL_CLASSIFICATION",
|
||||
},
|
||||
multimodalAudit: {
|
||||
modelId: "openai/gpt-4.1-mini",
|
||||
temperature: 0.3,
|
||||
maxTokens: 2800,
|
||||
supportsImages: true,
|
||||
stage: "multimodalAudit",
|
||||
envOverrideKey: "OPENROUTER_MODEL_MULTIMODAL_AUDIT",
|
||||
},
|
||||
germanCopy: {
|
||||
modelId: "openai/gpt-4.1-mini",
|
||||
temperature: 0.4,
|
||||
maxTokens: 1800,
|
||||
supportsImages: false,
|
||||
stage: "germanCopy",
|
||||
envOverrideKey: "OPENROUTER_MODEL_GERMAN_COPY",
|
||||
},
|
||||
qualityReview: {
|
||||
modelId: "openai/gpt-4.1-mini",
|
||||
temperature: 0.1,
|
||||
maxTokens: 900,
|
||||
supportsImages: false,
|
||||
stage: "qualityReview",
|
||||
envOverrideKey: "OPENROUTER_MODEL_QUALITY_REVIEW",
|
||||
},
|
||||
} as const;
|
||||
|
||||
function normalizeModelOverride(value: string | undefined): string | null {
|
||||
if (typeof value !== "string") return null;
|
||||
const trimmed = value.trim();
|
||||
return trimmed === "" ? null : trimmed;
|
||||
}
|
||||
|
||||
export function resolveModelProfile(
|
||||
profileKey: ModelProfileKey,
|
||||
env: Readonly<Record<string, string | undefined>> = process.env,
|
||||
): AiModelProfile {
|
||||
const profile = MODEL_PROFILES[profileKey];
|
||||
const override = normalizeModelOverride(env[profile.envOverrideKey]);
|
||||
|
||||
return {
|
||||
...profile,
|
||||
modelId: override ?? profile.modelId,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveModelId(
|
||||
profileKey: ModelProfileKey,
|
||||
env: Readonly<Record<string, string | undefined>> = process.env,
|
||||
): string {
|
||||
const profile = MODEL_PROFILES[profileKey];
|
||||
const override = normalizeModelOverride(env[profile.envOverrideKey]);
|
||||
|
||||
return override ?? profile.modelId;
|
||||
}
|
||||
Reference in New Issue
Block a user