structured-outputs 0.1.0-beta.22 → 0.1.0-beta.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/README.md +1 -1
  2. package/esm/ResponseFormat.d.ts +8 -8
  3. package/esm/ResponseFormat.d.ts.map +1 -1
  4. package/esm/ResponseFormat.js +4 -7
  5. package/esm/ResponseFormat.js.map +1 -1
  6. package/esm/Tool.d.ts +2 -3
  7. package/esm/Tool.d.ts.map +1 -1
  8. package/esm/Tool.js +2 -3
  9. package/esm/Tool.js.map +1 -1
  10. package/esm/types/Ty.d.ts +19 -12
  11. package/esm/types/Ty.d.ts.map +1 -1
  12. package/esm/types/Ty.js +28 -7
  13. package/esm/types/Ty.js.map +1 -1
  14. package/esm/types/array.d.ts +1 -1
  15. package/esm/types/array.d.ts.map +1 -1
  16. package/esm/types/array.js +1 -1
  17. package/esm/types/array.js.map +1 -1
  18. package/esm/types/constantUnion.d.ts +1 -1
  19. package/esm/types/constantUnion.d.ts.map +1 -1
  20. package/esm/types/constantUnion.js +1 -1
  21. package/esm/types/constantUnion.js.map +1 -1
  22. package/esm/types/mod.d.ts +2 -3
  23. package/esm/types/mod.d.ts.map +1 -1
  24. package/esm/types/mod.js +2 -3
  25. package/esm/types/mod.js.map +1 -1
  26. package/esm/types/object.d.ts +3 -4
  27. package/esm/types/object.d.ts.map +1 -1
  28. package/esm/types/object.js +3 -3
  29. package/esm/types/object.js.map +1 -1
  30. package/esm/types/primitives.d.ts +4 -4
  31. package/esm/types/primitives.d.ts.map +1 -1
  32. package/esm/types/primitives.js +4 -4
  33. package/esm/types/primitives.js.map +1 -1
  34. package/esm/types/std/Date.d.ts +4 -0
  35. package/esm/types/std/Date.d.ts.map +1 -0
  36. package/esm/types/std/Date.js +14 -0
  37. package/esm/types/std/Date.js.map +1 -0
  38. package/esm/types/std/Option.d.ts +3 -2
  39. package/esm/types/std/Option.d.ts.map +1 -1
  40. package/esm/types/std/Option.js +1 -1
  41. package/esm/types/std/color.d.ts +8 -0
  42. package/esm/types/std/color.d.ts.map +1 -0
  43. package/esm/types/std/color.js +13 -0
  44. package/esm/types/std/color.js.map +1 -0
  45. package/esm/types/std/mod.d.ts +2 -0
  46. package/esm/types/std/mod.d.ts.map +1 -1
  47. package/esm/types/std/mod.js +2 -0
  48. package/esm/types/std/mod.js.map +1 -1
  49. package/esm/types/taggedUnion.d.ts +1 -1
  50. package/esm/types/taggedUnion.d.ts.map +1 -1
  51. package/esm/types/taggedUnion.js +20 -14
  52. package/esm/types/taggedUnion.js.map +1 -1
  53. package/esm/types/transform.d.ts +3 -0
  54. package/esm/types/transform.d.ts.map +1 -0
  55. package/esm/types/transform.js +5 -0
  56. package/esm/types/transform.js.map +1 -0
  57. package/esm/types/tuple.d.ts +5 -0
  58. package/esm/types/tuple.d.ts.map +1 -0
  59. package/esm/types/tuple.js +11 -0
  60. package/esm/types/tuple.js.map +1 -0
  61. package/esm/util/recombine.d.ts +2 -0
  62. package/esm/util/recombine.d.ts.map +1 -0
  63. package/esm/util/recombine.js +4 -0
  64. package/esm/util/recombine.js.map +1 -0
  65. package/package.json +1 -1
  66. package/src/ResponseFormat.ts +14 -17
  67. package/src/Tool.ts +5 -6
  68. package/src/types/Ty.ts +71 -30
  69. package/src/types/array.ts +9 -5
  70. package/src/types/constantUnion.ts +2 -2
  71. package/src/types/mod.ts +2 -3
  72. package/src/types/object.ts +15 -9
  73. package/src/types/primitives.ts +8 -8
  74. package/src/types/std/Date.ts +19 -0
  75. package/src/types/std/Option.ts +2 -2
  76. package/src/types/std/color.ts +27 -0
  77. package/src/types/std/mod.ts +2 -0
  78. package/src/types/taggedUnion.ts +28 -15
  79. package/src/types/transform.ts +8 -0
  80. package/src/types/tuple.ts +17 -0
  81. package/src/util/recombine.ts +3 -0
  82. package/esm/oai.d.ts +0 -5
  83. package/esm/oai.d.ts.map +0 -1
  84. package/esm/oai.js +0 -2
  85. package/esm/oai.js.map +0 -1
  86. package/esm/types/Ref.d.ts +0 -4
  87. package/esm/types/Ref.d.ts.map +0 -1
  88. package/esm/types/Ref.js +0 -14
  89. package/esm/types/Ref.js.map +0 -1
  90. package/esm/types/RootTy.d.ts +0 -8
  91. package/esm/types/RootTy.d.ts.map +0 -1
  92. package/esm/types/RootTy.js +0 -17
  93. package/esm/types/RootTy.js.map +0 -1
  94. package/esm/types/constant.d.ts +0 -3
  95. package/esm/types/constant.d.ts.map +0 -1
  96. package/esm/types/constant.js +0 -7
  97. package/esm/types/constant.js.map +0 -1
  98. package/esm/util/phantoms.d.ts +0 -2
  99. package/esm/util/phantoms.d.ts.map +0 -1
  100. package/esm/util/phantoms.js +0 -4
  101. package/esm/util/phantoms.js.map +0 -1
  102. package/esm/util/recombineTaggedTemplateArgs.d.ts +0 -2
  103. package/esm/util/recombineTaggedTemplateArgs.d.ts.map +0 -1
  104. package/esm/util/recombineTaggedTemplateArgs.js +0 -4
  105. package/esm/util/recombineTaggedTemplateArgs.js.map +0 -1
  106. package/src/oai.ts +0 -5
  107. package/src/types/Ref.ts +0 -19
  108. package/src/types/RootTy.ts +0 -38
  109. package/src/types/constant.ts +0 -7
  110. package/src/util/phantoms.ts +0 -3
  111. package/src/util/recombineTaggedTemplateArgs.ts +0 -6
