diff --git a/packages/cli/src/nodehost.ts b/packages/cli/src/nodehost.ts index 6e628b22d8..f7edd750ee 100644 --- a/packages/cli/src/nodehost.ts +++ b/packages/cli/src/nodehost.ts @@ -196,8 +196,9 @@ export class NodeHost implements RuntimeHost { if (typeof value === "string") value = { model: value } const aliases = this._modelAliases[source] const c = aliases[id] || (aliases[id] = {}) - c.model = value.model - c.temperature = value.temperature + if (value.model !== undefined) (c as any).model = value.model + if (!isNaN(value.temperature)) + (c as any).temperature = value.temperature } async readConfig(): Promise { diff --git a/packages/cli/src/run.ts b/packages/cli/src/run.ts index 233a0d0843..e1d9095946 100644 --- a/packages/cli/src/run.ts +++ b/packages/cli/src/run.ts @@ -212,11 +212,9 @@ export async function runScriptInternal( const fenceFormat = options.fenceFormat if (options.json || options.yaml) overrideStdoutWithStdErr() - if (options.model) runtimeHost.modelAliases.large.model = options.model - if (options.smallModel) - runtimeHost.modelAliases.small.model = options.smallModel - if (options.visionModel) - runtimeHost.modelAliases.vision.model = options.visionModel + if (options.model) runtimeHost.setModelAlias("cli", "large", options.model) + if (options.smallModel) runtimeHost.setModelAlias("cli", "small", options.smallModel) + if (options.visionModel) runtimeHost.setModelAlias("cli", "vision", options.visionModel) for (const kv of options.modelAlias || []) { const aliases = parseKeyValuePair(kv) for (const [key, value] of Object.entries(aliases)) diff --git a/packages/cli/src/test.ts b/packages/cli/src/test.ts index 5803c103c7..a91e661e6e 100644 --- a/packages/cli/src/test.ts +++ b/packages/cli/src/test.ts @@ -109,11 +109,11 @@ export async function runPromptScriptTests( testDelay?: string } ): Promise { - if (options.model) runtimeHost.modelAliases.large.model = options.model + if (options.model) runtimeHost.setModelAlias("cli", "large", options.model) if (options.smallModel) - runtimeHost.modelAliases.small.model = options.smallModel + runtimeHost.setModelAlias("cli", "small", options.smallModel) if (options.visionModel) - runtimeHost.modelAliases.vision.model = options.visionModel + runtimeHost.setModelAlias("cli", "vision", options.visionModel) Object.entries(runtimeHost.modelAliases).forEach(([key, value]) => logVerbose(` ${key}: ${value.model}`) ) diff --git a/packages/cli/src/worker.ts b/packages/cli/src/worker.ts index edfca60a76..d05960bb2e 100644 --- a/packages/cli/src/worker.ts +++ b/packages/cli/src/worker.ts @@ -10,10 +10,11 @@ export async function worker() { } & object switch (type) { case "run": { - const { scriptId, files, ...options } = data as { + const { scriptId, files, options } = data as { scriptId: string - files: string[] - } & object + files: string[], + options: object + } const { result } = await runScriptInternal(scriptId, files, options) parentPort.postMessage(result) break diff --git a/packages/core/src/connection.ts b/packages/core/src/connection.ts index da07249a82..21d183f79f 100644 --- a/packages/core/src/connection.ts +++ b/packages/core/src/connection.ts @@ -76,7 +76,7 @@ export function findEnvVar( export async function parseDefaultsFromEnv(env: Record) { // legacy if (env.GENAISCRIPT_DEFAULT_MODEL) - runtimeHost.modelAliases.large.model = env.GENAISCRIPT_DEFAULT_MODEL + runtimeHost.setModelAlias("env", "large", env.GENAISCRIPT_DEFAULT_MODEL) const rx = /^GENAISCRIPT(_DEFAULT)?_((?[A-Z0-9_\-]+)_MODEL|MODEL_(?[A-Z0-9_\-]+))$/i @@ -88,7 +88,7 @@ export async function parseDefaultsFromEnv(env: Record) { runtimeHost.setModelAlias("env", id, v) } const t = normalizeFloat(env.GENAISCRIPT_DEFAULT_TEMPERATURE) - if (!isNaN(t)) runtimeHost.modelAliases.large.temperature = t + if (!isNaN(t)) runtimeHost.setModelAlias("env", "large", { temperature: t }) } export async function parseTokenFromEnv( diff --git a/packages/core/src/host.ts b/packages/core/src/host.ts index f126842bf5..df6e4d1829 100644 --- a/packages/core/src/host.ts +++ b/packages/core/src/host.ts @@ -113,7 +113,7 @@ export interface AzureTokenResolver { ): Promise } -export type ModelConfiguration = Pick +export type ModelConfiguration = Readonly> export type ModelConfigurations = { large: ModelConfiguration