diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index 8590444c2..e63143ef2 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -424,8 +424,7 @@ system({ lineNumbers: true, }) -$`## Annotation Format - +$`## Annotations Format Use the following format to report **file annotations** (same as GitHub Actions workflow). ::(notice|warning|error) file=,line=,endLine=,code=:: @@ -552,7 +551,8 @@ system({ title: "Generate diagrams" }) -$`Use mermaid syntax if you need to generate state diagrams, class inheritance diagrams, relationships.` +$`## Diagrams Format +Use mermaid syntax if you need to generate state diagrams, class inheritance diagrams, relationships.` ````` diff --git a/packages/cli/src/nodehost.ts b/packages/cli/src/nodehost.ts index 7f11cb05e..655f55389 100644 --- a/packages/cli/src/nodehost.ts +++ b/packages/cli/src/nodehost.ts @@ -131,7 +131,8 @@ export class NodeHost implements RuntimeHost { if (typeof value === "string") value = { model: value, source } const aliases = this._modelAliases[source] const c = aliases[id] || (aliases[id] = { source }) - if (value.model !== undefined) (c as any).model = value.model + if (value.model !== undefined && value.model !== id) + (c as any).model = value.model if (!isNaN(value.temperature)) (c as any).temperature = value.temperature } diff --git a/packages/core/src/genaisrc/system.annotations.genai.mjs b/packages/core/src/genaisrc/system.annotations.genai.mjs index dce344fbc..a734e09de 100644 --- a/packages/core/src/genaisrc/system.annotations.genai.mjs +++ b/packages/core/src/genaisrc/system.annotations.genai.mjs @@ -5,8 +5,7 @@ system({ lineNumbers: true, }) -$`## Annotation Format - +$`## Annotations Format Use the following format to report **file annotations** (same as GitHub Actions workflow). ::(notice|warning|error) file=,line=,endLine=,code=:: diff --git a/packages/core/src/genaisrc/system.diagrams.genai.mjs b/packages/core/src/genaisrc/system.diagrams.genai.mjs index 790f0f2ea..ee6a5421a 100644 --- a/packages/core/src/genaisrc/system.diagrams.genai.mjs +++ b/packages/core/src/genaisrc/system.diagrams.genai.mjs @@ -2,4 +2,5 @@ system({ title: "Generate diagrams" }) -$`Use mermaid syntax if you need to generate state diagrams, class inheritance diagrams, relationships.` \ No newline at end of file +$`## Diagrams Format +Use mermaid syntax if you need to generate state diagrams, class inheritance diagrams, relationships.` \ No newline at end of file diff --git a/packages/core/src/llms.ts b/packages/core/src/llms.ts index 62c6d8a33..d3c974300 100644 --- a/packages/core/src/llms.ts +++ b/packages/core/src/llms.ts @@ -1,3 +1,4 @@ +import { Model } from "@anthropic-ai/sdk/resources/index.mjs" import { LARGE_MODEL_ID, SMALL_MODEL_ID, VISION_MODEL_ID } from "./constants" import { ModelConfiguration, ModelConfigurations } from "./host" import LLMS from "./llms.json" @@ -14,8 +15,19 @@ export function defaultModelConfigurations(): ModelConfigurations { ] const res = { ...(Object.fromEntries( - aliases.map((alias) => [alias, readModelAlias(alias)]) + aliases.map<[string, ModelConfiguration]>((alias) => [ + alias, + readModelAlias(alias), + ]) ) as ModelConfigurations), + ...Object.fromEntries( + Object.entries(LLMS.aliases).map<[string, ModelConfiguration]>( + ([id, model]) => [ + id, + { model, source: "default" } satisfies ModelConfiguration, + ] + ) + ), } return structuredClone(res) @@ -30,6 +42,6 @@ export function defaultModelConfigurations(): ModelConfigurations { model: candidates[0], candidates, source: "default", - }) + } satisfies ModelConfiguration) } } diff --git a/packages/core/src/promptdom.ts b/packages/core/src/promptdom.ts index 71d9f5f63..9d33568c9 100644 --- a/packages/core/src/promptdom.ts +++ b/packages/core/src/promptdom.ts @@ -285,7 +285,7 @@ function renderDefNode(def: PromptDefNode): string { let res: string if (name && fenceFormat === "xml") { - res = `\n<${name}${dtype ? ` lang="${dtype}"` : ""}${filename ? ` file="${filename}"` : ""}${schema ? ` schema=${schema}` : ""}${diffFormat}>\n${body}\n` + res = `\n<${name}${dtype ? ` lang="${dtype}"` : ""}${filename ? ` file="${filename}"` : ""}${schema ? ` schema=${schema}` : ""}${diffFormat}>\n${body}<${name}>\n` } else if (fenceFormat === "none") { res = `\n${name ? name + ":\n" : ""}${body}\n` } else { diff --git a/packages/core/src/runpromptcontext.ts b/packages/core/src/runpromptcontext.ts index aed17fd0f..1a934de01 100644 --- a/packages/core/src/runpromptcontext.ts +++ b/packages/core/src/runpromptcontext.ts @@ -33,7 +33,13 @@ import { } from "./parameters" import { consoleLogFormat, stdout } from "./logging" import { isGlobMatch } from "./glob" -import { arrayify, logError, logVerbose, logWarn } from "./util" +import { + arrayify, + deleteEmptyValues, + logError, + logVerbose, + logWarn, +} from "./util" import { renderShellOutput } from "./chatrender" import { jinjaRender } from "./jinja" import { mustacheRender } from "./mustache" @@ -503,7 +509,8 @@ export function createChatGenerationContext( ...rest, } ) - return res + if (res.error) throw res.error + return deleteEmptyValues(res) } ) } diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts index a58b11073..f8e212244 100644 --- a/packages/core/src/util.ts +++ b/packages/core/src/util.ts @@ -62,21 +62,23 @@ export function parseBoolean(s: string) { } export function deleteUndefinedValues>(o: T): T { - for (const k in o) if (o[k] === undefined) delete o[k] + if (typeof o === "object") + for (const k in o) if (o[k] === undefined) delete o[k] return o } export function deleteEmptyValues>(o: T): T { - for (const k in o) { - const v = o[k] - if ( - v === undefined || - v === null || - v === "" || - (Array.isArray(v) && !v.length) - ) - delete o[k] - } + if (typeof o === "object") + for (const k in o) { + const v = o[k] + if ( + v === undefined || + v === null || + v === "" || + (Array.isArray(v) && !v.length) + ) + delete o[k] + } return o }