MCPcopy Index your code
hub / github.com/anomalyco/opencode / applyModel

Function applyModel

packages/core/src/plugin/models-dev.ts:76–117  ·  view source on GitHub ↗
(
  draft: ModelV2Info,
  model: ModelsDev.Model,
  input: {
    readonly name?: string
    readonly cost?: ModelV2Info["cost"]
    readonly request?: NonNullable<NonNullable<ModelsDev.Model["experimental"]>["modes"]>[string]["provider"]
  } = {},
)

Source from the content-addressed store, hash-verified

74}
75
76function applyModel(
77 draft: ModelV2Info,
78 model: ModelsDev.Model,
79 input: {
80 readonly name?: string
81 readonly cost?: ModelV2Info["cost"]
82 readonly request?: NonNullable<NonNullable<ModelsDev.Model["experimental"]>["modes"]>[string]["provider"]
83 } = {},
84) {
85 draft.name = input.name ?? model.name
86 draft.family = model.family
87 draft.api = model.provider?.npm
88 ? {
89 id: model.id,
90 type: "aisdk",
91 package: model.provider.npm,
92 url: model.provider.api,
93 }
94 : {
95 id: model.id,
96 type: "native",
97 url: model.provider?.api,
98 settings: {},
99 }
100 draft.capabilities = {
101 tools: model.tool_call,
102 input: [...(model.modalities?.input ?? [])],
103 output: [...(model.modalities?.output ?? [])],
104 }
105 draft.variants = []
106 draft.time.released = released(model.release_date)
107 draft.cost = input.cost ?? cost(model.cost)
108 draft.status = model.status ?? "active"
109 draft.enabled = true
110 draft.limit = {
111 context: model.limit.context,
112 input: model.limit.input,
113 output: model.limit.output,
114 }
115 Object.assign(draft.request.headers, input.request?.headers ?? {})
116 Object.assign(draft.request.body, input.request?.body ?? {})
117}
118
119export const ModelsDevPlugin = define({
120 id: "models-dev",

Callers 1

models-dev.tsFile · 0.85

Calls 2

releasedFunction · 0.85
costFunction · 0.70

Tested by

no test coverage detected