model-request.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. export * as ModelRequest from "./model-request"
  2. import { Effect, Schema } from "effect"
  3. import { Provider } from "./provider"
  4. export interface Generation extends Schema.Schema.Type<typeof Generation> {}
  5. export const Generation = Schema.Struct({
  6. maxTokens: Schema.Number.pipe(Schema.optional),
  7. temperature: Schema.Number.pipe(Schema.optional),
  8. topP: Schema.Number.pipe(Schema.optional),
  9. topK: Schema.Number.pipe(Schema.optional),
  10. frequencyPenalty: Schema.Number.pipe(Schema.optional),
  11. presencePenalty: Schema.Number.pipe(Schema.optional),
  12. seed: Schema.Number.pipe(Schema.optional),
  13. stop: Schema.String.pipe(Schema.Array, Schema.mutable, Schema.optional),
  14. })
  15. export interface Request extends Schema.Schema.Type<typeof Request> {}
  16. export const Request = Schema.Struct({
  17. ...Provider.Request.fields,
  18. generation: Generation.pipe(
  19. Schema.optionalKey,
  20. Schema.withConstructorDefault(Effect.succeed({})),
  21. Schema.withDecodingDefaultKey(Effect.succeed({})),
  22. ),
  23. options: Schema.Record(Schema.String, Schema.Any).pipe(
  24. Schema.optionalKey,
  25. Schema.withConstructorDefault(Effect.succeed({})),
  26. Schema.withDecodingDefaultKey(Effect.succeed({})),
  27. ),
  28. })