-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -471,7 +471,9 @@ | |
"web", | ||
"search the web to accomplish tasks.", | ||
`Your are a helpful LLM agent that can use web search. | ||
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 commentThe 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.
|
||
{ | ||
system: [ | ||
"system.safety_jailbreak", | ||
|
@@ -3060,7 +3062,8 @@ | |
count, | ||
ignoreMissingProvider: true, | ||
}) | ||
if (!webPages) return "error: no web search provider configured" | ||
if (!webPages) | ||
return "error: no web search provider configured (https://microsoft.github.io/genaiscript/reference/scripts/web-search/)" | ||
return YAML.stringify( | ||
webPages.map((f) => ({ | ||
url: f.filename, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,14 @@ | |
} | ||
} | ||
|
||
export function applyScriptModelAliases(script: PromptScript) { | ||
applyModelOptions(script, "script") | ||
if (script.modelAliases) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. The function
|
||
|
||
export function logModelAliases() { | ||
const modelAlias = runtimeHost.modelAliases | ||
if (Object.values(modelAlias).some((m) => m.source !== "default")) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,11 @@ | |
stdout, | ||
} from "../../core/src/logging" | ||
import { ensureDotGenaiscriptPath, setupTraceWriting } from "./trace" | ||
import { applyModelOptions, logModelAliases } from "./modelalias" | ||
import { | ||
applyModelOptions, | ||
applyScriptModelAliases, | ||
logModelAliases, | ||
} from "./modelalias" | ||
import { createCancellationController } from "./cancel" | ||
import { parsePromptScriptMeta } from "../../core/src/template" | ||
import { Fragment } from "../../core/src/generation" | ||
|
@@ -351,7 +355,7 @@ | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. The function call
|
||
logModelAliases() | ||
const { info } = await resolveModelConnectionInfo(script, { | ||
trace, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,10 +270,15 @@ | |
smallModel?: ModelSmallType | ||
|
||
/** | ||
* Configure the `vision` model alias. | ||
*/ | ||
visionModel?: ModelVisionType | ||
|
||
/** | ||
* A list of model aliases to use. | ||
*/ | ||
modelAliases?: Record<string, string> | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The field
|
||
|
||
interface ModelOptions extends ModelConnectionOptions, ModelTemplateOptions { | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
script({ | ||
model: "foo", | ||
modelAliases: { foo: "small" }, | ||
}) | ||
$`Write a poem.` |
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".