refactor(core): simplify model requests

This commit is contained in:
Dax Raad
2026-06-24 10:51:41 -04:00
parent 116ac93ddb
commit 17f312d537
21 changed files with 56 additions and 685 deletions

View File

@@ -7,7 +7,6 @@ export { Integration } from "./integration"
export { LLM } from "./llm"
export { Location } from "./location"
export { Model } from "./model"
export { ModelRequest } from "./model-request"
export { Permission } from "./permission"
export { Project } from "./project"
export { Provider } from "./provider"

View File

@@ -1,31 +0,0 @@
export * as ModelRequest from "./model-request"
import { Effect, Schema } from "effect"
import { Provider } from "./provider"
export interface Generation extends Schema.Schema.Type<typeof Generation> {}
export const Generation = Schema.Struct({
maxTokens: Schema.Number.pipe(Schema.optional),
temperature: Schema.Number.pipe(Schema.optional),
topP: Schema.Number.pipe(Schema.optional),
topK: Schema.Number.pipe(Schema.optional),
frequencyPenalty: Schema.Number.pipe(Schema.optional),
presencePenalty: Schema.Number.pipe(Schema.optional),
seed: Schema.Number.pipe(Schema.optional),
stop: Schema.String.pipe(Schema.Array, Schema.mutable, Schema.optional),
})
export interface Request extends Schema.Schema.Type<typeof Request> {}
export const Request = Schema.Struct({
...Provider.Request.fields,
generation: Generation.pipe(
Schema.optionalKey,
Schema.withConstructorDefault(Effect.succeed({})),
Schema.withDecodingDefaultKey(Effect.succeed({})),
),
options: Schema.Record(Schema.String, Schema.Any).pipe(
Schema.optionalKey,
Schema.withConstructorDefault(Effect.succeed({})),
Schema.withDecodingDefaultKey(Effect.succeed({})),
),
})

View File

@@ -1,7 +1,6 @@
export * as Model from "./model"
import { Schema } from "effect"
import { ModelRequest } from "./model-request"
import { Provider } from "./provider"
import { withStatics } from "./schema"
@@ -63,12 +62,12 @@ export const Info = Schema.Struct({
api: Api,
capabilities: Capabilities,
request: Schema.Struct({
...ModelRequest.Request.fields,
...Provider.Request.fields,
variant: Schema.String.pipe(Schema.optional),
}),
variants: Schema.Struct({
id: VariantID,
...ModelRequest.Request.fields,
...Provider.Request.fields,
}).pipe(Schema.Array, Schema.mutable),
time: Schema.Struct({
released: Schema.Finite,
@@ -92,7 +91,7 @@ export const Info = Schema.Struct({
name: modelID,
api: { id: modelID, type: "native", settings: {} },
capabilities: { tools: false, input: [], output: [] },
request: { headers: {}, body: {}, generation: {}, options: {} },
request: { headers: {}, body: {} },
variants: [],
time: { released: 0 },
cost: [],