mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
refactor(ai,core): drop redundant typeof check on endpoint.baseURL (#57597)
This commit is contained in:
committed by
GitHub
Unverified
parent
6843fb7b9c
commit
c600cddc68
@@ -132,7 +132,7 @@ const makeRouteLanguageModel = <Options extends ProviderOptions, Compact extends
|
||||
) => {
|
||||
const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined)
|
||||
if (!provider) throw new Error(`Route.model(${route.id}) requires a provider`)
|
||||
if (!endpointBaseURL(route.endpoint))
|
||||
if (!route.endpoint.baseURL)
|
||||
throw new ProviderConfigurationError({
|
||||
provider: ProviderID.make(provider),
|
||||
message: `Route.model(${route.id}) requires an endpoint baseURL — configure it on the route first`,
|
||||
@@ -160,9 +160,6 @@ const mergeRouteDefaults = (base: RouteDefaults | undefined, patch: RouteDefault
|
||||
}
|
||||
}
|
||||
|
||||
const endpointBaseURL = <Body>(endpoint: Endpoint.Definition<Body>) =>
|
||||
typeof endpoint.baseURL === "string" ? endpoint.baseURL : undefined
|
||||
|
||||
const mergeHeaders = (...items: ReadonlyArray<Record<string, string> | undefined>) => {
|
||||
const entries = items.flatMap((item) =>
|
||||
item === undefined ? [] : Object.entries(item).filter((entry): entry is [string, string] => entry[1] !== undefined),
|
||||
|
||||
@@ -304,7 +304,7 @@ export const layer = Layer.effect(
|
||||
const baseURL = base.model.route.endpoint.baseURL
|
||||
const modelHook = yield* hooks.trigger("session", "model.request", {
|
||||
...scope,
|
||||
baseURL: typeof baseURL === "string" ? baseURL : undefined,
|
||||
baseURL,
|
||||
headers: { ...base.http?.headers },
|
||||
})
|
||||
const route =
|
||||
|
||||
Reference in New Issue
Block a user