-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add support for LLM provider aliases and options
- Loading branch information
Showing
11 changed files
with
93 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { MODEL_PROVIDERS } from "../../core/src/constants" | ||
import { parseKeyValuePair } from "../../core/src/fence" | ||
import { runtimeHost } from "../../core/src/host" | ||
import { logVerbose } from "../../core/src/util" | ||
import { PromptScriptRunOptions } from "./main" | ||
|
||
export function applyModelOptions( | ||
options: Partial< | ||
Pick< | ||
PromptScriptRunOptions, | ||
"model" | "smallModel" | "visionModel" | "modelAlias" | "provider" | ||
> | ||
> | ||
) { | ||
if (options.provider) { | ||
const provider = MODEL_PROVIDERS.find((p) => p.id === options.provider) | ||
if (!provider) | ||
throw new Error(`Model provider not found: ${options.provider}`) | ||
for (const [key, value] of Object.entries(provider.aliases || {})) | ||
runtimeHost.setModelAlias("cli", key, provider.id + ":" + value) | ||
} | ||
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)) | ||
runtimeHost.setModelAlias("cli", key, value) | ||
} | ||
|
||
const modelAlias = runtimeHost.modelAliases | ||
if (Object.values(modelAlias).some((m) => m.source !== "default")) | ||
Object.entries(runtimeHost.modelAliases).forEach(([key, value]) => | ||
logVerbose(` ${key}: ${value.model} (${value.source})`) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters