LLMs: pubDate support

This commit is contained in:
Enrico Ros
2026-05-04 13:48:29 -07:00
parent acdbb2fbaf
commit e21abdef45
4 changed files with 27 additions and 0 deletions
+1
View File
@@ -25,6 +25,7 @@ export interface DLLM {
label: string;
created: number | 0;
updated?: number | 0;
pubDate?: string; // official release date in 'YYYYMMDD'
description: string;
hidden: boolean;
+1
View File
@@ -107,6 +107,7 @@ function _createDLLMFromModelDescription(d: ModelDescriptionSchema, service: DMo
label: d.label,
created: d.created || 0,
updated: d.updated || 0,
...(d.pubDate && { pubDate: d.pubDate }),
description: d.description,
hidden: !!d.hidden,
@@ -137,6 +137,7 @@ export const ModelDescription_schema = z.object({
label: z.string(),
created: z.int().optional(),
updated: z.int().optional(),
pubDate: z.string().regex(/^\d{8}$/).optional(), // editorial: model's official public release date 'YYYYMMDD'. Required for editorial entries (KnownModelEditorial) and for 0-day-fillable paths (Anthropic placeholder, Gemini unknown-model fallback). Omitted for dynamic-only vendors and unknown variants where we have no reliable signal.
description: z.string(),
contextWindow: z.int().nullable(),
interfaces: z.array(z.enum(LLMS_ALL_INTERFACES).or(z.string())), // backward compatibility: to not Break client-side interface parsing on newer server
@@ -155,6 +156,7 @@ export const ModelDescription_schema = z.object({
// Each vendor's lookup filters to only what works through OpenRouter's OAI-compatible API.
// OpenRouter merges these with its own auto-detected interfaces and params.
export type OrtVendorLookupResult = {
pubDate?: ModelDescriptionSchema['pubDate'];
interfaces?: ModelDescriptionSchema['interfaces'];
parameterSpecs?: ModelDescriptionSchema['parameterSpecs'];
initialTemperature?: number; // vendor-specific default (e.g. Gemini 1.0); undefined = use global fallback (0.5)
@@ -111,6 +111,28 @@ export function llmDevValidateParameterSpecs_DEV(model: ModelDescriptionSchema):
}
// -- pubDate helpers --
/**
* Format an epoch / Date / nothing as 'YYYYMMDD'.
* Accepts either a Unix epoch (seconds), a Date, or undefined (-> today).
*/
export function formatPubDate(input?: number | Date): string {
let date: Date;
if (input instanceof Date && Number.isFinite(input.getTime()))
date = input;
else if (typeof input === 'number' && Number.isFinite(input) && input > 0) {
const candidate = new Date(input * 1000);
date = Number.isFinite(candidate.getTime()) ? candidate : new Date();
} else
date = new Date();
const y = date.getUTCFullYear();
const m = String(date.getUTCMonth() + 1).padStart(2, '0');
const d = String(date.getUTCDate()).padStart(2, '0');
return `${y}${m}${d}`;
}
// -- Manual model mappings: types and helper --
export type ManualMappings = (KnownModel | KnownLink)[];
@@ -224,6 +246,7 @@ export function fromManualMapping(mappings: (KnownModel | KnownLink)[], upstream
};
// apply optional fields
if (m.pubDate) md.pubDate = m.pubDate;
if (m.parameterSpecs) md.parameterSpecs = m.parameterSpecs;
if (m.maxCompletionTokens) md.maxCompletionTokens = m.maxCompletionTokens;
if (m.benchmark) md.benchmark = m.benchmark;