-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for model aliases in script function #1164
Conversation
Model aliases can now be defined directly in the script function.
@@ -24,7 +24,7 @@ script({ | |||
``` | |||
|
|||
Model aliases can be defined as environment varialbles (through the `.env` file), | |||
in a configuration file or through the [cli](/genaiscript/reference/cli/run). | |||
in a configuration file, through the [cli](/genaiscript/reference/cli/run) or in the `script` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in "environment varialbles" should be "environment variables".
AI-generated content by pr-docs-review-commit
model_alias_typo
may be incorrect
Answer the question in <QUERY>.`, | ||
Search the web and answer the question in <QUERY>. | ||
- Expand <QUERY> into an optimized search query for better results. | ||
- Answer exclusively with live information from the web.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message should include a link to the web search documentation for better user guidance.
AI-generated content by pr-docs-review-commit
web_search_error_message
may be incorrect
Object.entries(script.modelAliases).forEach(([name, alias]) => { | ||
runtimeHost.setModelAlias("script", name, alias) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function applyScriptModelAliases
is not used anywhere in the codebase and can be removed to clean up the code.
AI-generated content by pr-review-commit
unnecessary_function
may be incorrect
/** | ||
* A list of model aliases to use. | ||
*/ | ||
modelAliases?: Record<string, string> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field modelAliases
in the interface ModelAliasesOptions
is defined but not used anywhere in the codebase and can be removed to clean up the code.
AI-generated content by pr-review-commit
unused_interface_field
may be incorrect
@@ -351,7 +355,7 @@ export async function runScriptInternal( | |||
const stats = new GenerationStats("") | |||
try { | |||
if (options.label) trace.heading(2, options.label) | |||
applyModelOptions(script, "script") | |||
applyScriptModelAliases(script) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function call applyScriptModelAliases(script)
is unnecessary as it's already called in the previous line. This can be simplified by removing one of the calls to avoid redundancy.
AI-generated content by pr-review-commit
unnecessary_function_call
may be incorrect
Define model aliases directly within the script function, enhancing flexibility in model management. This update allows users to specify aliases in the script, alongside existing methods like environment variables and configuration files.
Summary of Changes
✨ Added support for defining model aliases in the
script
function:modelAliases
property in thescript
function to define model aliases directly in scripts.🛠️ Improved error handling for web search:
📖 Documentation updates:
🧩 New helper function:
applyScriptModelAliases
to handle model alias definitions within scripts.🗂️ Sample script added:
model-alias.genai.mjs
) showcasing the newmodelAliases
functionality.These changes enhance flexibility in model alias configuration and improve usability and clarity in both the codebase and documentation. 🚀