-
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.
Add model alias configuration support and documentation (#941)
* feat: π§ add model alias configuration support * feat: π add model aliases support and documentation
- Loading branch information
Showing
10 changed files
with
155 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: Model Aliases | ||
description: Give friendly names to models | ||
sidebar: | ||
order: 60 | ||
--- | ||
|
||
You can define **model aliases** in your project to give friendly names to models and abstract away from a particular model version/tag. | ||
|
||
So instead of hard-coding a model type, | ||
|
||
```js 'model: "openai:gpt-4o"' | ||
script({ | ||
model: "openai:gpt-4o", | ||
}) | ||
``` | ||
|
||
You can use/define an alias like `large`. | ||
|
||
```js 'model: "large"' | ||
script({ | ||
model: "large", | ||
}) | ||
``` | ||
|
||
Model aliases can be defined as environment varialbles (through the `.env` file), | ||
in a configuration file or through the [cli](/genaiscript/reference/cli/run). | ||
|
||
This `.env` file defines a `llama32` alias for the `ollama:llama3.2:1b` model. | ||
|
||
```txt title=".env" | ||
GENAISCRIPT_MODEL_LLAMA32="ollama:llama3.2:1b" | ||
``` | ||
|
||
You can then use the `llama32` alias in your scripts. | ||
|
||
```js 'model: "llama32"' | ||
script({ | ||
model: "llama32", | ||
}) | ||
``` | ||
|
||
## Defining aliases | ||
|
||
The following configuration are support in order importance (last one wins): | ||
|
||
- [configuration file](/genaiscript/reference/configuration-files) with the `modelAliases` field | ||
|
||
```json title="genaiscript.config.js" | ||
{ | ||
"modelAliases": { | ||
"llama32": "ollama:llama3.2:1b" | ||
} | ||
} | ||
``` | ||
|
||
- environment variables with keys of the pattern `GENAISCRIPT_MODEL_ALIAS=...` | ||
- [cli](/genaiscript/reference/cli/run) with the `--model-alias` flag | ||
|
||
```sh | ||
genaiscript run --model-alias llama32=ollama:llama3.2:1b | ||
``` | ||
|
||
## Builtin aliases | ||
|
||
By default, GenAIScript supports the following model aliases: | ||
|
||
- `large`: `gpt-4o like` model | ||
- `small`: `gpt-4o-mini` model or similar. A smaller, cheaper faster model | ||
- `vision`: `gpt-4o-mini`. A model that can analyze images |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
{ | ||
"$schema": "../../core/src/schemas/hostconfiguration.schema.json", | ||
"include": ["../../genaisrc/*.genai.mts"] | ||
"include": ["../../genaisrc/*.genai.mts"], | ||
"modelAliases": { | ||
"llama32": "ollama:llama3.2:1b", | ||
"llama32hot": { | ||
"model": "ollama:llama3.2:1b", | ||
"temperature": 2 | ||
} | ||
} | ||
} |