@@ -1 +0,0 @@
1
- {"version":3,"file":"RootTy.js","sourceRoot":"","sources":["../../src/types/RootTy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B,MAAM,UAAU,MAAM,CACpB,QAAkB,EAClB,UAA0B,EAAE,EAC5B,UAAmB,EAAE;IAErB,OAAO,MAAM,CAAC,MAAM,CAClB,CAA2B,QAA8B,EAAE,GAAG,SAAa,EAAE,EAAE,CAC7E,MAAM,CAAoB,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EACrF,QAAQ,EAAkB,EAC1B;QACE,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE;QAClC,IAAI,EAAE,CAAgD,MAAS,EAAE,EAAE;YACjE,OAAO,MAAM,CAAyB,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;QACrF,CAAC;QACD,MAAM;YACJ,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,MAAM;YACJ,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CACF,CAAA;AACH,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Ty } from "./Ty.js";
2
- export declare function constant<V extends number | string>(value: V): Ty<V, never>;
3
- //# sourceMappingURL=constant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/types/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAI1E"}
@@ -1,7 +0,0 @@
1
- import { Ty } from "./Ty.js";
2
- export function constant(value) {
3
- return Ty(() => ({
4
- const: value,
5
- }));
6
- }
7
- //# sourceMappingURL=constant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/types/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,UAAU,QAAQ,CAA4B,KAAQ;IAC1D,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,KAAK,EAAE,KAAK;KACb,CAAC,CAAC,CAAA;AACL,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function phantoms<T>(): T;
2
- //# sourceMappingURL=phantoms.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phantoms.d.ts","sourceRoot":"","sources":["../../src/util/phantoms.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,KAAK,CAAC,CAE/B"}
@@ -1,4 +0,0 @@
1
- export function phantoms() {
2
- return {};
3
- }
4
- //# sourceMappingURL=phantoms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phantoms.js","sourceRoot":"","sources":["../../src/util/phantoms.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ;IACtB,OAAO,EAAO,CAAA;AAChB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function recombineTaggedTemplateArgs(strings: TemplateStringsArray, values: Array<number | string>): string;
2
- //# sourceMappingURL=recombineTaggedTemplateArgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recombineTaggedTemplateArgs.d.ts","sourceRoot":"","sources":["../../src/util/recombineTaggedTemplateArgs.ts"],"names":[],"mappings":"AAAA,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAC7B,MAAM,CAER"}
@@ -1,4 +0,0 @@
1
- export function recombineTaggedTemplateArgs(strings, values) {
2
- return strings.reduce((acc, cur, i) => `${acc}${cur}${values[i] ?? ""}`, "");
3
- }
4
- //# sourceMappingURL=recombineTaggedTemplateArgs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recombineTaggedTemplateArgs.js","sourceRoot":"","sources":["../../src/util/recombineTaggedTemplateArgs.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,2BAA2B,CACzC,OAA6B,EAC7B,MAA8B;IAE9B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAC9E,CAAC"}
package/src/oai.ts DELETED
@@ -1,5 +0,0 @@
1
- import type Openai from "openai"
2
-
3
- export type JsonSchema = Openai.ResponseFormatJSONSchema["json_schema"]
4
- export type ChatCompletion = Openai.Chat.ChatCompletion
5
- export type ChatCompletionChoice = Openai.Chat.Completions.ChatCompletion.Choice
package/src/types/Ref.ts DELETED
@@ -1,19 +0,0 @@
1
- import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js"
2
- import type { Applied, Schema, Ty } from "./Ty.js"
3
-
4
- export type Ref = (ty: Ty) => Schema
5
-
6
- export function Ref(applied: Applied): Ref {
7
- return (ty) => {
8
- applied = { ...applied, ...ty[""].applied }
9
- const description = ty[""].context
10
- .map(({ template, placeheld }) =>
11
- recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k]!))
12
- )
13
- .join(" ")
14
- return {
15
- ...ty[""].toSchema(Ref(applied)),
16
- ...description ? { description } : {},
17
- }
18
- }
19
- }
@@ -1,38 +0,0 @@
1
- import { phantoms } from "../util/phantoms.js"
2
- import { Ref } from "./Ref.js"
3
- import type { Applied, Context, Schema, ToSchema, Ty } from "./Ty.js"
4
-
5
- export function RootTy<T, P extends keyof any = never>(
6
- toSchema: ToSchema,
7
- context: Array<Context> = [],
8
- applied: Applied = {},
9
- ): RootTy<T, P> {
10
- return Object.assign(
11
- <P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
12
- RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...context], applied),
13
- phantoms<{ T: T; P: P }>(),
14
- {
15
- "": { toSchema, context, applied },
16
- fill: <A extends Partial<Record<P, string | number>>>(values: A) => {
17
- return RootTy<T, Exclude<P, keyof A>>(toSchema, context, { ...applied, ...values })
18
- },
19
- schema(this: RootTy<T, never>) {
20
- return Ref({})(this)
21
- },
22
- isRoot(): this is RootTy {
23
- return true
24
- },
25
- },
26
- )
27
- }
28
-
29
- export interface RootTy<T = any, P extends keyof any = keyof any> extends Ty<T, P> {
30
- <P2 extends Array<keyof any>>(
31
- template: TemplateStringsArray,
32
- ...placeheld: P2
33
- ): RootTy<T, P | P2[number]>
34
- fill: <A extends Partial<Record<P, number | string>>>(
35
- values: A,
36
- ) => RootTy<T, Exclude<P, keyof A>>
37
- schema(this: RootTy<T, never>): Schema
38
- }
@@ -1,7 +0,0 @@
1
- import { Ty } from "./Ty.js"
2
-
3
- export function constant<V extends number | string>(value: V): Ty<V, never> {
4
- return Ty(() => ({
5
- const: value,
6
- }))
7
- }
@@ -1,3 +0,0 @@
1
- export function phantoms<T>(): T {
2
- return {} as T
3
- }
@@ -1,6 +0,0 @@
1
- export function recombineTaggedTemplateArgs(
2
- strings: TemplateStringsArray,
3
- values: Array<number | string>,
4
- ): string {
5
- return strings.reduce((acc, cur, i) => `${acc}${cur}${values[i] ?? ""}`, "")
6
- }