Skip to content

Commit 8d80efd

Browse files
committed
Revert "refactor: split up models.dev and config model definitions to prevent coupling (#20605)"
This reverts commit 23c8656.
1 parent 8512e70 commit 8d80efd

File tree

4 files changed

+26
-70
lines changed

4 files changed

+26
-70
lines changed

packages/opencode/src/config/config.ts

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -730,77 +730,28 @@ export namespace Config {
730730
})
731731
export type Layout = z.infer<typeof Layout>
732732

733-
export const Model = z
734-
.object({
735-
id: z.string(),
736-
name: z.string(),
737-
family: z.string().optional(),
738-
release_date: z.string(),
739-
attachment: z.boolean(),
740-
reasoning: z.boolean(),
741-
temperature: z.boolean(),
742-
tool_call: z.boolean(),
743-
interleaved: z
744-
.union([
745-
z.literal(true),
746-
z
747-
.object({
748-
field: z.enum(["reasoning_content", "reasoning_details"]),
749-
})
750-
.strict(),
751-
])
752-
.optional(),
753-
cost: z
754-
.object({
755-
input: z.number(),
756-
output: z.number(),
757-
cache_read: z.number().optional(),
758-
cache_write: z.number().optional(),
759-
context_over_200k: z
760-
.object({
761-
input: z.number(),
762-
output: z.number(),
763-
cache_read: z.number().optional(),
764-
cache_write: z.number().optional(),
765-
})
766-
.optional(),
767-
})
768-
.optional(),
769-
limit: z.object({
770-
context: z.number(),
771-
input: z.number().optional(),
772-
output: z.number(),
773-
}),
774-
modalities: z
775-
.object({
776-
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
777-
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
778-
})
779-
.optional(),
780-
experimental: z.boolean().optional(),
781-
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
782-
options: z.record(z.string(), z.any()),
783-
headers: z.record(z.string(), z.string()).optional(),
784-
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
785-
variants: z
786-
.record(
787-
z.string(),
788-
z
789-
.object({
790-
disabled: z.boolean().optional().describe("Disable this variant for the model"),
791-
})
792-
.catchall(z.any()),
793-
)
794-
.optional()
795-
.describe("Variant-specific configuration"),
796-
})
797-
.partial()
798-
799733
export const Provider = ModelsDev.Provider.partial()
800734
.extend({
801735
whitelist: z.array(z.string()).optional(),
802736
blacklist: z.array(z.string()).optional(),
803-
models: z.record(z.string(), Model).optional(),
737+
models: z
738+
.record(
739+
z.string(),
740+
ModelsDev.Model.partial().extend({
741+
variants: z
742+
.record(
743+
z.string(),
744+
z
745+
.object({
746+
disabled: z.boolean().optional().describe("Disable this variant for the model"),
747+
})
748+
.catchall(z.any()),
749+
)
750+
.optional()
751+
.describe("Variant-specific configuration"),
752+
}),
753+
)
754+
.optional(),
804755
options: z
805756
.object({
806757
apiKey: z.string().optional(),

packages/opencode/src/provider/models.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ export namespace ModelsDev {
6161
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
6262
})
6363
.optional(),
64+
experimental: z.boolean().optional(),
6465
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
66+
options: z.record(z.string(), z.any()),
67+
headers: z.record(z.string(), z.string()).optional(),
6568
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
69+
variants: z.record(z.string(), z.record(z.string(), z.any())).optional(),
6670
})
6771
export type Model = z.infer<typeof Model>
6872

packages/opencode/src/provider/provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ export namespace Provider {
903903
npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible",
904904
},
905905
status: model.status ?? "active",
906-
headers: {},
907-
options: {},
906+
headers: model.headers ?? {},
907+
options: model.options ?? {},
908908
cost: {
909909
input: model.cost?.input ?? 0,
910910
output: model.cost?.output ?? 0,

packages/opencode/src/session/llm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Provider } from "@/provider/provider"
22
import { Log } from "@/util/log"
3-
import { Effect, Layer, Record, ServiceMap } from "effect"
3+
import { Cause, Effect, Layer, Record, ServiceMap } from "effect"
4+
import * as Queue from "effect/Queue"
45
import * as Stream from "effect/Stream"
56
import { streamText, wrapLanguageModel, type ModelMessage, type Tool, tool, jsonSchema } from "ai"
67
import { mergeDeep, pipe } from "remeda"

0 commit comments

Comments
 (0)