structured-outputs 0.1.0-beta.20 → 0.1.0-beta.21
Sign up to get free protection for your applications and to get access to all the features.
- package/esm/ResponseFormat.d.ts +21 -0
- package/esm/ResponseFormat.d.ts.map +1 -0
- package/esm/ResponseFormat.js +43 -19
- package/esm/ResponseFormat.js.map +1 -1
- package/esm/oai.d.ts +5 -0
- package/esm/oai.d.ts.map +1 -0
- package/esm/oai.js +2 -0
- package/esm/oai.js.map +1 -0
- package/package.json +5 -10
- package/src/ResponseFormat.ts +48 -41
- package/src/oai.ts +5 -0
- package/esm/_dnt.shims.js +0 -58
- package/esm/_dnt.shims.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/almost_equals.js +0 -47
- package/esm/deps/jsr.io/@std/assert/1.0.8/almost_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/array_includes.js +0 -47
- package/esm/deps/jsr.io/@std/assert/1.0.8/array_includes.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/assert.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.8/assert.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/assertion_error.js +0 -31
- package/esm/deps/jsr.io/@std/assert/1.0.8/assertion_error.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/equal.js +0 -184
- package/esm/deps/jsr.io/@std/assert/1.0.8/equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/equals.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.8/equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/exists.js +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.8/exists.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/fail.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/fail.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/false.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.8/false.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/instance_of.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.8/instance_of.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/is_error.js +0 -54
- package/esm/deps/jsr.io/@std/assert/1.0.8/is_error.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/less.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.8/less.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/less_or_equal.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/less_or_equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/match.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/mod.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.8/mod.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_instance_of.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_instance_of.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_match.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/object_match.js +0 -160
- package/esm/deps/jsr.io/@std/assert/1.0.8/object_match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/rejects.js +0 -54
- package/esm/deps/jsr.io/@std/assert/1.0.8/rejects.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/strict_equals.js +0 -58
- package/esm/deps/jsr.io/@std/assert/1.0.8/strict_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/string_includes.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/string_includes.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/throws.js +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.8/throws.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/unimplemented.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/unimplemented.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/unreachable.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/unreachable.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +0 -111
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +0 -277
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +0 -180
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +0 -38
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +0 -208
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +0 -3
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js.map +0 -1
- package/src/_dnt.shims.ts +0 -60
- package/src/deps/jsr.io/@std/assert/1.0.8/almost_equals.ts +0 -55
- package/src/deps/jsr.io/@std/assert/1.0.8/array_includes.ts +0 -57
- package/src/deps/jsr.io/@std/assert/1.0.8/assert.ts +0 -23
- package/src/deps/jsr.io/@std/assert/1.0.8/assertion_error.ts +0 -31
- package/src/deps/jsr.io/@std/assert/1.0.8/equal.ts +0 -210
- package/src/deps/jsr.io/@std/assert/1.0.8/equals.ts +0 -52
- package/src/deps/jsr.io/@std/assert/1.0.8/exists.ts +0 -31
- package/src/deps/jsr.io/@std/assert/1.0.8/fail.ts +0 -21
- package/src/deps/jsr.io/@std/assert/1.0.8/false.ts +0 -26
- package/src/deps/jsr.io/@std/assert/1.0.8/greater.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/instance_of.ts +0 -64
- package/src/deps/jsr.io/@std/assert/1.0.8/is_error.ts +0 -65
- package/src/deps/jsr.io/@std/assert/1.0.8/less.ts +0 -29
- package/src/deps/jsr.io/@std/assert/1.0.8/less_or_equal.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/match.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/mod.ts +0 -47
- package/src/deps/jsr.io/@std/assert/1.0.8/not_equals.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/not_instance_of.ts +0 -33
- package/src/deps/jsr.io/@std/assert/1.0.8/not_match.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.ts +0 -42
- package/src/deps/jsr.io/@std/assert/1.0.8/object_match.ts +0 -202
- package/src/deps/jsr.io/@std/assert/1.0.8/rejects.ts +0 -123
- package/src/deps/jsr.io/@std/assert/1.0.8/strict_equals.ts +0 -67
- package/src/deps/jsr.io/@std/assert/1.0.8/string_includes.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/throws.ts +0 -111
- package/src/deps/jsr.io/@std/assert/1.0.8/unimplemented.ts +0 -21
- package/src/deps/jsr.io/@std/assert/1.0.8/unreachable.ts +0 -21
- package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +0 -134
- package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +0 -317
- package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +0 -204
- package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +0 -39
- package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +0 -233
- package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +0 -18
- package/types/ResponseFormat.d.ts +0 -26
- package/types/ResponseFormat.d.ts.map +0 -1
- package/types/_dnt.shims.d.ts +0 -2
- package/types/_dnt.shims.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/almost_equals.d.ts +0 -29
- package/types/deps/jsr.io/@std/assert/1.0.8/almost_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/array_includes.d.ts +0 -24
- package/types/deps/jsr.io/@std/assert/1.0.8/array_includes.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/assert.d.ts +0 -16
- package/types/deps/jsr.io/@std/assert/1.0.8/assert.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/assertion_error.d.ts +0 -26
- package/types/deps/jsr.io/@std/assert/1.0.8/assertion_error.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/equal.d.ts +0 -17
- package/types/deps/jsr.io/@std/assert/1.0.8/equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/equals.d.ts +0 -22
- package/types/deps/jsr.io/@std/assert/1.0.8/equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/exists.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/exists.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/fail.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/fail.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/false.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/false.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/greater.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/greater.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/instance_of.d.ts +0 -23
- package/types/deps/jsr.io/@std/assert/1.0.8/instance_of.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/is_error.d.ts +0 -25
- package/types/deps/jsr.io/@std/assert/1.0.8/is_error.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/less.d.ts +0 -19
- package/types/deps/jsr.io/@std/assert/1.0.8/less.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/less_or_equal.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/less_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/match.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/mod.d.ts +0 -44
- package/types/deps/jsr.io/@std/assert/1.0.8/mod.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_equals.d.ts +0 -21
- package/types/deps/jsr.io/@std/assert/1.0.8/not_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_instance_of.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/not_instance_of.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_match.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/not_match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.d.ts +0 -23
- package/types/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/object_match.d.ts +0 -28
- package/types/deps/jsr.io/@std/assert/1.0.8/object_match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/rejects.d.ts +0 -42
- package/types/deps/jsr.io/@std/assert/1.0.8/rejects.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/strict_equals.d.ts +0 -24
- package/types/deps/jsr.io/@std/assert/1.0.8/strict_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/string_includes.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/string_includes.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/throws.d.ts +0 -45
- package/types/deps/jsr.io/@std/assert/1.0.8/throws.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/unimplemented.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/unimplemented.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/unreachable.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/unreachable.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +0 -82
- package/types/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +0 -140
- package/types/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +0 -99
- package/types/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/format.d.ts +0 -2
- package/types/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +0 -159
- package/types/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/types.d.ts +0 -16
- package/types/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +0 -1
- /package/{types → esm}/Tool.d.ts +0 -0
- /package/{types → esm}/Tool.d.ts.map +0 -0
- /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
- /package/{types → esm}/_dnt.polyfills.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/mod.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/mod.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/omit.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/omit.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/pick.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/pick.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sample.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sample.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/union.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/union.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/zip.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/zip.d.ts.map +0 -0
- /package/{types → esm}/mod.d.ts +0 -0
- /package/{types → esm}/mod.d.ts.map +0 -0
- /package/{types → esm}/types/Ref.d.ts +0 -0
- /package/{types → esm}/types/Ref.d.ts.map +0 -0
- /package/{types → esm}/types/RootTy.d.ts +0 -0
- /package/{types → esm}/types/RootTy.d.ts.map +0 -0
- /package/{types → esm}/types/Ty.d.ts +0 -0
- /package/{types → esm}/types/Ty.d.ts.map +0 -0
- /package/{types → esm}/types/array.d.ts +0 -0
- /package/{types → esm}/types/array.d.ts.map +0 -0
- /package/{types → esm}/types/constant.d.ts +0 -0
- /package/{types → esm}/types/constant.d.ts.map +0 -0
- /package/{types → esm}/types/constantUnion.d.ts +0 -0
- /package/{types → esm}/types/constantUnion.d.ts.map +0 -0
- /package/{types → esm}/types/leaves.d.ts +0 -0
- /package/{types → esm}/types/leaves.d.ts.map +0 -0
- /package/{types → esm}/types/mod.d.ts +0 -0
- /package/{types → esm}/types/mod.d.ts.map +0 -0
- /package/{types → esm}/types/object.d.ts +0 -0
- /package/{types → esm}/types/object.d.ts.map +0 -0
- /package/{types → esm}/types/std/Option.d.ts +0 -0
- /package/{types → esm}/types/std/Option.d.ts.map +0 -0
- /package/{types → esm}/types/std/Wrapper.d.ts +0 -0
- /package/{types → esm}/types/std/Wrapper.d.ts.map +0 -0
- /package/{types → esm}/types/std/mod.d.ts +0 -0
- /package/{types → esm}/types/std/mod.d.ts.map +0 -0
- /package/{types → esm}/types/taggedUnion.d.ts +0 -0
- /package/{types → esm}/types/taggedUnion.d.ts.map +0 -0
- /package/{types → esm}/util/phantoms.d.ts +0 -0
- /package/{types → esm}/util/phantoms.d.ts.map +0 -0
- /package/{types → esm}/util/recombineTaggedTemplateArgs.d.ts +0 -0
- /package/{types → esm}/util/recombineTaggedTemplateArgs.d.ts.map +0 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { RootTy } from "./types/mod.js";
|
2
|
+
import type { ChatCompletion, JsonSchema } from "./oai.js";
|
3
|
+
export interface ResponseFormat<T> {
|
4
|
+
(template: TemplateStringsArray, ...quasis: Array<string>): ResponseFormat<T>;
|
5
|
+
type: "json_schema";
|
6
|
+
/** The desired return type in JSON Schema. */
|
7
|
+
json_schema: JsonSchema;
|
8
|
+
/** Parse the content of the first choice into a typed object. */
|
9
|
+
parseFirstChoice(completion: ChatCompletion): T;
|
10
|
+
/** Parse all choice contents into an array of typed object. */
|
11
|
+
parseChoices(completion: ChatCompletion): Array<T>;
|
12
|
+
}
|
13
|
+
export declare function ResponseFormat<T>(name: string, ty: RootTy<T, never>): ResponseFormat<T>;
|
14
|
+
export declare namespace ResponseFormat {
|
15
|
+
function unwrapFirstChoice(completion: ChatCompletion): string;
|
16
|
+
function unwrapChoices(completions: ChatCompletion): string[];
|
17
|
+
}
|
18
|
+
export declare class ResponseFormatUnwrapError extends Error {
|
19
|
+
readonly name = "UnwrapResponseError";
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=ResponseFormat.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ResponseFormat.d.ts","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAwB,UAAU,EAAE,MAAM,UAAU,CAAA;AAEhF,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;IAC7E,IAAI,EAAE,aAAa,CAAA;IACnB,8CAA8C;IAC9C,WAAW,EAAE,UAAU,CAAA;IACvB,iEAAiE;IACjE,gBAAgB,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAA;IAC/C,+DAA+D;IAC/D,YAAY,CAAC,UAAU,EAAE,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;CACnD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAEvF;AAoCD,yBAAiB,cAAc,CAAC;IAC9B,SAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CAMpE;IAED,SAAgB,aAAa,CAAC,WAAW,EAAE,cAAc,GAAG,MAAM,EAAE,CAEnE;CAoBF;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,yBAAwB;CAC/C"}
|
package/esm/ResponseFormat.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { assert } from "./deps/jsr.io/@std/assert/1.0.8/mod.js";
|
2
1
|
import { recombineTaggedTemplateArgs } from "./util/recombineTaggedTemplateArgs.js";
|
3
2
|
export function ResponseFormat(name, ty) {
|
4
3
|
return ResponseFormat_(name, ty);
|
@@ -12,25 +11,11 @@ function ResponseFormat_(name, ty, description) {
|
|
12
11
|
schema: ty.schema(),
|
13
12
|
strict: true,
|
14
13
|
},
|
15
|
-
|
16
|
-
return
|
17
|
-
...completion,
|
18
|
-
choices: completion.choices.map((choice) => ({
|
19
|
-
...choice,
|
20
|
-
message: {
|
21
|
-
...choice.message,
|
22
|
-
content: choice.message.content ? JSON.parse(choice.message.content) : null,
|
23
|
-
},
|
24
|
-
})),
|
25
|
-
};
|
14
|
+
parseFirstChoice: (completion) => {
|
15
|
+
return JSON.parse(ResponseFormat.unwrapFirstChoice(completion));
|
26
16
|
},
|
27
|
-
|
28
|
-
|
29
|
-
assert(firstChoice);
|
30
|
-
const { finish_reason, message } = firstChoice;
|
31
|
-
const { content, refusal } = message;
|
32
|
-
assert(content, JSON.stringify({ finish_reason, refusal, usage }));
|
33
|
-
return JSON.parse(content);
|
17
|
+
parseChoices: (completion) => {
|
18
|
+
return ResponseFormat.unwrapChoices(completion).map((content) => JSON.parse(content));
|
34
19
|
},
|
35
20
|
toJSON() {
|
36
21
|
const { type, json_schema } = this;
|
@@ -38,4 +23,43 @@ function ResponseFormat_(name, ty, description) {
|
|
38
23
|
},
|
39
24
|
});
|
40
25
|
}
|
26
|
+
(function (ResponseFormat) {
|
27
|
+
function unwrapFirstChoice(completion) {
|
28
|
+
const { choices: [firstChoice] } = completion;
|
29
|
+
if (!firstChoice) {
|
30
|
+
throw new ResponseFormatUnwrapError("No choices contained within the completion response.");
|
31
|
+
}
|
32
|
+
return unwrapChoice(firstChoice);
|
33
|
+
}
|
34
|
+
ResponseFormat.unwrapFirstChoice = unwrapFirstChoice;
|
35
|
+
function unwrapChoices(completions) {
|
36
|
+
return completions.choices.map(unwrapChoice);
|
37
|
+
}
|
38
|
+
ResponseFormat.unwrapChoices = unwrapChoices;
|
39
|
+
function unwrapChoice(choice) {
|
40
|
+
const { finish_reason, message } = choice;
|
41
|
+
if (finish_reason !== "stop") {
|
42
|
+
throw new ResponseFormatUnwrapError(`Completion responded with "${finish_reason}" as finish reason; ${message}`);
|
43
|
+
}
|
44
|
+
const { content, refusal } = message;
|
45
|
+
if (refusal) {
|
46
|
+
throw new ResponseFormatUnwrapError(`Openai refused to fulfill completion request; ${refusal}`);
|
47
|
+
}
|
48
|
+
if (!content) {
|
49
|
+
throw new ResponseFormatUnwrapError("First response choice contained no content.");
|
50
|
+
}
|
51
|
+
return content;
|
52
|
+
}
|
53
|
+
})(ResponseFormat || (ResponseFormat = {}));
|
54
|
+
export class ResponseFormatUnwrapError extends Error {
|
55
|
+
constructor() {
|
56
|
+
super(...arguments);
|
57
|
+
Object.defineProperty(this, "name", {
|
58
|
+
enumerable: true,
|
59
|
+
configurable: true,
|
60
|
+
writable: true,
|
61
|
+
value: "UnwrapResponseError"
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}
|
41
65
|
//# sourceMappingURL=ResponseFormat.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResponseFormat.js","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"ResponseFormat.js","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAA;AAcnF,MAAM,UAAU,cAAc,CAAI,IAAY,EAAE,EAAoB;IAClE,OAAO,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAClC,CAAC;AAED,SAAS,eAAe,CACtB,IAAY,EACZ,EAAoB,EACpB,WAAoB;IAEpB,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,QAA8B,EAAE,GAAG,MAAqB,EAAE,EAAE,CAC3D,eAAe,CACb,IAAI,EACJ,EAAE,EACF,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAC5F,EACH;QACE,IAAI,EAAE,aAAsB;QAC5B,WAAW,EAAE;YACX,IAAI;YACJ,WAAW;YACX,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE;YACnB,MAAM,EAAE,IAAI;SACb;QACD,gBAAgB,EAAE,CAAC,UAA0B,EAAK,EAAE;YAClD,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;QACjE,CAAC;QACD,YAAY,EAAE,CAAC,UAA0B,EAAY,EAAE;YACrD,OAAO,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACvF,CAAC;QACD,MAAM;YACJ,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;YAClC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QAC9B,CAAC;KACF,CACF,CAAA;AACH,CAAC;AAED,WAAiB,cAAc;IAC7B,SAAgB,iBAAiB,CAAC,UAA0B;QAC1D,MAAM,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,UAAU,CAAA;QAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,yBAAyB,CAAC,sDAAsD,CAAC,CAAA;QAC7F,CAAC;QACD,OAAO,YAAY,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC;IANe,gCAAiB,oBAMhC,CAAA;IAED,SAAgB,aAAa,CAAC,WAA2B;QACvD,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,CAAC;IAFe,4BAAa,gBAE5B,CAAA;IAED,SAAS,YAAY,CAAC,MAA4B;QAChD,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QACzC,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;YAC7B,MAAM,IAAI,yBAAyB,CACjC,8BAA8B,aAAa,uBAAuB,OAAO,EAAE,CAC5E,CAAA;QACH,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QACpC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,yBAAyB,CACjC,iDAAiD,OAAO,EAAE,CAC3D,CAAA;QACH,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,yBAAyB,CAAC,6CAA6C,CAAC,CAAA;QACpF,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC,EA/BgB,cAAc,KAAd,cAAc,QA+B9B;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAApD;;QACoB;;;;mBAAO,qBAAqB;WAAA;IAChD,CAAC;CAAA"}
|
package/esm/oai.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
import type Openai from "openai";
|
2
|
+
export type JsonSchema = Openai.ResponseFormatJSONSchema["json_schema"];
|
3
|
+
export type ChatCompletion = Openai.Chat.ChatCompletion;
|
4
|
+
export type ChatCompletionChoice = Openai.Chat.Completions.ChatCompletion.Choice;
|
5
|
+
//# sourceMappingURL=oai.d.ts.map
|
package/esm/oai.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"oai.d.ts","sourceRoot":"","sources":["../src/oai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAA;AACvE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAA;AACvD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAA"}
|
package/esm/oai.js
ADDED
package/esm/oai.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"oai.js","sourceRoot":"","sources":["../src/oai.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "structured-outputs",
|
3
|
-
"version": "0.1.0-beta.
|
3
|
+
"version": "0.1.0-beta.21",
|
4
4
|
"description": "Compose OpenAI structured output schemas.",
|
5
5
|
"repository": "github:harrysolovay/structured-outputs.git",
|
6
6
|
"license": "Apache-2.0",
|
7
7
|
"main": "./esm/mod.js",
|
8
8
|
"module": "./esm/mod.js",
|
9
|
-
"types": "./types/mod.d.ts",
|
10
9
|
"exports": {
|
11
10
|
".": {
|
12
|
-
"import":
|
13
|
-
"types": "./types/mod.d.ts",
|
14
|
-
"default": "./esm/mod.js"
|
15
|
-
}
|
11
|
+
"import": "./esm/mod.js"
|
16
12
|
}
|
17
13
|
},
|
18
|
-
"
|
19
|
-
|
14
|
+
"_generatedBy": "dnt@dev",
|
15
|
+
"peerDependencies": {
|
20
16
|
"openai": "^4.68.1"
|
21
|
-
}
|
22
|
-
"_generatedBy": "dnt@dev"
|
17
|
+
}
|
23
18
|
}
|
package/src/ResponseFormat.ts
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
-
import { assert } from "./deps/jsr.io/@std/assert/1.0.8/mod.js"
|
2
|
-
import type Openai from "openai"
|
3
|
-
import type { ResponseFormatJSONSchema } from "openai/resources/index.js"
|
4
1
|
import type { RootTy } from "./types/mod.js"
|
5
2
|
import { recombineTaggedTemplateArgs } from "./util/recombineTaggedTemplateArgs.js"
|
3
|
+
import type { ChatCompletion, ChatCompletionChoice, JsonSchema } from "./oai.js"
|
4
|
+
|
5
|
+
export interface ResponseFormat<T> {
|
6
|
+
(template: TemplateStringsArray, ...quasis: Array<string>): ResponseFormat<T>
|
7
|
+
type: "json_schema"
|
8
|
+
/** The desired return type in JSON Schema. */
|
9
|
+
json_schema: JsonSchema
|
10
|
+
/** Parse the content of the first choice into a typed object. */
|
11
|
+
parseFirstChoice(completion: ChatCompletion): T
|
12
|
+
/** Parse all choice contents into an array of typed object. */
|
13
|
+
parseChoices(completion: ChatCompletion): Array<T>
|
14
|
+
}
|
6
15
|
|
7
16
|
export function ResponseFormat<T>(name: string, ty: RootTy<T, never>): ResponseFormat<T> {
|
8
17
|
return ResponseFormat_(name, ty)
|
@@ -28,25 +37,11 @@ function ResponseFormat_<T>(
|
|
28
37
|
schema: ty.schema(),
|
29
38
|
strict: true,
|
30
39
|
},
|
31
|
-
|
32
|
-
return
|
33
|
-
...completion,
|
34
|
-
choices: completion.choices.map((choice) => ({
|
35
|
-
...choice,
|
36
|
-
message: {
|
37
|
-
...choice.message,
|
38
|
-
content: choice.message.content ? JSON.parse(choice.message.content) : null,
|
39
|
-
},
|
40
|
-
})),
|
41
|
-
}
|
40
|
+
parseFirstChoice: (completion: ChatCompletion): T => {
|
41
|
+
return JSON.parse(ResponseFormat.unwrapFirstChoice(completion))
|
42
42
|
},
|
43
|
-
|
44
|
-
|
45
|
-
assert(firstChoice)
|
46
|
-
const { finish_reason, message } = firstChoice
|
47
|
-
const { content, refusal } = message
|
48
|
-
assert(content, JSON.stringify({ finish_reason, refusal, usage }))
|
49
|
-
return JSON.parse(content)
|
43
|
+
parseChoices: (completion: ChatCompletion): Array<T> => {
|
44
|
+
return ResponseFormat.unwrapChoices(completion).map((content) => JSON.parse(content))
|
50
45
|
},
|
51
46
|
toJSON() {
|
52
47
|
const { type, json_schema } = this
|
@@ -56,27 +51,39 @@ function ResponseFormat_<T>(
|
|
56
51
|
)
|
57
52
|
}
|
58
53
|
|
59
|
-
export
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
parseFirstOrThrow(completion: ChatCompletion): T
|
68
|
-
}
|
54
|
+
export namespace ResponseFormat {
|
55
|
+
export function unwrapFirstChoice(completion: ChatCompletion): string {
|
56
|
+
const { choices: [firstChoice] } = completion
|
57
|
+
if (!firstChoice) {
|
58
|
+
throw new ResponseFormatUnwrapError("No choices contained within the completion response.")
|
59
|
+
}
|
60
|
+
return unwrapChoice(firstChoice)
|
61
|
+
}
|
69
62
|
|
70
|
-
export
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
63
|
+
export function unwrapChoices(completions: ChatCompletion): string[] {
|
64
|
+
return completions.choices.map(unwrapChoice)
|
65
|
+
}
|
66
|
+
|
67
|
+
function unwrapChoice(choice: ChatCompletionChoice) {
|
68
|
+
const { finish_reason, message } = choice
|
69
|
+
if (finish_reason !== "stop") {
|
70
|
+
throw new ResponseFormatUnwrapError(
|
71
|
+
`Completion responded with "${finish_reason}" as finish reason; ${message}`,
|
72
|
+
)
|
73
|
+
}
|
74
|
+
const { content, refusal } = message
|
75
|
+
if (refusal) {
|
76
|
+
throw new ResponseFormatUnwrapError(
|
77
|
+
`Openai refused to fulfill completion request; ${refusal}`,
|
78
|
+
)
|
76
79
|
}
|
77
|
-
|
80
|
+
if (!content) {
|
81
|
+
throw new ResponseFormatUnwrapError("First response choice contained no content.")
|
82
|
+
}
|
83
|
+
return content
|
84
|
+
}
|
78
85
|
}
|
79
86
|
|
80
|
-
|
81
|
-
|
82
|
-
|
87
|
+
export class ResponseFormatUnwrapError extends Error {
|
88
|
+
override readonly name = "UnwrapResponseError"
|
89
|
+
}
|
package/src/oai.ts
ADDED
package/esm/_dnt.shims.js
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
const dntGlobals = {};
|
2
|
-
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
3
|
-
function createMergeProxy(baseObj, extObj) {
|
4
|
-
return new Proxy(baseObj, {
|
5
|
-
get(_target, prop, _receiver) {
|
6
|
-
if (prop in extObj) {
|
7
|
-
return extObj[prop];
|
8
|
-
}
|
9
|
-
else {
|
10
|
-
return baseObj[prop];
|
11
|
-
}
|
12
|
-
},
|
13
|
-
set(_target, prop, value) {
|
14
|
-
if (prop in extObj) {
|
15
|
-
delete extObj[prop];
|
16
|
-
}
|
17
|
-
baseObj[prop] = value;
|
18
|
-
return true;
|
19
|
-
},
|
20
|
-
deleteProperty(_target, prop) {
|
21
|
-
let success = false;
|
22
|
-
if (prop in extObj) {
|
23
|
-
delete extObj[prop];
|
24
|
-
success = true;
|
25
|
-
}
|
26
|
-
if (prop in baseObj) {
|
27
|
-
delete baseObj[prop];
|
28
|
-
success = true;
|
29
|
-
}
|
30
|
-
return success;
|
31
|
-
},
|
32
|
-
ownKeys(_target) {
|
33
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
34
|
-
const extKeys = Reflect.ownKeys(extObj);
|
35
|
-
const extKeysSet = new Set(extKeys);
|
36
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
37
|
-
},
|
38
|
-
defineProperty(_target, prop, desc) {
|
39
|
-
if (prop in extObj) {
|
40
|
-
delete extObj[prop];
|
41
|
-
}
|
42
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
43
|
-
return true;
|
44
|
-
},
|
45
|
-
getOwnPropertyDescriptor(_target, prop) {
|
46
|
-
if (prop in extObj) {
|
47
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
51
|
-
}
|
52
|
-
},
|
53
|
-
has(_target, prop) {
|
54
|
-
return prop in extObj || prop in baseObj;
|
55
|
-
},
|
56
|
-
});
|
57
|
-
}
|
58
|
-
//# sourceMappingURL=_dnt.shims.js.map
|
package/esm/_dnt.shims.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"_dnt.shims.js","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,EAClB,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEtE,SAAS,gBAAgB,CACvB,OAAU,EACV,MAAS;IAET,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS;YAC1B,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK;YACtB,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACA,OAAe,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,cAAc,CAAC,OAAO,EAAE,IAAI;YAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBACpB,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;gBAC9B,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,OAAO;YACb,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;QACrE,CAAC;QACD,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI;YAChC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,wBAAwB,CAAC,OAAO,EAAE,IAAI;YACpC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC;QAC3C,CAAC;KACF,CAAQ,CAAC;AACZ,CAAC"}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
-
// This module is browser compatible.
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
4
|
-
/**
|
5
|
-
* Make an assertion that `actual` and `expected` are almost equal numbers
|
6
|
-
* through a given tolerance. It can be used to take into account IEEE-754
|
7
|
-
* double-precision floating-point representation limitations. If the values
|
8
|
-
* are not almost equal then throw.
|
9
|
-
*
|
10
|
-
* The default tolerance is one hundred thousandth of a percent of the
|
11
|
-
* expected value.
|
12
|
-
*
|
13
|
-
* @example Usage
|
14
|
-
* ```ts ignore
|
15
|
-
* import { assertAlmostEquals } from "@std/assert";
|
16
|
-
*
|
17
|
-
* assertAlmostEquals(0.01, 0.02); // Throws
|
18
|
-
* assertAlmostEquals(1e-8, 1e-9); // Throws
|
19
|
-
* assertAlmostEquals(1.000000001e-8, 1.000000002e-8); // Doesn't throw
|
20
|
-
* assertAlmostEquals(0.01, 0.02, 0.1); // Doesn't throw
|
21
|
-
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16); // Doesn't throw
|
22
|
-
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17); // Throws
|
23
|
-
* ```
|
24
|
-
*
|
25
|
-
* @param actual The actual value to compare.
|
26
|
-
* @param expected The expected value to compare.
|
27
|
-
* @param tolerance The tolerance to consider the values almost equal. The
|
28
|
-
* default is one hundred thousandth of a percent of the expected value.
|
29
|
-
* @param msg The optional message to include in the error.
|
30
|
-
*/
|
31
|
-
export function assertAlmostEquals(actual, expected, tolerance, msg) {
|
32
|
-
if (Object.is(actual, expected)) {
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
const delta = Math.abs(expected - actual);
|
36
|
-
if (tolerance === undefined) {
|
37
|
-
tolerance = isFinite(expected) ? Math.abs(expected * 1e-7) : 1e-7;
|
38
|
-
}
|
39
|
-
if (delta <= tolerance) {
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
43
|
-
const f = (n) => Number.isInteger(n) ? n : n.toExponential();
|
44
|
-
throw new AssertionError(`Expected actual: "${f(actual)}" to be close to "${f(expected)}": \
|
45
|
-
delta "${f(delta)}" is greater than "${f(tolerance)}"${msgSuffix}`);
|
46
|
-
}
|
47
|
-
//# sourceMappingURL=almost_equals.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"almost_equals.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.8/almost_equals.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,QAAgB,EAChB,SAAkB,EAClB,GAAY;IAEZ,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC1C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,CAAC;IACD,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACrE,MAAM,IAAI,cAAc,CACtB,qBAAqB,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC;SACzD,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,SAAS,CAAC,IAAI,SAAS,EAAE,CAC/D,CAAC;AACJ,CAAC"}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
-
// This module is browser compatible.
|
3
|
-
import { equal } from "./equal.js";
|
4
|
-
import { format } from "../../internal/1.0.5/format.js";
|
5
|
-
import { AssertionError } from "./assertion_error.js";
|
6
|
-
/**
|
7
|
-
* Make an assertion that `actual` includes the `expected` values. If not then
|
8
|
-
* an error will be thrown.
|
9
|
-
*
|
10
|
-
* Type parameter can be specified to ensure values under comparison have the
|
11
|
-
* same type.
|
12
|
-
*
|
13
|
-
* @example Usage
|
14
|
-
* ```ts ignore
|
15
|
-
* import { assertArrayIncludes } from "@std/assert";
|
16
|
-
*
|
17
|
-
* assertArrayIncludes([1, 2], [2]); // Doesn't throw
|
18
|
-
* assertArrayIncludes([1, 2], [3]); // Throws
|
19
|
-
* ```
|
20
|
-
*
|
21
|
-
* @typeParam T The type of the elements in the array to compare.
|
22
|
-
* @param actual The array-like object to check for.
|
23
|
-
* @param expected The array-like object to check for.
|
24
|
-
* @param msg The optional message to display if the assertion fails.
|
25
|
-
*/
|
26
|
-
export function assertArrayIncludes(actual, expected, msg) {
|
27
|
-
const missing = [];
|
28
|
-
for (let i = 0; i < expected.length; i++) {
|
29
|
-
let found = false;
|
30
|
-
for (let j = 0; j < actual.length; j++) {
|
31
|
-
if (equal(expected[i], actual[j])) {
|
32
|
-
found = true;
|
33
|
-
break;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
if (!found) {
|
37
|
-
missing.push(expected[i]);
|
38
|
-
}
|
39
|
-
}
|
40
|
-
if (missing.length === 0) {
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
44
|
-
msg = `Expected actual: "${format(actual)}" to include: "${format(expected)}"${msgSuffix}\nmissing: ${format(missing)}`;
|
45
|
-
throw new AssertionError(msg);
|
46
|
-
}
|
47
|
-
//# sourceMappingURL=array_includes.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"array_includes.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.8/array_includes.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAuB,EACvB,QAAyB,EACzB,GAAY;IAEZ,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClC,KAAK,GAAG,IAAI,CAAC;gBACb,MAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,GAAG,GAAG,qBAAqB,MAAM,CAAC,MAAM,CAAC,kBACvC,MAAM,CAAC,QAAQ,CACjB,IAAI,SAAS,cAAc,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7C,MAAM,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
-
// This module is browser compatible.
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
4
|
-
/**
|
5
|
-
* Make an assertion, error will be thrown if `expr` does not have truthy value.
|
6
|
-
*
|
7
|
-
* @example Usage
|
8
|
-
* ```ts ignore
|
9
|
-
* import { assert } from "@std/assert";
|
10
|
-
*
|
11
|
-
* assert("hello".includes("ello")); // Doesn't throw
|
12
|
-
* assert("hello".includes("world")); // Throws
|
13
|
-
* ```
|
14
|
-
*
|
15
|
-
* @param expr The expression to test.
|
16
|
-
* @param msg The optional message to display if the assertion fails.
|
17
|
-
*/
|
18
|
-
export function assert(expr, msg = "") {
|
19
|
-
if (!expr) {
|
20
|
-
throw new AssertionError(msg);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
//# sourceMappingURL=assert.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.8/assert.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,GAAG,GAAG,EAAE;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
-
// This module is browser compatible.
|
3
|
-
/**
|
4
|
-
* Error thrown when an assertion fails.
|
5
|
-
*
|
6
|
-
* @example Usage
|
7
|
-
* ```ts ignore
|
8
|
-
* import { AssertionError } from "@std/assert";
|
9
|
-
*
|
10
|
-
* try {
|
11
|
-
* throw new AssertionError("foo", { cause: "bar" });
|
12
|
-
* } catch (error) {
|
13
|
-
* if (error instanceof AssertionError) {
|
14
|
-
* error.message === "foo"; // true
|
15
|
-
* error.cause === "bar"; // true
|
16
|
-
* }
|
17
|
-
* }
|
18
|
-
* ```
|
19
|
-
*/
|
20
|
-
export class AssertionError extends Error {
|
21
|
-
/** Constructs a new instance.
|
22
|
-
*
|
23
|
-
* @param message The error message.
|
24
|
-
* @param options Additional options. This argument is still unstable. It may change in the future release.
|
25
|
-
*/
|
26
|
-
constructor(message, options) {
|
27
|
-
super(message, options);
|
28
|
-
this.name = "AssertionError";
|
29
|
-
}
|
30
|
-
}
|
31
|
-
//# sourceMappingURL=assertion_error.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"assertion_error.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.8/assertion_error.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;IACH,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|