Skip to content

Commit

Permalink
feat: log verbose model alias resolution 🔍
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 10, 2024
1 parent 05a818b commit 5da0289
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/azuretoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function createAzureToken(

// Log the expiration time of the token
logVerbose(
`azure token expires at ${new Date(res.expiresOnTimestamp).toLocaleString()}`
`azure: token expires at ${new Date(res.expiresOnTimestamp).toLocaleString()}`
)

return res
Expand Down
19 changes: 16 additions & 3 deletions packages/core/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { errorMessage } from "./error"
import { LanguageModelConfiguration, host, runtimeHost } from "./host"
import { AbortSignalOptions, MarkdownTrace, TraceOptions } from "./trace"
import { assert } from "./util"
import { assert, logVerbose } from "./util"

/**
* model
Expand Down Expand Up @@ -127,8 +127,21 @@ export async function resolveModelConnectionInfo(
...DEFAULT_MODEL_CANDIDATES,
]

// apply model alias
m = runtimeHost.modelAliases[m]?.model || m
// recursively resolve model aliases
if (m) {
const seen = [m]
const modelAliases = runtimeHost.modelAliases
while (modelAliases[m]) {
const alias = modelAliases[m].model
if (seen.includes(alias))
throw new Error(
`Circular model alias: ${alias}, seen ${[...seen].join(",")}`
)
m = alias
seen.push(m)
}
if (seen.length > 1) logVerbose(`model_aliases: ${seen.join(" -> ")}`)
}

const resolveModel = async (
model: string,
Expand Down

0 comments on commit 5da0289

Please sign in to comment.