From 6cce2d1356588f90d0d06328c2d1bde5265e2838 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Thu, 19 Dec 2024 18:21:27 +0100 Subject: [PATCH 01/22] llm as judge support --- packages/core/src/chat.ts | 2 +- packages/sample/genaisrc/judge.genai.mts | 80 ++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 packages/sample/genaisrc/judge.genai.mts diff --git a/packages/core/src/chat.ts b/packages/core/src/chat.ts index 7aa453aad..c49ad0455 100644 --- a/packages/core/src/chat.ts +++ b/packages/core/src/chat.ts @@ -785,7 +785,7 @@ async function choicesToLogitBias( disableFallback: true, })) || {} if (!encode) { - logWarn( + logVerbose( `unabled to compute logit bias, no token encoder found for ${model}` ) trace.warn( diff --git a/packages/sample/genaisrc/judge.genai.mts b/packages/sample/genaisrc/judge.genai.mts new file mode 100644 index 000000000..4b50b5a4c --- /dev/null +++ b/packages/sample/genaisrc/judge.genai.mts @@ -0,0 +1,80 @@ +/** + * + * @param task + * @param result + * @param categories + * @param options + * @returns + */ +async function judgeClassify( + task: Awaitable, + result: Awaitable, + categories: Record, + options?: { + logprobs?: boolean + topLogprobs?: number + model?: ModelType + temperature?: number + } +) { + const unknown = "unknown" + const unknownText = + "if you do not have enough information or certainty to categorize the result" ++ + const choices = { ...categories, ...{ [unknown]: unknownText } } + const res = await runPrompt( + async (ctx) => { + ctx.$`## Task + You will be given a task description in and a response from a chat bot in . + Your task is to judge and classify according to the categories in . + + - Rely exclusively on the information provided in the task and the response. + + ## Output + The output should start with the step-by-step explanation of the classification (one paragraph). + Finish the output with the category name on a single line, no other words. + `.role("system") + ctx.def("TASK", await task) + ctx.def("RESULT", await result) + ctx.def( + "CATEGORY", + Object.entries(choices) + .map((kv) => `- ${kv[0]}: ${kv[1]}`) + .join("\n") + ) + }, + { + system: ["system.output_plaintext", "system.safety_jailbreak"], + choices: Object.keys(choices), + logprobs: options?.logprobs, + topLogprobs: options?.topLogprobs, + temperature: options?.temperature || 0.1, + model: options?.model || "small", + } + ) + + // extract the classifiction + const category = Object.keys(choices) + .map((category) => ({ + category, + l: res.text.lastIndexOf(category), + })) + .filter(({ l }) => l > -1) + .sort((a, b) => a.l - b.l)[0]?.category + + const logprob = res.logprobs?.reverse().find((lp) => lp.token === category) + return { + category, + logprob, + } +} + +const task = "Generate a funny joke." +//const { text: result } = await runPrompt(task) +let result = "Why did the tomato turn red? Because boo." + +const res = await judgeClassify(task, result, { + pass: "the joke was funny", + fail: "the joke was not funny", +}) +console.log(res) From 9b572efa13479d389536343020d8b2d6167f1254 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:56:42 +0000 Subject: [PATCH 02/22] =?UTF-8?q?style:=20=F0=9F=92=84=20remove=20redundan?= =?UTF-8?q?t=20blank=20line=20in=20judge.genai.mts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sample/genaisrc/judge.genai.mts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sample/genaisrc/judge.genai.mts b/packages/sample/genaisrc/judge.genai.mts index 4b50b5a4c..ceaf713ed 100644 --- a/packages/sample/genaisrc/judge.genai.mts +++ b/packages/sample/genaisrc/judge.genai.mts @@ -20,7 +20,7 @@ async function judgeClassify( const unknown = "unknown" const unknownText = "if you do not have enough information or certainty to categorize the result" -+ + const choices = { ...categories, ...{ [unknown]: unknownText } } const res = await runPrompt( async (ctx) => { @@ -54,7 +54,7 @@ async function judgeClassify( ) // extract the classifiction - const category = Object.keys(choices) + const category = Object.keys(choices) .map((category) => ({ category, l: res.text.lastIndexOf(category), From 5725842b1cde07c20cda88c1e280ad4c8f4554de Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:57:30 +0000 Subject: [PATCH 03/22] =?UTF-8?q?feat:=20=F0=9F=A7=AA=20extend=20judgeClas?= =?UTF-8?q?sify=20to=20support=20WorkspaceFile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sample/genaisrc/judge.genai.mts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sample/genaisrc/judge.genai.mts b/packages/sample/genaisrc/judge.genai.mts index ceaf713ed..60cbf7bb3 100644 --- a/packages/sample/genaisrc/judge.genai.mts +++ b/packages/sample/genaisrc/judge.genai.mts @@ -7,8 +7,8 @@ * @returns */ async function judgeClassify( - task: Awaitable, - result: Awaitable, + task: Awaitable, + result: Awaitable, categories: Record, options?: { logprobs?: boolean From e17d55b9eacfba1891430ee5216a2960ab024586 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 02:03:04 +0000 Subject: [PATCH 04/22] =?UTF-8?q?feat:=20=F0=9F=8F=97=EF=B8=8F=20add=20che?= =?UTF-8?q?ck=20for=20undefined=20text=20in=20tracePromptResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/chat.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/core/src/chat.ts b/packages/core/src/chat.ts index c49ad0455..f39d7e7ed 100644 --- a/packages/core/src/chat.ts +++ b/packages/core/src/chat.ts @@ -1052,18 +1052,20 @@ export function tracePromptResult( const { text } = resp || {} // try to sniff the output type - const language = JSON5TryParse(text) - ? "json" - : XMLTryParse(text) - ? "xml" - : /^(-|\*|#+|```)\s/im.test(text) - ? "markdown" - : "text" - trace.detailsFenced(`🔠 output`, text, language) - if (language === "markdown") - trace.appendContent( - "\n\n" + HTMLEscape(prettifyMarkdown(text)) + "\n\n" - ) + if (text !== undefined) { + const language = JSON5TryParse(text) + ? "json" + : XMLTryParse(text) + ? "xml" + : /^(-|\*|#+|```)\s/im.test(text) + ? "markdown" + : "text" + trace.detailsFenced(`🔠 output`, text, language) + if (language === "markdown") + trace.appendContent( + "\n\n" + HTMLEscape(prettifyMarkdown(text)) + "\n\n" + ) + } } export function appendUserMessage( From f16d9150736fde5e357bc06f59e1655f65024a1f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 06:36:43 +0000 Subject: [PATCH 05/22] add g2thinking --- packages/core/src/types/prompt_template.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 4bd1f7304..4ad900c21 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -157,6 +157,7 @@ type ModelType = OptionsOrString< | "huggingface:microsoft/Phi-3-mini-4k-instruct" | "jan:llama3.2-3b-instruct" | "google:gemini-2.0-flash-exp" + | "google:gemini-2.0-flash-thinking-exp-1219" | "google:gemini-1.5-flash" | "google:gemini-1.5-flash-latest" | "google:gemini-1.5-flash-8b" From c62171d125c84867ee97553ae09a96a16a13794f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 07:14:42 +0000 Subject: [PATCH 06/22] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20model=20alias?= =?UTF-8?q?=20support=20and=20update=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/public/schemas/llms.json | 51 +++++++++++ .../content/docs/reference/cli/commands.md | 75 ++++++++++++++++ packages/cli/src/nodehost.ts | 89 +++++++++---------- packages/cli/src/parse.ts | 3 +- packages/core/src/constants.ts | 50 ----------- packages/core/src/llms.json | 72 ++++++++++++--- packages/core/src/util.ts | 14 +++ 7 files changed, 241 insertions(+), 113 deletions(-) diff --git a/docs/public/schemas/llms.json b/docs/public/schemas/llms.json index b750191fa..bc004791d 100644 --- a/docs/public/schemas/llms.json +++ b/docs/public/schemas/llms.json @@ -58,6 +58,48 @@ "bearerToken": { "type": "boolean", "description": "Indicates if bearer token is supported" + }, + "aliases": { + "type": "object", + "description": "List of model aliases for the provider", + "properties": { + "large": { + "type": "string", + "description": "Alias for large model" + }, + "small": { + "type": "string", + "description": "Alias for small model" + }, + "vision": { + "type": "string", + "description": "Alias for vision model" + }, + "reasoning": { + "type": "string", + "description": "Alias for reasoning model" + }, + "reasoning_small": { + "type": "string", + "description": "Alias for reasoning small model" + }, + "long": { + "type": "string", + "description": "Alias for long model" + }, + "agent": { + "type": "string", + "description": "Alias for agent model" + }, + "memory": { + "type": "string", + "description": "Alias for memory model" + }, + "embeddings": { + "type": "string", + "description": "Alias for embeddings model" + } + } } }, "additionalProperties": false, @@ -65,6 +107,15 @@ } } }, + "aliases": { + "type": "object", + "additionalProperties": true, + "patternProperties": { + "^[a-zA-Z0-9:_-]+$": { + "type": "string" + } + } + }, "pricings": { "type": "object", "additionalProperties": false, diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 120ff8111..5a933de22 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -1,3 +1,78 @@ +{ + "large": { + "model": "openai:gpt-4o", + "source": "default", + "candidates": [ + "openai:gpt-4o", + "azure_serverless:gpt-4o", + "anthropic:claude-2.1", + "google:gemini-1.5-pro-latest", + "github:gpt-4o", + "client:gpt-4o" + ] + }, + "small": { + "model": "openai:gpt-4o-mini", + "source": "default", + "candidates": [ + "openai:gpt-4o-mini", + "azure_serverless:gpt-4o-mini", + "anthropic:claude-instant-1.2", + "google:gemini-1.5-flash-latest", + "github:gpt-4o-mini", + "client:gpt-4o-mini" + ] + }, + "vision": { + "model": "openai:gpt-4o", + "source": "default", + "candidates": [ + "openai:gpt-4o", + "azure_serverless:gpt-4o", + "anthropic:claude-2.1", + "google:gemini-1.5-flash-latest", + "github:gpt-4o" + ] + }, + "embeddings": { + "model": "openai:text-embedding-3-small", + "source": "default", + "candidates": [ + "openai:text-embedding-3-small", + "github:text-embedding-3-small" + ] + }, + "reasoning": { + "model": "openai:o1", + "source": "default", + "candidates": [ + "openai:o1", + "azure_serverless:o1-preview", + "github:o1-preview" + ] + }, + "reasoning_small": { + "model": "openai:o1-mini", + "source": "default", + "candidates": [ + "openai:o1-mini", + "azure_serverless:o1-mini", + "github:o1-mini" + ] + }, + "agent": { + "model": "large", + "source": "default" + }, + "long": { + "model": "large", + "source": "default" + }, + "memory": { + "model": "large", + "source": "default" + } +} --- title: Commands description: List of all CLI commands diff --git a/packages/cli/src/nodehost.ts b/packages/cli/src/nodehost.ts index b09c736e7..100f02d2c 100644 --- a/packages/cli/src/nodehost.ts +++ b/packages/cli/src/nodehost.ts @@ -17,27 +17,16 @@ import { parseTokenFromEnv, } from "../../core/src/connection" import { - DEFAULT_LARGE_MODEL, MODEL_PROVIDER_AZURE_OPENAI, SHELL_EXEC_TIMEOUT, - DEFAULT_EMBEDDINGS_MODEL, - DEFAULT_SMALL_MODEL, AZURE_COGNITIVE_SERVICES_TOKEN_SCOPES, MODEL_PROVIDER_AZURE_SERVERLESS_MODELS, AZURE_AI_INFERENCE_TOKEN_SCOPES, MODEL_PROVIDER_AZURE_SERVERLESS_OPENAI, DOT_ENV_FILENAME, - DEFAULT_VISION_MODEL, LARGE_MODEL_ID, SMALL_MODEL_ID, - DEFAULT_SMALL_MODEL_CANDIDATES, - DEFAULT_LARGE_MODEL_CANDIDATES, - DEFAULT_EMBEDDINGS_MODEL_CANDIDATES, - DEFAULT_VISION_MODEL_CANDIDATES, - DEFAULT_REASONING_MODEL, - DEFAULT_REASONING_SMALL_MODEL, - DEFAULT_REASONING_SMALL_MODEL_CANDIDATES, - DEFAULT_REASONING_MODEL_CANDIDATES, + VISION_MODEL_ID, } from "../../core/src/constants" import { tryReadText } from "../../core/src/fs" import { @@ -54,7 +43,7 @@ import { ModelConfiguration, } from "../../core/src/host" import { TraceOptions } from "../../core/src/trace" -import { logError, logVerbose } from "../../core/src/util" +import { deleteEmptyValues, logError, logVerbose } from "../../core/src/util" import { parseModelIdentifier } from "../../core/src/models" import { LanguageModel } from "../../core/src/chat" import { errorMessage, NotSupportedError } from "../../core/src/error" @@ -73,6 +62,7 @@ import { resolveGlobalConfiguration } from "../../core/src/config" import { HostConfiguration } from "../../core/src/hostconfiguration" import { resolveLanguageModel } from "../../core/src/lm" import { CancellationOptions } from "../../core/src/cancellation" +import LLMS from "../../../packages/core/src/llms.json" class NodeServerManager implements ServerManager { async start(): Promise { @@ -83,6 +73,43 @@ class NodeServerManager implements ServerManager { } } +function readModelAliases(): ModelConfigurations { + const aliases = [ + LARGE_MODEL_ID, + SMALL_MODEL_ID, + VISION_MODEL_ID, + "embeddings", + "reasoning", + "reasoning_small", + ] + const res = { + ...(Object.fromEntries( + aliases.map((alias) => [alias, readModelAlias(alias)]) + ) as ModelConfigurations), + ...Object.fromEntries( + Object.entries(LLMS.aliases).map((kv) => [ + kv[0], + { + model: kv[1], + source: "default", + } satisfies ModelConfiguration, + ]) + ), + } + return res + + function readModelAlias(alias: string) { + const candidates = Object.values(LLMS.providers) + .map(({ aliases }) => (aliases as Record)?.[alias]) + .filter((c) => !!c) + return deleteEmptyValues({ + model: candidates[0], + source: "default", + candidates, + }) + } +} + export class NodeHost implements RuntimeHost { private pulledModels: string[] = [] readonly dotEnvPath: string @@ -97,41 +124,7 @@ export class NodeHost implements RuntimeHost { "default" | "cli" | "env" | "config", Omit > = { - default: { - large: { - model: DEFAULT_LARGE_MODEL, - source: "default", - candidates: DEFAULT_LARGE_MODEL_CANDIDATES, - }, - small: { - model: DEFAULT_SMALL_MODEL, - source: "default", - candidates: DEFAULT_SMALL_MODEL_CANDIDATES, - }, - vision: { - model: DEFAULT_VISION_MODEL, - source: "default", - candidates: DEFAULT_VISION_MODEL_CANDIDATES, - }, - embeddings: { - model: DEFAULT_EMBEDDINGS_MODEL, - source: "default", - candidates: DEFAULT_EMBEDDINGS_MODEL_CANDIDATES, - }, - reasoning: { - model: DEFAULT_REASONING_MODEL, - source: "default", - candidates: DEFAULT_REASONING_MODEL_CANDIDATES, - }, - ["reasoning_small"]: { - model: DEFAULT_REASONING_SMALL_MODEL, - source: "default", - candidates: DEFAULT_REASONING_SMALL_MODEL_CANDIDATES, - }, - long: { model: LARGE_MODEL_ID, source: "default" }, - agent: { model: LARGE_MODEL_ID, source: "default" }, - memory: { model: SMALL_MODEL_ID, source: "default" }, - }, + default: readModelAliases(), cli: {}, env: {}, config: {}, diff --git a/packages/cli/src/parse.ts b/packages/cli/src/parse.ts index d2de135c4..97e4d15bd 100644 --- a/packages/cli/src/parse.ts +++ b/packages/cli/src/parse.ts @@ -16,7 +16,6 @@ import { YAMLParse, YAMLStringify } from "../../core/src/yaml" import { resolveTokenEncoder } from "../../core/src/encoders" import { CSV_REGEX, - DEFAULT_LARGE_MODEL, INI_REGEX, JSON5_REGEX, MD_REGEX, @@ -203,7 +202,7 @@ export async function parseTokens( filesGlobs: string[], options: { excludedFiles: string[]; model: string } ) { - const { model = DEFAULT_LARGE_MODEL } = options || {} + const { model } = options || {} const { encode: encoder } = await resolveTokenEncoder(model) const files = await expandFiles(filesGlobs, options?.excludedFiles) diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index 37e651533..79bcbea21 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -57,56 +57,6 @@ export const SMALL_MODEL_ID = "small" export const LARGE_MODEL_ID = "large" export const VISION_MODEL_ID = "vision" export const DEFAULT_FENCE_FORMAT: FenceFormat = "xml" -export const DEFAULT_LARGE_MODEL = "openai:gpt-4o" -export const DEFAULT_LARGE_MODEL_CANDIDATES = [ - "azure_serverless:gpt-4o", - DEFAULT_LARGE_MODEL, - "google:gemini-1.5-pro-latest", - "anthropic:claude-2.1", - "mistral:mistral-large-latest", - "github:gpt-4o", - "client:gpt-4", -] -export const DEFAULT_VISION_MODEL = "openai:gpt-4o" -export const DEFAULT_VISION_MODEL_CANDIDATES = [ - "azure_serverless:gpt-4o", - DEFAULT_VISION_MODEL, - "google:gemini-1.5-flash-latest", - "anthropic:claude-2.1", - "github:gpt-4o", -] -export const DEFAULT_SMALL_MODEL = "openai:gpt-4o-mini" -export const DEFAULT_SMALL_MODEL_CANDIDATES = [ - "azure_serverless:gpt-4o-mini", - DEFAULT_SMALL_MODEL, - "google:gemini-1.5-flash-latest", - "anthropic:claude-instant-1.2", - "mistral:mistral-small-latest", - "github:gpt-4o-mini", - "client:gpt-4-mini", -] -export const DEFAULT_EMBEDDINGS_MODEL_CANDIDATES = [ - "azure:text-embedding-3-small", - "azure:text-embedding-2-small", - "openai:text-embedding-3-small", - "github:text-embedding-3-small", - "client:text-embedding-3-small", -] -export const DEFAULT_REASONING_SMALL_MODEL = "openai:o1-mini" -export const DEFAULT_REASONING_SMALL_MODEL_CANDIDATES = [ - "azure_serverless:o1-mini", - DEFAULT_REASONING_SMALL_MODEL, - "github:o1-mini", - "client:o1-mini", -] -export const DEFAULT_REASONING_MODEL = "openai:o1" -export const DEFAULT_REASONING_MODEL_CANDIDATES = [ - "azure_serverless:o1-preview", - DEFAULT_REASONING_MODEL, - "github:o1-preview", - "client:o1-preview", -] -export const DEFAULT_EMBEDDINGS_MODEL = "openai:text-embedding-ada-002" export const DEFAULT_TEMPERATURE = 0.8 export const BUILTIN_PREFIX = "_builtin/" export const CACHE_LLMREQUEST_PREFIX = "genaiscript/cache/llm/" diff --git a/packages/core/src/llms.json b/packages/core/src/llms.json index 4d4c16974..f679be40e 100644 --- a/packages/core/src/llms.json +++ b/packages/core/src/llms.json @@ -4,16 +4,15 @@ { "id": "openai", "detail": "OpenAI (or compatible)", - "bearerToken": true - }, - { - "id": "github", - "detail": "GitHub Models", - "logprobs": false, - "topLogprobs": false, - "limitations": "Smaller context windows, and rate limiting", - "prediction": false, - "bearerToken": true + "bearerToken": true, + "aliases": { + "large": "openai:gpt-4o", + "small": "openai:gpt-4o-mini", + "vision": "openai:gpt-4o", + "embeddings": "openai:text-embedding-3-small", + "reasoning": "openai:o1", + "reasoning_small": "openai:o1-mini" + } }, { "id": "azure", @@ -23,7 +22,14 @@ { "id": "azure_serverless", "detail": "Azure AI OpenAI (serverless deployments)", - "bearerToken": false + "bearerToken": false, + "aliases": { + "large": "azure_serverless:gpt-4o", + "small": "azure_serverless:gpt-4o-mini", + "vision": "azure_serverless:gpt-4o", + "reasoning": "azure_serverless:o1-preview", + "reasoning_small": "azure_serverless:o1-mini" + } }, { "id": "azure_serverless_models", @@ -36,7 +42,12 @@ "detail": "Anthropic models", "logprobs": false, "topLogprobs": false, - "prediction": false + "prediction": false, + "aliases": { + "large": "anthropic:claude-2.1", + "small": "anthropic:claude-instant-1.2", + "vision": "anthropic:claude-2.1" + } }, { "id": "google", @@ -45,7 +56,12 @@ "tools": false, "openaiCompatibility": "https://ai.google.dev/gemini-api/docs/openai", "prediction": false, - "bearerToken": true + "bearerToken": true, + "aliases": { + "large": "google:gemini-1.5-pro-latest", + "small": "google:gemini-1.5-flash-latest", + "vision": "google:gemini-1.5-flash-latest" + } }, { "id": "huggingface", @@ -58,6 +74,31 @@ "prediction": false, "bearerToken": true }, + { + "id": "github", + "detail": "GitHub Models", + "logprobs": false, + "topLogprobs": false, + "limitations": "Smaller context windows, and rate limiting", + "prediction": false, + "bearerToken": true, + "aliases": { + "large": "github:gpt-4o", + "small": "github:gpt-4o-mini", + "vision": "github:gpt-4o", + "embeddings": "github:text-embedding-3-small", + "reasoning": "github:o1-preview", + "reasoning_small": "github:o1-mini" + } + }, + { + "id": "client", + "detail": "GitHub Copilot Chat Modes", + "aliases": { + "large": "client:gpt-4o", + "small": "client:gpt-4o-mini" + } + }, { "id": "transformers", "detail": "Hugging Face Transformers", @@ -99,6 +140,11 @@ "prediction": false } ], + "aliases": { + "agent": "large", + "long": "large", + "memory": "large" + }, "pricings": { "openai:gpt-4o": { "price_per_million_input_tokens": 2.5, diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts index dbd9aef94..a58b11073 100644 --- a/packages/core/src/util.ts +++ b/packages/core/src/util.ts @@ -66,6 +66,20 @@ export function deleteUndefinedValues>(o: T): T { 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] + } + return o +} + export function collapseEmptyLines(text: string) { return text?.replace(/(\r?\n){2,}/g, "\n\n") } From 0d394b9c86d778a3c698ee042690a192f0e9edee Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 07:37:16 +0000 Subject: [PATCH 07/22] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20support=20for?= =?UTF-8?q?=20listing=20model=20information=20in=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/docs/reference/cli/commands.md | 86 +++---------------- packages/cli/src/cli.ts | 9 +- packages/cli/src/info.ts | 9 +- packages/cli/src/nodehost.ts | 41 +-------- packages/core/src/llms.ts | 41 +++++++++ packages/core/src/testhost.ts | 14 +-- 6 files changed, 71 insertions(+), 129 deletions(-) create mode 100644 packages/core/src/llms.ts diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 5a933de22..88c0b720e 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -1,78 +1,3 @@ -{ - "large": { - "model": "openai:gpt-4o", - "source": "default", - "candidates": [ - "openai:gpt-4o", - "azure_serverless:gpt-4o", - "anthropic:claude-2.1", - "google:gemini-1.5-pro-latest", - "github:gpt-4o", - "client:gpt-4o" - ] - }, - "small": { - "model": "openai:gpt-4o-mini", - "source": "default", - "candidates": [ - "openai:gpt-4o-mini", - "azure_serverless:gpt-4o-mini", - "anthropic:claude-instant-1.2", - "google:gemini-1.5-flash-latest", - "github:gpt-4o-mini", - "client:gpt-4o-mini" - ] - }, - "vision": { - "model": "openai:gpt-4o", - "source": "default", - "candidates": [ - "openai:gpt-4o", - "azure_serverless:gpt-4o", - "anthropic:claude-2.1", - "google:gemini-1.5-flash-latest", - "github:gpt-4o" - ] - }, - "embeddings": { - "model": "openai:text-embedding-3-small", - "source": "default", - "candidates": [ - "openai:text-embedding-3-small", - "github:text-embedding-3-small" - ] - }, - "reasoning": { - "model": "openai:o1", - "source": "default", - "candidates": [ - "openai:o1", - "azure_serverless:o1-preview", - "github:o1-preview" - ] - }, - "reasoning_small": { - "model": "openai:o1-mini", - "source": "default", - "candidates": [ - "openai:o1-mini", - "azure_serverless:o1-mini", - "github:o1-mini" - ] - }, - "agent": { - "model": "large", - "source": "default" - }, - "long": { - "model": "large", - "source": "default" - }, - "memory": { - "model": "large", - "source": "default" - } -} --- title: Commands description: List of all CLI commands @@ -327,6 +252,17 @@ Options: -h, --help display help for command ``` +## `models` + +``` +Usage: genaiscript models [options] + +List model information + +Options: + -h, --help display help for command +``` + ## `cache` ``` diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 67c090a95..88002cb16 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -24,7 +24,7 @@ import { } from "./parse" // Parsing functions import { compileScript, createScript, fixScripts, listScripts } from "./scripts" // Script utilities import { codeQuery } from "./codequery" // Code parsing and query execution -import { envInfo, modelInfo, systemInfo } from "./info" // Information utilities +import { envInfo, modelsInfo, scriptModelInfo, systemInfo } from "./info" // Information utilities import { scriptTestList, scriptTestsView, scriptsTest } from "./test" // Test functions import { cacheClear } from "./cache" // Cache management import "node:console" // Importing console for side effects @@ -320,7 +320,11 @@ export async function cli() { .description("List model connection information for scripts") .argument("[script]", "Script id or file") .option("-t, --token", "show token") - .action(modelInfo) // Action to show model information + .action(scriptModelInfo) // Action to show model information + + const models = program.command("models") + .description("List model information") + .action(modelsInfo) // Define 'cache' command for cache management const cache = program.command("cache").description("Cache management") @@ -446,5 +450,6 @@ export async function cli() { .option("-e, --error", "show errors") .option("-m, --models", "show models if possible") .action(envInfo) // Action to show environment information + program.parse() // Parse command-line arguments } diff --git a/packages/cli/src/info.ts b/packages/cli/src/info.ts index 086ad13c0..dd8d39f27 100644 --- a/packages/cli/src/info.ts +++ b/packages/cli/src/info.ts @@ -117,7 +117,10 @@ async function resolveScriptsConnectionInfo( * @param script - The specific script ID or filename to filter by (optional). * @param options - Configuration options, including whether to show tokens. */ -export async function modelInfo(script: string, options?: { token?: boolean }) { +export async function scriptModelInfo( + script: string, + options?: { token?: boolean } +) { const prj = await buildProject() const templates = prj.scripts.filter( (t) => @@ -128,3 +131,7 @@ export async function modelInfo(script: string, options?: { token?: boolean }) { const info = await resolveScriptsConnectionInfo(templates, options) console.log(YAMLStringify(info)) } + +export async function modelsInfo() { + console.log(YAML.stringify(runtimeHost.modelAliases)) +} diff --git a/packages/cli/src/nodehost.ts b/packages/cli/src/nodehost.ts index 100f02d2c..0a83d3c77 100644 --- a/packages/cli/src/nodehost.ts +++ b/packages/cli/src/nodehost.ts @@ -62,7 +62,7 @@ import { resolveGlobalConfiguration } from "../../core/src/config" import { HostConfiguration } from "../../core/src/hostconfiguration" import { resolveLanguageModel } from "../../core/src/lm" import { CancellationOptions } from "../../core/src/cancellation" -import LLMS from "../../../packages/core/src/llms.json" +import { defaultModelConfigurations } from "../../core/src/llms" class NodeServerManager implements ServerManager { async start(): Promise { @@ -73,43 +73,6 @@ class NodeServerManager implements ServerManager { } } -function readModelAliases(): ModelConfigurations { - const aliases = [ - LARGE_MODEL_ID, - SMALL_MODEL_ID, - VISION_MODEL_ID, - "embeddings", - "reasoning", - "reasoning_small", - ] - const res = { - ...(Object.fromEntries( - aliases.map((alias) => [alias, readModelAlias(alias)]) - ) as ModelConfigurations), - ...Object.fromEntries( - Object.entries(LLMS.aliases).map((kv) => [ - kv[0], - { - model: kv[1], - source: "default", - } satisfies ModelConfiguration, - ]) - ), - } - return res - - function readModelAlias(alias: string) { - const candidates = Object.values(LLMS.providers) - .map(({ aliases }) => (aliases as Record)?.[alias]) - .filter((c) => !!c) - return deleteEmptyValues({ - model: candidates[0], - source: "default", - candidates, - }) - } -} - export class NodeHost implements RuntimeHost { private pulledModels: string[] = [] readonly dotEnvPath: string @@ -124,7 +87,7 @@ export class NodeHost implements RuntimeHost { "default" | "cli" | "env" | "config", Omit > = { - default: readModelAliases(), + default: defaultModelConfigurations(), cli: {}, env: {}, config: {}, diff --git a/packages/core/src/llms.ts b/packages/core/src/llms.ts new file mode 100644 index 000000000..ca320f8c5 --- /dev/null +++ b/packages/core/src/llms.ts @@ -0,0 +1,41 @@ +import { LARGE_MODEL_ID, SMALL_MODEL_ID, VISION_MODEL_ID } from "./constants" +import { ModelConfiguration, ModelConfigurations } from "./host" +import LLMS from "./llms.json" +import { deleteEmptyValues } from "./util" + +export function defaultModelConfigurations(): ModelConfigurations { + const aliases = [ + LARGE_MODEL_ID, + SMALL_MODEL_ID, + VISION_MODEL_ID, + "embeddings", + "reasoning", + "reasoning_small", + ] + const res = { + ...(Object.fromEntries( + aliases.map((alias) => [alias, readModelAlias(alias)]) + ) as ModelConfigurations), + ...Object.fromEntries( + Object.entries(LLMS.aliases).map((kv) => [ + kv[0], + { + model: kv[1], + source: "default", + } satisfies ModelConfiguration, + ]) + ), + } + return structuredClone(res) + + function readModelAlias(alias: string) { + const candidates = Object.values(LLMS.providers) + .map(({ aliases }) => (aliases as Record)?.[alias]) + .filter((c) => !!c) + return deleteEmptyValues({ + model: candidates[0], + source: "default", + candidates, + }) + } +} diff --git a/packages/core/src/testhost.ts b/packages/core/src/testhost.ts index 46f730618..3984a02ce 100644 --- a/packages/core/src/testhost.ts +++ b/packages/core/src/testhost.ts @@ -19,12 +19,6 @@ import { ResponseStatus, } from "./host" import { TraceOptions } from "./trace" -import { - DEFAULT_EMBEDDINGS_MODEL, - DEFAULT_LARGE_MODEL, - DEFAULT_SMALL_MODEL, - DEFAULT_VISION_MODEL, -} from "./constants" import { dirname, extname, @@ -38,6 +32,7 @@ import { import { LanguageModel } from "./chat" import { NotSupportedError } from "./error" import { Project } from "./server/messages" +import { defaultModelConfigurations } from "./llms" // Function to create a frozen object representing Node.js path methods // This object provides utility methods for path manipulations @@ -68,12 +63,7 @@ export class TestHost implements RuntimeHost { azureToken: AzureTokenResolver = undefined // Default options for language models - readonly modelAliases: ModelConfigurations = { - large: { model: DEFAULT_LARGE_MODEL, source: "default" }, - small: { model: DEFAULT_SMALL_MODEL, source: "default" }, - vision: { model: DEFAULT_VISION_MODEL, source: "default" }, - embeddings: { model: DEFAULT_EMBEDDINGS_MODEL, source: "default" }, - } + readonly modelAliases: ModelConfigurations = defaultModelConfigurations() // Static method to set this class as the runtime host static install() { From d6da24ce33373fb19f7cdc6de15fa57cd553dc8e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 09:29:57 +0000 Subject: [PATCH 08/22] updated list of models --- packages/core/src/llms.json | 102 ++++++++++++++++++++++-------- packages/core/src/llms.ts | 16 ++--- packages/core/src/vectorsearch.ts | 1 - 3 files changed, 79 insertions(+), 40 deletions(-) diff --git a/packages/core/src/llms.json b/packages/core/src/llms.json index f679be40e..edb51c279 100644 --- a/packages/core/src/llms.json +++ b/packages/core/src/llms.json @@ -6,12 +6,12 @@ "detail": "OpenAI (or compatible)", "bearerToken": true, "aliases": { - "large": "openai:gpt-4o", - "small": "openai:gpt-4o-mini", - "vision": "openai:gpt-4o", - "embeddings": "openai:text-embedding-3-small", - "reasoning": "openai:o1", - "reasoning_small": "openai:o1-mini" + "large": "gpt-4o", + "small": "gpt-4o-mini", + "vision": "gpt-4o", + "embeddings": "text-embedding-3-small", + "reasoning": "o1", + "reasoning_small": "o1-mini" } }, { @@ -24,11 +24,11 @@ "detail": "Azure AI OpenAI (serverless deployments)", "bearerToken": false, "aliases": { - "large": "azure_serverless:gpt-4o", - "small": "azure_serverless:gpt-4o-mini", - "vision": "azure_serverless:gpt-4o", - "reasoning": "azure_serverless:o1-preview", - "reasoning_small": "azure_serverless:o1-mini" + "large": "gpt-4o", + "small": "gpt-4o-mini", + "vision": "gpt-4o", + "reasoning": "o1", + "reasoning_small": "o1-mini" } }, { @@ -44,9 +44,19 @@ "topLogprobs": false, "prediction": false, "aliases": { - "large": "anthropic:claude-2.1", - "small": "anthropic:claude-instant-1.2", - "vision": "anthropic:claude-2.1" + "large": "claude-3-5-sonnet-latest", + "small": "claude-3-5-haiku-latest" + } + }, + { + "id": "anthropic_bedrock", + "detail": "Anthropic on AWS Bedrock models", + "logprobs": false, + "topLogprobs": false, + "prediction": false, + "aliases": { + "large": "anthropic.claude-3-5-sonnet-20241022-v2:0", + "small": "anthropic.claude-3-5-haiku-20241022-v1:0" } }, { @@ -58,9 +68,11 @@ "prediction": false, "bearerToken": true, "aliases": { - "large": "google:gemini-1.5-pro-latest", - "small": "google:gemini-1.5-flash-latest", - "vision": "google:gemini-1.5-flash-latest" + "large": "gemini-1.5-pro-latest", + "small": "gemini-1.5-flash-latest", + "vision": "gemini-1.5-pro-latest", + "reasoning": "gemini-2.0-flash-exp", + "embeddings": "text-embedding-004" } }, { @@ -72,7 +84,12 @@ "id": "mistal", "detail": "Mistral AI", "prediction": false, - "bearerToken": true + "bearerToken": true, + "aliases": { + "large": "mistral-large-latest", + "small": "mistral-small-latest", + "vision": "pixtral-large-latest" + } }, { "id": "github", @@ -83,20 +100,22 @@ "prediction": false, "bearerToken": true, "aliases": { - "large": "github:gpt-4o", - "small": "github:gpt-4o-mini", - "vision": "github:gpt-4o", - "embeddings": "github:text-embedding-3-small", - "reasoning": "github:o1-preview", - "reasoning_small": "github:o1-mini" + "large": "gpt-4o", + "small": "gpt-4o-mini", + "vision": "gpt-4o", + "embeddings": "text-embedding-3-small", + "reasoning": "o1-preview", + "reasoning_small": "o1-mini" } }, { "id": "client", "detail": "GitHub Copilot Chat Modes", "aliases": { - "large": "client:gpt-4o", - "small": "client:gpt-4o-mini" + "large": "gpt-4o", + "small": "gpt-4o-mini", + "reasoning": "o1-preview", + "reasoning_small": "o1-mini" } }, { @@ -127,7 +146,13 @@ "openaiCompatibility": "https://www.alibabacloud.com/help/en/model-studio/developer-reference/compatibility-of-openai-with-dashscope", "tools": false, "prediction": false, - "bearerToken": true + "bearerToken": true, + "aliases": { + "large": "qwen-max", + "small": "qwen-turbo", + "long": "qwen-plus", + "embeddings": "text-embedding-v3" + } }, { "id": "llamafile", @@ -143,7 +168,8 @@ "aliases": { "agent": "large", "long": "large", - "memory": "large" + "memory": "large", + "reasoning_small": "reasoning" }, "pricings": { "openai:gpt-4o": { @@ -546,6 +572,26 @@ "price_per_million_input_tokens": 3, "price_per_million_output_tokens": 15, "input_cache_token_rebate": 0.1 + }, + "anthropic:claude-3-5-sonnet-20241022": { + "price_per_million_input_tokens": 3, + "price_per_million_output_tokens": 15, + "input_cache_token_rebate": 0.1 + }, + "anthropic:claude-3-5-sonnet-latest": { + "price_per_million_input_tokens": 3, + "price_per_million_output_tokens": 15, + "input_cache_token_rebate": 0.1 + }, + "anthropic:claude-3-5-haiku-20241022": { + "price_per_million_input_tokens": 0.8, + "price_per_million_output_tokens": 4, + "input_cache_token_rebate": 0.1 + }, + "anthropic:claude-3-5-haiku-latest": { + "price_per_million_input_tokens": 0.8, + "price_per_million_output_tokens": 4, + "input_cache_token_rebate": 0.1 } } } diff --git a/packages/core/src/llms.ts b/packages/core/src/llms.ts index ca320f8c5..62c6d8a33 100644 --- a/packages/core/src/llms.ts +++ b/packages/core/src/llms.ts @@ -16,26 +16,20 @@ export function defaultModelConfigurations(): ModelConfigurations { ...(Object.fromEntries( aliases.map((alias) => [alias, readModelAlias(alias)]) ) as ModelConfigurations), - ...Object.fromEntries( - Object.entries(LLMS.aliases).map((kv) => [ - kv[0], - { - model: kv[1], - source: "default", - } satisfies ModelConfiguration, - ]) - ), } return structuredClone(res) function readModelAlias(alias: string) { const candidates = Object.values(LLMS.providers) - .map(({ aliases }) => (aliases as Record)?.[alias]) + .map(({ id, aliases }) => { + const ref = (aliases as Record)?.[alias] + return ref ? `${id}:${ref}` : undefined + }) .filter((c) => !!c) return deleteEmptyValues({ model: candidates[0], - source: "default", candidates, + source: "default", }) } } diff --git a/packages/core/src/vectorsearch.ts b/packages/core/src/vectorsearch.ts index 260e01911..844d15642 100644 --- a/packages/core/src/vectorsearch.ts +++ b/packages/core/src/vectorsearch.ts @@ -8,7 +8,6 @@ import { resolveModelConnectionInfo } from "./models" import { runtimeHost, host } from "./host" import { AZURE_OPENAI_API_VERSION, - DEFAULT_EMBEDDINGS_MODEL_CANDIDATES, MODEL_PROVIDER_AZURE_OPENAI, MODEL_PROVIDER_AZURE_SERVERLESS_MODELS, MODEL_PROVIDER_AZURE_SERVERLESS_OPENAI, From f034b8624756622335ff262db3f33a037a46508e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 14:22:12 +0000 Subject: [PATCH 09/22] =?UTF-8?q?feat:=20=E2=9C=A8=20update=20LLM=20aliase?= =?UTF-8?q?s=20and=20models,=20fix=20mistral=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/llms.json | 58 +++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/packages/core/src/llms.json b/packages/core/src/llms.json index edb51c279..10e30279f 100644 --- a/packages/core/src/llms.json +++ b/packages/core/src/llms.json @@ -68,10 +68,10 @@ "prediction": false, "bearerToken": true, "aliases": { - "large": "gemini-1.5-pro-latest", + "large": "gemini-2.0-flash-exp", "small": "gemini-1.5-flash-latest", - "vision": "gemini-1.5-pro-latest", - "reasoning": "gemini-2.0-flash-exp", + "vision": "gemini-2.0-flash-exp", + "reasoning": "gemini-2.0-flash-thinking-exp-1219", "embeddings": "text-embedding-004" } }, @@ -81,7 +81,7 @@ "prediction": false }, { - "id": "mistal", + "id": "mistral", "detail": "Mistral AI", "prediction": false, "bearerToken": true, @@ -91,6 +91,20 @@ "vision": "pixtral-large-latest" } }, + { + "id": "alibaba", + "detail": "Alibaba models", + "openaiCompatibility": "https://www.alibabacloud.com/help/en/model-studio/developer-reference/compatibility-of-openai-with-dashscope", + "tools": false, + "prediction": false, + "bearerToken": true, + "aliases": { + "large": "qwen-max", + "small": "qwen-turbo", + "long": "qwen-plus", + "embeddings": "text-embedding-v3" + } + }, { "id": "github", "detail": "GitHub Models", @@ -108,16 +122,6 @@ "reasoning_small": "o1-mini" } }, - { - "id": "client", - "detail": "GitHub Copilot Chat Modes", - "aliases": { - "large": "gpt-4o", - "small": "gpt-4o-mini", - "reasoning": "o1-preview", - "reasoning_small": "o1-mini" - } - }, { "id": "transformers", "detail": "Hugging Face Transformers", @@ -140,20 +144,6 @@ "detail": "Jan local server", "prediction": false }, - { - "id": "alibaba", - "detail": "Alibaba models", - "openaiCompatibility": "https://www.alibabacloud.com/help/en/model-studio/developer-reference/compatibility-of-openai-with-dashscope", - "tools": false, - "prediction": false, - "bearerToken": true, - "aliases": { - "large": "qwen-max", - "small": "qwen-turbo", - "long": "qwen-plus", - "embeddings": "text-embedding-v3" - } - }, { "id": "llamafile", "detail": "llamafile.ai local model", @@ -163,6 +153,18 @@ "id": "litellm", "detail": "LiteLLM proxy", "prediction": false + }, + { + "id": "client", + "detail": "GitHub Copilot Chat Modes", + "tools": false, + "prediction": false, + "aliases": { + "large": "gpt-4o", + "small": "gpt-4o-mini", + "reasoning": "o1-preview", + "reasoning_small": "o1-mini" + } } ], "aliases": { From fd17d69509ca476daac1b8b0499e15471ba1f8c2 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 14:23:49 +0000 Subject: [PATCH 10/22] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20logprobs=20and?= =?UTF-8?q?=20topLogprobs=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/llms.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/src/llms.json b/packages/core/src/llms.json index 10e30279f..9537a2645 100644 --- a/packages/core/src/llms.json +++ b/packages/core/src/llms.json @@ -64,6 +64,8 @@ "detail": "Google AI", "seed": false, "tools": false, + "logprobs": false, + "topLogprobs": false, "openaiCompatibility": "https://ai.google.dev/gemini-api/docs/openai", "prediction": false, "bearerToken": true, From aa7f3340d046368b56d0f5cb01ef7e17d5faf9ec Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sat, 21 Dec 2024 04:36:40 +0000 Subject: [PATCH 11/22] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20aliases=20and?= =?UTF-8?q?=20logit=5Fbias=20support=20to=20providers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/src/components/LLMProviderFeatures.astro | 55 +++++++++++++++---- .../docs/getting-started/configuration.mdx | 2 +- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/docs/src/components/LLMProviderFeatures.astro b/docs/src/components/LLMProviderFeatures.astro index 164a625a9..104ff98f0 100644 --- a/docs/src/components/LLMProviderFeatures.astro +++ b/docs/src/components/LLMProviderFeatures.astro @@ -5,8 +5,11 @@ interface Props { provider: string } const { provider } = Astro.props -const info: Record & { openaiCompatibility?: string, limitations?: boolean } = - LLMS.providers.find(({ id }) => id === provider) as any +const info: Record & { + openaiCompatibility?: string + limitations?: boolean + aliases?: Record +} = LLMS.providers.find(({ id }) => id === provider) as any if (!info) { throw new Error(`Provider ${provider} not found`) } @@ -17,6 +20,9 @@ const features: Record = { topP: { name: "top_p ignored", }, + logitBias: { + name: "logit_bias ignored", + }, logprobs: { name: "logprobs (and top logprobs) ignored", }, @@ -26,31 +32,58 @@ const features: Record = { tools: { name: "Tools implemented as fallback tools automatically.", }, + prediction: { + name: "Ignore prediction of output tokens", + }, } -const { openaiCompatibility, limitations, ...rest } = info +const { openaiCompatibility, limitations, aliases, bearerToken, ...rest } = info const unsupported = Object.keys(rest) .sort() .map((id) => ({ id, supported: info[id] })) .filter(({ supported }) => supported === false) --- +{ + aliases && ( + <> +

Aliases

+

+ The following model aliases are attempted by default in + GenAIScript. +

+ + + + + + {Object.entries(aliases).map(([key, value]) => ( + + + + + ))} +
AliasModel identifier
{key}{value}
+ + ) +} + { openaiCompatibility || limitations || unsupported?.length > 0 ? ( <> -

Limitations

+

Limitations

    {!!limitations &&
  • {limitations}
  • } {!!openaiCompatibility && (
  • - Uses OpenAI compatibility layer + Uses{" "} + + OpenAI compatibility layer +
  • )} - {Object.keys(features) - .map((id) => ({ id, supported: info[id] })) - .filter(({ supported }) => supported === false) - .map(({ id }) => ( -
  • {features[id]?.name || id}
  • - ))} + {unsupported.map(({ id }) => ( +
  • {features[id]?.name || id}
  • + ))}
) : null diff --git a/docs/src/content/docs/getting-started/configuration.mdx b/docs/src/content/docs/getting-started/configuration.mdx index 1123382b1..00ec0dc96 100644 --- a/docs/src/content/docs/getting-started/configuration.mdx +++ b/docs/src/content/docs/getting-started/configuration.mdx @@ -984,7 +984,7 @@ script({ - + ## Alibaba Cloud From c7958a122cf52621ff02e4be44a347f91a5006dc Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sat, 21 Dec 2024 04:39:59 +0000 Subject: [PATCH 12/22] =?UTF-8?q?feat:=20=F0=9F=94=A7=20add=20`info=20mode?= =?UTF-8?q?ls=20alias`=20command=20to=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/docs/reference/cli/commands.md | 36 +++++++++++++------ packages/cli/src/cli.ts | 18 ++++++---- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 88c0b720e..6093a2fa5 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -252,17 +252,6 @@ Options: -h, --help display help for command ``` -## `models` - -``` -Usage: genaiscript models [options] - -List model information - -Options: - -h, --help display help for command -``` - ## `cache` ``` @@ -515,6 +504,7 @@ Commands: help Show help for all commands system Show system information env [options] [provider] Show .env information + models ``` ### `info help` @@ -552,3 +542,27 @@ Options: -m, --models show models if possible -h, --help display help for command ``` + +### `info models` + +``` +Usage: genaiscript info models [options] [command] + +Options: + -h, --help display help for command + +Commands: + alias Show model alias mapping + help [command] display help for command +``` + +#### `models alias` + +``` +Usage: genaiscript info models alias [options] + +Show model alias mapping + +Options: + -h, --help display help for command +``` diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 88002cb16..29fed0de6 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -24,7 +24,7 @@ import { } from "./parse" // Parsing functions import { compileScript, createScript, fixScripts, listScripts } from "./scripts" // Script utilities import { codeQuery } from "./codequery" // Code parsing and query execution -import { envInfo, modelsInfo, scriptModelInfo, systemInfo } from "./info" // Information utilities +import { envInfo, modelsInfo as modelAliasesInfo, scriptModelInfo, systemInfo } from "./info" // Information utilities import { scriptTestList, scriptTestsView, scriptsTest } from "./test" // Test functions import { cacheClear } from "./cache" // Cache management import "node:console" // Importing console for side effects @@ -254,7 +254,10 @@ export async function cli() { ) .arguments("