diff --git a/.gitignore b/.gitignore index 1ef280e1..8b1228a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -.prism.log +*.gem .idea/ +.prism.log .ruby-lsp/ .yardoc/ -doc/ -sorbet/ Brewfile.lock.json bin/tapioca -*.gem +doc/ +sorbet/* +!/sorbet/config diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f14b480a..aaf968a1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.2" + ".": "0.1.0-alpha.3" } \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index e0a360b6..df60b4df 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,6 +10,10 @@ AllCops: SuggestExtensions: false TargetRubyVersion: 3.1.0 +# Whether MFA is required or not should be left to the token configuration. +Gemspec/RequireMFA: + Enabled: false + # Don't require this extra line break, it can be excessive. Layout/EmptyLineAfterGuardClause: Enabled: false @@ -68,6 +72,10 @@ Lint/EmptyInPattern: Exclude: - "test/**/*" +Lint/MissingCopEnableDirective: + Exclude: + - "examples/**/*.rb" + Lint/MissingSuper: Exclude: - "**/*.rbi" @@ -76,9 +84,21 @@ Lint/MissingSuper: Lint/UnusedMethodArgument: AutoCorrect: false +# This option is prone to causing accidental bugs. +Lint/UselessAssignment: + AutoCorrect: false + Exclude: + - "examples/**/*.rb" + Metrics/AbcSize: Enabled: false +Metrics/BlockLength: + AllowedPatterns: + - assert_pattern + Exclude: + - "**/*.rbi" + Metrics/ClassLength: Enabled: false @@ -88,13 +108,21 @@ Metrics/CyclomaticComplexity: Metrics/MethodLength: Enabled: false +Metrics/ModuleLength: + Exclude: + - "**/*.rbi" + Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +# Need to preserve block identifier for documentation. Naming/BlockForwarding: + Enabled: false + +Naming/ClassAndModuleCamelCase: Exclude: - "**/*.rbi" @@ -102,6 +130,10 @@ Naming/MethodParameterName: Exclude: - "**/*.rbi" +Naming/PredicateName: + Exclude: + - "**/*.rbi" + Naming/VariableNumber: Enabled: false @@ -121,6 +153,9 @@ Style/Alias: Style/AndOr: EnforcedStyle: always +Style/ArgumentsForwarding: + Enabled: false + Style/BisectedAttrAccessor: Exclude: - "**/*.rbi" @@ -203,6 +238,10 @@ Style/RegexpLiteral: Style/SafeNavigation: Enabled: false +Style/SignalException: + Exclude: + - Rakefile + # We use these sparingly, where we anticipate future branches for the # inner conditional. Style/SoleNestedConditional: @@ -215,3 +254,8 @@ Style/StringLiterals: # Prefer explicit symbols for clarity; you can search for `:the_symbol`. Style/SymbolArray: EnforcedStyle: brackets + +# This option makes examples harder to read for ruby novices. +Style/SymbolProc: + Exclude: + - "examples/**/*.rb" diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 00000000..4f571833 --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,10 @@ +--- +max_files: 0 +include: + - '*.gemspec' + - 'Rakefile' + - 'examples/**/*.rb' + - 'lib/**/*.rb' + - 'test/openai/test_helper.rb' +exclude: + - 'rbi/**/*' diff --git a/.stats.yml b/.stats.yml index 26b57a65..b21d5dae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,4 @@ configured_endpoints: 80 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-c8579861bc21d4d2155a5b9e8e7d54faee8083730673c4d32cbbe573d7fb4116.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6663c59193eb95b201e492de17dcbd5e126ba03d18ce66287a3e2c632ca56fe7.yml +openapi_spec_hash: 7996d2c34cc44fe2ce9ffe93c0ab774e +config_hash: 2daae06cc598821ccf87201de0861e40 diff --git a/.yardopts b/.yardopts index c7c3301d..004c697b 100644 --- a/.yardopts +++ b/.yardopts @@ -1,3 +1,4 @@ --markup markdown +--markup-provider redcarpet --exclude /rbi --exclude /sig diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a2be31..827bd3cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,80 @@ # Changelog +## 0.1.0-alpha.3 (2025-04-01) + +Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/openai/openai-ruby/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) + +### ⚠ BREAKING CHANGES + +* use tagged enums in sorbet type definitions ([#49](https://github.com/openai/openai-ruby/issues/49)) +* support `for item in stream` style iteration on `Stream`s ([#44](https://github.com/openai/openai-ruby/issues/44)) +* **model:** base model should recursively store coerced base models ([#29](https://github.com/openai/openai-ruby/issues/29)) + +### Features + +* **api:** add `get /chat/completions` endpoint ([4570a0f](https://github.com/openai/openai-ruby/commit/4570a0fcda6721f01f2c8d5100dc98c721ef62de)) +* **api:** add `get /responses/{response_id}/input_items` endpoint ([7eaee28](https://github.com/openai/openai-ruby/commit/7eaee28b2671c6dfa24ce5ce18d525da5de5703e)) +* **api:** new models for TTS, STT, + new audio features for Realtime ([#46](https://github.com/openai/openai-ruby/issues/46)) ([56c2a3f](https://github.com/openai/openai-ruby/commit/56c2a3ffecc1b69d2ae96cc84de19d82b14c9c09)) +* **api:** o1-pro now available through the API ([#43](https://github.com/openai/openai-ruby/issues/43)) ([e158e7e](https://github.com/openai/openai-ruby/commit/e158e7ef3e1edd6198cd9b2e8aa51ad686d80d04)) +* collapse anonymous enum into unions ([#54](https://github.com/openai/openai-ruby/issues/54)) ([9fc4185](https://github.com/openai/openai-ruby/commit/9fc418595f4ff1824ed97368f566c4d1526e90dc)) +* consistently accept `AnyHash` types in parameter positions in sorbet ([#57](https://github.com/openai/openai-ruby/issues/57)) ([adf7232](https://github.com/openai/openai-ruby/commit/adf7232437b8ddd302992f01ceaa7961ed790b2f)) +* **internal:** converter interface should recurse without schema ([#68](https://github.com/openai/openai-ruby/issues/68)) ([2c67222](https://github.com/openai/openai-ruby/commit/2c672222cae7a01acf9ef75ab1fefdc549d92938)) +* prevent tapioca from introspecting the gem internals ([#56](https://github.com/openai/openai-ruby/issues/56)) ([09df54b](https://github.com/openai/openai-ruby/commit/09df54b133e92648318c337e20bd977ca900d21d)) +* support `for item in stream` style iteration on `Stream`s ([#44](https://github.com/openai/openai-ruby/issues/44)) ([517cf73](https://github.com/openai/openai-ruby/commit/517cf73e1e55be3df24276025711522968fd2375)) +* use tagged enums in sorbet type definitions ([#49](https://github.com/openai/openai-ruby/issues/49)) ([c0a0340](https://github.com/openai/openai-ruby/commit/c0a03401ebe2ccdbf7ff4019a5f1cf661590cce2)) + + +### Bug Fixes + +* **api:** correct some Responses types ([#30](https://github.com/openai/openai-ruby/issues/30)) ([51b4d37](https://github.com/openai/openai-ruby/commit/51b4d37d5a5c276cec08ea6164fd3c18397d1dea)) +* **client:** remove duplicate types ([#47](https://github.com/openai/openai-ruby/issues/47)) ([d26429c](https://github.com/openai/openai-ruby/commit/d26429c3f3c3fb1aab201fdd4ad2cd4c44ef6aa1)) +* label optional keyword arguments in *.rbs type definitions ([#41](https://github.com/openai/openai-ruby/issues/41)) ([fe7be91](https://github.com/openai/openai-ruby/commit/fe7be916f4c309dfe1cc07d5d0c0a3de9cba2ee0)) +* missing union constants in rbs and rbi type definitions ([#28](https://github.com/openai/openai-ruby/issues/28)) ([8a1a86e](https://github.com/openai/openai-ruby/commit/8a1a86e656277cedd68b180997e666a7b39daa1f)) +* **model:** base model should recursively store coerced base models ([#29](https://github.com/openai/openai-ruby/issues/29)) ([ab2daf1](https://github.com/openai/openai-ruby/commit/ab2daf1d8d0f6df9aa08a41e8948bcfbd4ff32e0)) +* pages should be able to accept non-converter models ([#60](https://github.com/openai/openai-ruby/issues/60)) ([ca44472](https://github.com/openai/openai-ruby/commit/ca44472a404acd570d9af5c7d9764601d457bbc8)) +* path interpolation template strings ([#77](https://github.com/openai/openai-ruby/issues/77)) ([f1eec93](https://github.com/openai/openai-ruby/commit/f1eec93ebd458477507fc6502ef4fb0360f9c2f4)) +* resolve tapioca derived sorbet errors ([#45](https://github.com/openai/openai-ruby/issues/45)) ([f155158](https://github.com/openai/openai-ruby/commit/f155158a6dd0c020a6f3d9b707d39e905e01c5a2)) +* sorbet class aliases are not type aliases ([#40](https://github.com/openai/openai-ruby/issues/40)) ([871fcd5](https://github.com/openai/openai-ruby/commit/871fcd5b3056629155b46aa08533df587442b6c5)) +* switch to github compatible markdown engine ([#73](https://github.com/openai/openai-ruby/issues/73)) ([5ea2f1a](https://github.com/openai/openai-ruby/commit/5ea2f1a8543c0bdb3537cd63da7e1ffda5c32018)) +* type names ([acb2ad3](https://github.com/openai/openai-ruby/commit/acb2ad31e4ad0bd8859e113f269c3dbfadd959dd)) +* **types:** improve responses type names ([#34](https://github.com/openai/openai-ruby/issues/34)) ([a82dc6f](https://github.com/openai/openai-ruby/commit/a82dc6f37205110eb08a44f252f40f1dd341d1f5)) +* yard example tag formatting ([#53](https://github.com/openai/openai-ruby/issues/53)) ([f9282fc](https://github.com/openai/openai-ruby/commit/f9282fc932d66159cf6632c632a74a12162b9a28)) + + +### Chores + +* `BaseModel` fields that are `BaseModel` typed should also accept `Hash` ([#52](https://github.com/openai/openai-ruby/issues/52)) ([aab09b2](https://github.com/openai/openai-ruby/commit/aab09b2d10e2a60b1591834fe7c91f0b2a00056e)) +* add `[@yieldparam](https://github.com/yieldparam)` to yard doc ([#36](https://github.com/openai/openai-ruby/issues/36)) ([aa0519b](https://github.com/openai/openai-ruby/commit/aa0519bda596cdb77c3c7fa2635199a8751f652b)) +* add example directory ([#39](https://github.com/openai/openai-ruby/issues/39)) ([c62326d](https://github.com/openai/openai-ruby/commit/c62326d76587d8e519f29ad1d3bca4d02cfb7702)) +* add hash of OpenAPI spec/config inputs to .stats.yml ([6bd0b48](https://github.com/openai/openai-ruby/commit/6bd0b48f06eeba23faa18039795b46dc0b07b51a)) +* add type annotations for enum and union member listing methods ([#55](https://github.com/openai/openai-ruby/issues/55)) ([a2be966](https://github.com/openai/openai-ruby/commit/a2be96630a99700a1fae79c3969e72a677fff270)) +* **api:** updates to supported Voice IDs ([#64](https://github.com/openai/openai-ruby/issues/64)) ([6c42664](https://github.com/openai/openai-ruby/commit/6c42664eacbaf21d8359c096c496ff50661e82cb)) +* disable dangerous rubocop auto correct rule ([#62](https://github.com/openai/openai-ruby/issues/62)) ([f34ac80](https://github.com/openai/openai-ruby/commit/f34ac8099aeac766ff90268bb5b14ba0529f6fa9)) +* disable overloads in `*.rbs` definitions for readable LSP errors ([#42](https://github.com/openai/openai-ruby/issues/42)) ([2364f78](https://github.com/openai/openai-ruby/commit/2364f78c6bf0b618b8b454dccbd17924a9874168)) +* disable unnecessary linter rules for sorbet manifests ([#35](https://github.com/openai/openai-ruby/issues/35)) ([cf2f693](https://github.com/openai/openai-ruby/commit/cf2f6934740b1bb7c611c4bc5b9c41c5cebbe0c1)) +* document Client's concurrency capability ([#33](https://github.com/openai/openai-ruby/issues/33)) ([9b08fb0](https://github.com/openai/openai-ruby/commit/9b08fb062416ca8c72e531b9389d68c2fd730af8)) +* fix misc rubocop errors ([#74](https://github.com/openai/openai-ruby/issues/74)) ([40315e6](https://github.com/openai/openai-ruby/commit/40315e6ce56d1f93691fbd928254cdf24c2da8b1)) +* ignore some spurious linter warnings and formatting changes ([#31](https://github.com/openai/openai-ruby/issues/31)) ([e376e31](https://github.com/openai/openai-ruby/commit/e376e31709236578305bf453cfbe8e056057d669)) +* **internal:** add sorbet config for SDK local development ([#38](https://github.com/openai/openai-ruby/issues/38)) ([f8cb16b](https://github.com/openai/openai-ruby/commit/f8cb16bccf2d4fb4d13a369eaad8102ef110a550)) +* **internal:** bugfix ([#51](https://github.com/openai/openai-ruby/issues/51)) ([0967a13](https://github.com/openai/openai-ruby/commit/0967a139e6dc24bfdf3b4c5e3b9770d39d610904)) +* **internal:** codegen related update ([#27](https://github.com/openai/openai-ruby/issues/27)) ([83ac858](https://github.com/openai/openai-ruby/commit/83ac85861a0dd1756c46cdad962f3ab0c758d9ae)) +* **internal:** minor refactoring of utils ([#67](https://github.com/openai/openai-ruby/issues/67)) ([47f9f49](https://github.com/openai/openai-ruby/commit/47f9f49b2acd2a1549d497fa542dfab368b939d3)) +* **internal:** version bump ([#26](https://github.com/openai/openai-ruby/issues/26)) ([b9dde82](https://github.com/openai/openai-ruby/commit/b9dde82f091f820ea09eea4521fc2bd63d8ec32e)) +* more accurate type annotations for SDK internals ([#71](https://github.com/openai/openai-ruby/issues/71)) ([2071dd2](https://github.com/openai/openai-ruby/commit/2071dd2ffbdcd49d20245c8d04c8839a3caca240)) +* more aggressive tapioca detection logic for skipping compiler introspection ([#65](https://github.com/openai/openai-ruby/issues/65)) ([1da15be](https://github.com/openai/openai-ruby/commit/1da15be44dba6b54b9432b62d1fdb7551f2faff6)) +* more readable output when tests fail ([#63](https://github.com/openai/openai-ruby/issues/63)) ([c3cfea9](https://github.com/openai/openai-ruby/commit/c3cfea9124334e728dcf08a294b35338c8412137)) +* re-order assignment lines to make unions easier to read ([#66](https://github.com/openai/openai-ruby/issues/66)) ([50f6e5e](https://github.com/openai/openai-ruby/commit/50f6e5e2abbb007fa8786a24eb7d0bf8398499ed)) +* recursively accept `AnyHash` for `BaseModel`s in arrays and hashes ([#58](https://github.com/openai/openai-ruby/issues/58)) ([92f1cba](https://github.com/openai/openai-ruby/commit/92f1cbabc8f3bb009e18ccadc11479e330dec11c)) +* reduce verbosity in type declarations ([#61](https://github.com/openai/openai-ruby/issues/61)) ([9517e27](https://github.com/openai/openai-ruby/commit/9517e27589c1b88e50e22d39f29b3e1c485e1a53)) +* relocate internal modules ([#70](https://github.com/openai/openai-ruby/issues/70)) ([350fe34](https://github.com/openai/openai-ruby/commit/350fe34846d92d114eb49a92464837884d1ca355)) +* Remove deprecated/unused remote spec feature ([e2bffd6](https://github.com/openai/openai-ruby/commit/e2bffd65e8552e00b647b1f013cbc5fc2017ba6d)) +* remove unnecessary & confusing module ([#69](https://github.com/openai/openai-ruby/issues/69)) ([c0ea470](https://github.com/openai/openai-ruby/commit/c0ea470fc329c7ccf2161a1eb8b58ea19a43565a)) +* support binary responses ([#76](https://github.com/openai/openai-ruby/issues/76)) ([1b19e9b](https://github.com/openai/openai-ruby/commit/1b19e9bafa82baebd48924f01825aa2cfc2e9d68)) +* switch to prettier looking sorbet annotations ([#59](https://github.com/openai/openai-ruby/issues/59)) ([0ab5871](https://github.com/openai/openai-ruby/commit/0ab5871d8fb4d9e28eee39d2c937842fd84828a1)) +* update readme ([#72](https://github.com/openai/openai-ruby/issues/72)) ([21ed2b6](https://github.com/openai/openai-ruby/commit/21ed2b6915e2bec2f3be41a369bf05da345b0d5b)) +* use fully qualified name in sorbet README example ([#75](https://github.com/openai/openai-ruby/issues/75)) ([273a784](https://github.com/openai/openai-ruby/commit/273a7843957997b28452d328b29e4973bda1836b)) +* use multi-line formatting style for really long lines ([#37](https://github.com/openai/openai-ruby/issues/37)) ([acb95ee](https://github.com/openai/openai-ruby/commit/acb95eed637593576db09fd5d31ea4bba67e5a22)) + ## 0.1.0-alpha.2 (2025-03-18) Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/openai/openai-ruby/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) diff --git a/Gemfile b/Gemfile index b064fc5a..e5ec01e9 100644 --- a/Gemfile +++ b/Gemfile @@ -5,12 +5,6 @@ source "https://rubygems.org" gemspec group :development do - gem "async" - gem "minitest" - gem "minitest-focus" - gem "minitest-hooks" - gem "minitest-proveit" - gem "minitest-rg" gem "rake" gem "rbs" gem "rubocop" @@ -20,6 +14,19 @@ group :development do # TODO: using a fork for now, the prettier below has a bug gem "syntax_tree-rbs", github: "stainless-api/syntax_tree-rbs", branch: "main" gem "tapioca" +end + +group :development, :test do + gem "async" + gem "minitest" + gem "minitest-focus" + gem "minitest-hooks" + gem "minitest-proveit" + gem "minitest-rg" +end + +group :development, :docs do + gem "redcarpet" gem "webrick" gem "yard" end diff --git a/Gemfile.lock b/Gemfile.lock index 333b95fb..0bcf3d3b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - openai (0.1.0.pre.alpha.2) + openai (0.1.0.pre.alpha.3) connection_pool GEM @@ -29,8 +29,8 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) - ast (2.4.2) - async (2.23.0) + ast (2.4.3) + async (2.23.1) console (~> 1.29) fiber-annotation io-event (~> 1.9) @@ -41,11 +41,11 @@ GEM bigdecimal (3.1.9) concurrent-ruby (1.3.5) connection_pool (2.5.0) - console (1.29.3) + console (1.30.2) fiber-annotation fiber-local (~> 1.1) json - csv (3.3.2) + csv (3.3.3) drb (2.2.1) erubi (1.13.1) ffi (1.17.1) @@ -56,16 +56,16 @@ GEM fileutils (1.7.3) i18n (1.14.7) concurrent-ruby (~> 1.0) - io-event (1.9.0) - json (2.10.1) + io-event (1.10.0) + json (2.10.2) language_server-protocol (3.17.0.4) lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.6) - metrics (0.12.1) - minitest (5.25.4) + logger (1.7.0) + metrics (0.12.2) + minitest (5.25.5) minitest-focus (1.4.0) minitest (>= 4, < 6) minitest-hooks (1.5.2) @@ -74,26 +74,29 @@ GEM minitest (> 5, < 7) minitest-rg (5.3.0) minitest (~> 5.0) + mutex_m (0.3.0) netrc (0.11.0) parallel (1.26.3) - parser (3.3.7.1) + parser (3.3.7.4) ast (~> 2.4.1) racc prettier_print (1.2.1) - prism (1.3.0) + prism (1.4.0) racc (1.8.1) rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rbi (0.2.4) + rbi (0.3.1) prism (~> 1.0) + rbs (>= 3.4.4) sorbet-runtime (>= 0.5.9204) - rbs (3.8.1) + rbs (3.9.2) logger + redcarpet (3.6.1) regexp_parser (2.10.0) - rubocop (1.73.2) + rubocop (1.75.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -101,41 +104,43 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.43.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) + rubocop-ast (1.43.0) + parser (>= 3.3.7.2) + prism (~> 1.4) ruby-progressbar (1.13.0) securerandom (0.4.1) - sorbet (0.5.11888) - sorbet-static (= 0.5.11888) - sorbet-runtime (0.5.11888) - sorbet-static (0.5.11888-x86_64-linux) - sorbet-static-and-runtime (0.5.11888) - sorbet (= 0.5.11888) - sorbet-runtime (= 0.5.11888) - spoom (1.5.4) + sorbet (0.5.11966) + sorbet-static (= 0.5.11966) + sorbet-runtime (0.5.11966) + sorbet-static (0.5.11966-x86_64-linux) + sorbet-static-and-runtime (0.5.11966) + sorbet (= 0.5.11966) + sorbet-runtime (= 0.5.11966) + spoom (1.6.1) erubi (>= 1.10.0) prism (>= 0.28.0) rbi (>= 0.2.3) sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) - steep (1.9.4) + steep (1.10.0) activesupport (>= 5.1) concurrent-ruby (>= 1.1.10) csv (>= 3.0.9) fileutils (>= 1.1.0) json (>= 2.1.0) - language_server-protocol (>= 3.15, < 4.0) + language_server-protocol (>= 3.17.0.4, < 4.0) listen (~> 3.0) logger (>= 1.3.0) + mutex_m (>= 0.3.0) parser (>= 3.1) rainbow (>= 2.2.2, < 4.0) - rbs (~> 3.8) + rbs (~> 3.9) securerandom (>= 0.1) strscan (>= 1.0.0) - terminal-table (>= 2, < 4) + terminal-table (>= 2, < 5) uri (>= 0.12.0) strscan (3.1.2) syntax_tree (6.2.0) @@ -150,13 +155,15 @@ GEM spoom (>= 1.2.0) thor (>= 1.2.0) yard-sorbet - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) thor (1.3.2) traces (0.15.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) uri (1.0.3) webrick (1.9.1) yard (0.9.37) @@ -177,6 +184,7 @@ DEPENDENCIES openai! rake rbs + redcarpet rubocop sorbet steep diff --git a/README.md b/README.md index 8b458397..a2b1e0e8 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ The OpenAI Ruby library provides convenient access to the OpenAI REST API from a ## Documentation -Documentation for the most recent release of this gem can be found [on RubyDoc](https://gemdocs.org/gems/openai/latest). +Documentation for released of this gem can be found [on RubyDoc](https://gemdocs.org/gems/openai). The underlying REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). ## Installation -To use this gem during the beta, install directly from GitHub with Bundler by adding the following to your application's `Gemfile`: +To use this gem, install via Bundler by adding the following to your application's `Gemfile`: ```ruby -gem "openai", git: "https://github.com/openai/openai-ruby", branch: "main" +gem "openai", "~> 0.1.0.pre.alpha.2" ``` To fetch an initial copy of the gem: @@ -22,12 +22,6 @@ To fetch an initial copy of the gem: bundle install ``` -To update the version used by your application when updates are pushed to GitHub: - -```sh -bundle update openai -``` - ## Usage ```ruby @@ -81,7 +75,7 @@ stream = openai.chat.completions.create_streaming( model: "gpt-4o" ) -stream.for_each do |completion| +stream.each do |completion| puts(completion) end ``` @@ -166,14 +160,18 @@ openai.chat.completions.create( ## Sorbet Support +**This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality. + This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`. What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet itself. Due to limitations with the Sorbet type system, where a method otherwise can take an instance of `OpenAI::BaseModel` class, you will need to use the `**` splat operator to pass the arguments: +Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience. + ```ruby -model = CompletionCreateParams.new( +model = OpenAI::Models::Chat::CompletionCreateParams.new( messages: [{ role: "user", content: "Say this is a test" @@ -184,6 +182,18 @@ model = CompletionCreateParams.new( openai.chat.completions.create(**model) ``` +## Advanced + +### Concurrency & Connection Pooling + +The `OpenAI::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count. + +When the maximum number of connections has been checked out from the connection pool, the `Client` will wait for an in use connection to become available. The queue time for this mechanism is accounted for by the per-request timeout. + +Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure. + +Currently, `OpenAI::Client` instances are only fork-safe if there are no in-flight HTTP requests. + ## Versioning This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time. diff --git a/Rakefile b/Rakefile index 7ea8a2fc..92963d6a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,20 +1,25 @@ # frozen_string_literal: true +require "securerandom" +require "shellwords" + require "minitest/test_task" require "rake/clean" require "rubocop/rake_task" -require "securerandom" -require "shellwords" CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/]) xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --] -task(default: [:test, :format]) +multitask(default: [:test]) + +multitask(:test) do + rb = + FileList[ENV.fetch("TEST", "./test/**/*_test.rb")] + .map { "require_relative(#{_1.dump});" } + .join -Minitest::TestTask.create do |t| - t.libs = %w[.] - t.test_globs = ENV.fetch("TEST", "./test/**/*_test.rb") + ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 } end RuboCop::RakeTask.new(:rubocop) do |t| @@ -35,24 +40,25 @@ multitask(:syntax_tree) do inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? %w[-i''] : %w[-i] uuid = SecureRandom.uuid - # `syntax_tree` has trouble with `rbs`'s class aliases + # `syntax_tree` has trouble with `rbs`'s class & module aliases sed = xargs + %w[sed -E] + inplace + %w[-e] - # annotate class aliases with a unique comment - pre = sed + ["s/class ([^ ]+) = (.+$)/# #{uuid}\\n\\1: \\2/", "--"] + # annotate unprocessable aliases with a unique comment + pre = sed + ["s/(class|module) ([^ ]+) = (.+$)/# \\1 #{uuid}\\n\\2: \\3/", "--"] fmt = xargs + %w[stree write --plugin=rbs --] - # remove the unique comment and transform class aliases to type aliases + # remove the unique comment and unprocessable aliases to type aliases subst = <<~SED - s/# #{uuid}// + s/# (class|module) #{uuid}/\\1/ t l1 b + : l1 - n - s/([^ :]+): (.+$)/class \\1 = \\2/ + N + s/\\n *([^:]+): (.+)$/ \\1 = \\2/ SED - # 1. delete the unique comment - # 2. if deletion happened, branch to label `l1`, else continue - # 3. transform the class alias to a type alias at label `l1` + # for each line: + # 1. try transform the unique comment into `class | module`, if successful, branch to label `l1`. + # 2. at label `l1`, join previously annotated line with `class | module` information. pst = sed + [subst, "--"] # transform class aliases to type aliases, which syntax tree has no trouble with @@ -70,7 +76,7 @@ multitask(:steep) do end multitask(:sorbet) do - sh(*%w[srb typecheck -- .], chdir: "./rbi") + sh(*%w[srb typecheck]) end file("sorbet/tapioca") do diff --git a/Steepfile b/Steepfile index 48667fe7..6e5d0ac5 100644 --- a/Steepfile +++ b/Steepfile @@ -9,7 +9,7 @@ target :lib do YAML.safe_load_file("./manifest.yaml", symbolize_names: true) => { dependencies: } # currently these libraries lack the `*.rbs` annotations required by `steep` - stdlibs = dependencies - %w[etc net/http rbconfig set stringio] + stdlibs = dependencies - %w[English etc net/http rbconfig set stringio] stdlibs.each { library(_1) } end diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 00000000..d8c73e93 --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/lib/openai.rb b/lib/openai.rb index 77ad926a..a2330683 100644 --- a/lib/openai.rb +++ b/lib/openai.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true # Standard libraries. +require "English" require "cgi" require "date" require "erb" @@ -15,20 +16,43 @@ require "time" require "uri" +# We already ship the preferred sorbet manifests in the package itself. +# `tapioca` currently does not offer us a way to opt out of unnecessary compilation. +if Object.const_defined?(:Tapioca) && caller.chain([$PROGRAM_NAME]).chain(ARGV).grep(/tapioca/) + Warning.warn( + <<~WARN + \n + ⚠️ skipped loading of "openai" gem under `tapioca`. + + This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation. + \n + WARN + ) + return +end + # Gems. require "connection_pool" # Package files. require_relative "openai/version" require_relative "openai/util" -require_relative "openai/extern" -require_relative "openai/base_model" -require_relative "openai/base_page" -require_relative "openai/base_stream" +require_relative "openai/type/converter" +require_relative "openai/type/unknown" +require_relative "openai/type/boolean_model" +require_relative "openai/type/enum" +require_relative "openai/type/union" +require_relative "openai/type/array_of" +require_relative "openai/type/hash_of" +require_relative "openai/type/base_model" +require_relative "openai/type/base_page" +require_relative "openai/type/base_stream" +require_relative "openai/type/request_parameters" +require_relative "openai/type" require_relative "openai/request_options" require_relative "openai/errors" -require_relative "openai/base_client" -require_relative "openai/pooled_net_requester" +require_relative "openai/transport/base_client" +require_relative "openai/transport/pooled_net_requester" require_relative "openai/client" require_relative "openai/stream" require_relative "openai/cursor_page" @@ -36,12 +60,18 @@ require_relative "openai/models/reasoning_effort" require_relative "openai/models/chat/chat_completion_message" require_relative "openai/models/fine_tuning/fine_tuning_job_wandb_integration_object" +require_relative "openai/models/responses/response_function_tool_call" +require_relative "openai/models/all_models" require_relative "openai/models/audio/speech_create_params" require_relative "openai/models/audio/speech_model" require_relative "openai/models/audio/transcription" require_relative "openai/models/audio/transcription_create_params" require_relative "openai/models/audio/transcription_create_response" +require_relative "openai/models/audio/transcription_include" require_relative "openai/models/audio/transcription_segment" +require_relative "openai/models/audio/transcription_stream_event" +require_relative "openai/models/audio/transcription_text_delta_event" +require_relative "openai/models/audio/transcription_text_done_event" require_relative "openai/models/audio/transcription_verbose" require_relative "openai/models/audio/transcription_word" require_relative "openai/models/audio/translation" @@ -259,6 +289,8 @@ require_relative "openai/models/responses/response_code_interpreter_tool_call" require_relative "openai/models/responses/response_completed_event" require_relative "openai/models/responses/response_computer_tool_call" +require_relative "openai/models/responses/response_computer_tool_call_output_item" +require_relative "openai/models/responses/response_computer_tool_call_output_screenshot" require_relative "openai/models/responses/response_content" require_relative "openai/models/responses/response_content_part_added_event" require_relative "openai/models/responses/response_content_part_done_event" @@ -276,7 +308,8 @@ require_relative "openai/models/responses/response_format_text_json_schema_config" require_relative "openai/models/responses/response_function_call_arguments_delta_event" require_relative "openai/models/responses/response_function_call_arguments_done_event" -require_relative "openai/models/responses/response_function_tool_call" +require_relative "openai/models/responses/response_function_tool_call_item" +require_relative "openai/models/responses/response_function_tool_call_output_item" require_relative "openai/models/responses/response_function_web_search" require_relative "openai/models/responses/response_includable" require_relative "openai/models/responses/response_incomplete_event" @@ -288,7 +321,9 @@ require_relative "openai/models/responses/response_input_image" require_relative "openai/models/responses/response_input_item" require_relative "openai/models/responses/response_input_message_content_list" +require_relative "openai/models/responses/response_input_message_item" require_relative "openai/models/responses/response_input_text" +require_relative "openai/models/responses/response_item" require_relative "openai/models/responses/response_item_list" require_relative "openai/models/responses/response_output_audio" require_relative "openai/models/responses/response_output_item" @@ -316,6 +351,7 @@ require_relative "openai/models/responses/tool_choice_options" require_relative "openai/models/responses/tool_choice_types" require_relative "openai/models/responses/web_search_tool" +require_relative "openai/models/responses_model" require_relative "openai/models/static_file_chunking_strategy" require_relative "openai/models/static_file_chunking_strategy_object" require_relative "openai/models/static_file_chunking_strategy_object_param" diff --git a/lib/openai/base_client.rb b/lib/openai/base_client.rb deleted file mode 100644 index b5cc5490..00000000 --- a/lib/openai/base_client.rb +++ /dev/null @@ -1,456 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @api private - # - # @abstract - class BaseClient - # from whatwg fetch spec - MAX_REDIRECTS = 20 - - # rubocop:disable Style/MutableConstant - PLATFORM_HEADERS = { - "x-stainless-arch" => OpenAI::Util.arch, - "x-stainless-lang" => "ruby", - "x-stainless-os" => OpenAI::Util.os, - "x-stainless-package-version" => OpenAI::VERSION, - "x-stainless-runtime" => ::RUBY_ENGINE, - "x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION - } - # rubocop:enable Style/MutableConstant - - class << self - # @api private - # - # @param req [Hash{Symbol=>Object}] - # - # @raise [ArgumentError] - def validate!(req) - keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options] - case req - in Hash - req.each_key do |k| - unless keys.include?(k) - raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}") - end - end - else - raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}") - end - end - - # @api private - # - # @param status [Integer] - # @param headers [Hash{String=>String}, Net::HTTPHeader] - # - # @return [Boolean] - def should_retry?(status, headers:) - coerced = OpenAI::Util.coerce_boolean(headers["x-should-retry"]) - case [coerced, status] - in [true | false, _] - coerced - in [_, 408 | 409 | 429 | (500..)] - # retry on: - # 408: timeouts - # 409: locks - # 429: rate limits - # 500+: unknown errors - true - else - false - end - end - - # @api private - # - # @param request [Hash{Symbol=>Object}] . - # - # @option request [Symbol] :method - # - # @option request [URI::Generic] :url - # - # @option request [Hash{String=>String}] :headers - # - # @option request [Object] :body - # - # @option request [Integer] :max_retries - # - # @option request [Float] :timeout - # - # @param status [Integer] - # - # @param response_headers [Hash{String=>String}, Net::HTTPHeader] - # - # @return [Hash{Symbol=>Object}] - def follow_redirect(request, status:, response_headers:) - method, url, headers = request.fetch_values(:method, :url, :headers) - location = - Kernel.then do - URI.join(url, response_headers["location"]) - rescue ArgumentError - message = "Server responded with status #{status} but no valid location header." - raise OpenAI::APIConnectionError.new(url: url, message: message) - end - - request = {**request, url: location} - - case [url.scheme, location.scheme] - in ["https", "http"] - message = "Tried to redirect to a insecure URL" - raise OpenAI::APIConnectionError.new(url: url, message: message) - else - nil - end - - # from whatwg fetch spec - case [status, method] - in [301 | 302, :post] | [303, _] - drop = %w[content-encoding content-language content-length content-location content-type] - request = { - **request, - method: method == :head ? :head : :get, - headers: headers.except(*drop), - body: nil - } - else - end - - # from undici - if OpenAI::Util.uri_origin(url) != OpenAI::Util.uri_origin(location) - drop = %w[authorization cookie host proxy-authorization] - request = {**request, headers: request.fetch(:headers).except(*drop)} - end - - request - end - - # @api private - # - # @param status [Integer, OpenAI::APIConnectionError] - # @param stream [Enumerable, nil] - def reap_connection!(status, stream:) - case status - in (..199) | (300..499) - stream&.each { next } - in OpenAI::APIConnectionError | (500..) - OpenAI::Util.close_fused!(stream) - else - end - end - end - - # @api private - # @return [OpenAI::PooledNetRequester] - attr_accessor :requester - - # @api private - # - # @param base_url [String] - # @param timeout [Float] - # @param max_retries [Integer] - # @param initial_retry_delay [Float] - # @param max_retry_delay [Float] - # @param headers [Hash{String=>String, Integer, Array, nil}] - # @param idempotency_header [String, nil] - def initialize( - base_url:, - timeout: 0.0, - max_retries: 0, - initial_retry_delay: 0.0, - max_retry_delay: 0.0, - headers: {}, - idempotency_header: nil - ) - @requester = OpenAI::PooledNetRequester.new - @headers = OpenAI::Util.normalized_headers( - self.class::PLATFORM_HEADERS, - { - "accept" => "application/json", - "content-type" => "application/json" - }, - headers - ) - @base_url = OpenAI::Util.parse_uri(base_url) - @idempotency_header = idempotency_header&.to_s&.downcase - @max_retries = max_retries - @timeout = timeout - @initial_retry_delay = initial_retry_delay - @max_retry_delay = max_retry_delay - end - - # @api private - # - # @return [Hash{String=>String}] - private def auth_headers = {} - - # @api private - # - # @return [String] - private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}" - - # @api private - # - # @param req [Hash{Symbol=>Object}] . - # - # @option req [Symbol] :method - # - # @option req [String, Array] :path - # - # @option req [Hash{String=>Array, String, nil}, nil] :query - # - # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers - # - # @option req [Object, nil] :body - # - # @option req [Symbol, nil] :unwrap - # - # @option req [Class, nil] :page - # - # @option req [Class, nil] :stream - # - # @option req [OpenAI::Converter, Class, nil] :model - # - # @param opts [Hash{Symbol=>Object}] . - # - # @option opts [String, nil] :idempotency_key - # - # @option opts [Hash{String=>Array, String, nil}, nil] :extra_query - # - # @option opts [Hash{String=>String, nil}, nil] :extra_headers - # - # @option opts [Hash{Symbol=>Object}, nil] :extra_body - # - # @option opts [Integer, nil] :max_retries - # - # @option opts [Float, nil] :timeout - # - # @return [Hash{Symbol=>Object}] - private def build_request(req, opts) - method, uninterpolated_path = req.fetch_values(:method, :path) - - path = OpenAI::Util.interpolate_path(uninterpolated_path) - - query = OpenAI::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h) - - headers = OpenAI::Util.normalized_headers( - @headers, - auth_headers, - req[:headers].to_h, - opts[:extra_headers].to_h - ) - - if @idempotency_header && - !headers.key?(@idempotency_header) && - !Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) - headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key } - end - - unless headers.key?("x-stainless-retry-count") - headers["x-stainless-retry-count"] = "0" - end - - timeout = opts.fetch(:timeout, @timeout).to_f.clamp((0..)) - unless headers.key?("x-stainless-timeout") || timeout.zero? - headers["x-stainless-timeout"] = timeout.to_s - end - - headers.reject! { |_, v| v.to_s.empty? } - - body = - case method - in :get | :head | :options | :trace - nil - else - OpenAI::Util.deep_merge(*[req[:body], opts[:extra_body]].compact) - end - - headers, encoded = OpenAI::Util.encode_content(headers, body) - { - method: method, - url: OpenAI::Util.join_parsed_uri(@base_url, {**req, path: path, query: query}), - headers: headers, - body: encoded, - max_retries: opts.fetch(:max_retries, @max_retries), - timeout: timeout - } - end - - # @api private - # - # @param headers [Hash{String=>String}] - # @param retry_count [Integer] - # - # @return [Float] - private def retry_delay(headers, retry_count:) - # Non-standard extension - span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 } - return span if span - - retry_header = headers["retry-after"] - return span if (span = Float(retry_header, exception: false)) - - span = retry_header&.then do - Time.httpdate(_1) - Time.now - rescue ArgumentError - nil - end - return span if span - - scale = retry_count**2 - jitter = 1 - (0.25 * rand) - (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay) - end - - # @api private - # - # @param request [Hash{Symbol=>Object}] . - # - # @option request [Symbol] :method - # - # @option request [URI::Generic] :url - # - # @option request [Hash{String=>String}] :headers - # - # @option request [Object] :body - # - # @option request [Integer] :max_retries - # - # @option request [Float] :timeout - # - # @param redirect_count [Integer] - # - # @param retry_count [Integer] - # - # @param send_retry_header [Boolean] - # - # @raise [OpenAI::APIError] - # @return [Array(Integer, Net::HTTPResponse, Enumerable)] - private def send_request(request, redirect_count:, retry_count:, send_retry_header:) - url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout) - input = {**request.except(:timeout), deadline: OpenAI::Util.monotonic_secs + timeout} - - if send_retry_header - headers["x-stainless-retry-count"] = retry_count.to_s - end - - begin - status, response, stream = @requester.execute(input) - rescue OpenAI::APIConnectionError => e - status = e - end - - case status - in ..299 - [status, response, stream] - in 300..399 if redirect_count >= self.class::MAX_REDIRECTS - self.class.reap_connection!(status, stream: stream) - - message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects." - raise OpenAI::APIConnectionError.new(url: url, message: message) - in 300..399 - self.class.reap_connection!(status, stream: stream) - - request = self.class.follow_redirect(request, status: status, response_headers: response) - send_request( - request, - redirect_count: redirect_count + 1, - retry_count: retry_count, - send_retry_header: send_retry_header - ) - in OpenAI::APIConnectionError if retry_count >= max_retries - raise status - in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response) - decoded = Kernel.then do - OpenAI::Util.decode_content(response, stream: stream, suppress_error: true) - ensure - self.class.reap_connection!(status, stream: stream) - end - - raise OpenAI::APIStatusError.for( - url: url, - status: status, - body: decoded, - request: nil, - response: response - ) - in (400..) | OpenAI::APIConnectionError - self.class.reap_connection!(status, stream: stream) - - delay = retry_delay(response, retry_count: retry_count) - sleep(delay) - - send_request( - request, - redirect_count: redirect_count, - retry_count: retry_count + 1, - send_retry_header: send_retry_header - ) - end - end - - # Execute the request specified by `req`. This is the method that all resource - # methods call into. - # - # @param req [Hash{Symbol=>Object}] . - # - # @option req [Symbol] :method - # - # @option req [String, Array] :path - # - # @option req [Hash{String=>Array, String, nil}, nil] :query - # - # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers - # - # @option req [Object, nil] :body - # - # @option req [Symbol, nil] :unwrap - # - # @option req [Class, nil] :page - # - # @option req [Class, nil] :stream - # - # @option req [OpenAI::Converter, Class, nil] :model - # - # @option req [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :options - # - # @raise [OpenAI::APIError] - # @return [Object] - def request(req) - self.class.validate!(req) - model = req.fetch(:model) { OpenAI::Unknown } - opts = req[:options].to_h - OpenAI::RequestOptions.validate!(opts) - request = build_request(req.except(:options), opts) - url = request.fetch(:url) - - # Don't send the current retry count in the headers if the caller modified the header defaults. - send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0" - status, response, stream = send_request( - request, - redirect_count: 0, - retry_count: 0, - send_retry_header: send_retry_header - ) - - decoded = OpenAI::Util.decode_content(response, stream: stream) - case req - in { stream: Class => st } - st.new(model: model, url: url, status: status, response: response, messages: decoded) - in { page: Class => page } - page.new(client: self, req: req, headers: response, page_data: decoded) - else - unwrapped = OpenAI::Util.dig(decoded, req[:unwrap]) - OpenAI::Converter.coerce(model, unwrapped) - end - end - - # @return [String] - def inspect - # rubocop:disable Layout/LineLength - base_url = OpenAI::Util.unparse_uri(@base_url) - "#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{base_url} max_retries=#{@max_retries} timeout=#{@timeout}>" - # rubocop:enable Layout/LineLength - end - end -end diff --git a/lib/openai/base_model.rb b/lib/openai/base_model.rb deleted file mode 100644 index 4ef0106e..00000000 --- a/lib/openai/base_model.rb +++ /dev/null @@ -1,1221 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @api private - module Converter - # rubocop:disable Lint/UnusedMethodArgument - - # @api private - # - # @param value [Object] - # - # @return [Object] - def coerce(value) = value - - # @api private - # - # @param value [Object] - # - # @return [Object] - def dump(value) = value - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) = (raise NotImplementedError) - - # rubocop:enable Lint/UnusedMethodArgument - - class << self - # @api private - # - # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - # - # @return [Proc] - def type_info(spec) - case spec - in Hash - type_info(spec.slice(:const, :enum, :union).first&.last) - in Proc - spec - in OpenAI::Converter | Class | Symbol - -> { spec } - in true | false - -> { OpenAI::BooleanModel } - in NilClass | Integer | Float - -> { spec.class } - end - end - - # @api private - # - # Based on `target`, transform `value` into `target`, to the extent possible: - # - # 1. if the given `value` conforms to `target` already, return the given `value` - # 2. if it's possible and safe to convert the given `value` to `target`, then the - # converted value - # 3. otherwise, the given `value` unaltered - # - # @param target [OpenAI::Converter, Class] - # @param value [Object] - # - # @return [Object] - def coerce(target, value) - case target - in OpenAI::Converter - target.coerce(value) - in Symbol - case value - in Symbol | String if (val = value.to_sym) == target - val - else - value - end - in Class - case target - in -> { _1 <= NilClass } - nil - in -> { _1 <= Integer } - value.is_a?(Numeric) ? Integer(value) : value - in -> { _1 <= Float } - value.is_a?(Numeric) ? Float(value) : value - in -> { _1 <= Symbol } - value.is_a?(String) ? value.to_sym : value - in -> { _1 <= String } - value.is_a?(Symbol) ? value.to_s : value - in -> { _1 <= Date || _1 <= Time } - value.is_a?(String) ? target.parse(value) : value - in -> { _1 <= IO } - value.is_a?(String) ? StringIO.new(value) : value - else - value - end - end - end - - # @api private - # - # @param target [OpenAI::Converter, Class] - # @param value [Object] - # - # @return [Object] - def dump(target, value) - case target - in OpenAI::Converter - target.dump(value) - else - value - end - end - - # @api private - # - # The underlying algorithm for computing maximal compatibility is subject to - # future improvements. - # - # Similar to `#.coerce`, used to determine the best union variant to decode into. - # - # 1. determine if strict-ish coercion is possible - # 2. return either result of successful coercion or if loose coercion is possible - # 3. return a score for recursively tallied count for fields that can be coerced - # - # @param target [OpenAI::Converter, Class] - # @param value [Object] - # - # @return [Object] - def try_strict_coerce(target, value) - case target - in OpenAI::Converter - target.try_strict_coerce(value) - in Symbol - case value - in Symbol | String if (val = value.to_sym) == target - [true, val, 1] - else - [false, false, 0] - end - in Class - case [target, value] - in [-> { _1 <= NilClass }, _] - [true, nil, value.nil? ? 1 : 0] - in [-> { _1 <= Integer }, Numeric] - [true, Integer(value), 1] - in [-> { _1 <= Float }, Numeric] - [true, Float(value), 1] - in [-> { _1 <= Symbol }, String] - [true, value.to_sym, 1] - in [-> { _1 <= String }, Symbol] - [true, value.to_s, 1] - in [-> { _1 <= Date || _1 <= Time }, String] - Kernel.then do - [true, target.parse(value), 1] - rescue ArgumentError - [false, false, 0] - end - in [_, ^target] - [true, value, 1] - else - [false, false, 0] - end - end - end - end - end - - # @api private - # - # @abstract - # - # When we don't know what to expect for the value. - class Unknown - extend OpenAI::Converter - - # rubocop:disable Lint/UnusedMethodArgument - - private_class_method :new - - # @param other [Object] - # - # @return [Boolean] - def self.===(other) = true - - # @param other [Object] - # - # @return [Boolean] - def self.==(other) = other.is_a?(Class) && other <= OpenAI::Unknown - - class << self - # @!parse - # # @api private - # # - # # @param value [Object] - # # - # # @return [Object] - # def coerce(value) = super - - # @!parse - # # @api private - # # - # # @param value [Object] - # # - # # @return [Object] - # def dump(value) = super - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - # prevent unknown variant from being chosen during the first coercion pass - [false, true, 0] - end - end - - # rubocop:enable Lint/UnusedMethodArgument - end - - # @api private - # - # @abstract - # - # Ruby has no Boolean class; this is something for models to refer to. - class BooleanModel - extend OpenAI::Converter - - private_class_method :new - - # @param other [Object] - # - # @return [Boolean] - def self.===(other) = other == true || other == false - - # @param other [Object] - # - # @return [Boolean] - def self.==(other) = other.is_a?(Class) && other <= OpenAI::BooleanModel - - class << self - # @!parse - # # @api private - # # - # # @param value [Boolean, Object] - # # - # # @return [Boolean, Object] - # def coerce(value) = super - - # @!parse - # # @api private - # # - # # @param value [Boolean, Object] - # # - # # @return [Boolean, Object] - # def dump(value) = super - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - case value - in true | false - [true, value, 1] - else - [false, false, 0] - end - end - end - end - - # @api private - # - # @abstract - # - # A value from among a specified list of options. OpenAPI enum values map to Ruby - # values in the SDK as follows: - # - # 1. boolean => true | false - # 2. integer => Integer - # 3. float => Float - # 4. string => Symbol - # - # We can therefore convert string values to Symbols, but can't convert other - # values safely. - # - # @example - # ```ruby - # # `chat_model` is a `OpenAI::Models::ChatModel` - # case chat_model - # when OpenAI::Models::ChatModel::O3_MINI - # # ... - # when OpenAI::Models::ChatModel::O3_MINI_2025_01_31 - # # ... - # when OpenAI::Models::ChatModel::O1 - # # ... - # else - # puts(chat_model) - # end - # ``` - # - # @example - # ```ruby - # case chat_model - # in :"o3-mini" - # # ... - # in :"o3-mini-2025-01-31" - # # ... - # in :o1 - # # ... - # else - # puts(chat_model) - # end - # ``` - class Enum - extend OpenAI::Converter - - class << self - # All of the valid Symbol values for this enum. - # - # @return [Array] - def values = (@values ||= constants.map { const_get(_1) }) - - # @api private - # - # Guard against thread safety issues by instantiating `@values`. - private def finalize! = values - end - - private_class_method :new - - # @param other [Object] - # - # @return [Boolean] - def self.===(other) = values.include?(other) - - # @param other [Object] - # - # @return [Boolean] - def self.==(other) - other.is_a?(Class) && other <= OpenAI::Enum && other.values.to_set == values.to_set - end - - class << self - # @api private - # - # @param value [String, Symbol, Object] - # - # @return [Symbol, Object] - def coerce(value) - case value - in Symbol | String if values.include?(val = value.to_sym) - val - else - value - end - end - - # @!parse - # # @api private - # # - # # @param value [Symbol, Object] - # # - # # @return [Symbol, Object] - # def dump(value) = super - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - return [true, value, 1] if values.include?(value) - - case value - in Symbol | String if values.include?(val = value.to_sym) - [true, val, 1] - else - case [value, values.first] - in [true | false, true | false] | [Integer, Integer] | [Symbol | String, Symbol] - [false, true, 0] - else - [false, false, 0] - end - end - end - end - end - - # @api private - # - # @abstract - # - # @example - # ```ruby - # # `chat_completion_content_part` is a `OpenAI::Models::Chat::ChatCompletionContentPart` - # case chat_completion_content_part - # when OpenAI::Models::Chat::ChatCompletionContentPartText - # puts(chat_completion_content_part.text) - # when OpenAI::Models::Chat::ChatCompletionContentPartImage - # puts(chat_completion_content_part.image_url) - # when OpenAI::Models::Chat::ChatCompletionContentPartInputAudio - # puts(chat_completion_content_part.input_audio) - # else - # puts(chat_completion_content_part) - # end - # ``` - # - # @example - # ```ruby - # case chat_completion_content_part - # in {type: :text, text: text} - # puts(text) - # in {type: :image_url, image_url: image_url} - # puts(image_url) - # in {type: :input_audio, input_audio: input_audio} - # puts(input_audio) - # else - # puts(chat_completion_content_part) - # end - # ``` - class Union - extend OpenAI::Converter - - class << self - # @api private - # - # All of the specified variant info for this union. - # - # @return [Array] - private def known_variants = (@known_variants ||= []) - - # @api private - # - # @return [Array] - protected def derefed_variants - @known_variants.map { |key, variant_fn| [key, variant_fn.call] } - end - - # All of the specified variants for this union. - # - # @return [Array] - def variants - derefed_variants.map(&:last) - end - - # @api private - # - # @param property [Symbol] - private def discriminator(property) - case property - in Symbol - @discriminator = property - end - end - - # @api private - # - # @param key [Symbol, Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - private def variant(key, spec = nil) - variant_info = - case key - in Symbol - [key, OpenAI::Converter.type_info(spec)] - in Proc | OpenAI::Converter | Class | Hash - [nil, OpenAI::Converter.type_info(key)] - end - - known_variants << variant_info - end - - # @api private - # - # @param value [Object] - # - # @return [OpenAI::Converter, Class, nil] - private def resolve_variant(value) - case [@discriminator, value] - in [_, OpenAI::BaseModel] - value.class - in [Symbol, Hash] - key = - if value.key?(@discriminator) - value.fetch(@discriminator) - elsif value.key?((discriminator = @discriminator.to_s)) - value.fetch(discriminator) - end - - key = key.to_sym if key.is_a?(String) - _, resolved = known_variants.find { |k,| k == key } - resolved.nil? ? OpenAI::Unknown : resolved.call - else - nil - end - end - end - - # rubocop:disable Style/HashEachMethods - # rubocop:disable Style/CaseEquality - - private_class_method :new - - # @param other [Object] - # - # @return [Boolean] - def self.===(other) - known_variants.any? do |_, variant_fn| - variant_fn.call === other - end - end - - # @param other [Object] - # - # @return [Boolean] - def self.==(other) - other.is_a?(Class) && other <= OpenAI::Union && other.derefed_variants == derefed_variants - end - - class << self - # @api private - # - # @param value [Object] - # - # @return [Object] - def coerce(value) - if (variant = resolve_variant(value)) - return OpenAI::Converter.coerce(variant, value) - end - - matches = [] - - known_variants.each do |_, variant_fn| - variant = variant_fn.call - - case OpenAI::Converter.try_strict_coerce(variant, value) - in [true, coerced, _] - return coerced - in [false, true, score] - matches << [score, variant] - in [false, false, _] - nil - end - end - - _, variant = matches.sort! { _2.first <=> _1.first }.find { |score,| !score.zero? } - variant.nil? ? value : OpenAI::Converter.coerce(variant, value) - end - - # @api private - # - # @param value [Object] - # - # @return [Object] - def dump(value) - if (variant = resolve_variant(value)) - return OpenAI::Converter.dump(variant, value) - end - - known_variants.each do |_, variant_fn| - variant = variant_fn.call - if variant === value - return OpenAI::Converter.dump(variant, value) - end - end - value - end - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - # TODO(ruby) this will result in super linear decoding behaviour for nested unions - # follow up with a decoding context that captures current strictness levels - if (variant = resolve_variant(value)) - return Converter.try_strict_coerce(variant, value) - end - - coercible = false - max_score = 0 - - known_variants.each do |_, variant_fn| - variant = variant_fn.call - - case OpenAI::Converter.try_strict_coerce(variant, value) - in [true, coerced, score] - return [true, coerced, score] - in [false, true, score] - coercible = true - max_score = [max_score, score].max - in [false, false, _] - nil - end - end - - [false, coercible, max_score] - end - end - - # rubocop:enable Style/CaseEquality - # rubocop:enable Style/HashEachMethods - end - - # @api private - # - # @abstract - # - # Array of items of a given type. - class ArrayOf - include OpenAI::Converter - - private_class_method :new - - def self.[](...) = new(...) - - # @param other [Object] - # - # @return [Boolean] - def ===(other) - type = item_type - case other - in Array - # rubocop:disable Style/CaseEquality - other.all? { type === _1 } - # rubocop:enable Style/CaseEquality - else - false - end - end - - # @param other [Object] - # - # @return [Boolean] - def ==(other) = other.is_a?(OpenAI::ArrayOf) && other.item_type == item_type - - # @api private - # - # @param value [Enumerable, Object] - # - # @return [Array, Object] - def coerce(value) - type = item_type - case value - in Enumerable unless value.is_a?(Hash) - value.map { OpenAI::Converter.coerce(type, _1) } - else - value - end - end - - # @api private - # - # @param value [Enumerable, Object] - # - # @return [Array, Object] - def dump(value) - type = item_type - case value - in Enumerable unless value.is_a?(Hash) - value.map { OpenAI::Converter.dump(type, _1) }.to_a - else - value - end - end - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - case value - in Array - type = item_type - great_success = true - tally = 0 - - mapped = - value.map do |item| - case OpenAI::Converter.try_strict_coerce(type, item) - in [true, coerced, score] - tally += score - coerced - in [false, true, score] - great_success = false - tally += score - item - in [false, false, _] - great_success &&= item.nil? - item - end - end - - if great_success - [true, mapped, tally] - else - [false, true, tally] - end - else - [false, false, 0] - end - end - - # @api private - # - # @return [OpenAI::Converter, Class] - protected def item_type = @item_type_fn.call - - # @api private - # - # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - def initialize(type_info, spec = {}) - @item_type_fn = OpenAI::Converter.type_info(type_info || spec) - end - end - - # @api private - # - # @abstract - # - # Hash of items of a given type. - class HashOf - include OpenAI::Converter - - private_class_method :new - - def self.[](...) = new(...) - - # @param other [Object] - # - # @return [Boolean] - def ===(other) - type = item_type - case other - in Hash - other.all? do |key, val| - case [key, val] - in [Symbol | String, ^type] - true - else - false - end - end - else - false - end - end - - # @param other [Object] - # - # @return [Boolean] - def ==(other) = other.is_a?(OpenAI::HashOf) && other.item_type == item_type - - # @api private - # - # @param value [Hash{Object=>Object}, Object] - # - # @return [Hash{Symbol=>Object}, Object] - def coerce(value) - type = item_type - case value - in Hash - value.to_h do |key, val| - coerced = OpenAI::Converter.coerce(type, val) - [key.is_a?(String) ? key.to_sym : key, coerced] - end - else - value - end - end - - # @api private - # - # @param value [Hash{Object=>Object}, Object] - # - # @return [Hash{Symbol=>Object}, Object] - def dump(value) - type = item_type - case value - in Hash - value.transform_values do |val| - OpenAI::Converter.dump(type, val) - end - else - value - end - end - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - case value - in Hash - type = item_type - great_success = true - tally = 0 - - mapped = - value.transform_values do |val| - case OpenAI::Converter.try_strict_coerce(type, val) - in [true, coerced, score] - tally += score - coerced - in [false, true, score] - great_success = false - tally += score - val - in [false, false, _] - great_success &&= val.nil? - val - end - end - - if great_success - [true, mapped, tally] - else - [false, true, tally] - end - else - [false, false, 0] - end - end - - # @api private - # - # @return [OpenAI::Converter, Class] - protected def item_type = @item_type_fn.call - - # @api private - # - # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - def initialize(type_info, spec = {}) - @item_type_fn = OpenAI::Converter.type_info(type_info || spec) - end - end - - # @abstract - # - # @example - # ```ruby - # # `comparison_filter` is a `OpenAI::Models::ComparisonFilter` - # comparison_filter => { - # key: key, - # type: type, - # value: value - # } - # ``` - class BaseModel - extend OpenAI::Converter - - class << self - # @api private - # - # Assumes superclass fields are totally defined before fields are accessed / - # defined on subclasses. - # - # @return [Hash{Symbol=>Hash{Symbol=>Object}}] - def known_fields - @known_fields ||= (self < OpenAI::BaseModel ? superclass.known_fields.dup : {}) - end - - # @api private - # - # @return [Hash{Symbol=>Hash{Symbol=>Object}}] - def fields - known_fields.transform_values do |field| - {**field.except(:type_fn), type: field.fetch(:type_fn).call} - end - end - - # @api private - # - # @return [Hash{Symbol=>Proc}] - def defaults = (@defaults ||= {}) - - # @api private - # - # @param name_sym [Symbol] - # - # @param required [Boolean] - # - # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - private def add_field(name_sym, required:, type_info:, spec:) - type_fn, info = - case type_info - in Proc | Class | OpenAI::Converter - [OpenAI::Converter.type_info({**spec, union: type_info}), spec] - in Hash - [OpenAI::Converter.type_info(type_info), type_info] - end - - fallback = info[:const] - defaults[name_sym] = fallback if required && !info[:nil?] && info.key?(:const) - - key = info.fetch(:api_name, name_sym) - setter = "#{name_sym}=" - - if known_fields.key?(name_sym) - [name_sym, setter].each { undef_method(_1) } - end - - known_fields[name_sym] = {mode: @mode, key: key, required: required, type_fn: type_fn} - - define_method(setter) do |val| - @data[key] = val - end - - define_method(name_sym) do - field_type = type_fn.call - value = @data.fetch(key) { self.class.defaults[key] } - OpenAI::Converter.coerce(field_type, value) - rescue StandardError - name = self.class.name.split("::").last - raise OpenAI::ConversionError.new( - "Failed to parse #{name}.#{name_sym} as #{field_type.inspect}. " \ - "To get the unparsed API response, use #{name}[:#{key}]." - ) - end - end - - # @api private - # - # @param name_sym [Symbol] - # - # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - def required(name_sym, type_info, spec = {}) - add_field(name_sym, required: true, type_info: type_info, spec: spec) - end - - # @api private - # - # @param name_sym [Symbol] - # - # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Converter, Class] - # - # @param spec [Hash{Symbol=>Object}] . - # - # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const - # - # @option spec [Proc] :enum - # - # @option spec [Proc] :union - # - # @option spec [Boolean] :"nil?" - def optional(name_sym, type_info, spec = {}) - add_field(name_sym, required: false, type_info: type_info, spec: spec) - end - - # @api private - # - # `request_only` attributes not excluded from `.#coerce` when receiving responses - # even if well behaved servers should not send them - # - # @param blk [Proc] - private def request_only(&blk) - @mode = :dump - blk.call - ensure - @mode = nil - end - - # @api private - # - # `response_only` attributes are omitted from `.#dump` when making requests - # - # @param blk [Proc] - private def response_only(&blk) - @mode = :coerce - blk.call - ensure - @mode = nil - end - end - - # @param other [Object] - # - # @return [Boolean] - def ==(other) - case other - in OpenAI::BaseModel - self.class.fields == other.class.fields && @data == other.to_h - else - false - end - end - - class << self - # @api private - # - # @param value [OpenAI::BaseModel, Hash{Object=>Object}, Object] - # - # @return [OpenAI::BaseModel, Object] - def coerce(value) - case OpenAI::Util.coerce_hash(value) - in Hash => coerced - new(coerced) - else - value - end - end - - # @api private - # - # @param value [OpenAI::BaseModel, Object] - # - # @return [Hash{Object=>Object}, Object] - def dump(value) - unless (coerced = OpenAI::Util.coerce_hash(value)).is_a?(Hash) - return value - end - - values = coerced.filter_map do |key, val| - name = key.to_sym - case (field = known_fields[name]) - in nil - [name, val] - else - mode, type_fn, api_name = field.fetch_values(:mode, :type_fn, :key) - case mode - in :coerce - next - else - target = type_fn.call - [api_name, OpenAI::Converter.dump(target, val)] - end - end - end.to_h - - defaults.each do |key, val| - next if values.key?(key) - - values[key] = val - end - - values - end - - # @api private - # - # @param value [Object] - # - # @return [Array(true, Object, nil), Array(false, Boolean, Integer)] - def try_strict_coerce(value) - case value - in Hash | OpenAI::BaseModel - value = value.to_h - else - return [false, false, 0] - end - - keys = value.keys.to_set - great_success = true - tally = 0 - acc = {} - - known_fields.each_value do |field| - mode, required, type_fn, api_name = field.fetch_values(:mode, :required, :type_fn, :key) - keys.delete(api_name) - - case [required && mode != :dump, value.key?(api_name)] - in [_, true] - target = type_fn.call - item = value.fetch(api_name) - case OpenAI::Converter.try_strict_coerce(target, item) - in [true, coerced, score] - tally += score - acc[api_name] = coerced - in [false, true, score] - great_success = false - tally += score - acc[api_name] = item - in [false, false, _] - great_success &&= item.nil? - end - in [true, false] - great_success = false - in [false, false] - nil - end - end - - keys.each do |key| - acc[key] = value.fetch(key) - end - - great_success ? [true, new(acc), tally] : [false, true, tally] - end - end - - # Returns the raw value associated with the given key, if found. Otherwise, nil is - # returned. - # - # It is valid to lookup keys that are not in the API spec, for example to access - # undocumented features. This method does not parse response data into - # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. - # - # @param key [Symbol] - # - # @return [Object, nil] - def [](key) - unless key.instance_of?(Symbol) - raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}") - end - - @data[key] - end - - # Returns a Hash of the data underlying this object. O(1) - # - # Keys are Symbols and values are the raw values from the response. The return - # value indicates which values were ever set on the object. i.e. there will be a - # key in this hash if they ever were, even if the set value was nil. - # - # This method is not recursive. The returned value is shared by the object, so it - # should not be mutated. - # - # @return [Hash{Symbol=>Object}] - def to_h = @data - - alias_method :to_hash, :to_h - - # @param keys [Array, nil] - # - # @return [Hash{Symbol=>Object}] - def deconstruct_keys(keys) - (keys || self.class.known_fields.keys).filter_map do |k| - unless self.class.known_fields.key?(k) - next - end - - [k, method(k).call] - end - .to_h - end - - # Create a new instance of a model. - # - # @param data [Hash{Symbol=>Object}, OpenAI::BaseModel] - def initialize(data = {}) - case OpenAI::Util.coerce_hash(data) - in Hash => coerced - @data = coerced.transform_keys(&:to_sym) - else - raise ArgumentError.new("Expected a #{Hash} or #{OpenAI::BaseModel}, got #{data.inspect}") - end - end - - # @return [String] - def to_s = @data.to_s - - # @return [String] - def inspect - "#<#{self.class.name}:0x#{object_id.to_s(16)} #{deconstruct_keys(nil).map do |k, v| - "#{k}=#{v.inspect}" - end.join(' ')}>" - end - end -end diff --git a/lib/openai/base_page.rb b/lib/openai/base_page.rb deleted file mode 100644 index c8a9058a..00000000 --- a/lib/openai/base_page.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @example - # ```ruby - # if page.has_next? - # page = page.next_page - # end - # ``` - # - # @example - # ```ruby - # page.auto_paging_each do |completion| - # puts(completion) - # end - # ``` - # - # @example - # ```ruby - # completions = page - # .to_enum - # .lazy - # .select { _1.object_id.even? } - # .map(&:itself) - # .take(2) - # .to_a - # - # completions => Array - # ``` - module BasePage - # @return [Boolean] - def next_page? = (raise NotImplementedError) - - # @raise [OpenAI::APIError] - # @return [OpenAI::BasePage] - def next_page = (raise NotImplementedError) - - # @param blk [Proc] - # - # @return [void] - def auto_paging_each(&) = (raise NotImplementedError) - - # @return [Enumerable] - def to_enum = super(:auto_paging_each) - - alias_method :enum_for, :to_enum - - # @api private - # - # @param client [OpenAI::BaseClient] - # @param req [Hash{Symbol=>Object}] - # @param headers [Hash{String=>String}, Net::HTTPHeader] - # @param page_data [Object] - def initialize(client:, req:, headers:, page_data:) - @client = client - @req = req - super() - end - end -end diff --git a/lib/openai/base_stream.rb b/lib/openai/base_stream.rb deleted file mode 100644 index 59f8f874..00000000 --- a/lib/openai/base_stream.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @example - # ```ruby - # stream.for_each do |chunk| - # puts(chunk) - # end - # ``` - # - # @example - # ```ruby - # chunks = stream - # .to_enum - # .lazy - # .select { _1.object_id.even? } - # .map(&:itself) - # .take(2) - # .to_a - # - # chunks => Array - # ``` - module BaseStream - # @return [void] - def close = OpenAI::Util.close_fused!(@iterator) - - # @api private - # - # @return [Enumerable] - private def iterator = (raise NotImplementedError) - - # @param blk [Proc] - # - # @return [void] - def for_each(&) - unless block_given? - raise ArgumentError.new("A block must be given to ##{__method__}") - end - @iterator.each(&) - end - - # @return [Enumerable] - def to_enum = @iterator - - alias_method :enum_for, :to_enum - - # @api private - # - # @param model [Class, OpenAI::Converter] - # @param url [URI::Generic] - # @param status [Integer] - # @param response [Net::HTTPResponse] - # @param messages [Enumerable] - def initialize(model:, url:, status:, response:, messages:) - @model = model - @url = url - @status = status - @response = response - @messages = messages - @iterator = iterator - end - end -end diff --git a/lib/openai/client.rb b/lib/openai/client.rb index 126da608..02db6417 100644 --- a/lib/openai/client.rb +++ b/lib/openai/client.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module OpenAI - class Client < OpenAI::BaseClient + class Client < OpenAI::Transport::BaseClient # Default max number of retries to attempt after a failed retryable request. DEFAULT_MAX_RETRIES = 2 diff --git a/lib/openai/cursor_page.rb b/lib/openai/cursor_page.rb index 35b585e9..640aa03b 100644 --- a/lib/openai/cursor_page.rb +++ b/lib/openai/cursor_page.rb @@ -2,33 +2,28 @@ module OpenAI # @example - # ```ruby - # if cursor_page.has_next? - # cursor_page = cursor_page.next_page - # end - # ``` + # if cursor_page.has_next? + # cursor_page = cursor_page.next_page + # end # # @example - # ```ruby - # cursor_page.auto_paging_each do |completion| - # puts(completion) - # end - # ``` + # cursor_page.auto_paging_each do |completion| + # puts(completion) + # end # # @example - # ```ruby - # completions = cursor_page - # .to_enum - # .lazy - # .select { _1.object_id.even? } - # .map(&:itself) - # .take(2) - # .to_a + # completions = + # cursor_page + # .to_enum + # .lazy + # .select { _1.object_id.even? } + # .map(&:itself) + # .take(2) + # .to_a # - # completions => Array - # ``` + # completions => Array class CursorPage - include OpenAI::BasePage + include OpenAI::Type::BasePage # @return [Array, nil] attr_accessor :data @@ -38,7 +33,7 @@ class CursorPage # @api private # - # @param client [OpenAI::BaseClient] + # @param client [OpenAI::Transport::BaseClient] # @param req [Hash{Symbol=>Object}] # @param headers [Hash{String=>String}, Net::HTTPHeader] # @param page_data [Hash{Symbol=>Object}] @@ -48,7 +43,7 @@ def initialize(client:, req:, headers:, page_data:) case page_data in {data: Array | nil => data} - @data = data&.map { model.coerce(_1) } + @data = data&.map { OpenAI::Type::Converter.coerce(model, _1) } else end diff --git a/lib/openai/errors.rb b/lib/openai/errors.rb index 7a4228e8..ad1e9852 100644 --- a/lib/openai/errors.rb +++ b/lib/openai/errors.rb @@ -171,9 +171,9 @@ def self.for(url:, status:, body:, request:, response:, message: nil) # @param message [String, nil] def initialize(url:, status:, body:, request:, response:, message: nil) message ||= OpenAI::Util.dig(body, :message) { {url: url.to_s, status: status, body: body} } - @code = OpenAI::Converter.coerce(String, OpenAI::Util.dig(body, :code)) - @param = OpenAI::Converter.coerce(String, OpenAI::Util.dig(body, :param)) - @type = OpenAI::Converter.coerce(String, OpenAI::Util.dig(body, :type)) + @code = OpenAI::Type::Converter.coerce(String, OpenAI::Util.dig(body, :code)) + @param = OpenAI::Type::Converter.coerce(String, OpenAI::Util.dig(body, :param)) + @type = OpenAI::Type::Converter.coerce(String, OpenAI::Util.dig(body, :type)) super( url: url, status: status, diff --git a/lib/openai/extern.rb b/lib/openai/extern.rb deleted file mode 100644 index 1ab41492..00000000 --- a/lib/openai/extern.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @api private - module Extern - end -end diff --git a/lib/openai/models/all_models.rb b/lib/openai/models/all_models.rb new file mode 100644 index 00000000..f09c1abd --- /dev/null +++ b/lib/openai/models/all_models.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module AllModels + extend OpenAI::Union + + variant String + + variant enum: -> { OpenAI::Models::ChatModel } + + variant const: -> { OpenAI::Models::AllModels::O1_PRO } + + variant const: -> { OpenAI::Models::AllModels::O1_PRO_2025_03_19 } + + variant const: -> { OpenAI::Models::AllModels::COMPUTER_USE_PREVIEW } + + variant const: -> { OpenAI::Models::AllModels::COMPUTER_USE_PREVIEW_2025_03_11 } + + # @!parse + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel, Symbol)] + # def self.variants; end + + # @!group + + O1_PRO = :"o1-pro" + O1_PRO_2025_03_19 = :"o1-pro-2025-03-19" + COMPUTER_USE_PREVIEW = :"computer-use-preview" + COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11" + + # @!endgroup + end + end +end diff --git a/lib/openai/models/audio/speech_create_params.rb b/lib/openai/models/audio/speech_create_params.rb index b7e77b57..f59e9311 100644 --- a/lib/openai/models/audio/speech_create_params.rb +++ b/lib/openai/models/audio/speech_create_params.rb @@ -5,7 +5,7 @@ module Models module Audio class SpeechCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute input @@ -16,19 +16,30 @@ class SpeechCreateParams < OpenAI::BaseModel # @!attribute model # One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. # # @return [String, Symbol, OpenAI::Models::Audio::SpeechModel] required :model, union: -> { OpenAI::Models::Audio::SpeechCreateParams::Model } # @!attribute voice # The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). # - # @return [Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice] - required :voice, enum: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice } + # @return [String, Symbol] + required :voice, union: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice } + + # @!attribute [r] instructions + # Control the voice of your generated audio with additional instructions. Does not + # work with `tts-1` or `tts-1-hd`. + # + # @return [String, nil] + optional :instructions, String + + # @!parse + # # @return [String] + # attr_writer :instructions # @!attribute [r] response_format # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, @@ -55,41 +66,71 @@ class SpeechCreateParams < OpenAI::BaseModel # @!parse # # @param input [String] # # @param model [String, Symbol, OpenAI::Models::Audio::SpeechModel] - # # @param voice [Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice] + # # @param voice [String, Symbol] + # # @param instructions [String] # # @param response_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat] # # @param speed [Float] # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] # # - # def initialize(input:, model:, voice:, response_format: nil, speed: nil, request_options: {}, **) = super + # def initialize(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, request_options: {}, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` - class Model < OpenAI::Union + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. + module Model + extend OpenAI::Union + variant String - # One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1` or `tts-1-hd` + # One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. variant enum: -> { OpenAI::Models::Audio::SpeechModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::Audio::SpeechModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::Audio::SpeechModel)] + # def self.variants; end end - # @abstract - # # The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). - class Voice < OpenAI::Enum + module Voice + extend OpenAI::Union + + variant String + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ALLOY } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ASH } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::BALLAD } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::CORAL } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ECHO } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::FABLE } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ONYX } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::NOVA } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::SAGE } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::SHIMMER } + + variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::VERSE } + + # @!parse + # # @return [Array(String, Symbol)] + # def self.variants; end + + # @!group + ALLOY = :alloy ASH = :ash + BALLAD = :ballad CORAL = :coral ECHO = :echo FABLE = :fable @@ -97,15 +138,16 @@ class Voice < OpenAI::Enum NOVA = :nova SAGE = :sage SHIMMER = :shimmer + VERSE = :verse - finalize! + # @!endgroup end - # @abstract - # # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, # `wav`, and `pcm`. - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + MP3 = :mp3 OPUS = :opus AAC = :aac @@ -114,6 +156,10 @@ class ResponseFormat < OpenAI::Enum PCM = :pcm finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/audio/speech_model.rb b/lib/openai/models/audio/speech_model.rb index 96744e0c..fad7aa94 100644 --- a/lib/openai/models/audio/speech_model.rb +++ b/lib/openai/models/audio/speech_model.rb @@ -3,12 +3,18 @@ module OpenAI module Models module Audio - # @abstract - class SpeechModel < OpenAI::Enum + module SpeechModel + extend OpenAI::Enum + TTS_1 = :"tts-1" TTS_1_HD = :"tts-1-hd" + GPT_4O_MINI_TTS = :"gpt-4o-mini-tts" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/audio/transcription.rb b/lib/openai/models/audio/transcription.rb index 6bd2d97b..8185ea6c 100644 --- a/lib/openai/models/audio/transcription.rb +++ b/lib/openai/models/audio/transcription.rb @@ -10,15 +10,69 @@ class Transcription < OpenAI::BaseModel # @return [String] required :text, String + # @!attribute [r] logprobs + # The log probabilities of the tokens in the transcription. Only returned with the + # models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added + # to the `include` array. + # + # @return [Array, nil] + optional :logprobs, -> { OpenAI::ArrayOf[OpenAI::Models::Audio::Transcription::Logprob] } + + # @!parse + # # @return [Array] + # attr_writer :logprobs + # @!parse # # Represents a transcription response returned by model, based on the provided # # input. # # # # @param text [String] + # # @param logprobs [Array] # # - # def initialize(text:, **) = super + # def initialize(text:, logprobs: nil, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void + + class Logprob < OpenAI::BaseModel + # @!attribute [r] token + # The token in the transcription. + # + # @return [String, nil] + optional :token, String + + # @!parse + # # @return [String] + # attr_writer :token + + # @!attribute [r] bytes + # The bytes of the token. + # + # @return [Array, nil] + optional :bytes, OpenAI::ArrayOf[Float] + + # @!parse + # # @return [Array] + # attr_writer :bytes + + # @!attribute [r] logprob + # The log probability of the token. + # + # @return [Float, nil] + optional :logprob, Float + + # @!parse + # # @return [Float] + # attr_writer :logprob + + # @!parse + # # @param token [String] + # # @param bytes [Array] + # # @param logprob [Float] + # # + # def initialize(token: nil, bytes: nil, logprob: nil, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end end end end diff --git a/lib/openai/models/audio/transcription_create_params.rb b/lib/openai/models/audio/transcription_create_params.rb index d6d9f071..bcd93827 100644 --- a/lib/openai/models/audio/transcription_create_params.rb +++ b/lib/openai/models/audio/transcription_create_params.rb @@ -5,7 +5,7 @@ module Models module Audio class TranscriptionCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute file @@ -16,12 +16,27 @@ class TranscriptionCreateParams < OpenAI::BaseModel required :file, IO # @!attribute model - # ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). # # @return [String, Symbol, OpenAI::Models::AudioModel] required :model, union: -> { OpenAI::Models::Audio::TranscriptionCreateParams::Model } + # @!attribute [r] include + # Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. + # + # @return [Array, nil] + optional :include, -> { OpenAI::ArrayOf[enum: OpenAI::Models::Audio::TranscriptionInclude] } + + # @!parse + # # @return [Array] + # attr_writer :include + # @!attribute [r] language # The language of the input audio. Supplying the input language in # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) @@ -49,7 +64,8 @@ class TranscriptionCreateParams < OpenAI::BaseModel # @!attribute [r] response_format # The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. # # @return [Symbol, OpenAI::Models::AudioResponseFormat, nil] optional :response_format, enum: -> { OpenAI::Models::AudioResponseFormat } @@ -90,6 +106,7 @@ class TranscriptionCreateParams < OpenAI::BaseModel # @!parse # # @param file [IO, StringIO] # # @param model [String, Symbol, OpenAI::Models::AudioModel] + # # @param include [Array] # # @param language [String] # # @param prompt [String] # # @param response_format [Symbol, OpenAI::Models::AudioResponseFormat] @@ -100,6 +117,7 @@ class TranscriptionCreateParams < OpenAI::BaseModel # def initialize( # file:, # model:, + # include: nil, # language: nil, # prompt: nil, # response_format: nil, @@ -113,29 +131,33 @@ class TranscriptionCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # - # ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. - class Model < OpenAI::Union + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + module Model + extend OpenAI::Union + variant String - # ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. + # ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source Whisper V2 model). variant enum: -> { OpenAI::Models::AudioModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::AudioModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::AudioModel)] + # def self.variants; end end - # @abstract - class TimestampGranularity < OpenAI::Enum + module TimestampGranularity + extend OpenAI::Enum + WORD = :word SEGMENT = :segment finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/audio/transcription_create_response.rb b/lib/openai/models/audio/transcription_create_response.rb index 2ad0d933..fe9d6a25 100644 --- a/lib/openai/models/audio/transcription_create_response.rb +++ b/lib/openai/models/audio/transcription_create_response.rb @@ -3,11 +3,11 @@ module OpenAI module Models module Audio - # @abstract - # # Represents a transcription response returned by model, based on the provided # input. - class TranscriptionCreateResponse < OpenAI::Union + module TranscriptionCreateResponse + extend OpenAI::Union + # Represents a transcription response returned by model, based on the provided input. variant -> { OpenAI::Models::Audio::Transcription } @@ -15,10 +15,8 @@ class TranscriptionCreateResponse < OpenAI::Union variant -> { OpenAI::Models::Audio::TranscriptionVerbose } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)] + # def self.variants; end end end end diff --git a/lib/openai/models/audio/transcription_include.rb b/lib/openai/models/audio/transcription_include.rb new file mode 100644 index 00000000..7c76eb59 --- /dev/null +++ b/lib/openai/models/audio/transcription_include.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Audio + module TranscriptionInclude + extend OpenAI::Enum + + LOGPROBS = :logprobs + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + end + end +end diff --git a/lib/openai/models/audio/transcription_stream_event.rb b/lib/openai/models/audio/transcription_stream_event.rb new file mode 100644 index 00000000..40437586 --- /dev/null +++ b/lib/openai/models/audio/transcription_stream_event.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Audio + # Emitted when there is an additional text delta. This is also the first event + # emitted when the transcription starts. Only emitted when you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `Stream` parameter set to `true`. + module TranscriptionStreamEvent + extend OpenAI::Union + + discriminator :type + + # Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`. + variant :"transcript.text.delta", -> { OpenAI::Models::Audio::TranscriptionTextDeltaEvent } + + # Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`. + variant :"transcript.text.done", -> { OpenAI::Models::Audio::TranscriptionTextDoneEvent } + + # @!parse + # # @return [Array(OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent)] + # def self.variants; end + end + end + end +end diff --git a/lib/openai/models/audio/transcription_text_delta_event.rb b/lib/openai/models/audio/transcription_text_delta_event.rb new file mode 100644 index 00000000..ec8ca4f4 --- /dev/null +++ b/lib/openai/models/audio/transcription_text_delta_event.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Audio + class TranscriptionTextDeltaEvent < OpenAI::BaseModel + # @!attribute delta + # The text delta that was additionally transcribed. + # + # @return [String] + required :delta, String + + # @!attribute type + # The type of the event. Always `transcript.text.delta`. + # + # @return [Symbol, :"transcript.text.delta"] + required :type, const: :"transcript.text.delta" + + # @!attribute [r] logprobs + # The log probabilities of the delta. Only included if you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `include[]` parameter set to `logprobs`. + # + # @return [Array, nil] + optional :logprobs, -> { OpenAI::ArrayOf[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob] } + + # @!parse + # # @return [Array] + # attr_writer :logprobs + + # @!parse + # # Emitted when there is an additional text delta. This is also the first event + # # emitted when the transcription starts. Only emitted when you + # # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # # with the `Stream` parameter set to `true`. + # # + # # @param delta [String] + # # @param logprobs [Array] + # # @param type [Symbol, :"transcript.text.delta"] + # # + # def initialize(delta:, logprobs: nil, type: :"transcript.text.delta", **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + + class Logprob < OpenAI::BaseModel + # @!attribute [r] token + # The token that was used to generate the log probability. + # + # @return [String, nil] + optional :token, String + + # @!parse + # # @return [String] + # attr_writer :token + + # @!attribute [r] bytes + # The bytes that were used to generate the log probability. + # + # @return [Array, nil] + optional :bytes, OpenAI::ArrayOf[OpenAI::Unknown] + + # @!parse + # # @return [Array] + # attr_writer :bytes + + # @!attribute [r] logprob + # The log probability of the token. + # + # @return [Float, nil] + optional :logprob, Float + + # @!parse + # # @return [Float] + # attr_writer :logprob + + # @!parse + # # @param token [String] + # # @param bytes [Array] + # # @param logprob [Float] + # # + # def initialize(token: nil, bytes: nil, logprob: nil, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + end + end + end +end diff --git a/lib/openai/models/audio/transcription_text_done_event.rb b/lib/openai/models/audio/transcription_text_done_event.rb new file mode 100644 index 00000000..b2a78b25 --- /dev/null +++ b/lib/openai/models/audio/transcription_text_done_event.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Audio + class TranscriptionTextDoneEvent < OpenAI::BaseModel + # @!attribute text + # The text that was transcribed. + # + # @return [String] + required :text, String + + # @!attribute type + # The type of the event. Always `transcript.text.done`. + # + # @return [Symbol, :"transcript.text.done"] + required :type, const: :"transcript.text.done" + + # @!attribute [r] logprobs + # The log probabilities of the individual tokens in the transcription. Only + # included if you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `include[]` parameter set to `logprobs`. + # + # @return [Array, nil] + optional :logprobs, -> { OpenAI::ArrayOf[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob] } + + # @!parse + # # @return [Array] + # attr_writer :logprobs + + # @!parse + # # Emitted when the transcription is complete. Contains the complete transcription + # # text. Only emitted when you + # # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # # with the `Stream` parameter set to `true`. + # # + # # @param text [String] + # # @param logprobs [Array] + # # @param type [Symbol, :"transcript.text.done"] + # # + # def initialize(text:, logprobs: nil, type: :"transcript.text.done", **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + + class Logprob < OpenAI::BaseModel + # @!attribute [r] token + # The token that was used to generate the log probability. + # + # @return [String, nil] + optional :token, String + + # @!parse + # # @return [String] + # attr_writer :token + + # @!attribute [r] bytes + # The bytes that were used to generate the log probability. + # + # @return [Array, nil] + optional :bytes, OpenAI::ArrayOf[OpenAI::Unknown] + + # @!parse + # # @return [Array] + # attr_writer :bytes + + # @!attribute [r] logprob + # The log probability of the token. + # + # @return [Float, nil] + optional :logprob, Float + + # @!parse + # # @return [Float] + # attr_writer :logprob + + # @!parse + # # @param token [String] + # # @param bytes [Array] + # # @param logprob [Float] + # # + # def initialize(token: nil, bytes: nil, logprob: nil, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + end + end + end +end diff --git a/lib/openai/models/audio/translation_create_params.rb b/lib/openai/models/audio/translation_create_params.rb index 4fd4a4dc..5f5c90ad 100644 --- a/lib/openai/models/audio/translation_create_params.rb +++ b/lib/openai/models/audio/translation_create_params.rb @@ -5,7 +5,7 @@ module Models module Audio class TranslationCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute file @@ -39,11 +39,11 @@ class TranslationCreateParams < OpenAI::BaseModel # The format of the output, in one of these options: `json`, `text`, `srt`, # `verbose_json`, or `vtt`. # - # @return [Symbol, OpenAI::Models::AudioResponseFormat, nil] - optional :response_format, enum: -> { OpenAI::Models::AudioResponseFormat } + # @return [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat, nil] + optional :response_format, enum: -> { OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat } # @!parse - # # @return [Symbol, OpenAI::Models::AudioResponseFormat] + # # @return [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat] # attr_writer :response_format # @!attribute [r] temperature @@ -64,7 +64,7 @@ class TranslationCreateParams < OpenAI::BaseModel # # @param file [IO, StringIO] # # @param model [String, Symbol, OpenAI::Models::AudioModel] # # @param prompt [String] - # # @param response_format [Symbol, OpenAI::Models::AudioResponseFormat] + # # @param response_format [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat] # # @param temperature [Float] # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] # # @@ -72,21 +72,37 @@ class TranslationCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # ID of the model to use. Only `whisper-1` (which is powered by our open source # Whisper V2 model) is currently available. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. variant enum: -> { OpenAI::Models::AudioModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::AudioModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::AudioModel)] + # def self.variants; end + end + + # The format of the output, in one of these options: `json`, `text`, `srt`, + # `verbose_json`, or `vtt`. + module ResponseFormat + extend OpenAI::Enum + + JSON = :json + TEXT = :text + SRT = :srt + VERBOSE_JSON = :verbose_json + VTT = :vtt + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/audio/translation_create_response.rb b/lib/openai/models/audio/translation_create_response.rb index 94020236..2511f059 100644 --- a/lib/openai/models/audio/translation_create_response.rb +++ b/lib/openai/models/audio/translation_create_response.rb @@ -3,17 +3,16 @@ module OpenAI module Models module Audio - # @abstract - class TranslationCreateResponse < OpenAI::Union + module TranslationCreateResponse + extend OpenAI::Union + variant -> { OpenAI::Models::Audio::Translation } variant -> { OpenAI::Models::Audio::TranslationVerbose } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)] + # def self.variants; end end end end diff --git a/lib/openai/models/audio_model.rb b/lib/openai/models/audio_model.rb index 81db712e..d0ffd0c5 100644 --- a/lib/openai/models/audio_model.rb +++ b/lib/openai/models/audio_model.rb @@ -2,11 +2,18 @@ module OpenAI module Models - # @abstract - class AudioModel < OpenAI::Enum + module AudioModel + extend OpenAI::Enum + WHISPER_1 = :"whisper-1" + GPT_4O_TRANSCRIBE = :"gpt-4o-transcribe" + GPT_4O_MINI_TRANSCRIBE = :"gpt-4o-mini-transcribe" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/audio_response_format.rb b/lib/openai/models/audio_response_format.rb index 8b92a3b9..0b6e75b3 100644 --- a/lib/openai/models/audio_response_format.rb +++ b/lib/openai/models/audio_response_format.rb @@ -2,11 +2,12 @@ module OpenAI module Models - # @abstract - # # The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. - class AudioResponseFormat < OpenAI::Enum + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. + module AudioResponseFormat + extend OpenAI::Enum + JSON = :json TEXT = :text SRT = :srt @@ -14,6 +15,10 @@ class AudioResponseFormat < OpenAI::Enum VTT = :vtt finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/batch.rb b/lib/openai/models/batch.rb index 91778516..96e290bb 100644 --- a/lib/openai/models/batch.rb +++ b/lib/openai/models/batch.rb @@ -224,10 +224,10 @@ class Batch < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The current status of the batch. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + VALIDATING = :validating FAILED = :failed IN_PROGRESS = :in_progress @@ -238,6 +238,10 @@ class Status < OpenAI::Enum CANCELLED = :cancelled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Errors < OpenAI::BaseModel diff --git a/lib/openai/models/batch_cancel_params.rb b/lib/openai/models/batch_cancel_params.rb index 3e1d39cd..6772ee41 100644 --- a/lib/openai/models/batch_cancel_params.rb +++ b/lib/openai/models/batch_cancel_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class BatchCancelParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/batch_create_params.rb b/lib/openai/models/batch_create_params.rb index 8fa58e3f..b58fb416 100644 --- a/lib/openai/models/batch_create_params.rb +++ b/lib/openai/models/batch_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class BatchCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute completion_window @@ -16,9 +16,9 @@ class BatchCreateParams < OpenAI::BaseModel # @!attribute endpoint # The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. # # @return [Symbol, OpenAI::Models::BatchCreateParams::Endpoint] required :endpoint, enum: -> { OpenAI::Models::BatchCreateParams::Endpoint } @@ -59,28 +59,37 @@ class BatchCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The time frame within which the batch should be processed. Currently only `24h` # is supported. - class CompletionWindow < OpenAI::Enum + module CompletionWindow + extend OpenAI::Enum + NUMBER_24H = :"24h" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. - class Endpoint < OpenAI::Enum + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. + module Endpoint + extend OpenAI::Enum + + V1_RESPONSES = :"/v1/responses" V1_CHAT_COMPLETIONS = :"/v1/chat/completions" V1_EMBEDDINGS = :"/v1/embeddings" V1_COMPLETIONS = :"/v1/completions" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/batch_list_params.rb b/lib/openai/models/batch_list_params.rb index 368bc08b..5bd6a019 100644 --- a/lib/openai/models/batch_list_params.rb +++ b/lib/openai/models/batch_list_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class BatchListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after diff --git a/lib/openai/models/batch_retrieve_params.rb b/lib/openai/models/batch_retrieve_params.rb index 252ed4ca..12c4186e 100644 --- a/lib/openai/models/batch_retrieve_params.rb +++ b/lib/openai/models/batch_retrieve_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class BatchRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/beta/assistant_create_params.rb b/lib/openai/models/beta/assistant_create_params.rb index f66edb15..dab3186e 100644 --- a/lib/openai/models/beta/assistant_create_params.rb +++ b/lib/openai/models/beta/assistant_create_params.rb @@ -5,7 +5,7 @@ module Models module Beta class AssistantCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute model @@ -157,24 +157,22 @@ class AssistantCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them. variant enum: -> { OpenAI::Models::ChatModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] + # def self.variants; end end class ToolResources < OpenAI::BaseModel @@ -312,11 +310,11 @@ class VectorStore < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + discriminator :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. @@ -392,10 +390,8 @@ class Static < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/assistant_delete_params.rb b/lib/openai/models/beta/assistant_delete_params.rb index 9262c91e..939c39ee 100644 --- a/lib/openai/models/beta/assistant_delete_params.rb +++ b/lib/openai/models/beta/assistant_delete_params.rb @@ -5,7 +5,7 @@ module Models module Beta class AssistantDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/beta/assistant_list_params.rb b/lib/openai/models/beta/assistant_list_params.rb index 2deef264..601a694b 100644 --- a/lib/openai/models/beta/assistant_list_params.rb +++ b/lib/openai/models/beta/assistant_list_params.rb @@ -5,7 +5,7 @@ module Models module Beta class AssistantListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -67,15 +67,19 @@ class AssistantListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/assistant_response_format_option.rb b/lib/openai/models/beta/assistant_response_format_option.rb index 1e0036f2..48b15aaa 100644 --- a/lib/openai/models/beta/assistant_response_format_option.rb +++ b/lib/openai/models/beta/assistant_response_format_option.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Beta - # @abstract - # # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), @@ -25,7 +23,9 @@ module Beta # the message content may be partially cut off if `finish_reason="length"`, which # indicates the generation exceeded `max_tokens` or the conversation exceeded the # max context length. - class AssistantResponseFormatOption < OpenAI::Union + module AssistantResponseFormatOption + extend OpenAI::Union + # `auto` is the default value variant const: :auto @@ -43,10 +43,8 @@ class AssistantResponseFormatOption < OpenAI::Union variant -> { OpenAI::Models::ResponseFormatJSONSchema } # @!parse - # class << self - # # @return [Array(Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/assistant_retrieve_params.rb b/lib/openai/models/beta/assistant_retrieve_params.rb index d61babe9..40ba9b41 100644 --- a/lib/openai/models/beta/assistant_retrieve_params.rb +++ b/lib/openai/models/beta/assistant_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module Beta class AssistantRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/beta/assistant_stream_event.rb b/lib/openai/models/beta/assistant_stream_event.rb index fdc598d7..734ad6c4 100644 --- a/lib/openai/models/beta/assistant_stream_event.rb +++ b/lib/openai/models/beta/assistant_stream_event.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Beta - # @abstract - # # Represents an event emitted when streaming a Run. # # Each event in a server-sent events stream has an `event` and `data` property: @@ -25,7 +23,9 @@ module Beta # gracefully in your code. See the # [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) # to learn how to integrate the Assistants API with streaming. - class AssistantStreamEvent < OpenAI::Union + module AssistantStreamEvent + extend OpenAI::Union + discriminator :event # Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created. @@ -727,10 +727,8 @@ class ErrorEvent < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/assistant_tool.rb b/lib/openai/models/beta/assistant_tool.rb index 0ea9bc07..2a2c655d 100644 --- a/lib/openai/models/beta/assistant_tool.rb +++ b/lib/openai/models/beta/assistant_tool.rb @@ -3,8 +3,9 @@ module OpenAI module Models module Beta - # @abstract - class AssistantTool < OpenAI::Union + module AssistantTool + extend OpenAI::Union + discriminator :type variant :code_interpreter, -> { OpenAI::Models::Beta::CodeInterpreterTool } @@ -14,10 +15,8 @@ class AssistantTool < OpenAI::Union variant :function, -> { OpenAI::Models::Beta::FunctionTool } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/assistant_tool_choice.rb b/lib/openai/models/beta/assistant_tool_choice.rb index 9aba0349..b7cb38c3 100644 --- a/lib/openai/models/beta/assistant_tool_choice.rb +++ b/lib/openai/models/beta/assistant_tool_choice.rb @@ -30,15 +30,19 @@ class AssistantToolChoice < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of the tool. If type is `function`, the function name must be set - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FUNCTION = :function CODE_INTERPRETER = :code_interpreter FILE_SEARCH = :file_search finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/assistant_tool_choice_option.rb b/lib/openai/models/beta/assistant_tool_choice_option.rb index 62a2c795..807dc2eb 100644 --- a/lib/openai/models/beta/assistant_tool_choice_option.rb +++ b/lib/openai/models/beta/assistant_tool_choice_option.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Beta - # @abstract - # # Controls which (if any) tool is called by the model. `none` means the model will # not call any tools and instead generates a message. `auto` is the default value # and means the model can pick between generating a message or calling one or more @@ -12,32 +10,36 @@ module Beta # to the user. Specifying a particular tool like `{"type": "file_search"}` or # `{"type": "function", "function": {"name": "my_function"}}` forces the model to # call that tool. - class AssistantToolChoiceOption < OpenAI::Union + module AssistantToolChoiceOption + extend OpenAI::Union + # `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. variant enum: -> { OpenAI::Models::Beta::AssistantToolChoiceOption::Auto } # Specifies a tool the model should use. Use to force the model to call a specific tool. variant -> { OpenAI::Models::Beta::AssistantToolChoice } - # @abstract - # # `none` means the model will not call any tools and instead generates a message. # `auto` means the model can pick between generating a message or calling one or # more tools. `required` means the model must call one or more tools before # responding to the user. - class Auto < OpenAI::Enum + module Auto + extend OpenAI::Enum + NONE = :none AUTO = :auto REQUIRED = :required finalize! + + # @!parse + # # @return [Array] + # def self.values; end end # @!parse - # class << self - # # @return [Array(Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice)] - # def variants; end - # end + # # @return [Array(Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/assistant_update_params.rb b/lib/openai/models/beta/assistant_update_params.rb index 494df652..6b2bbaf8 100644 --- a/lib/openai/models/beta/assistant_update_params.rb +++ b/lib/openai/models/beta/assistant_update_params.rb @@ -5,7 +5,7 @@ module Models module Beta class AssistantUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute description @@ -161,116 +161,114 @@ class AssistantUpdateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - # @!group - - O3_MINI = :"o3-mini" - O3_MINI_2025_01_31 = :"o3-mini-2025-01-31" - O1 = :o1 - O1_2024_12_17 = :"o1-2024-12-17" - GPT_4O = :"gpt-4o" - GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20" - GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06" - GPT_4O_2024_05_13 = :"gpt-4o-2024-05-13" - GPT_4O_MINI = :"gpt-4o-mini" - GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18" - GPT_4_5_PREVIEW = :"gpt-4.5-preview" - GPT_4_5_PREVIEW_2025_02_27 = :"gpt-4.5-preview-2025-02-27" - GPT_4_TURBO = :"gpt-4-turbo" - GPT_4_TURBO_2024_04_09 = :"gpt-4-turbo-2024-04-09" - GPT_4_0125_PREVIEW = :"gpt-4-0125-preview" - GPT_4_TURBO_PREVIEW = :"gpt-4-turbo-preview" - GPT_4_1106_PREVIEW = :"gpt-4-1106-preview" - GPT_4_VISION_PREVIEW = :"gpt-4-vision-preview" - GPT_4 = :"gpt-4" - GPT_4_0314 = :"gpt-4-0314" - GPT_4_0613 = :"gpt-4-0613" - GPT_4_32K = :"gpt-4-32k" - GPT_4_32K_0314 = :"gpt-4-32k-0314" - GPT_4_32K_0613 = :"gpt-4-32k-0613" - GPT_3_5_TURBO = :"gpt-3.5-turbo" - GPT_3_5_TURBO_16K = :"gpt-3.5-turbo-16k" - GPT_3_5_TURBO_0613 = :"gpt-3.5-turbo-0613" - GPT_3_5_TURBO_1106 = :"gpt-3.5-turbo-1106" - GPT_3_5_TURBO_0125 = :"gpt-3.5-turbo-0125" - GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613" - - # @!endgroup + module Model + extend OpenAI::Union variant String - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI_2025_01_31 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI_2025_01_31 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::O1 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O1 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::O1_2024_12_17 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O1_2024_12_17 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_11_20 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_11_20 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_08_06 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_08_06 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_05_13 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_05_13 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI_2024_07_18 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI_2024_07_18 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW_2025_02_27 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW_2025_02_27 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_2024_04_09 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_2024_04_09 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0125_PREVIEW + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0125_PREVIEW } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_PREVIEW + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_PREVIEW } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1106_PREVIEW + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1106_PREVIEW } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_VISION_PREVIEW + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_VISION_PREVIEW } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0314 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0314 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0613 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0613 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0314 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0314 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0613 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0613 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0613 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0613 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_1106 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_1106 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0125 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0125 } - variant const: OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K_0613 + variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K_0613 } # @!parse - # class << self - # # @return [Array(String, Symbol)] - # def variants; end - # end + # # @return [Array(String, Symbol)] + # def self.variants; end + + # @!group + + O3_MINI = :"o3-mini" + O3_MINI_2025_01_31 = :"o3-mini-2025-01-31" + O1 = :o1 + O1_2024_12_17 = :"o1-2024-12-17" + GPT_4O = :"gpt-4o" + GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20" + GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06" + GPT_4O_2024_05_13 = :"gpt-4o-2024-05-13" + GPT_4O_MINI = :"gpt-4o-mini" + GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18" + GPT_4_5_PREVIEW = :"gpt-4.5-preview" + GPT_4_5_PREVIEW_2025_02_27 = :"gpt-4.5-preview-2025-02-27" + GPT_4_TURBO = :"gpt-4-turbo" + GPT_4_TURBO_2024_04_09 = :"gpt-4-turbo-2024-04-09" + GPT_4_0125_PREVIEW = :"gpt-4-0125-preview" + GPT_4_TURBO_PREVIEW = :"gpt-4-turbo-preview" + GPT_4_1106_PREVIEW = :"gpt-4-1106-preview" + GPT_4_VISION_PREVIEW = :"gpt-4-vision-preview" + GPT_4 = :"gpt-4" + GPT_4_0314 = :"gpt-4-0314" + GPT_4_0613 = :"gpt-4-0613" + GPT_4_32K = :"gpt-4-32k" + GPT_4_32K_0314 = :"gpt-4-32k-0314" + GPT_4_32K_0613 = :"gpt-4-32k-0613" + GPT_3_5_TURBO = :"gpt-3.5-turbo" + GPT_3_5_TURBO_16K = :"gpt-3.5-turbo-16k" + GPT_3_5_TURBO_0613 = :"gpt-3.5-turbo-0613" + GPT_3_5_TURBO_1106 = :"gpt-3.5-turbo-1106" + GPT_3_5_TURBO_0125 = :"gpt-3.5-turbo-0125" + GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613" + + # @!endgroup end class ToolResources < OpenAI::BaseModel diff --git a/lib/openai/models/beta/file_search_tool.rb b/lib/openai/models/beta/file_search_tool.rb index 333f1770..98e95ab3 100644 --- a/lib/openai/models/beta/file_search_tool.rb +++ b/lib/openai/models/beta/file_search_tool.rb @@ -105,15 +105,19 @@ class RankingOptions < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The ranker to use for the file search. If not specified will use the `auto` # ranker. - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO = :auto DEFAULT_2024_08_21 = :default_2024_08_21 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/message_stream_event.rb b/lib/openai/models/beta/message_stream_event.rb index b110bfed..6f0bdf04 100644 --- a/lib/openai/models/beta/message_stream_event.rb +++ b/lib/openai/models/beta/message_stream_event.rb @@ -3,12 +3,12 @@ module OpenAI module Models module Beta - # @abstract - # # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # created. - class MessageStreamEvent < OpenAI::Union + module MessageStreamEvent + extend OpenAI::Union + discriminator :event # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created. @@ -160,10 +160,8 @@ class ThreadMessageIncomplete < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/run_step_stream_event.rb b/lib/openai/models/beta/run_step_stream_event.rb index 82c7266e..a3dc27d6 100644 --- a/lib/openai/models/beta/run_step_stream_event.rb +++ b/lib/openai/models/beta/run_step_stream_event.rb @@ -3,12 +3,12 @@ module OpenAI module Models module Beta - # @abstract - # # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is created. - class RunStepStreamEvent < OpenAI::Union + module RunStepStreamEvent + extend OpenAI::Union + discriminator :event # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created. @@ -212,10 +212,8 @@ class ThreadRunStepExpired < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/run_stream_event.rb b/lib/openai/models/beta/run_stream_event.rb index f8548343..058cde20 100644 --- a/lib/openai/models/beta/run_stream_event.rb +++ b/lib/openai/models/beta/run_stream_event.rb @@ -3,11 +3,11 @@ module OpenAI module Models module Beta - # @abstract - # # Occurs when a new # [run](https://platform.openai.com/docs/api-reference/runs/object) is created. - class RunStreamEvent < OpenAI::Union + module RunStreamEvent + extend OpenAI::Union + discriminator :event # Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created. @@ -292,10 +292,8 @@ class ThreadRunExpired < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/thread_create_and_run_params.rb b/lib/openai/models/beta/thread_create_and_run_params.rb index 72d1ae24..56c776fa 100644 --- a/lib/openai/models/beta/thread_create_and_run_params.rb +++ b/lib/openai/models/beta/thread_create_and_run_params.rb @@ -5,7 +5,7 @@ module Models module Beta class ThreadCreateAndRunParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute assistant_id @@ -210,23 +210,21 @@ class ThreadCreateAndRunParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. variant enum: -> { OpenAI::Models::ChatModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] + # def self.variants; end end class Thread < OpenAI::BaseModel @@ -323,38 +321,41 @@ class Message < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The text contents of the message. - class Content < OpenAI::Union - MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] + module Content + extend OpenAI::Union # The text contents of the message. variant String # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). - variant OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Content::MessageContentPartParamArray + variant -> { OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Content::MessageContentPartParamArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + MessageContentPartParamArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] end - # @abstract - # # The role of the entity that is creating the message. Allowed values include: # # - `user`: Indicates the message is sent by an actual user and should be used in # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Attachment < OpenAI::BaseModel @@ -387,8 +388,9 @@ class Attachment < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + discriminator :type variant :code_interpreter, -> { OpenAI::Models::Beta::CodeInterpreterTool } @@ -412,10 +414,8 @@ class FileSearch < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch)] + # def self.variants; end end end end @@ -556,11 +556,11 @@ class VectorStore < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + discriminator :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. @@ -636,10 +636,8 @@ class Static < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] + # def self.variants; end end end end @@ -723,8 +721,9 @@ class FileSearch < OpenAI::BaseModel end end - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + variant -> { OpenAI::Models::Beta::CodeInterpreterTool } variant -> { OpenAI::Models::Beta::FileSearchTool } @@ -732,10 +731,8 @@ class Tool < OpenAI::Union variant -> { OpenAI::Models::Beta::FunctionTool } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)] + # def self.variants; end end class TruncationStrategy < OpenAI::BaseModel @@ -766,17 +763,21 @@ class TruncationStrategy < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The truncation strategy to use for the thread. The default is `auto`. If set to # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO = :auto LAST_MESSAGES = :last_messages finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/thread_create_params.rb b/lib/openai/models/beta/thread_create_params.rb index 6d67b56a..3095b908 100644 --- a/lib/openai/models/beta/thread_create_params.rb +++ b/lib/openai/models/beta/thread_create_params.rb @@ -5,7 +5,7 @@ module Models module Beta class ThreadCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] messages @@ -96,38 +96,41 @@ class Message < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The text contents of the message. - class Content < OpenAI::Union - MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] + module Content + extend OpenAI::Union # The text contents of the message. variant String # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). - variant OpenAI::Models::Beta::ThreadCreateParams::Message::Content::MessageContentPartParamArray + variant -> { OpenAI::Models::Beta::ThreadCreateParams::Message::Content::MessageContentPartParamArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + MessageContentPartParamArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] end - # @abstract - # # The role of the entity that is creating the message. Allowed values include: # # - `user`: Indicates the message is sent by an actual user and should be used in # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Attachment < OpenAI::BaseModel @@ -160,8 +163,9 @@ class Attachment < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + discriminator :type variant :code_interpreter, -> { OpenAI::Models::Beta::CodeInterpreterTool } @@ -185,10 +189,8 @@ class FileSearch < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch)] + # def self.variants; end end end end @@ -328,11 +330,11 @@ class VectorStore < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + discriminator :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. @@ -408,10 +410,8 @@ class Static < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/thread_delete_params.rb b/lib/openai/models/beta/thread_delete_params.rb index bff19a8a..f81ea4ec 100644 --- a/lib/openai/models/beta/thread_delete_params.rb +++ b/lib/openai/models/beta/thread_delete_params.rb @@ -5,7 +5,7 @@ module Models module Beta class ThreadDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/beta/thread_retrieve_params.rb b/lib/openai/models/beta/thread_retrieve_params.rb index cd0bc3c8..4df984d4 100644 --- a/lib/openai/models/beta/thread_retrieve_params.rb +++ b/lib/openai/models/beta/thread_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module Beta class ThreadRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/beta/thread_update_params.rb b/lib/openai/models/beta/thread_update_params.rb index 2d9eeab2..e4d3d234 100644 --- a/lib/openai/models/beta/thread_update_params.rb +++ b/lib/openai/models/beta/thread_update_params.rb @@ -5,7 +5,7 @@ module Models module Beta class ThreadUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute metadata diff --git a/lib/openai/models/beta/threads/annotation.rb b/lib/openai/models/beta/threads/annotation.rb index 3f0a547d..b7822e85 100644 --- a/lib/openai/models/beta/threads/annotation.rb +++ b/lib/openai/models/beta/threads/annotation.rb @@ -4,12 +4,12 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant # uses the "file_search" tool to search files. - class Annotation < OpenAI::Union + module Annotation + extend OpenAI::Union + discriminator :type # A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. @@ -19,10 +19,8 @@ class Annotation < OpenAI::Union variant :file_path, -> { OpenAI::Models::Beta::Threads::FilePathAnnotation } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/annotation_delta.rb b/lib/openai/models/beta/threads/annotation_delta.rb index 6b22d5be..8bbb2ee1 100644 --- a/lib/openai/models/beta/threads/annotation_delta.rb +++ b/lib/openai/models/beta/threads/annotation_delta.rb @@ -4,12 +4,12 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant # uses the "file_search" tool to search files. - class AnnotationDelta < OpenAI::Union + module AnnotationDelta + extend OpenAI::Union + discriminator :type # A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. @@ -19,10 +19,8 @@ class AnnotationDelta < OpenAI::Union variant :file_path, -> { OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/image_file.rb b/lib/openai/models/beta/threads/image_file.rb index 2156325f..2a06f605 100644 --- a/lib/openai/models/beta/threads/image_file.rb +++ b/lib/openai/models/beta/threads/image_file.rb @@ -32,16 +32,20 @@ class ImageFile < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO = :auto LOW = :low HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/image_file_delta.rb b/lib/openai/models/beta/threads/image_file_delta.rb index 81caa23f..9f702f21 100644 --- a/lib/openai/models/beta/threads/image_file_delta.rb +++ b/lib/openai/models/beta/threads/image_file_delta.rb @@ -36,16 +36,20 @@ class ImageFileDelta < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO = :auto LOW = :low HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/image_url.rb b/lib/openai/models/beta/threads/image_url.rb index 8c08ac9d..e6830beb 100644 --- a/lib/openai/models/beta/threads/image_url.rb +++ b/lib/openai/models/beta/threads/image_url.rb @@ -31,16 +31,20 @@ class ImageURL < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. Default value is `auto` - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO = :auto LOW = :low HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/image_url_delta.rb b/lib/openai/models/beta/threads/image_url_delta.rb index ad6177d4..d47277f4 100644 --- a/lib/openai/models/beta/threads/image_url_delta.rb +++ b/lib/openai/models/beta/threads/image_url_delta.rb @@ -35,16 +35,20 @@ class ImageURLDelta < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO = :auto LOW = :low HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/message.rb b/lib/openai/models/beta/threads/message.rb index 0a6b9d1b..b3a7faab 100644 --- a/lib/openai/models/beta/threads/message.rb +++ b/lib/openai/models/beta/threads/message.rb @@ -172,8 +172,9 @@ class Attachment < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + variant -> { OpenAI::Models::Beta::CodeInterpreterTool } variant -> { OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly } @@ -194,10 +195,8 @@ class AssistantToolsFileSearchTypeOnly < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly)] + # def self.variants; end end end @@ -217,10 +216,10 @@ class IncompleteDetails < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The reason the message is incomplete. - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + CONTENT_FILTER = :content_filter MAX_TOKENS = :max_tokens RUN_CANCELLED = :run_cancelled @@ -228,29 +227,41 @@ class Reason < OpenAI::Enum RUN_FAILED = :run_failed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end - # @abstract - # # The entity that produced the message. One of `user` or `assistant`. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The status of the message, which can be either `in_progress`, `incomplete`, or # `completed`. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress INCOMPLETE = :incomplete COMPLETED = :completed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/message_content.rb b/lib/openai/models/beta/threads/message_content.rb index 7e6e4698..4e4280f1 100644 --- a/lib/openai/models/beta/threads/message_content.rb +++ b/lib/openai/models/beta/threads/message_content.rb @@ -4,11 +4,11 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContent < OpenAI::Union + module MessageContent + extend OpenAI::Union + discriminator :type # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -24,10 +24,8 @@ class MessageContent < OpenAI::Union variant :refusal, -> { OpenAI::Models::Beta::Threads::RefusalContentBlock } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/message_content_delta.rb b/lib/openai/models/beta/threads/message_content_delta.rb index bcf970c1..4cbf92ef 100644 --- a/lib/openai/models/beta/threads/message_content_delta.rb +++ b/lib/openai/models/beta/threads/message_content_delta.rb @@ -4,11 +4,11 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContentDelta < OpenAI::Union + module MessageContentDelta + extend OpenAI::Union + discriminator :type # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -24,10 +24,8 @@ class MessageContentDelta < OpenAI::Union variant :image_url, -> { OpenAI::Models::Beta::Threads::ImageURLDeltaBlock } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/message_content_part_param.rb b/lib/openai/models/beta/threads/message_content_part_param.rb index 74766529..20ea5568 100644 --- a/lib/openai/models/beta/threads/message_content_part_param.rb +++ b/lib/openai/models/beta/threads/message_content_part_param.rb @@ -4,11 +4,11 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContentPartParam < OpenAI::Union + module MessageContentPartParam + extend OpenAI::Union + discriminator :type # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. @@ -21,10 +21,8 @@ class MessageContentPartParam < OpenAI::Union variant :text, -> { OpenAI::Models::Beta::Threads::TextContentBlockParam } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/message_create_params.rb b/lib/openai/models/beta/threads/message_create_params.rb index b0a54ec9..6738bb76 100644 --- a/lib/openai/models/beta/threads/message_create_params.rb +++ b/lib/openai/models/beta/threads/message_create_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class MessageCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute content @@ -56,38 +56,41 @@ class MessageCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The text contents of the message. - class Content < OpenAI::Union - MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] + module Content + extend OpenAI::Union # The text contents of the message. variant String # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). - variant OpenAI::Models::Beta::Threads::MessageCreateParams::Content::MessageContentPartParamArray + variant -> { OpenAI::Models::Beta::Threads::MessageCreateParams::Content::MessageContentPartParamArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + MessageContentPartParamArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] end - # @abstract - # # The role of the entity that is creating the message. Allowed values include: # # - `user`: Indicates the message is sent by an actual user and should be used in # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Attachment < OpenAI::BaseModel @@ -120,8 +123,9 @@ class Attachment < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + discriminator :type variant :code_interpreter, -> { OpenAI::Models::Beta::CodeInterpreterTool } @@ -145,10 +149,8 @@ class FileSearch < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/message_delete_params.rb b/lib/openai/models/beta/threads/message_delete_params.rb index 8055fbe0..abe4fb7f 100644 --- a/lib/openai/models/beta/threads/message_delete_params.rb +++ b/lib/openai/models/beta/threads/message_delete_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class MessageDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/message_delta.rb b/lib/openai/models/beta/threads/message_delta.rb index f3bc9993..301bea9e 100644 --- a/lib/openai/models/beta/threads/message_delta.rb +++ b/lib/openai/models/beta/threads/message_delta.rb @@ -35,14 +35,18 @@ class MessageDelta < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The entity that produced the message. One of `user` or `assistant`. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/message_list_params.rb b/lib/openai/models/beta/threads/message_list_params.rb index 1a302d8c..cc3f0ae0 100644 --- a/lib/openai/models/beta/threads/message_list_params.rb +++ b/lib/openai/models/beta/threads/message_list_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class MessageListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -79,15 +79,19 @@ class MessageListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/message_retrieve_params.rb b/lib/openai/models/beta/threads/message_retrieve_params.rb index 0280a2b9..c51fa75c 100644 --- a/lib/openai/models/beta/threads/message_retrieve_params.rb +++ b/lib/openai/models/beta/threads/message_retrieve_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class MessageRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/message_update_params.rb b/lib/openai/models/beta/threads/message_update_params.rb index 5e7ff7f0..46ffdaa4 100644 --- a/lib/openai/models/beta/threads/message_update_params.rb +++ b/lib/openai/models/beta/threads/message_update_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class MessageUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/run.rb b/lib/openai/models/beta/threads/run.rb index 02c20e73..05dd765d 100644 --- a/lib/openai/models/beta/threads/run.rb +++ b/lib/openai/models/beta/threads/run.rb @@ -305,15 +305,19 @@ class IncompleteDetails < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The reason why the run is incomplete. This will point to which specific token # limit was reached over the course of the run. - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + MAX_COMPLETION_TOKENS = :max_completion_tokens MAX_PROMPT_TOKENS = :max_prompt_tokens finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -340,15 +344,19 @@ class LastError < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR = :server_error RATE_LIMIT_EXCEEDED = :rate_limit_exceeded INVALID_PROMPT = :invalid_prompt finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -424,17 +432,21 @@ class TruncationStrategy < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The truncation strategy to use for the thread. The default is `auto`. If set to # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO = :auto LAST_MESSAGES = :last_messages finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end diff --git a/lib/openai/models/beta/threads/run_cancel_params.rb b/lib/openai/models/beta/threads/run_cancel_params.rb index 230c1059..14a4bc2b 100644 --- a/lib/openai/models/beta/threads/run_cancel_params.rb +++ b/lib/openai/models/beta/threads/run_cancel_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunCancelParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/run_create_params.rb b/lib/openai/models/beta/threads/run_create_params.rb index c5c473e5..ad9f9698 100644 --- a/lib/openai/models/beta/threads/run_create_params.rb +++ b/lib/openai/models/beta/threads/run_create_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute assistant_id @@ -285,38 +285,41 @@ class AdditionalMessage < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The text contents of the message. - class Content < OpenAI::Union - MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] + module Content + extend OpenAI::Union # The text contents of the message. variant String # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models). - variant OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Content::MessageContentPartParamArray + variant -> { OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Content::MessageContentPartParamArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + MessageContentPartParamArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }] end - # @abstract - # # The role of the entity that is creating the message. Allowed values include: # # - `user`: Indicates the message is sent by an actual user and should be used in # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Attachment < OpenAI::BaseModel @@ -349,8 +352,9 @@ class Attachment < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + discriminator :type variant :code_interpreter, -> { OpenAI::Models::Beta::CodeInterpreterTool } @@ -374,31 +378,27 @@ class FileSearch < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch)] + # def self.variants; end end end end - # @abstract - # # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. variant enum: -> { OpenAI::Models::ChatModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] + # def self.variants; end end class TruncationStrategy < OpenAI::BaseModel @@ -429,17 +429,21 @@ class TruncationStrategy < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The truncation strategy to use for the thread. The default is `auto`. If set to # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO = :auto LAST_MESSAGES = :last_messages finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/run_list_params.rb b/lib/openai/models/beta/threads/run_list_params.rb index ce011119..8f3dfdb6 100644 --- a/lib/openai/models/beta/threads/run_list_params.rb +++ b/lib/openai/models/beta/threads/run_list_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -68,15 +68,19 @@ class RunListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/run_retrieve_params.rb b/lib/openai/models/beta/threads/run_retrieve_params.rb index bd9194cf..4bc9a2aa 100644 --- a/lib/openai/models/beta/threads/run_retrieve_params.rb +++ b/lib/openai/models/beta/threads/run_retrieve_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/run_status.rb b/lib/openai/models/beta/threads/run_status.rb index b85ac1e3..351e323f 100644 --- a/lib/openai/models/beta/threads/run_status.rb +++ b/lib/openai/models/beta/threads/run_status.rb @@ -4,12 +4,12 @@ module OpenAI module Models module Beta module Threads - # @abstract - # # The status of the run, which can be either `queued`, `in_progress`, # `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, # `incomplete`, or `expired`. - class RunStatus < OpenAI::Enum + module RunStatus + extend OpenAI::Enum + QUEUED = :queued IN_PROGRESS = :in_progress REQUIRES_ACTION = :requires_action @@ -21,6 +21,10 @@ class RunStatus < OpenAI::Enum EXPIRED = :expired finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb b/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb index 5c747924..c2d753ad 100644 --- a/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb +++ b/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunSubmitToolOutputsParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/run_update_params.rb b/lib/openai/models/beta/threads/run_update_params.rb index 9d1f9b01..6e213a7f 100644 --- a/lib/openai/models/beta/threads/run_update_params.rb +++ b/lib/openai/models/beta/threads/run_update_params.rb @@ -6,7 +6,7 @@ module Beta module Threads class RunUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb b/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb index 0313a163..4cfc8daf 100644 --- a/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb +++ b/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb @@ -63,10 +63,10 @@ class CodeInterpreter < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Text output from the Code Interpreter tool call as part of a run step. - class Output < OpenAI::Union + module Output + extend OpenAI::Union + discriminator :type # Text output from the Code Interpreter tool call as part of a run step. @@ -139,10 +139,8 @@ class Image < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb b/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb index 9e9097b3..8b00e21b 100644 --- a/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb +++ b/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb @@ -86,10 +86,10 @@ class CodeInterpreter < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Text output from the Code Interpreter tool call as part of a run step. - class Output < OpenAI::Union + module Output + extend OpenAI::Union + discriminator :type # Text output from the Code Interpreter tool call as part of a run step. @@ -98,10 +98,8 @@ class Output < OpenAI::Union variant :image, -> { OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/runs/file_search_tool_call.rb b/lib/openai/models/beta/threads/runs/file_search_tool_call.rb index 9011d196..282a9534 100644 --- a/lib/openai/models/beta/threads/runs/file_search_tool_call.rb +++ b/lib/openai/models/beta/threads/runs/file_search_tool_call.rb @@ -93,15 +93,19 @@ class RankingOptions < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The ranker to use for the file search. If not specified will use the `auto` # ranker. - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO = :auto DEFAULT_2024_08_21 = :default_2024_08_21 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -179,13 +183,17 @@ class Content < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of the content. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/runs/run_step.rb b/lib/openai/models/beta/threads/runs/run_step.rb index 4a7aa3e2..acd1f507 100644 --- a/lib/openai/models/beta/threads/runs/run_step.rb +++ b/lib/openai/models/beta/threads/runs/run_step.rb @@ -183,22 +183,26 @@ class LastError < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # One of `server_error` or `rate_limit_exceeded`. - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR = :server_error RATE_LIMIT_EXCEEDED = :rate_limit_exceeded finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end - # @abstract - # # The status of the run step, which can be either `in_progress`, `cancelled`, # `failed`, `completed`, or `expired`. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress CANCELLED = :cancelled FAILED = :failed @@ -206,12 +210,16 @@ class Status < OpenAI::Enum EXPIRED = :expired finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The details of the run step. - class StepDetails < OpenAI::Union + module StepDetails + extend OpenAI::Union + discriminator :type # Details of the message creation by the run step. @@ -221,20 +229,22 @@ class StepDetails < OpenAI::Union variant :tool_calls, -> { OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails)] + # def self.variants; end end - # @abstract - # # The type of run step, which can be either `message_creation` or `tool_calls`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE_CREATION = :message_creation TOOL_CALLS = :tool_calls finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Usage < OpenAI::BaseModel diff --git a/lib/openai/models/beta/threads/runs/run_step_delta.rb b/lib/openai/models/beta/threads/runs/run_step_delta.rb index c8ba4aa1..84f2aa92 100644 --- a/lib/openai/models/beta/threads/runs/run_step_delta.rb +++ b/lib/openai/models/beta/threads/runs/run_step_delta.rb @@ -25,10 +25,10 @@ class RunStepDelta < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The details of the run step. - class StepDetails < OpenAI::Union + module StepDetails + extend OpenAI::Union + discriminator :type # Details of the message creation by the run step. @@ -38,10 +38,8 @@ class StepDetails < OpenAI::Union variant :tool_calls, -> { OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/runs/run_step_include.rb b/lib/openai/models/beta/threads/runs/run_step_include.rb index ae9413a8..f2f05bbe 100644 --- a/lib/openai/models/beta/threads/runs/run_step_include.rb +++ b/lib/openai/models/beta/threads/runs/run_step_include.rb @@ -5,11 +5,17 @@ module Models module Beta module Threads module Runs - # @abstract - class RunStepInclude < OpenAI::Enum - STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT = :"step_details.tool_calls[*].file_search.results[*].content" + module RunStepInclude + extend OpenAI::Enum + + STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT = + :"step_details.tool_calls[*].file_search.results[*].content" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end diff --git a/lib/openai/models/beta/threads/runs/step_list_params.rb b/lib/openai/models/beta/threads/runs/step_list_params.rb index 685e0e75..eb22d47e 100644 --- a/lib/openai/models/beta/threads/runs/step_list_params.rb +++ b/lib/openai/models/beta/threads/runs/step_list_params.rb @@ -7,7 +7,7 @@ module Threads module Runs class StepListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id @@ -92,15 +92,19 @@ class StepListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/beta/threads/runs/step_retrieve_params.rb b/lib/openai/models/beta/threads/runs/step_retrieve_params.rb index 5329f9d4..ff4b6ccd 100644 --- a/lib/openai/models/beta/threads/runs/step_retrieve_params.rb +++ b/lib/openai/models/beta/threads/runs/step_retrieve_params.rb @@ -7,7 +7,7 @@ module Threads module Runs class StepRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute thread_id diff --git a/lib/openai/models/beta/threads/runs/tool_call.rb b/lib/openai/models/beta/threads/runs/tool_call.rb index 20cc29a6..12ba7d73 100644 --- a/lib/openai/models/beta/threads/runs/tool_call.rb +++ b/lib/openai/models/beta/threads/runs/tool_call.rb @@ -5,10 +5,10 @@ module Models module Beta module Threads module Runs - # @abstract - # # Details of the Code Interpreter tool call the run step was involved in. - class ToolCall < OpenAI::Union + module ToolCall + extend OpenAI::Union + discriminator :type # Details of the Code Interpreter tool call the run step was involved in. @@ -19,10 +19,8 @@ class ToolCall < OpenAI::Union variant :function, -> { OpenAI::Models::Beta::Threads::Runs::FunctionToolCall } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall)] + # def self.variants; end end end end diff --git a/lib/openai/models/beta/threads/runs/tool_call_delta.rb b/lib/openai/models/beta/threads/runs/tool_call_delta.rb index 3dae6b9b..c8c796f3 100644 --- a/lib/openai/models/beta/threads/runs/tool_call_delta.rb +++ b/lib/openai/models/beta/threads/runs/tool_call_delta.rb @@ -5,10 +5,10 @@ module Models module Beta module Threads module Runs - # @abstract - # # Details of the Code Interpreter tool call the run step was involved in. - class ToolCallDelta < OpenAI::Union + module ToolCallDelta + extend OpenAI::Union + discriminator :type # Details of the Code Interpreter tool call the run step was involved in. @@ -19,10 +19,8 @@ class ToolCallDelta < OpenAI::Union variant :function, -> { OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta)] + # def self.variants; end end end end diff --git a/lib/openai/models/chat/chat_completion.rb b/lib/openai/models/chat/chat_completion.rb index b80607a6..bc94f59d 100644 --- a/lib/openai/models/chat/chat_completion.rb +++ b/lib/openai/models/chat/chat_completion.rb @@ -133,15 +133,15 @@ class Choice < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The reason the model stopped generating tokens. This will be `stop` if the model # hit a natural stop point or a provided stop sequence, `length` if the maximum # number of tokens specified in the request was reached, `content_filter` if # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP = :stop LENGTH = :length TOOL_CALLS = :tool_calls @@ -149,6 +149,10 @@ class FinishReason < OpenAI::Enum FUNCTION_CALL = :function_call finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Logprobs < OpenAI::BaseModel @@ -176,14 +180,18 @@ class Logprobs < OpenAI::BaseModel end end - # @abstract - # # The service tier used for processing the request. - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + SCALE = :scale DEFAULT = :default finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat/chat_completion_assistant_message_param.rb b/lib/openai/models/chat/chat_completion_assistant_message_param.rb index 0ab1ed53..c6a293dd 100644 --- a/lib/openai/models/chat/chat_completion_assistant_message_param.rb +++ b/lib/openai/models/chat/chat_completion_assistant_message_param.rb @@ -106,24 +106,22 @@ class Audio < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The contents of the assistant message. Required unless `tool_calls` or # `function_call` is specified. - class Content < OpenAI::Union - ArrayOfContentPartArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart }] + module Content + extend OpenAI::Union # The contents of the assistant message. variant String # An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`. - variant OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPartArray + variant -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPartArray } - # @abstract - # # Learn about # [text inputs](https://platform.openai.com/docs/guides/text-generation). - class ArrayOfContentPart < OpenAI::Union + module ArrayOfContentPart + extend OpenAI::Union + discriminator :type # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). @@ -132,17 +130,16 @@ class ArrayOfContentPart < OpenAI::Union variant :refusal, -> { OpenAI::Models::Chat::ChatCompletionContentPartRefusal } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal)] + # def self.variants; end end # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ArrayOfContentPartArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart }] end # @deprecated diff --git a/lib/openai/models/chat/chat_completion_audio_param.rb b/lib/openai/models/chat/chat_completion_audio_param.rb index 5d72b2de..638a7c7e 100644 --- a/lib/openai/models/chat/chat_completion_audio_param.rb +++ b/lib/openai/models/chat/chat_completion_audio_param.rb @@ -15,8 +15,8 @@ class ChatCompletionAudioParam < OpenAI::BaseModel # The voice the model uses to respond. Supported voices are `alloy`, `ash`, # `ballad`, `coral`, `echo`, `sage`, and `shimmer`. # - # @return [Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice] - required :voice, enum: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice } + # @return [String, Symbol] + required :voice, union: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice } # @!parse # # Parameters for audio output. Required when audio output is requested with @@ -24,17 +24,17 @@ class ChatCompletionAudioParam < OpenAI::BaseModel # # [Learn more](https://platform.openai.com/docs/guides/audio). # # # # @param format_ [Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Format] - # # @param voice [Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice] + # # @param voice [String, Symbol] # # # def initialize(format_:, voice:, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, # or `pcm16`. - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + WAV = :wav MP3 = :mp3 FLAC = :flac @@ -42,23 +42,60 @@ class Format < OpenAI::Enum PCM16 = :pcm16 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The voice the model uses to respond. Supported voices are `alloy`, `ash`, # `ballad`, `coral`, `echo`, `sage`, and `shimmer`. - class Voice < OpenAI::Enum + module Voice + extend OpenAI::Union + + variant String + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ALLOY } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ASH } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::BALLAD } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::CORAL } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ECHO } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::FABLE } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ONYX } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::NOVA } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::SAGE } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::SHIMMER } + + variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::VERSE } + + # @!parse + # # @return [Array(String, Symbol)] + # def self.variants; end + + # @!group + ALLOY = :alloy ASH = :ash BALLAD = :ballad CORAL = :coral ECHO = :echo + FABLE = :fable + ONYX = :onyx + NOVA = :nova SAGE = :sage SHIMMER = :shimmer VERSE = :verse - finalize! + # @!endgroup end end end diff --git a/lib/openai/models/chat/chat_completion_chunk.rb b/lib/openai/models/chat/chat_completion_chunk.rb index 0c8a0cea..dde734e3 100644 --- a/lib/openai/models/chat/chat_completion_chunk.rb +++ b/lib/openai/models/chat/chat_completion_chunk.rb @@ -58,8 +58,11 @@ class ChatCompletionChunk < OpenAI::BaseModel # @!attribute usage # An optional field that will only be present when you set # `stream_options: {"include_usage": true}` in your request. When present, it - # contains a null value except for the last chunk which contains the token usage - # statistics for the entire request. + # contains a null value **except for the last chunk** which contains the token + # usage statistics for the entire request. + # + # **NOTE:** If the stream is interrupted or cancelled, you may not receive the + # final usage chunk which contains the total token usage for the request. # # @return [OpenAI::Models::CompletionUsage, nil] optional :usage, -> { OpenAI::Models::CompletionUsage }, nil?: true @@ -230,10 +233,10 @@ class FunctionCall < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The role of the author of this message. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + DEVELOPER = :developer SYSTEM = :system USER = :user @@ -241,6 +244,10 @@ class Role < OpenAI::Enum TOOL = :tool finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class ToolCall < OpenAI::BaseModel @@ -321,26 +328,30 @@ class Function < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The type of the tool. Currently, only `function` is supported. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FUNCTION = :function finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end - # @abstract - # # The reason the model stopped generating tokens. This will be `stop` if the model # hit a natural stop point or a provided stop sequence, `length` if the maximum # number of tokens specified in the request was reached, `content_filter` if # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP = :stop LENGTH = :length TOOL_CALLS = :tool_calls @@ -348,6 +359,10 @@ class FinishReason < OpenAI::Enum FUNCTION_CALL = :function_call finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Logprobs < OpenAI::BaseModel @@ -375,14 +390,18 @@ class Logprobs < OpenAI::BaseModel end end - # @abstract - # # The service tier used for processing the request. - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + SCALE = :scale DEFAULT = :default finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat/chat_completion_content_part.rb b/lib/openai/models/chat/chat_completion_content_part.rb index f9fede31..72530466 100644 --- a/lib/openai/models/chat/chat_completion_content_part.rb +++ b/lib/openai/models/chat/chat_completion_content_part.rb @@ -3,11 +3,11 @@ module OpenAI module Models module Chat - # @abstract - # # Learn about # [text inputs](https://platform.openai.com/docs/guides/text-generation). - class ChatCompletionContentPart < OpenAI::Union + module ChatCompletionContentPart + extend OpenAI::Union + discriminator :type # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). @@ -67,32 +67,30 @@ class File < OpenAI::BaseModel # # @return [String] # attr_writer :file_id - # @!attribute [r] file_name + # @!attribute [r] filename # The name of the file, used when passing the file to the model as a string. # # @return [String, nil] - optional :file_name, String + optional :filename, String # @!parse # # @return [String] - # attr_writer :file_name + # attr_writer :filename # @!parse # # @param file_data [String] # # @param file_id [String] - # # @param file_name [String] + # # @param filename [String] # # - # def initialize(file_data: nil, file_id: nil, file_name: nil, **) = super + # def initialize(file_data: nil, file_id: nil, filename: nil, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void end end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File)] + # def self.variants; end end end diff --git a/lib/openai/models/chat/chat_completion_content_part_image.rb b/lib/openai/models/chat/chat_completion_content_part_image.rb index 9990262c..3fd2baeb 100644 --- a/lib/openai/models/chat/chat_completion_content_part_image.rb +++ b/lib/openai/models/chat/chat_completion_content_part_image.rb @@ -51,16 +51,20 @@ class ImageURL < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the detail level of the image. Learn more in the # [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding). - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO = :auto LOW = :low HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat/chat_completion_content_part_input_audio.rb b/lib/openai/models/chat/chat_completion_content_part_input_audio.rb index 0ed3dff8..269e74c7 100644 --- a/lib/openai/models/chat/chat_completion_content_part_input_audio.rb +++ b/lib/openai/models/chat/chat_completion_content_part_input_audio.rb @@ -48,14 +48,18 @@ class InputAudio < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The format of the encoded audio data. Currently supports "wav" and "mp3". - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + WAV = :wav MP3 = :mp3 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat/chat_completion_developer_message_param.rb b/lib/openai/models/chat/chat_completion_developer_message_param.rb index d7d8b7c4..98b66dd7 100644 --- a/lib/openai/models/chat/chat_completion_developer_message_param.rb +++ b/lib/openai/models/chat/chat_completion_developer_message_param.rb @@ -40,23 +40,22 @@ class ChatCompletionDeveloperMessageParam < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The contents of the developer message. - class Content < OpenAI::Union - ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] + module Content + extend OpenAI::Union # The contents of the developer message. variant String # An array of content parts with a defined type. For developer messages, only type `text` is supported. - variant OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam::Content::ChatCompletionContentPartTextArray + variant -> { OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam::Content::ChatCompletionContentPartTextArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ChatCompletionContentPartTextArray = + OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] end end end diff --git a/lib/openai/models/chat/chat_completion_message_param.rb b/lib/openai/models/chat/chat_completion_message_param.rb index 811b7f8c..d55d9826 100644 --- a/lib/openai/models/chat/chat_completion_message_param.rb +++ b/lib/openai/models/chat/chat_completion_message_param.rb @@ -3,12 +3,12 @@ module OpenAI module Models module Chat - # @abstract - # # Developer-provided instructions that the model should follow, regardless of # messages sent by the user. With o1 models and newer, `developer` messages # replace the previous `system` messages. - class ChatCompletionMessageParam < OpenAI::Union + module ChatCompletionMessageParam + extend OpenAI::Union + discriminator :role # Developer-provided instructions that the model should follow, regardless of @@ -33,10 +33,8 @@ class ChatCompletionMessageParam < OpenAI::Union variant :function, -> { OpenAI::Models::Chat::ChatCompletionFunctionMessageParam } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam)] + # def self.variants; end end end diff --git a/lib/openai/models/chat/chat_completion_modality.rb b/lib/openai/models/chat/chat_completion_modality.rb index 725b907d..f759271a 100644 --- a/lib/openai/models/chat/chat_completion_modality.rb +++ b/lib/openai/models/chat/chat_completion_modality.rb @@ -3,12 +3,17 @@ module OpenAI module Models module Chat - # @abstract - class ChatCompletionModality < OpenAI::Enum + module ChatCompletionModality + extend OpenAI::Enum + TEXT = :text AUDIO = :audio finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end diff --git a/lib/openai/models/chat/chat_completion_prediction_content.rb b/lib/openai/models/chat/chat_completion_prediction_content.rb index d5aca19d..e170c46d 100644 --- a/lib/openai/models/chat/chat_completion_prediction_content.rb +++ b/lib/openai/models/chat/chat_completion_prediction_content.rb @@ -30,26 +30,25 @@ class ChatCompletionPredictionContent < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The content that should be matched when generating a model response. If # generated tokens would match this content, the entire model response can be # returned much more quickly. - class Content < OpenAI::Union - ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] + module Content + extend OpenAI::Union # The content used for a Predicted Output. This is often the # text of a file you are regenerating with minor changes. variant String # An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text inputs. - variant OpenAI::Models::Chat::ChatCompletionPredictionContent::Content::ChatCompletionContentPartTextArray + variant -> { OpenAI::Models::Chat::ChatCompletionPredictionContent::Content::ChatCompletionContentPartTextArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ChatCompletionContentPartTextArray = + OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] end end end diff --git a/lib/openai/models/chat/chat_completion_role.rb b/lib/openai/models/chat/chat_completion_role.rb index 234d78a6..33673904 100644 --- a/lib/openai/models/chat/chat_completion_role.rb +++ b/lib/openai/models/chat/chat_completion_role.rb @@ -3,10 +3,10 @@ module OpenAI module Models module Chat - # @abstract - # # The role of the author of a message - class ChatCompletionRole < OpenAI::Enum + module ChatCompletionRole + extend OpenAI::Enum + DEVELOPER = :developer SYSTEM = :system USER = :user @@ -15,6 +15,10 @@ class ChatCompletionRole < OpenAI::Enum FUNCTION = :function finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end diff --git a/lib/openai/models/chat/chat_completion_stream_options.rb b/lib/openai/models/chat/chat_completion_stream_options.rb index be16b6d6..0d66702d 100644 --- a/lib/openai/models/chat/chat_completion_stream_options.rb +++ b/lib/openai/models/chat/chat_completion_stream_options.rb @@ -7,8 +7,11 @@ class ChatCompletionStreamOptions < OpenAI::BaseModel # @!attribute [r] include_usage # If set, an additional chunk will be streamed before the `data: [DONE]` message. # The `usage` field on this chunk shows the token usage statistics for the entire - # request, and the `choices` field will always be an empty array. All other chunks - # will also include a `usage` field, but with a null value. + # request, and the `choices` field will always be an empty array. + # + # All other chunks will also include a `usage` field, but with a null value. + # **NOTE:** If the stream is interrupted, you may not receive the final usage + # chunk which contains the total token usage for the request. # # @return [Boolean, nil] optional :include_usage, OpenAI::BooleanModel diff --git a/lib/openai/models/chat/chat_completion_system_message_param.rb b/lib/openai/models/chat/chat_completion_system_message_param.rb index 658bb497..b311ca43 100644 --- a/lib/openai/models/chat/chat_completion_system_message_param.rb +++ b/lib/openai/models/chat/chat_completion_system_message_param.rb @@ -40,23 +40,22 @@ class ChatCompletionSystemMessageParam < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The contents of the system message. - class Content < OpenAI::Union - ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] + module Content + extend OpenAI::Union # The contents of the system message. variant String # An array of content parts with a defined type. For system messages, only type `text` is supported. - variant OpenAI::Models::Chat::ChatCompletionSystemMessageParam::Content::ChatCompletionContentPartTextArray + variant -> { OpenAI::Models::Chat::ChatCompletionSystemMessageParam::Content::ChatCompletionContentPartTextArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ChatCompletionContentPartTextArray = + OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] end end end diff --git a/lib/openai/models/chat/chat_completion_tool_choice_option.rb b/lib/openai/models/chat/chat_completion_tool_choice_option.rb index 28f7750e..7b6d3ff8 100644 --- a/lib/openai/models/chat/chat_completion_tool_choice_option.rb +++ b/lib/openai/models/chat/chat_completion_tool_choice_option.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Chat - # @abstract - # # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can # pick between generating a message or calling one or more tools. `required` means @@ -14,31 +12,35 @@ module Chat # # `none` is the default when no tools are present. `auto` is the default if tools # are present. - class ChatCompletionToolChoiceOption < OpenAI::Union + module ChatCompletionToolChoiceOption + extend OpenAI::Union + # `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. variant enum: -> { OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto } # Specifies a tool the model should use. Use to force the model to call a specific function. variant -> { OpenAI::Models::Chat::ChatCompletionNamedToolChoice } - # @abstract - # # `none` means the model will not call any tool and instead generates a message. # `auto` means the model can pick between generating a message or calling one or # more tools. `required` means the model must call one or more tools. - class Auto < OpenAI::Enum + module Auto + extend OpenAI::Enum + NONE = :none AUTO = :auto REQUIRED = :required finalize! + + # @!parse + # # @return [Array] + # def self.values; end end # @!parse - # class << self - # # @return [Array(Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)] - # def variants; end - # end + # # @return [Array(Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)] + # def self.variants; end end end diff --git a/lib/openai/models/chat/chat_completion_tool_message_param.rb b/lib/openai/models/chat/chat_completion_tool_message_param.rb index 6ba3a959..31644647 100644 --- a/lib/openai/models/chat/chat_completion_tool_message_param.rb +++ b/lib/openai/models/chat/chat_completion_tool_message_param.rb @@ -31,23 +31,22 @@ class ChatCompletionToolMessageParam < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The contents of the tool message. - class Content < OpenAI::Union - ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] + module Content + extend OpenAI::Union # The contents of the tool message. variant String # An array of content parts with a defined type. For tool messages, only type `text` is supported. - variant OpenAI::Models::Chat::ChatCompletionToolMessageParam::Content::ChatCompletionContentPartTextArray + variant -> { OpenAI::Models::Chat::ChatCompletionToolMessageParam::Content::ChatCompletionContentPartTextArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ChatCompletionContentPartTextArray = + OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }] end end end diff --git a/lib/openai/models/chat/chat_completion_user_message_param.rb b/lib/openai/models/chat/chat_completion_user_message_param.rb index 18451c7b..b938d473 100644 --- a/lib/openai/models/chat/chat_completion_user_message_param.rb +++ b/lib/openai/models/chat/chat_completion_user_message_param.rb @@ -39,23 +39,22 @@ class ChatCompletionUserMessageParam < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The contents of the user message. - class Content < OpenAI::Union - ChatCompletionContentPartArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionContentPart }] + module Content + extend OpenAI::Union # The text contents of the message. variant String # An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs. - variant OpenAI::Models::Chat::ChatCompletionUserMessageParam::Content::ChatCompletionContentPartArray + variant -> { OpenAI::Models::Chat::ChatCompletionUserMessageParam::Content::ChatCompletionContentPartArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + ChatCompletionContentPartArray = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionContentPart }] end end end diff --git a/lib/openai/models/chat/completion_create_params.rb b/lib/openai/models/chat/completion_create_params.rb index 49e175c1..8eb609ab 100644 --- a/lib/openai/models/chat/completion_create_params.rb +++ b/lib/openai/models/chat/completion_create_params.rb @@ -5,7 +5,7 @@ module Models module Chat class CompletionCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute messages @@ -417,14 +417,14 @@ class CompletionCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a # wide range of models with different capabilities, performance characteristics, # and price points. Refer to the # [model guide](https://platform.openai.com/docs/models) to browse and compare # available models. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI @@ -434,14 +434,10 @@ class Model < OpenAI::Union variant enum: -> { OpenAI::Models::ChatModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] + # def self.variants; end end - # @abstract - # # @deprecated # # Deprecated in favor of `tool_choice`. @@ -458,30 +454,34 @@ class Model < OpenAI::Union # # `none` is the default when no functions are present. `auto` is the default if # functions are present. - class FunctionCall < OpenAI::Union + module FunctionCall + extend OpenAI::Union + # `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function. variant enum: -> { OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode } # Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. variant -> { OpenAI::Models::Chat::ChatCompletionFunctionCallOption } - # @abstract - # # `none` means the model will not call a function and instead generates a message. # `auto` means the model can pick between generating a message or calling a # function. - class FunctionCallMode < OpenAI::Enum + module FunctionCallMode + extend OpenAI::Enum + NONE = :none AUTO = :auto finalize! + + # @!parse + # # @return [Array] + # def self.values; end end # @!parse - # class << self - # # @return [Array(Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)] - # def variants; end - # end + # # @return [Array(Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)] + # def self.variants; end end # @deprecated @@ -530,16 +530,19 @@ class Function < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - class Modality < OpenAI::Enum + module Modality + extend OpenAI::Enum + TEXT = :text AUDIO = :audio finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # An object specifying the format that the model must output. # # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured @@ -550,7 +553,9 @@ class Modality < OpenAI::Enum # Setting to `{ "type": "json_object" }` enables the older JSON mode, which # ensures the message the model generates is valid JSON. Using `json_schema` is # preferred for models that support it. - class ResponseFormat < OpenAI::Union + module ResponseFormat + extend OpenAI::Union + # Default response format. Used to generate text responses. variant -> { OpenAI::Models::ResponseFormatText } @@ -565,14 +570,10 @@ class ResponseFormat < OpenAI::Union variant -> { OpenAI::Models::ResponseFormatJSONObject } # @!parse - # class << self - # # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject)] + # def self.variants; end end - # @abstract - # # Specifies the latency tier to use for processing the request. This parameter is # relevant for customers subscribed to the scale tier service: # @@ -587,29 +588,33 @@ class ResponseFormat < OpenAI::Union # # When this parameter is set, the response body will include the `service_tier` # utilized. - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + AUTO = :auto DEFAULT = :default finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. - class Stop < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] + module Stop + extend OpenAI::Union variant String - variant OpenAI::Models::Chat::CompletionCreateParams::Stop::StringArray + variant -> { OpenAI::Models::Chat::CompletionCreateParams::Stop::StringArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] end class WebSearchOptions < OpenAI::BaseModel @@ -645,16 +650,20 @@ class WebSearchOptions < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - class SearchContextSize < OpenAI::Enum + module SearchContextSize + extend OpenAI::Enum + LOW = :low MEDIUM = :medium HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class UserLocation < OpenAI::BaseModel diff --git a/lib/openai/models/chat/completion_delete_params.rb b/lib/openai/models/chat/completion_delete_params.rb index d3a43ac0..cbcb2c22 100644 --- a/lib/openai/models/chat/completion_delete_params.rb +++ b/lib/openai/models/chat/completion_delete_params.rb @@ -5,7 +5,7 @@ module Models module Chat class CompletionDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/chat/completion_list_params.rb b/lib/openai/models/chat/completion_list_params.rb index 81936268..8b2e8ef7 100644 --- a/lib/openai/models/chat/completion_list_params.rb +++ b/lib/openai/models/chat/completion_list_params.rb @@ -5,7 +5,7 @@ module Models module Chat class CompletionListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -69,15 +69,19 @@ class CompletionListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order for Chat Completions by timestamp. Use `asc` for ascending order or # `desc` for descending order. Defaults to `asc`. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat/completion_retrieve_params.rb b/lib/openai/models/chat/completion_retrieve_params.rb index 248e8caf..e8ee1b1c 100644 --- a/lib/openai/models/chat/completion_retrieve_params.rb +++ b/lib/openai/models/chat/completion_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module Chat class CompletionRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/chat/completion_update_params.rb b/lib/openai/models/chat/completion_update_params.rb index bc642e24..32797eb4 100644 --- a/lib/openai/models/chat/completion_update_params.rb +++ b/lib/openai/models/chat/completion_update_params.rb @@ -5,7 +5,7 @@ module Models module Chat class CompletionUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute metadata diff --git a/lib/openai/models/chat/completions/message_list_params.rb b/lib/openai/models/chat/completions/message_list_params.rb index 66af6ada..74ccbdc7 100644 --- a/lib/openai/models/chat/completions/message_list_params.rb +++ b/lib/openai/models/chat/completions/message_list_params.rb @@ -6,7 +6,7 @@ module Chat module Completions class MessageListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -50,15 +50,19 @@ class MessageListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order for messages by timestamp. Use `asc` for ascending order or `desc` # for descending order. Defaults to `asc`. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/chat_model.rb b/lib/openai/models/chat_model.rb index 29b0a851..3da0931e 100644 --- a/lib/openai/models/chat_model.rb +++ b/lib/openai/models/chat_model.rb @@ -2,8 +2,9 @@ module OpenAI module Models - # @abstract - class ChatModel < OpenAI::Enum + module ChatModel + extend OpenAI::Enum + O3_MINI = :"o3-mini" O3_MINI_2025_01_31 = :"o3-mini-2025-01-31" O1 = :o1 @@ -12,11 +13,6 @@ class ChatModel < OpenAI::Enum O1_PREVIEW_2024_09_12 = :"o1-preview-2024-09-12" O1_MINI = :"o1-mini" O1_MINI_2024_09_12 = :"o1-mini-2024-09-12" - COMPUTER_USE_PREVIEW = :"computer-use-preview" - COMPUTER_USE_PREVIEW_2025_02_04 = :"computer-use-preview-2025-02-04" - COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11" - GPT_4_5_PREVIEW = :"gpt-4.5-preview" - GPT_4_5_PREVIEW_2025_02_27 = :"gpt-4.5-preview-2025-02-27" GPT_4O = :"gpt-4o" GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20" GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06" @@ -26,6 +22,10 @@ class ChatModel < OpenAI::Enum GPT_4O_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-audio-preview-2024-12-17" GPT_4O_MINI_AUDIO_PREVIEW = :"gpt-4o-mini-audio-preview" GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-mini-audio-preview-2024-12-17" + GPT_4O_SEARCH_PREVIEW = :"gpt-4o-search-preview" + GPT_4O_MINI_SEARCH_PREVIEW = :"gpt-4o-mini-search-preview" + GPT_4O_SEARCH_PREVIEW_2025_03_11 = :"gpt-4o-search-preview-2025-03-11" + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 = :"gpt-4o-mini-search-preview-2025-03-11" CHATGPT_4O_LATEST = :"chatgpt-4o-latest" GPT_4O_MINI = :"gpt-4o-mini" GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18" @@ -50,6 +50,10 @@ class ChatModel < OpenAI::Enum GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/comparison_filter.rb b/lib/openai/models/comparison_filter.rb index 17be219d..e79a3435 100644 --- a/lib/openai/models/comparison_filter.rb +++ b/lib/openai/models/comparison_filter.rb @@ -41,8 +41,6 @@ class ComparisonFilter < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`. # # - `eq`: equals @@ -51,7 +49,9 @@ class ComparisonFilter < OpenAI::BaseModel # - `gte`: greater than or equal # - `lt`: less than # - `lte`: less than or equal - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + EQ = :eq NE = :ne GT = :gt @@ -60,13 +60,17 @@ class Type < OpenAI::Enum LTE = :lte finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The value to compare against the attribute key; supports string, number, or # boolean types. - class Value < OpenAI::Union + module Value + extend OpenAI::Union + variant String variant Float @@ -74,10 +78,8 @@ class Value < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/completion_choice.rb b/lib/openai/models/completion_choice.rb index 6237b56e..5e4a549b 100644 --- a/lib/openai/models/completion_choice.rb +++ b/lib/openai/models/completion_choice.rb @@ -37,18 +37,22 @@ class CompletionChoice < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The reason the model stopped generating tokens. This will be `stop` if the model # hit a natural stop point or a provided stop sequence, `length` if the maximum # number of tokens specified in the request was reached, or `content_filter` if # content was omitted due to a flag from our content filters. - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP = :stop LENGTH = :length CONTENT_FILTER = :content_filter finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Logprobs < OpenAI::BaseModel diff --git a/lib/openai/models/completion_create_params.rb b/lib/openai/models/completion_create_params.rb index c1c44876..d4935347 100644 --- a/lib/openai/models/completion_create_params.rb +++ b/lib/openai/models/completion_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class CompletionCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute model @@ -228,83 +228,77 @@ class CompletionCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - # @!group - - GPT_3_5_TURBO_INSTRUCT = :"gpt-3.5-turbo-instruct" - DAVINCI_002 = :"davinci-002" - BABBAGE_002 = :"babbage-002" - - # @!endgroup + module Model + extend OpenAI::Union variant String - variant const: OpenAI::Models::CompletionCreateParams::Model::GPT_3_5_TURBO_INSTRUCT + variant const: -> { OpenAI::Models::CompletionCreateParams::Model::GPT_3_5_TURBO_INSTRUCT } - variant const: OpenAI::Models::CompletionCreateParams::Model::DAVINCI_002 + variant const: -> { OpenAI::Models::CompletionCreateParams::Model::DAVINCI_002 } - variant const: OpenAI::Models::CompletionCreateParams::Model::BABBAGE_002 + variant const: -> { OpenAI::Models::CompletionCreateParams::Model::BABBAGE_002 } # @!parse - # class << self - # # @return [Array(String, Symbol)] - # def variants; end - # end + # # @return [Array(String, Symbol)] + # def self.variants; end + + # @!group + + GPT_3_5_TURBO_INSTRUCT = :"gpt-3.5-turbo-instruct" + DAVINCI_002 = :"davinci-002" + BABBAGE_002 = :"babbage-002" + + # @!endgroup end - # @abstract - # # The prompt(s) to generate completions for, encoded as a string, array of # strings, array of tokens, or array of token arrays. # # Note that <|endoftext|> is the document separator that the model sees during # training, so if a prompt is not specified the model will generate as if from the # beginning of a new document. - class Prompt < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] - - IntegerArray = OpenAI::ArrayOf[Integer] - - ArrayOfToken2DArray = OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]] + module Prompt + extend OpenAI::Union variant String - variant OpenAI::Models::CompletionCreateParams::Prompt::StringArray + variant -> { OpenAI::Models::CompletionCreateParams::Prompt::StringArray } - variant OpenAI::Models::CompletionCreateParams::Prompt::IntegerArray + variant -> { OpenAI::Models::CompletionCreateParams::Prompt::IntegerArray } - variant OpenAI::Models::CompletionCreateParams::Prompt::ArrayOfToken2DArray + variant -> { OpenAI::Models::CompletionCreateParams::Prompt::ArrayOfToken2DArray } # @!parse - # class << self - # # @return [Array(String, Array, Array, Array>)] - # def variants; end - # end + # # @return [Array(String, Array, Array, Array>)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] + + IntegerArray = OpenAI::ArrayOf[Integer] + + ArrayOfToken2DArray = OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]] end - # @abstract - # # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. - class Stop < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] + module Stop + extend OpenAI::Union variant String - variant OpenAI::Models::CompletionCreateParams::Stop::StringArray + variant -> { OpenAI::Models::CompletionCreateParams::Stop::StringArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] end end end diff --git a/lib/openai/models/compound_filter.rb b/lib/openai/models/compound_filter.rb index 11452bfe..7fd45e2c 100644 --- a/lib/openai/models/compound_filter.rb +++ b/lib/openai/models/compound_filter.rb @@ -26,31 +26,33 @@ class CompoundFilter < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A filter used to compare a specified attribute key to a given value using a # defined comparison operation. - class Filter < OpenAI::Union + module Filter + extend OpenAI::Union + # A filter used to compare a specified attribute key to a given value using a defined comparison operation. variant -> { OpenAI::Models::ComparisonFilter } variant OpenAI::Unknown # @!parse - # class << self - # # @return [Array(OpenAI::Models::ComparisonFilter, Object)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ComparisonFilter, Object)] + # def self.variants; end end - # @abstract - # # Type of operation: `and` or `or`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AND = :and OR = :or finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/embedding_create_params.rb b/lib/openai/models/embedding_create_params.rb index 4d126d18..7bcadd1d 100644 --- a/lib/openai/models/embedding_create_params.rb +++ b/lib/openai/models/embedding_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class EmbeddingCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute input @@ -76,8 +76,6 @@ class EmbeddingCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Input text to embed, encoded as a string or array of tokens. To embed multiple # inputs in a single request, pass an array of strings or array of token arrays. # The input must not exceed the max input tokens for the model (8192 tokens for @@ -86,61 +84,63 @@ class EmbeddingCreateParams < OpenAI::BaseModel # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) # for counting tokens. Some models may also impose a limit on total number of # tokens summed across inputs. - class Input < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] - - IntegerArray = OpenAI::ArrayOf[Integer] - - ArrayOfToken2DArray = OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]] + module Input + extend OpenAI::Union # The string that will be turned into an embedding. variant String # The array of strings that will be turned into an embedding. - variant OpenAI::Models::EmbeddingCreateParams::Input::StringArray + variant -> { OpenAI::Models::EmbeddingCreateParams::Input::StringArray } # The array of integers that will be turned into an embedding. - variant OpenAI::Models::EmbeddingCreateParams::Input::IntegerArray + variant -> { OpenAI::Models::EmbeddingCreateParams::Input::IntegerArray } # The array of arrays containing integers that will be turned into an embedding. - variant OpenAI::Models::EmbeddingCreateParams::Input::ArrayOfToken2DArray + variant -> { OpenAI::Models::EmbeddingCreateParams::Input::ArrayOfToken2DArray } # @!parse - # class << self - # # @return [Array(String, Array, Array, Array>)] - # def variants; end - # end + # # @return [Array(String, Array, Array, Array>)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] + + IntegerArray = OpenAI::ArrayOf[Integer] + + ArrayOfToken2DArray = OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]] end - # @abstract - # # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them. variant enum: -> { OpenAI::Models::EmbeddingModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::EmbeddingModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::EmbeddingModel)] + # def self.variants; end end - # @abstract - # # The format to return the embeddings in. Can be either `float` or # [`base64`](https://pypi.org/project/pybase64/). - class EncodingFormat < OpenAI::Enum + module EncodingFormat + extend OpenAI::Enum + FLOAT = :float BASE64 = :base64 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/embedding_model.rb b/lib/openai/models/embedding_model.rb index 65247fdf..e2e7df6a 100644 --- a/lib/openai/models/embedding_model.rb +++ b/lib/openai/models/embedding_model.rb @@ -2,13 +2,18 @@ module OpenAI module Models - # @abstract - class EmbeddingModel < OpenAI::Enum + module EmbeddingModel + extend OpenAI::Enum + TEXT_EMBEDDING_ADA_002 = :"text-embedding-ada-002" TEXT_EMBEDDING_3_SMALL = :"text-embedding-3-small" TEXT_EMBEDDING_3_LARGE = :"text-embedding-3-large" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/file_chunking_strategy.rb b/lib/openai/models/file_chunking_strategy.rb index 24c4dd7e..5cfb6edf 100644 --- a/lib/openai/models/file_chunking_strategy.rb +++ b/lib/openai/models/file_chunking_strategy.rb @@ -2,10 +2,10 @@ module OpenAI module Models - # @abstract - # # The strategy used to chunk the file. - class FileChunkingStrategy < OpenAI::Union + module FileChunkingStrategy + extend OpenAI::Union + discriminator :type variant :static, -> { OpenAI::Models::StaticFileChunkingStrategyObject } @@ -14,10 +14,8 @@ class FileChunkingStrategy < OpenAI::Union variant :other, -> { OpenAI::Models::OtherFileChunkingStrategyObject } # @!parse - # class << self - # # @return [Array(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject)] + # def self.variants; end end end end diff --git a/lib/openai/models/file_chunking_strategy_param.rb b/lib/openai/models/file_chunking_strategy_param.rb index d9e6a634..38682a15 100644 --- a/lib/openai/models/file_chunking_strategy_param.rb +++ b/lib/openai/models/file_chunking_strategy_param.rb @@ -2,11 +2,11 @@ module OpenAI module Models - # @abstract - # # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. Only applicable if `file_ids` is non-empty. - class FileChunkingStrategyParam < OpenAI::Union + module FileChunkingStrategyParam + extend OpenAI::Union + discriminator :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. @@ -16,10 +16,8 @@ class FileChunkingStrategyParam < OpenAI::Union variant :static, -> { OpenAI::Models::StaticFileChunkingStrategyObjectParam } # @!parse - # class << self - # # @return [Array(OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam)] + # def self.variants; end end end end diff --git a/lib/openai/models/file_content_params.rb b/lib/openai/models/file_content_params.rb index 38b39c6c..597cc103 100644 --- a/lib/openai/models/file_content_params.rb +++ b/lib/openai/models/file_content_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class FileContentParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/file_create_params.rb b/lib/openai/models/file_create_params.rb index 23e108a1..c37dba0c 100644 --- a/lib/openai/models/file_create_params.rb +++ b/lib/openai/models/file_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class FileCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute file diff --git a/lib/openai/models/file_delete_params.rb b/lib/openai/models/file_delete_params.rb index 54238ca0..22f10a38 100644 --- a/lib/openai/models/file_delete_params.rb +++ b/lib/openai/models/file_delete_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class FileDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/file_list_params.rb b/lib/openai/models/file_list_params.rb index 3a3c6b9b..9d825d43 100644 --- a/lib/openai/models/file_list_params.rb +++ b/lib/openai/models/file_list_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class FileListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -63,15 +63,19 @@ class FileListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/file_object.rb b/lib/openai/models/file_object.rb index f0476f5d..7b08ec97 100644 --- a/lib/openai/models/file_object.rb +++ b/lib/openai/models/file_object.rb @@ -99,12 +99,12 @@ class FileObject < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The intended purpose of the file. Supported values are `assistants`, # `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` # and `vision`. - class Purpose < OpenAI::Enum + module Purpose + extend OpenAI::Enum + ASSISTANTS = :assistants ASSISTANTS_OUTPUT = :assistants_output BATCH = :batch @@ -114,20 +114,28 @@ class Purpose < OpenAI::Enum VISION = :vision finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # @deprecated # # Deprecated. The current status of the file, which can be either `uploaded`, # `processed`, or `error`. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + UPLOADED = :uploaded PROCESSED = :processed ERROR = :error finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/file_purpose.rb b/lib/openai/models/file_purpose.rb index 8b4f9af2..73d23787 100644 --- a/lib/openai/models/file_purpose.rb +++ b/lib/openai/models/file_purpose.rb @@ -2,13 +2,13 @@ module OpenAI module Models - # @abstract - # # The intended purpose of the uploaded file. One of: - `assistants`: Used in the # Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: # Flexible file type for any purpose - `evals`: Used for eval data sets - class FilePurpose < OpenAI::Enum + module FilePurpose + extend OpenAI::Enum + ASSISTANTS = :assistants BATCH = :batch FINE_TUNE = :"fine-tune" @@ -17,6 +17,10 @@ class FilePurpose < OpenAI::Enum EVALS = :evals finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/file_retrieve_params.rb b/lib/openai/models/file_retrieve_params.rb index 391639a3..a4f815c3 100644 --- a/lib/openai/models/file_retrieve_params.rb +++ b/lib/openai/models/file_retrieve_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class FileRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/fine_tuning/fine_tuning_job.rb b/lib/openai/models/fine_tuning/fine_tuning_job.rb index 68876089..743bd260 100644 --- a/lib/openai/models/fine_tuning/fine_tuning_job.rb +++ b/lib/openai/models/fine_tuning/fine_tuning_job.rb @@ -272,60 +272,54 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end - # @abstract - # # The current status of the fine-tuning job, which can be either # `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + VALIDATING_FILES = :validating_files QUEUED = :queued RUNNING = :running @@ -334,6 +328,10 @@ class Status < OpenAI::Enum CANCELLED = :cancelled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Method < OpenAI::BaseModel @@ -459,68 +457,60 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. - class Beta < OpenAI::Union + module Beta + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end end @@ -594,64 +584,62 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end end - # @abstract - # # The type of method. Is either `supervised` or `dpo`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + SUPERVISED = :supervised DPO = :dpo finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/fine_tuning/fine_tuning_job_event.rb b/lib/openai/models/fine_tuning/fine_tuning_job_event.rb index 0688b7a8..92a9a009 100644 --- a/lib/openai/models/fine_tuning/fine_tuning_job_event.rb +++ b/lib/openai/models/fine_tuning/fine_tuning_job_event.rb @@ -69,25 +69,33 @@ class FineTuningJobEvent < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The log level of the event. - class Level < OpenAI::Enum + module Level + extend OpenAI::Enum + INFO = :info WARN = :warn ERROR = :error finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The type of event. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE = :message METRICS = :metrics finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/fine_tuning/job_cancel_params.rb b/lib/openai/models/fine_tuning/job_cancel_params.rb index 7427d15d..979023cf 100644 --- a/lib/openai/models/fine_tuning/job_cancel_params.rb +++ b/lib/openai/models/fine_tuning/job_cancel_params.rb @@ -5,7 +5,7 @@ module Models module FineTuning class JobCancelParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/fine_tuning/job_create_params.rb b/lib/openai/models/fine_tuning/job_create_params.rb index 6900ac01..1e8ddf18 100644 --- a/lib/openai/models/fine_tuning/job_create_params.rb +++ b/lib/openai/models/fine_tuning/job_create_params.rb @@ -5,7 +5,7 @@ module Models module FineTuning class JobCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute model @@ -142,35 +142,33 @@ class JobCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The name of the model to fine-tune. You can select one of the # [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). - class Model < OpenAI::Union - # @!group - - BABBAGE_002 = :"babbage-002" - DAVINCI_002 = :"davinci-002" - GPT_3_5_TURBO = :"gpt-3.5-turbo" - GPT_4O_MINI = :"gpt-4o-mini" - - # @!endgroup + module Model + extend OpenAI::Union variant String - variant const: OpenAI::Models::FineTuning::JobCreateParams::Model::BABBAGE_002 + variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::BABBAGE_002 } - variant const: OpenAI::Models::FineTuning::JobCreateParams::Model::DAVINCI_002 + variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::DAVINCI_002 } - variant const: OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_3_5_TURBO + variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_3_5_TURBO } - variant const: OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_4O_MINI + variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_4O_MINI } # @!parse - # class << self - # # @return [Array(String, Symbol)] - # def variants; end - # end + # # @return [Array(String, Symbol)] + # def self.variants; end + + # @!group + + BABBAGE_002 = :"babbage-002" + DAVINCI_002 = :"davinci-002" + GPT_3_5_TURBO = :"gpt-3.5-turbo" + GPT_4O_MINI = :"gpt-4o-mini" + + # @!endgroup end # @deprecated @@ -222,52 +220,46 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end @@ -471,68 +463,60 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. - class Beta < OpenAI::Union + module Beta + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end end @@ -606,64 +590,62 @@ class Hyperparameters < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union + module BatchSize + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end - # @abstract - # # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union + module LearningRateMultiplier + extend OpenAI::Union + variant const: :auto variant Float # @!parse - # class << self - # # @return [Array(Symbol, :auto, Float)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Float)] + # def self.variants; end end - # @abstract - # # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union + module NEpochs + extend OpenAI::Union + variant const: :auto variant Integer # @!parse - # class << self - # # @return [Array(Symbol, :auto, Integer)] - # def variants; end - # end + # # @return [Array(Symbol, :auto, Integer)] + # def self.variants; end end end end - # @abstract - # # The type of method. Is either `supervised` or `dpo`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + SUPERVISED = :supervised DPO = :dpo finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/fine_tuning/job_list_events_params.rb b/lib/openai/models/fine_tuning/job_list_events_params.rb index ad4de4f5..bbb67fa8 100644 --- a/lib/openai/models/fine_tuning/job_list_events_params.rb +++ b/lib/openai/models/fine_tuning/job_list_events_params.rb @@ -5,7 +5,7 @@ module Models module FineTuning class JobListEventsParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after diff --git a/lib/openai/models/fine_tuning/job_list_params.rb b/lib/openai/models/fine_tuning/job_list_params.rb index 6c53cafd..f9c13fc9 100644 --- a/lib/openai/models/fine_tuning/job_list_params.rb +++ b/lib/openai/models/fine_tuning/job_list_params.rb @@ -5,7 +5,7 @@ module Models module FineTuning class JobListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after diff --git a/lib/openai/models/fine_tuning/job_retrieve_params.rb b/lib/openai/models/fine_tuning/job_retrieve_params.rb index 5808c0a0..7735a847 100644 --- a/lib/openai/models/fine_tuning/job_retrieve_params.rb +++ b/lib/openai/models/fine_tuning/job_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module FineTuning class JobRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb b/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb index ef0571df..ee8722ea 100644 --- a/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb +++ b/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb @@ -6,7 +6,7 @@ module FineTuning module Jobs class CheckpointListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after diff --git a/lib/openai/models/image_create_variation_params.rb b/lib/openai/models/image_create_variation_params.rb index d4546f63..87a15c79 100644 --- a/lib/openai/models/image_create_variation_params.rb +++ b/lib/openai/models/image_create_variation_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ImageCreateVariationParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute image @@ -70,45 +70,51 @@ class ImageCreateVariationParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The model to use for image generation. Only `dall-e-2` is supported at this # time. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The model to use for image generation. Only `dall-e-2` is supported at this time. variant enum: -> { OpenAI::Models::ImageModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] + # def self.variants; end end - # @abstract - # # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL = :url B64_JSON = :b64_json finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256 = :"256x256" NUMBER_512X512 = :"512x512" NUMBER_1024X1024 = :"1024x1024" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/image_edit_params.rb b/lib/openai/models/image_edit_params.rb index 14c8b8cf..cf4ca6e4 100644 --- a/lib/openai/models/image_edit_params.rb +++ b/lib/openai/models/image_edit_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ImageEditParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute image @@ -101,45 +101,51 @@ class ImageEditParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The model to use for image generation. Only `dall-e-2` is supported at this # time. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The model to use for image generation. Only `dall-e-2` is supported at this time. variant enum: -> { OpenAI::Models::ImageModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] + # def self.variants; end end - # @abstract - # # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL = :url B64_JSON = :b64_json finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256 = :"256x256" NUMBER_512X512 = :"512x512" NUMBER_1024X1024 = :"1024x1024" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/image_generate_params.rb b/lib/openai/models/image_generate_params.rb index 577665bd..43ed870f 100644 --- a/lib/openai/models/image_generate_params.rb +++ b/lib/openai/models/image_generate_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ImageGenerateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute prompt @@ -104,52 +104,58 @@ class ImageGenerateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The model to use for image generation. - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The model to use for image generation. variant enum: -> { OpenAI::Models::ImageModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ImageModel)] + # def self.variants; end end - # @abstract - # # The quality of the image that will be generated. `hd` creates images with finer # details and greater consistency across the image. This param is only supported # for `dall-e-3`. - class Quality < OpenAI::Enum + module Quality + extend OpenAI::Enum + STANDARD = :standard HD = :hd finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL = :url B64_JSON = :b64_json finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or # `1024x1792` for `dall-e-3` models. - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256 = :"256x256" NUMBER_512X512 = :"512x512" NUMBER_1024X1024 = :"1024x1024" @@ -157,19 +163,27 @@ class Size < OpenAI::Enum NUMBER_1024X1792 = :"1024x1792" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The style of the generated images. Must be one of `vivid` or `natural`. Vivid # causes the model to lean towards generating hyper-real and dramatic images. # Natural causes the model to produce more natural, less hyper-real looking # images. This param is only supported for `dall-e-3`. - class Style < OpenAI::Enum + module Style + extend OpenAI::Enum + VIVID = :vivid NATURAL = :natural finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/image_model.rb b/lib/openai/models/image_model.rb index e49e6699..5f3d315c 100644 --- a/lib/openai/models/image_model.rb +++ b/lib/openai/models/image_model.rb @@ -2,12 +2,17 @@ module OpenAI module Models - # @abstract - class ImageModel < OpenAI::Enum + module ImageModel + extend OpenAI::Enum + DALL_E_2 = :"dall-e-2" DALL_E_3 = :"dall-e-3" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/model_delete_params.rb b/lib/openai/models/model_delete_params.rb index c5414ed7..3076a522 100644 --- a/lib/openai/models/model_delete_params.rb +++ b/lib/openai/models/model_delete_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ModelDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/model_list_params.rb b/lib/openai/models/model_list_params.rb index 37bd5c67..1718546b 100644 --- a/lib/openai/models/model_list_params.rb +++ b/lib/openai/models/model_list_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ModelListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/model_retrieve_params.rb b/lib/openai/models/model_retrieve_params.rb index a8779854..335e5c97 100644 --- a/lib/openai/models/model_retrieve_params.rb +++ b/lib/openai/models/model_retrieve_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ModelRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/moderation.rb b/lib/openai/models/moderation.rb index 0f3c5a90..b1bb2ec1 100644 --- a/lib/openai/models/moderation.rb +++ b/lib/openai/models/moderation.rb @@ -309,101 +309,166 @@ class CategoryAppliedInputTypes < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Harassment < OpenAI::Enum + module Harassment + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class HarassmentThreatening < OpenAI::Enum + module HarassmentThreatening + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class Hate < OpenAI::Enum + module Hate + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class HateThreatening < OpenAI::Enum + module HateThreatening + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class Illicit < OpenAI::Enum + module Illicit + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class IllicitViolent < OpenAI::Enum + module IllicitViolent + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class SelfHarm < OpenAI::Enum + module SelfHarm + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class SelfHarmInstruction < OpenAI::Enum + module SelfHarmInstruction + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class SelfHarmIntent < OpenAI::Enum + module SelfHarmIntent + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class Sexual < OpenAI::Enum + module Sexual + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class SexualMinor < OpenAI::Enum + module SexualMinor + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class Violence < OpenAI::Enum + module Violence + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class ViolenceGraphic < OpenAI::Enum + module ViolenceGraphic + extend OpenAI::Enum + TEXT = :text IMAGE = :image finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end diff --git a/lib/openai/models/moderation_create_params.rb b/lib/openai/models/moderation_create_params.rb index e0789618..93150dbd 100644 --- a/lib/openai/models/moderation_create_params.rb +++ b/lib/openai/models/moderation_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class ModerationCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute input @@ -36,38 +36,36 @@ class ModerationCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Input (or inputs) to classify. Can be a single string, an array of strings, or # an array of multi-modal input objects similar to other models. - class Input < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] - - ModerationMultiModalInputArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::ModerationMultiModalInput }] + module Input + extend OpenAI::Union # A string of text to classify for moderation. variant String # An array of strings to classify for moderation. - variant OpenAI::Models::ModerationCreateParams::Input::StringArray + variant -> { OpenAI::Models::ModerationCreateParams::Input::StringArray } # An array of multi-modal inputs to the moderation model. - variant OpenAI::Models::ModerationCreateParams::Input::ModerationMultiModalInputArray + variant -> { OpenAI::Models::ModerationCreateParams::Input::ModerationMultiModalInputArray } # @!parse - # class << self - # # @return [Array(String, Array, Array)] - # def variants; end - # end + # # @return [Array(String, Array, Array)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] + + ModerationMultiModalInputArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::ModerationMultiModalInput }] end - # @abstract - # # The content moderation model you would like to use. Learn more in # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and # learn about available models # [here](https://platform.openai.com/docs/models#moderation). - class Model < OpenAI::Union + module Model + extend OpenAI::Union + variant String # The content moderation model you would like to use. Learn more in @@ -76,10 +74,8 @@ class Model < OpenAI::Union variant enum: -> { OpenAI::Models::ModerationModel } # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ModerationModel)] - # def variants; end - # end + # # @return [Array(String, Symbol, OpenAI::Models::ModerationModel)] + # def self.variants; end end end end diff --git a/lib/openai/models/moderation_model.rb b/lib/openai/models/moderation_model.rb index 4089ad86..8d50271d 100644 --- a/lib/openai/models/moderation_model.rb +++ b/lib/openai/models/moderation_model.rb @@ -2,14 +2,19 @@ module OpenAI module Models - # @abstract - class ModerationModel < OpenAI::Enum + module ModerationModel + extend OpenAI::Enum + OMNI_MODERATION_LATEST = :"omni-moderation-latest" OMNI_MODERATION_2024_09_26 = :"omni-moderation-2024-09-26" TEXT_MODERATION_LATEST = :"text-moderation-latest" TEXT_MODERATION_STABLE = :"text-moderation-stable" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/moderation_multi_modal_input.rb b/lib/openai/models/moderation_multi_modal_input.rb index 47271a66..732739a6 100644 --- a/lib/openai/models/moderation_multi_modal_input.rb +++ b/lib/openai/models/moderation_multi_modal_input.rb @@ -2,10 +2,10 @@ module OpenAI module Models - # @abstract - # # An object describing an image to classify. - class ModerationMultiModalInput < OpenAI::Union + module ModerationMultiModalInput + extend OpenAI::Union + discriminator :type # An object describing an image to classify. @@ -15,10 +15,8 @@ class ModerationMultiModalInput < OpenAI::Union variant :text, -> { OpenAI::Models::ModerationTextInput } # @!parse - # class << self - # # @return [Array(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] + # def self.variants; end end end end diff --git a/lib/openai/models/reasoning.rb b/lib/openai/models/reasoning.rb index 28b7129f..64a9d430 100644 --- a/lib/openai/models/reasoning.rb +++ b/lib/openai/models/reasoning.rb @@ -12,10 +12,10 @@ class Reasoning < OpenAI::BaseModel # result in faster responses and fewer tokens used on reasoning in a response. # # @return [Symbol, OpenAI::Models::ReasoningEffort, nil] - required :effort, enum: -> { OpenAI::Models::ReasoningEffort }, nil?: true + optional :effort, enum: -> { OpenAI::Models::ReasoningEffort }, nil?: true # @!attribute generate_summary - # **o-series models only** + # **computer_use_preview only** # # A summary of the reasoning performed by the model. This can be useful for # debugging and understanding the model's reasoning process. One of `concise` or @@ -33,22 +33,26 @@ class Reasoning < OpenAI::BaseModel # # @param effort [Symbol, OpenAI::Models::ReasoningEffort, nil] # # @param generate_summary [Symbol, OpenAI::Models::Reasoning::GenerateSummary, nil] # # - # def initialize(effort:, generate_summary: nil, **) = super + # def initialize(effort: nil, generate_summary: nil, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # - # **o-series models only** + # **computer_use_preview only** # # A summary of the reasoning performed by the model. This can be useful for # debugging and understanding the model's reasoning process. One of `concise` or # `detailed`. - class GenerateSummary < OpenAI::Enum + module GenerateSummary + extend OpenAI::Enum + CONCISE = :concise DETAILED = :detailed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/reasoning_effort.rb b/lib/openai/models/reasoning_effort.rb index f1fee21d..f123316a 100644 --- a/lib/openai/models/reasoning_effort.rb +++ b/lib/openai/models/reasoning_effort.rb @@ -2,20 +2,24 @@ module OpenAI module Models - # @abstract - # # **o-series models only** # # Constrains effort on reasoning for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - class ReasoningEffort < OpenAI::Enum + module ReasoningEffort + extend OpenAI::Enum + LOW = :low MEDIUM = :medium HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/computer_tool.rb b/lib/openai/models/responses/computer_tool.rb index 65a0097a..6802a365 100644 --- a/lib/openai/models/responses/computer_tool.rb +++ b/lib/openai/models/responses/computer_tool.rb @@ -41,16 +41,20 @@ class ComputerTool < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of computer environment to control. - class Environment < OpenAI::Enum + module Environment + extend OpenAI::Enum + MAC = :mac WINDOWS = :windows UBUNTU = :ubuntu BROWSER = :browser finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/easy_input_message.rb b/lib/openai/models/responses/easy_input_message.rb index e4effc89..3c79d015 100644 --- a/lib/openai/models/responses/easy_input_message.rb +++ b/lib/openai/models/responses/easy_input_message.rb @@ -43,11 +43,11 @@ class EasyInputMessage < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Text, image, or audio input to the model, used to generate a response. Can also # contain previous assistant responses. - class Content < OpenAI::Union + module Content + extend OpenAI::Union + # A text input to the model. variant String @@ -56,32 +56,38 @@ class Content < OpenAI::Union variant -> { OpenAI::Models::Responses::ResponseInputMessageContentList } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end end - # @abstract - # # The role of the message input. One of `user`, `assistant`, `system`, or # `developer`. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user ASSISTANT = :assistant SYSTEM = :system DEVELOPER = :developer finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The type of the message input. Always `message`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE = :message finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/file_search_tool.rb b/lib/openai/models/responses/file_search_tool.rb index c2ba4177..6c9f5511 100644 --- a/lib/openai/models/responses/file_search_tool.rb +++ b/lib/openai/models/responses/file_search_tool.rb @@ -62,10 +62,10 @@ class FileSearchTool < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A filter to apply based on file attributes. - class Filters < OpenAI::Union + module Filters + extend OpenAI::Union + # A filter used to compare a specified attribute key to a given value using a defined comparison operation. variant -> { OpenAI::Models::ComparisonFilter } @@ -73,10 +73,8 @@ class Filters < OpenAI::Union variant -> { OpenAI::Models::CompoundFilter } # @!parse - # class << self - # # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)] + # def self.variants; end end class RankingOptions < OpenAI::BaseModel @@ -112,14 +110,18 @@ class RankingOptions < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The ranker to use for the file search. - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO = :auto DEFAULT_2024_11_15 = :"default-2024-11-15" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/input_item_list_params.rb b/lib/openai/models/responses/input_item_list_params.rb index e0cb2854..3bf3624b 100644 --- a/lib/openai/models/responses/input_item_list_params.rb +++ b/lib/openai/models/responses/input_item_list_params.rb @@ -5,7 +5,7 @@ module Models module Responses class InputItemListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -28,6 +28,17 @@ class InputItemListParams < OpenAI::BaseModel # # @return [String] # attr_writer :before + # @!attribute [r] include + # Additional fields to include in the response. See the `include` parameter for + # Response creation above for more information. + # + # @return [Array, nil] + optional :include, -> { OpenAI::ArrayOf[enum: OpenAI::Models::Responses::ResponseIncludable] } + + # @!parse + # # @return [Array] + # attr_writer :include + # @!attribute [r] limit # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. @@ -55,25 +66,30 @@ class InputItemListParams < OpenAI::BaseModel # @!parse # # @param after [String] # # @param before [String] + # # @param include [Array] # # @param limit [Integer] # # @param order [Symbol, OpenAI::Models::Responses::InputItemListParams::Order] # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] # # - # def initialize(after: nil, before: nil, limit: nil, order: nil, request_options: {}, **) = super + # def initialize(after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {}, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The order to return the input items in. Default is `asc`. # # - `asc`: Return the input items in ascending order. # - `desc`: Return the input items in descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response.rb b/lib/openai/models/responses/response.rb index 98b2c145..296c2d41 100644 --- a/lib/openai/models/responses/response.rb +++ b/lib/openai/models/responses/response.rb @@ -33,8 +33,8 @@ class Response < OpenAI::BaseModel # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. # # @return [String, nil] required :instructions, String, nil?: true @@ -58,7 +58,7 @@ class Response < OpenAI::BaseModel # available models. # # @return [String, Symbol, OpenAI::Models::ChatModel] - required :model, union: -> { OpenAI::Models::Responses::Response::Model } + required :model, union: -> { OpenAI::Models::ResponsesModel } # @!attribute object # The object type of this resource - always set to `response`. @@ -289,46 +289,27 @@ class IncompleteDetails < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The reason why the response is incomplete. - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + MAX_OUTPUT_TOKENS = :max_output_tokens CONTENT_FILTER = :content_filter finalize! - end - end - # @abstract - # - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a - # wide range of models with different capabilities, performance characteristics, - # and price points. Refer to the - # [model guide](https://platform.openai.com/docs/models) to browse and compare - # available models. - class Model < OpenAI::Union - variant String - - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI - # offers a wide range of models with different capabilities, performance - # characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models) - # to browse and compare available models. - variant enum: -> { OpenAI::Models::ChatModel } - - # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end + # @!parse + # # @return [Array] + # def self.values; end + end end - # @abstract - # # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. - class ToolChoice < OpenAI::Union + module ToolChoice + extend OpenAI::Union + # Controls which (if any) tool is called by the model. # # `none` means the model will not call any tool and instead generates a message. @@ -347,14 +328,10 @@ class ToolChoice < OpenAI::Union variant -> { OpenAI::Models::Responses::ToolChoiceFunction } # @!parse - # class << self - # # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction)] - # def variants; end - # end + # # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction)] + # def self.variants; end end - # @abstract - # # The truncation strategy to use for the model response. # # - `auto`: If the context of this response and previous ones exceeds the model's @@ -362,11 +339,17 @@ class ToolChoice < OpenAI::Union # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - class Truncation < OpenAI::Enum + module Truncation + extend OpenAI::Enum + AUTO = :auto DISABLED = :disabled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_code_interpreter_tool_call.rb b/lib/openai/models/responses/response_code_interpreter_tool_call.rb index e93e62cf..0d7ae42f 100644 --- a/lib/openai/models/responses/response_code_interpreter_tool_call.rb +++ b/lib/openai/models/responses/response_code_interpreter_tool_call.rb @@ -48,10 +48,10 @@ class ResponseCodeInterpreterToolCall < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The output of a code interpreter tool call that is text. - class Result < OpenAI::Union + module Result + extend OpenAI::Union + discriminator :type # The output of a code interpreter tool call that is text. @@ -131,21 +131,23 @@ class File < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files)] + # def self.variants; end end - # @abstract - # # The status of the code interpreter tool call. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress INTERPRETING = :interpreting COMPLETED = :completed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_computer_tool_call.rb b/lib/openai/models/responses/response_computer_tool_call.rb index 20bd85ae..6e5128d4 100644 --- a/lib/openai/models/responses/response_computer_tool_call.rb +++ b/lib/openai/models/responses/response_computer_tool_call.rb @@ -58,10 +58,10 @@ class ResponseComputerToolCall < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A click action. - class Action < OpenAI::Union + module Action + extend OpenAI::Union + discriminator :type # A click action. @@ -130,11 +130,11 @@ class Click < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Indicates which mouse button was pressed during the click. One of `left`, # `right`, `wheel`, `back`, or `forward`. - class Button < OpenAI::Enum + module Button + extend OpenAI::Enum + LEFT = :left RIGHT = :right WHEEL = :wheel @@ -142,6 +142,10 @@ class Button < OpenAI::Enum FORWARD = :forward finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -401,10 +405,8 @@ class Wait < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait)] + # def self.variants; end end class PendingSafetyCheck < OpenAI::BaseModel @@ -438,25 +440,33 @@ class PendingSafetyCheck < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The type of the computer call. Always `computer_call`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + COMPUTER_CALL = :computer_call finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_computer_tool_call_output_item.rb b/lib/openai/models/responses/response_computer_tool_call_output_item.rb new file mode 100644 index 00000000..856d3c99 --- /dev/null +++ b/lib/openai/models/responses/response_computer_tool_call_output_item.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseComputerToolCallOutputItem < OpenAI::BaseModel + # @!attribute id + # The unique ID of the computer call tool output. + # + # @return [String] + required :id, String + + # @!attribute call_id + # The ID of the computer tool call that produced the output. + # + # @return [String] + required :call_id, String + + # @!attribute output + # A computer screenshot image used with the computer use tool. + # + # @return [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] + required :output, -> { OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot } + + # @!attribute type + # The type of the computer tool call output. Always `computer_call_output`. + # + # @return [Symbol, :computer_call_output] + required :type, const: :computer_call_output + + # @!attribute [r] acknowledged_safety_checks + # The safety checks reported by the API that have been acknowledged by the + # developer. + # + # @return [Array, nil] + optional :acknowledged_safety_checks, + -> { OpenAI::ArrayOf[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck] } + + # @!parse + # # @return [Array] + # attr_writer :acknowledged_safety_checks + + # @!attribute [r] status + # The status of the message input. One of `in_progress`, `completed`, or + # `incomplete`. Populated when input items are returned via API. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status, nil] + optional :status, enum: -> { OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status } + + # @!parse + # # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status] + # attr_writer :status + + # @!parse + # # @param id [String] + # # @param call_id [String] + # # @param output [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] + # # @param acknowledged_safety_checks [Array] + # # @param status [Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status] + # # @param type [Symbol, :computer_call_output] + # # + # def initialize(id:, call_id:, output:, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + + class AcknowledgedSafetyCheck < OpenAI::BaseModel + # @!attribute id + # The ID of the pending safety check. + # + # @return [String] + required :id, String + + # @!attribute code + # The type of the pending safety check. + # + # @return [String] + required :code, String + + # @!attribute message + # Details about the pending safety check. + # + # @return [String] + required :message, String + + # @!parse + # # A pending safety check for the computer call. + # # + # # @param id [String] + # # @param code [String] + # # @param message [String] + # # + # def initialize(id:, code:, message:, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + + # The status of the message input. One of `in_progress`, `completed`, or + # `incomplete`. Populated when input items are returned via API. + module Status + extend OpenAI::Enum + + IN_PROGRESS = :in_progress + COMPLETED = :completed + INCOMPLETE = :incomplete + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + end + end + end +end diff --git a/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rb b/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rb new file mode 100644 index 00000000..4dc426ff --- /dev/null +++ b/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseComputerToolCallOutputScreenshot < OpenAI::BaseModel + # @!attribute type + # Specifies the event type. For a computer screenshot, this property is always set + # to `computer_screenshot`. + # + # @return [Symbol, :computer_screenshot] + required :type, const: :computer_screenshot + + # @!attribute [r] file_id + # The identifier of an uploaded file that contains the screenshot. + # + # @return [String, nil] + optional :file_id, String + + # @!parse + # # @return [String] + # attr_writer :file_id + + # @!attribute [r] image_url + # The URL of the screenshot image. + # + # @return [String, nil] + optional :image_url, String + + # @!parse + # # @return [String] + # attr_writer :image_url + + # @!parse + # # A computer screenshot image used with the computer use tool. + # # + # # @param file_id [String] + # # @param image_url [String] + # # @param type [Symbol, :computer_screenshot] + # # + # def initialize(file_id: nil, image_url: nil, type: :computer_screenshot, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + end + end +end diff --git a/lib/openai/models/responses/response_content.rb b/lib/openai/models/responses/response_content.rb index 72456bac..c3e86848 100644 --- a/lib/openai/models/responses/response_content.rb +++ b/lib/openai/models/responses/response_content.rb @@ -3,10 +3,10 @@ module OpenAI module Models module Responses - # @abstract - # # Multi-modal input and output contents. - class ResponseContent < OpenAI::Union + module ResponseContent + extend OpenAI::Union + # A text input to the model. variant -> { OpenAI::Models::Responses::ResponseInputText } @@ -23,10 +23,8 @@ class ResponseContent < OpenAI::Union variant -> { OpenAI::Models::Responses::ResponseOutputRefusal } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_content_part_added_event.rb b/lib/openai/models/responses/response_content_part_added_event.rb index 1fa8be8b..d1242f76 100644 --- a/lib/openai/models/responses/response_content_part_added_event.rb +++ b/lib/openai/models/responses/response_content_part_added_event.rb @@ -47,10 +47,10 @@ class ResponseContentPartAddedEvent < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The content part that was added. - class Part < OpenAI::Union + module Part + extend OpenAI::Union + discriminator :type # A text output from the model. @@ -60,10 +60,8 @@ class Part < OpenAI::Union variant :refusal, -> { OpenAI::Models::Responses::ResponseOutputRefusal } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_content_part_done_event.rb b/lib/openai/models/responses/response_content_part_done_event.rb index 0911d697..8481a853 100644 --- a/lib/openai/models/responses/response_content_part_done_event.rb +++ b/lib/openai/models/responses/response_content_part_done_event.rb @@ -47,10 +47,10 @@ class ResponseContentPartDoneEvent < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The content part that is done. - class Part < OpenAI::Union + module Part + extend OpenAI::Union + discriminator :type # A text output from the model. @@ -60,10 +60,8 @@ class Part < OpenAI::Union variant :refusal, -> { OpenAI::Models::Responses::ResponseOutputRefusal } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_create_params.rb b/lib/openai/models/responses/response_create_params.rb index 4c6c485b..e5c04cf7 100644 --- a/lib/openai/models/responses/response_create_params.rb +++ b/lib/openai/models/responses/response_create_params.rb @@ -5,7 +5,7 @@ module Models module Responses class ResponseCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute input @@ -30,7 +30,7 @@ class ResponseCreateParams < OpenAI::BaseModel # available models. # # @return [String, Symbol, OpenAI::Models::ChatModel] - required :model, union: -> { OpenAI::Models::Responses::ResponseCreateParams::Model } + required :model, union: -> { OpenAI::Models::ResponsesModel } # @!attribute include # Specify additional output data to include in the model response. Currently @@ -50,8 +50,8 @@ class ResponseCreateParams < OpenAI::BaseModel # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. # # @return [String, nil] optional :instructions, String, nil?: true @@ -242,8 +242,6 @@ class ResponseCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Text, image, or file inputs to the model, used to generate a response. # # Learn more: @@ -253,7 +251,9 @@ class ResponseCreateParams < OpenAI::BaseModel # - [File inputs](https://platform.openai.com/docs/guides/pdf-files) # - [Conversation state](https://platform.openai.com/docs/guides/conversation-state) # - [Function calling](https://platform.openai.com/docs/guides/function-calling) - class Input < OpenAI::Union + module Input + extend OpenAI::Union + # A text input to the model, equivalent to a text input with the # `user` role. variant String @@ -263,41 +263,16 @@ class Input < OpenAI::Union variant -> { OpenAI::Models::Responses::ResponseInput } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end end - # @abstract - # - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a - # wide range of models with different capabilities, performance characteristics, - # and price points. Refer to the - # [model guide](https://platform.openai.com/docs/models) to browse and compare - # available models. - class Model < OpenAI::Union - variant String - - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI - # offers a wide range of models with different capabilities, performance - # characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models) - # to browse and compare available models. - variant enum: -> { OpenAI::Models::ChatModel } - - # @!parse - # class << self - # # @return [Array(String, Symbol, OpenAI::Models::ChatModel)] - # def variants; end - # end - end - - # @abstract - # # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. - class ToolChoice < OpenAI::Union + module ToolChoice + extend OpenAI::Union + # Controls which (if any) tool is called by the model. # # `none` means the model will not call any tool and instead generates a message. @@ -316,14 +291,10 @@ class ToolChoice < OpenAI::Union variant -> { OpenAI::Models::Responses::ToolChoiceFunction } # @!parse - # class << self - # # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction)] - # def variants; end - # end + # # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction)] + # def self.variants; end end - # @abstract - # # The truncation strategy to use for the model response. # # - `auto`: If the context of this response and previous ones exceeds the model's @@ -331,11 +302,17 @@ class ToolChoice < OpenAI::Union # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - class Truncation < OpenAI::Enum + module Truncation + extend OpenAI::Enum + AUTO = :auto DISABLED = :disabled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_delete_params.rb b/lib/openai/models/responses/response_delete_params.rb index 0ecfdf28..ee46f30c 100644 --- a/lib/openai/models/responses/response_delete_params.rb +++ b/lib/openai/models/responses/response_delete_params.rb @@ -5,7 +5,7 @@ module Models module Responses class ResponseDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/responses/response_error.rb b/lib/openai/models/responses/response_error.rb index 47dd8b4b..4b7b4755 100644 --- a/lib/openai/models/responses/response_error.rb +++ b/lib/openai/models/responses/response_error.rb @@ -26,10 +26,10 @@ class ResponseError < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The error code for the response. - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR = :server_error RATE_LIMIT_EXCEEDED = :rate_limit_exceeded INVALID_PROMPT = :invalid_prompt @@ -50,6 +50,10 @@ class Code < OpenAI::Enum IMAGE_FILE_NOT_FOUND = :image_file_not_found finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_file_search_tool_call.rb b/lib/openai/models/responses/response_file_search_tool_call.rb index 8054ec60..20201242 100644 --- a/lib/openai/models/responses/response_file_search_tool_call.rb +++ b/lib/openai/models/responses/response_file_search_tool_call.rb @@ -52,11 +52,11 @@ class ResponseFileSearchToolCall < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The status of the file search tool call. One of `in_progress`, `searching`, # `incomplete` or `failed`, - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress SEARCHING = :searching COMPLETED = :completed @@ -64,6 +64,10 @@ class Status < OpenAI::Enum FAILED = :failed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class Result < OpenAI::BaseModel @@ -130,8 +134,9 @@ class Result < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -139,10 +144,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_format_text_config.rb b/lib/openai/models/responses/response_format_text_config.rb index 6749d6bc..ee665d54 100644 --- a/lib/openai/models/responses/response_format_text_config.rb +++ b/lib/openai/models/responses/response_format_text_config.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Responses - # @abstract - # # An object specifying the format that the model must output. # # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which @@ -18,7 +16,9 @@ module Responses # Setting to `{ "type": "json_object" }` enables the older JSON mode, which # ensures the message the model generates is valid JSON. Using `json_schema` is # preferred for models that support it. - class ResponseFormatTextConfig < OpenAI::Union + module ResponseFormatTextConfig + extend OpenAI::Union + discriminator :type # Default response format. Used to generate text responses. @@ -35,10 +35,8 @@ class ResponseFormatTextConfig < OpenAI::Union variant :json_object, -> { OpenAI::Models::ResponseFormatJSONObject } # @!parse - # class << self - # # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_format_text_json_schema_config.rb b/lib/openai/models/responses/response_format_text_json_schema_config.rb index 34aefbc9..06e3bf5e 100644 --- a/lib/openai/models/responses/response_format_text_json_schema_config.rb +++ b/lib/openai/models/responses/response_format_text_json_schema_config.rb @@ -4,6 +4,13 @@ module OpenAI module Models module Responses class ResponseFormatTextJSONSchemaConfig < OpenAI::BaseModel + # @!attribute name + # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores + # and dashes, with a maximum length of 64. + # + # @return [String] + required :name, String + # @!attribute schema # The schema for the response format, described as a JSON Schema object. Learn how # to build JSON schemas [here](https://json-schema.org/). @@ -28,17 +35,6 @@ class ResponseFormatTextJSONSchemaConfig < OpenAI::BaseModel # # @return [String] # attr_writer :description - # @!attribute [r] name - # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores - # and dashes, with a maximum length of 64. - # - # @return [String, nil] - optional :name, String - - # @!parse - # # @return [String] - # attr_writer :name - # @!attribute strict # Whether to enable strict schema adherence when generating the output. If set to # true, the model will always follow the exact schema defined in the `schema` @@ -54,13 +50,13 @@ class ResponseFormatTextJSONSchemaConfig < OpenAI::BaseModel # # more about # # [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). # # + # # @param name [String] # # @param schema [Hash{Symbol=>Object}] # # @param description [String] - # # @param name [String] # # @param strict [Boolean, nil] # # @param type [Symbol, :json_schema] # # - # def initialize(schema:, description: nil, name: nil, strict: nil, type: :json_schema, **) = super + # def initialize(name:, schema:, description: nil, strict: nil, type: :json_schema, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void end diff --git a/lib/openai/models/responses/response_function_tool_call.rb b/lib/openai/models/responses/response_function_tool_call.rb index 065ee3ea..6d337c8f 100644 --- a/lib/openai/models/responses/response_function_tool_call.rb +++ b/lib/openai/models/responses/response_function_tool_call.rb @@ -4,12 +4,6 @@ module OpenAI module Models module Responses class ResponseFunctionToolCall < OpenAI::BaseModel - # @!attribute id - # The unique ID of the function tool call. - # - # @return [String] - required :id, String - # @!attribute arguments # A JSON string of the arguments to pass to the function. # @@ -34,6 +28,16 @@ class ResponseFunctionToolCall < OpenAI::BaseModel # @return [Symbol, :function_call] required :type, const: :function_call + # @!attribute [r] id + # The unique ID of the function tool call. + # + # @return [String, nil] + optional :id, String + + # @!parse + # # @return [String] + # attr_writer :id + # @!attribute [r] status # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. @@ -50,27 +54,31 @@ class ResponseFunctionToolCall < OpenAI::BaseModel # # [function calling guide](https://platform.openai.com/docs/guides/function-calling) # # for more information. # # - # # @param id [String] # # @param arguments [String] # # @param call_id [String] # # @param name [String] + # # @param id [String] # # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCall::Status] # # @param type [Symbol, :function_call] # # - # def initialize(id:, arguments:, call_id:, name:, status: nil, type: :function_call, **) = super + # def initialize(arguments:, call_id:, name:, id: nil, status: nil, type: :function_call, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_function_tool_call_item.rb b/lib/openai/models/responses/response_function_tool_call_item.rb new file mode 100644 index 00000000..9317cee6 --- /dev/null +++ b/lib/openai/models/responses/response_function_tool_call_item.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseFunctionToolCallItem < OpenAI::Models::Responses::ResponseFunctionToolCall + # @!attribute id + # The unique ID of the function tool call. + # + # @return [String] + required :id, String + + # @!parse + # # A tool call to run a function. See the + # # [function calling guide](https://platform.openai.com/docs/guides/function-calling) + # # for more information. + # # + # # @param id [String] + # # + # def initialize(id:, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + end + end +end diff --git a/lib/openai/models/responses/response_function_tool_call_output_item.rb b/lib/openai/models/responses/response_function_tool_call_output_item.rb new file mode 100644 index 00000000..83d109ab --- /dev/null +++ b/lib/openai/models/responses/response_function_tool_call_output_item.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseFunctionToolCallOutputItem < OpenAI::BaseModel + # @!attribute id + # The unique ID of the function call tool output. + # + # @return [String] + required :id, String + + # @!attribute call_id + # The unique ID of the function tool call generated by the model. + # + # @return [String] + required :call_id, String + + # @!attribute output + # A JSON string of the output of the function tool call. + # + # @return [String] + required :output, String + + # @!attribute type + # The type of the function tool call output. Always `function_call_output`. + # + # @return [Symbol, :function_call_output] + required :type, const: :function_call_output + + # @!attribute [r] status + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status, nil] + optional :status, enum: -> { OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status } + + # @!parse + # # @return [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status] + # attr_writer :status + + # @!parse + # # @param id [String] + # # @param call_id [String] + # # @param output [String] + # # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status] + # # @param type [Symbol, :function_call_output] + # # + # def initialize(id:, call_id:, output:, status: nil, type: :function_call_output, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + module Status + extend OpenAI::Enum + + IN_PROGRESS = :in_progress + COMPLETED = :completed + INCOMPLETE = :incomplete + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + end + end + end +end diff --git a/lib/openai/models/responses/response_function_web_search.rb b/lib/openai/models/responses/response_function_web_search.rb index 8afd6c8b..78f572ca 100644 --- a/lib/openai/models/responses/response_function_web_search.rb +++ b/lib/openai/models/responses/response_function_web_search.rb @@ -35,16 +35,20 @@ class ResponseFunctionWebSearch < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The status of the web search tool call. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress SEARCHING = :searching COMPLETED = :completed FAILED = :failed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_includable.rb b/lib/openai/models/responses/response_includable.rb index 2d318473..39763a87 100644 --- a/lib/openai/models/responses/response_includable.rb +++ b/lib/openai/models/responses/response_includable.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Responses - # @abstract - # # Specify additional output data to include in the model response. Currently # supported values are: # @@ -13,12 +11,18 @@ module Responses # - `message.input_image.image_url`: Include image urls from the input message. # - `computer_call_output.output.image_url`: Include image urls from the computer # call output. - class ResponseIncludable < OpenAI::Enum + module ResponseIncludable + extend OpenAI::Enum + FILE_SEARCH_CALL_RESULTS = :"file_search_call.results" MESSAGE_INPUT_IMAGE_IMAGE_URL = :"message.input_image.image_url" COMPUTER_CALL_OUTPUT_OUTPUT_IMAGE_URL = :"computer_call_output.output.image_url" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_input_audio.rb b/lib/openai/models/responses/response_input_audio.rb index 24201588..a039c35c 100644 --- a/lib/openai/models/responses/response_input_audio.rb +++ b/lib/openai/models/responses/response_input_audio.rb @@ -33,14 +33,18 @@ class ResponseInputAudio < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The format of the audio data. Currently supported formats are `mp3` and `wav`. - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + MP3 = :mp3 WAV = :wav finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_input_content.rb b/lib/openai/models/responses/response_input_content.rb index 8d6226d4..41f9a7d7 100644 --- a/lib/openai/models/responses/response_input_content.rb +++ b/lib/openai/models/responses/response_input_content.rb @@ -3,10 +3,10 @@ module OpenAI module Models module Responses - # @abstract - # # A text input to the model. - class ResponseInputContent < OpenAI::Union + module ResponseInputContent + extend OpenAI::Union + discriminator :type # A text input to the model. @@ -19,10 +19,8 @@ class ResponseInputContent < OpenAI::Union variant :input_file, -> { OpenAI::Models::Responses::ResponseInputFile } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_input_image.rb b/lib/openai/models/responses/response_input_image.rb index e9334fd0..2e770199 100644 --- a/lib/openai/models/responses/response_input_image.rb +++ b/lib/openai/models/responses/response_input_image.rb @@ -43,16 +43,20 @@ class ResponseInputImage < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The detail level of the image to be sent to the model. One of `high`, `low`, or # `auto`. Defaults to `auto`. - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + HIGH = :high LOW = :low AUTO = :auto finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_input_item.rb b/lib/openai/models/responses/response_input_item.rb index cd5d395b..d2e09cef 100644 --- a/lib/openai/models/responses/response_input_item.rb +++ b/lib/openai/models/responses/response_input_item.rb @@ -3,14 +3,14 @@ module OpenAI module Models module Responses - # @abstract - # # A message input to the model with a role indicating instruction following # hierarchy. Instructions given with the `developer` or `system` role take # precedence over instructions given with the `user` role. Messages with the # `assistant` role are presumed to have been generated by the model in previous # interactions. - class ResponseInputItem < OpenAI::Union + module ResponseInputItem + extend OpenAI::Union + discriminator :type # A message input to the model with a role indicating instruction following @@ -106,36 +106,48 @@ class Message < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The role of the message input. One of `user`, `system`, or `developer`. - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER = :user SYSTEM = :system DEVELOPER = :developer finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The status of item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # The type of the message input. Always set to `message`. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE = :message finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -149,8 +161,8 @@ class ComputerCallOutput < OpenAI::BaseModel # @!attribute output # A computer screenshot image used with the computer use tool. # - # @return [OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output] - required :output, -> { OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output } + # @return [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] + required :output, -> { OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot } # @!attribute type # The type of the computer tool call output. Always `computer_call_output`. @@ -195,7 +207,7 @@ class ComputerCallOutput < OpenAI::BaseModel # # The output of a computer tool call. # # # # @param call_id [String] - # # @param output [OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output] + # # @param output [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] # # @param id [String] # # @param acknowledged_safety_checks [Array] # # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status] @@ -205,46 +217,6 @@ class ComputerCallOutput < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - class Output < OpenAI::BaseModel - # @!attribute type - # Specifies the event type. For a computer screenshot, this property is always set - # to `computer_screenshot`. - # - # @return [Symbol, :computer_screenshot] - required :type, const: :computer_screenshot - - # @!attribute [r] file_id - # The identifier of an uploaded file that contains the screenshot. - # - # @return [String, nil] - optional :file_id, String - - # @!parse - # # @return [String] - # attr_writer :file_id - - # @!attribute [r] image_url - # The URL of the screenshot image. - # - # @return [String, nil] - optional :image_url, String - - # @!parse - # # @return [String] - # attr_writer :image_url - - # @!parse - # # A computer screenshot image used with the computer use tool. - # # - # # @param file_id [String] - # # @param image_url [String] - # # @param type [Symbol, :computer_screenshot] - # # - # def initialize(file_id: nil, image_url: nil, type: :computer_screenshot, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - end - class AcknowledgedSafetyCheck < OpenAI::BaseModel # @!attribute id # The ID of the pending safety check. @@ -276,16 +248,20 @@ class AcknowledgedSafetyCheck < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -343,16 +319,20 @@ class FunctionCallOutput < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end @@ -381,10 +361,8 @@ class ItemReference < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ItemReference)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ItemReference)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_input_message_content_list.rb b/lib/openai/models/responses/response_input_message_content_list.rb index 9ac48e2d..98901e68 100644 --- a/lib/openai/models/responses/response_input_message_content_list.rb +++ b/lib/openai/models/responses/response_input_message_content_list.rb @@ -3,7 +3,8 @@ module OpenAI module Models module Responses - ResponseInputMessageContentList = OpenAI::ArrayOf[union: -> { OpenAI::Models::Responses::ResponseInputContent }] + ResponseInputMessageContentList = + OpenAI::ArrayOf[union: -> { OpenAI::Models::Responses::ResponseInputContent }] end end end diff --git a/lib/openai/models/responses/response_input_message_item.rb b/lib/openai/models/responses/response_input_message_item.rb new file mode 100644 index 00000000..3962d98d --- /dev/null +++ b/lib/openai/models/responses/response_input_message_item.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseInputMessageItem < OpenAI::BaseModel + # @!attribute id + # The unique ID of the message input. + # + # @return [String] + required :id, String + + # @!attribute content + # A list of one or many input items to the model, containing different content + # types. + # + # @return [Array] + required :content, -> { OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseInputContent] } + + # @!attribute role + # The role of the message input. One of `user`, `system`, or `developer`. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role] + required :role, enum: -> { OpenAI::Models::Responses::ResponseInputMessageItem::Role } + + # @!attribute [r] status + # The status of item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status, nil] + optional :status, enum: -> { OpenAI::Models::Responses::ResponseInputMessageItem::Status } + + # @!parse + # # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status] + # attr_writer :status + + # @!attribute [r] type + # The type of the message input. Always set to `message`. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type, nil] + optional :type, enum: -> { OpenAI::Models::Responses::ResponseInputMessageItem::Type } + + # @!parse + # # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type] + # attr_writer :type + + # @!parse + # # @param id [String] + # # @param content [Array] + # # @param role [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role] + # # @param status [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status] + # # @param type [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type] + # # + # def initialize(id:, content:, role:, status: nil, type: nil, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + + # The role of the message input. One of `user`, `system`, or `developer`. + module Role + extend OpenAI::Enum + + USER = :user + SYSTEM = :system + DEVELOPER = :developer + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + + # The status of item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + module Status + extend OpenAI::Enum + + IN_PROGRESS = :in_progress + COMPLETED = :completed + INCOMPLETE = :incomplete + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + + # The type of the message input. Always set to `message`. + module Type + extend OpenAI::Enum + + MESSAGE = :message + + finalize! + + # @!parse + # # @return [Array] + # def self.values; end + end + end + end + end +end diff --git a/lib/openai/models/responses/response_item.rb b/lib/openai/models/responses/response_item.rb new file mode 100644 index 00000000..ca1c9ee7 --- /dev/null +++ b/lib/openai/models/responses/response_item.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + # Content item used to generate a response. + module ResponseItem + extend OpenAI::Union + + discriminator :type + + variant :message, -> { OpenAI::Models::Responses::ResponseInputMessageItem } + + # An output message from the model. + variant :message, -> { OpenAI::Models::Responses::ResponseOutputMessage } + + # The results of a file search tool call. See the + # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information. + variant :file_search_call, -> { OpenAI::Models::Responses::ResponseFileSearchToolCall } + + # A tool call to a computer use tool. See the + # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information. + variant :computer_call, -> { OpenAI::Models::Responses::ResponseComputerToolCall } + + variant :computer_call_output, -> { OpenAI::Models::Responses::ResponseComputerToolCallOutputItem } + + # The results of a web search tool call. See the + # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information. + variant :web_search_call, -> { OpenAI::Models::Responses::ResponseFunctionWebSearch } + + # A tool call to run a function. See the + # [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information. + variant :function_call, -> { OpenAI::Models::Responses::ResponseFunctionToolCallItem } + + variant :function_call_output, -> { OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem } + + # @!parse + # # @return [Array(OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem)] + # def self.variants; end + end + end + end +end diff --git a/lib/openai/models/responses/response_item_list.rb b/lib/openai/models/responses/response_item_list.rb index 7890dc3a..34ca03ad 100644 --- a/lib/openai/models/responses/response_item_list.rb +++ b/lib/openai/models/responses/response_item_list.rb @@ -7,8 +7,8 @@ class ResponseItemList < OpenAI::BaseModel # @!attribute data # A list of items used to generate this response. # - # @return [Array] - required :data, -> { OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseItemList::Data] } + # @return [Array] + required :data, -> { OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseItem] } # @!attribute first_id # The ID of the first item in the list. @@ -37,7 +37,7 @@ class ResponseItemList < OpenAI::BaseModel # @!parse # # A list of Response items. # # - # # @param data [Array] + # # @param data [Array] # # @param first_id [String] # # @param has_more [Boolean] # # @param last_id [String] @@ -46,337 +46,6 @@ class ResponseItemList < OpenAI::BaseModel # def initialize(data:, first_id:, has_more:, last_id:, object: :list, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void - - # @abstract - # - # Content item used to generate a response. - class Data < OpenAI::Union - discriminator :type - - variant :message, -> { OpenAI::Models::Responses::ResponseItemList::Data::Message } - - # An output message from the model. - variant :message, -> { OpenAI::Models::Responses::ResponseOutputMessage } - - # The results of a file search tool call. See the - # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information. - variant :file_search_call, -> { OpenAI::Models::Responses::ResponseFileSearchToolCall } - - # A tool call to a computer use tool. See the - # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information. - variant :computer_call, -> { OpenAI::Models::Responses::ResponseComputerToolCall } - - variant :computer_call_output, - -> { OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput } - - # The results of a web search tool call. See the - # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information. - variant :web_search_call, -> { OpenAI::Models::Responses::ResponseFunctionWebSearch } - - # A tool call to run a function. See the - # [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information. - variant :function_call, -> { OpenAI::Models::Responses::ResponseFunctionToolCall } - - variant :function_call_output, - -> { OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput } - - class Message < OpenAI::BaseModel - # @!attribute id - # The unique ID of the message input. - # - # @return [String] - required :id, String - - # @!attribute content - # A list of one or many input items to the model, containing different content - # types. - # - # @return [Array] - required :content, -> { OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseInputContent] } - - # @!attribute role - # The role of the message input. One of `user`, `system`, or `developer`. - # - # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Role] - required :role, enum: -> { OpenAI::Models::Responses::ResponseItemList::Data::Message::Role } - - # @!attribute [r] status - # The status of item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - # - # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Status, nil] - optional :status, enum: -> { OpenAI::Models::Responses::ResponseItemList::Data::Message::Status } - - # @!parse - # # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Status] - # attr_writer :status - - # @!attribute [r] type - # The type of the message input. Always set to `message`. - # - # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Type, nil] - optional :type, enum: -> { OpenAI::Models::Responses::ResponseItemList::Data::Message::Type } - - # @!parse - # # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Type] - # attr_writer :type - - # @!parse - # # @param id [String] - # # @param content [Array] - # # @param role [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Role] - # # @param status [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Status] - # # @param type [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::Message::Type] - # # - # def initialize(id:, content:, role:, status: nil, type: nil, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - - # @abstract - # - # The role of the message input. One of `user`, `system`, or `developer`. - class Role < OpenAI::Enum - USER = :user - SYSTEM = :system - DEVELOPER = :developer - - finalize! - end - - # @abstract - # - # The status of item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - class Status < OpenAI::Enum - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - - finalize! - end - - # @abstract - # - # The type of the message input. Always set to `message`. - class Type < OpenAI::Enum - MESSAGE = :message - - finalize! - end - end - - class ComputerCallOutput < OpenAI::BaseModel - # @!attribute id - # The unique ID of the computer call tool output. - # - # @return [String] - required :id, String - - # @!attribute call_id - # The ID of the computer tool call that produced the output. - # - # @return [String] - required :call_id, String - - # @!attribute output - # A computer screenshot image used with the computer use tool. - # - # @return [OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output] - required :output, -> { OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output } - - # @!attribute type - # The type of the computer tool call output. Always `computer_call_output`. - # - # @return [Symbol, :computer_call_output] - required :type, const: :computer_call_output - - # @!attribute [r] acknowledged_safety_checks - # The safety checks reported by the API that have been acknowledged by the - # developer. - # - # @return [Array, nil] - optional :acknowledged_safety_checks, - -> { OpenAI::ArrayOf[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] } - - # @!parse - # # @return [Array] - # attr_writer :acknowledged_safety_checks - - # @!attribute [r] status - # The status of the message input. One of `in_progress`, `completed`, or - # `incomplete`. Populated when input items are returned via API. - # - # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Status, nil] - optional :status, - enum: -> { OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Status } - - # @!parse - # # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Status] - # attr_writer :status - - # @!parse - # # @param id [String] - # # @param call_id [String] - # # @param output [OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output] - # # @param acknowledged_safety_checks [Array] - # # @param status [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Status] - # # @param type [Symbol, :computer_call_output] - # # - # def initialize(id:, call_id:, output:, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - - class Output < OpenAI::BaseModel - # @!attribute type - # Specifies the event type. For a computer screenshot, this property is always set - # to `computer_screenshot`. - # - # @return [Symbol, :computer_screenshot] - required :type, const: :computer_screenshot - - # @!attribute [r] file_id - # The identifier of an uploaded file that contains the screenshot. - # - # @return [String, nil] - optional :file_id, String - - # @!parse - # # @return [String] - # attr_writer :file_id - - # @!attribute [r] image_url - # The URL of the screenshot image. - # - # @return [String, nil] - optional :image_url, String - - # @!parse - # # @return [String] - # attr_writer :image_url - - # @!parse - # # A computer screenshot image used with the computer use tool. - # # - # # @param file_id [String] - # # @param image_url [String] - # # @param type [Symbol, :computer_screenshot] - # # - # def initialize(file_id: nil, image_url: nil, type: :computer_screenshot, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - end - - class AcknowledgedSafetyCheck < OpenAI::BaseModel - # @!attribute id - # The ID of the pending safety check. - # - # @return [String] - required :id, String - - # @!attribute code - # The type of the pending safety check. - # - # @return [String] - required :code, String - - # @!attribute message - # Details about the pending safety check. - # - # @return [String] - required :message, String - - # @!parse - # # A pending safety check for the computer call. - # # - # # @param id [String] - # # @param code [String] - # # @param message [String] - # # - # def initialize(id:, code:, message:, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - end - - # @abstract - # - # The status of the message input. One of `in_progress`, `completed`, or - # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - - finalize! - end - end - - class FunctionCallOutput < OpenAI::BaseModel - # @!attribute id - # The unique ID of the function call tool output. - # - # @return [String] - required :id, String - - # @!attribute call_id - # The unique ID of the function tool call generated by the model. - # - # @return [String] - required :call_id, String - - # @!attribute output - # A JSON string of the output of the function tool call. - # - # @return [String] - required :output, String - - # @!attribute type - # The type of the function tool call output. Always `function_call_output`. - # - # @return [Symbol, :function_call_output] - required :type, const: :function_call_output - - # @!attribute [r] status - # The status of the item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - # - # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::Status, nil] - optional :status, - enum: -> { OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::Status } - - # @!parse - # # @return [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::Status] - # attr_writer :status - - # @!parse - # # @param id [String] - # # @param call_id [String] - # # @param output [String] - # # @param status [Symbol, OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::Status] - # # @param type [Symbol, :function_call_output] - # # - # def initialize(id:, call_id:, output:, status: nil, type: :function_call_output, **) = super - - # def initialize: (Hash | OpenAI::BaseModel) -> void - - # @abstract - # - # The status of the item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - class Status < OpenAI::Enum - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - - finalize! - end - end - - # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseItemList::Data::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput)] - # def variants; end - # end - end end end diff --git a/lib/openai/models/responses/response_output_item.rb b/lib/openai/models/responses/response_output_item.rb index 2ed933fd..2666a922 100644 --- a/lib/openai/models/responses/response_output_item.rb +++ b/lib/openai/models/responses/response_output_item.rb @@ -3,10 +3,10 @@ module OpenAI module Models module Responses - # @abstract - # # An output message from the model. - class ResponseOutputItem < OpenAI::Union + module ResponseOutputItem + extend OpenAI::Union + discriminator :type # An output message from the model. @@ -33,10 +33,8 @@ class ResponseOutputItem < OpenAI::Union variant :reasoning, -> { OpenAI::Models::Responses::ResponseReasoningItem } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_output_message.rb b/lib/openai/models/responses/response_output_message.rb index 1dee0300..04b05a0d 100644 --- a/lib/openai/models/responses/response_output_message.rb +++ b/lib/openai/models/responses/response_output_message.rb @@ -49,10 +49,10 @@ class ResponseOutputMessage < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A text output from the model. - class Content < OpenAI::Union + module Content + extend OpenAI::Union + discriminator :type # A text output from the model. @@ -62,22 +62,24 @@ class Content < OpenAI::Union variant :refusal, -> { OpenAI::Models::Responses::ResponseOutputRefusal } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] + # def self.variants; end end - # @abstract - # # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_output_text.rb b/lib/openai/models/responses/response_output_text.rb index 175d5eda..e6c46e68 100644 --- a/lib/openai/models/responses/response_output_text.rb +++ b/lib/openai/models/responses/response_output_text.rb @@ -34,10 +34,10 @@ class ResponseOutputText < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A citation to a file. - class Annotation < OpenAI::Union + module Annotation + extend OpenAI::Union + discriminator :type # A citation to a file. @@ -157,10 +157,8 @@ class FilePath < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_reasoning_item.rb b/lib/openai/models/responses/response_reasoning_item.rb index c4d60d3f..bb1bc110 100644 --- a/lib/openai/models/responses/response_reasoning_item.rb +++ b/lib/openai/models/responses/response_reasoning_item.rb @@ -68,16 +68,20 @@ class Summary < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_retrieve_params.rb b/lib/openai/models/responses/response_retrieve_params.rb index 4ca65d89..6d3028c3 100644 --- a/lib/openai/models/responses/response_retrieve_params.rb +++ b/lib/openai/models/responses/response_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module Responses class ResponseRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] include diff --git a/lib/openai/models/responses/response_status.rb b/lib/openai/models/responses/response_status.rb index e15a7a6e..31187039 100644 --- a/lib/openai/models/responses/response_status.rb +++ b/lib/openai/models/responses/response_status.rb @@ -3,17 +3,21 @@ module OpenAI module Models module Responses - # @abstract - # # The status of the response generation. One of `completed`, `failed`, # `in_progress`, or `incomplete`. - class ResponseStatus < OpenAI::Enum + module ResponseStatus + extend OpenAI::Enum + COMPLETED = :completed FAILED = :failed IN_PROGRESS = :in_progress INCOMPLETE = :incomplete finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/response_stream_event.rb b/lib/openai/models/responses/response_stream_event.rb index 85fe7a25..5dddc41f 100644 --- a/lib/openai/models/responses/response_stream_event.rb +++ b/lib/openai/models/responses/response_stream_event.rb @@ -3,10 +3,10 @@ module OpenAI module Models module Responses - # @abstract - # # Emitted when there is a partial audio response. - class ResponseStreamEvent < OpenAI::Union + module ResponseStreamEvent + extend OpenAI::Union + discriminator :type # Emitted when there is a partial audio response. @@ -122,10 +122,8 @@ class ResponseStreamEvent < OpenAI::Union -> { OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_text_annotation_delta_event.rb b/lib/openai/models/responses/response_text_annotation_delta_event.rb index 4d980266..f796c035 100644 --- a/lib/openai/models/responses/response_text_annotation_delta_event.rb +++ b/lib/openai/models/responses/response_text_annotation_delta_event.rb @@ -65,10 +65,10 @@ class ResponseTextAnnotationDeltaEvent < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A citation to a file. - class Annotation < OpenAI::Union + module Annotation + extend OpenAI::Union + discriminator :type # A citation to a file. @@ -191,10 +191,8 @@ class FilePath < OpenAI::BaseModel end # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/response_usage.rb b/lib/openai/models/responses/response_usage.rb index 198bb4bd..8e4ccddd 100644 --- a/lib/openai/models/responses/response_usage.rb +++ b/lib/openai/models/responses/response_usage.rb @@ -10,6 +10,12 @@ class ResponseUsage < OpenAI::BaseModel # @return [Integer] required :input_tokens, Integer + # @!attribute input_tokens_details + # A detailed breakdown of the input tokens. + # + # @return [OpenAI::Models::Responses::ResponseUsage::InputTokensDetails] + required :input_tokens_details, -> { OpenAI::Models::Responses::ResponseUsage::InputTokensDetails } + # @!attribute output_tokens # The number of output tokens. # @@ -33,14 +39,33 @@ class ResponseUsage < OpenAI::BaseModel # # breakdown of output tokens, and the total tokens used. # # # # @param input_tokens [Integer] + # # @param input_tokens_details [OpenAI::Models::Responses::ResponseUsage::InputTokensDetails] # # @param output_tokens [Integer] # # @param output_tokens_details [OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails] # # @param total_tokens [Integer] # # - # def initialize(input_tokens:, output_tokens:, output_tokens_details:, total_tokens:, **) = super + # def initialize(input_tokens:, input_tokens_details:, output_tokens:, output_tokens_details:, total_tokens:, **) = super # def initialize: (Hash | OpenAI::BaseModel) -> void + class InputTokensDetails < OpenAI::BaseModel + # @!attribute cached_tokens + # The number of tokens that were retrieved from the cache. + # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + # + # @return [Integer] + required :cached_tokens, Integer + + # @!parse + # # A detailed breakdown of the input tokens. + # # + # # @param cached_tokens [Integer] + # # + # def initialize(cached_tokens:, **) = super + + # def initialize: (Hash | OpenAI::BaseModel) -> void + end + class OutputTokensDetails < OpenAI::BaseModel # @!attribute reasoning_tokens # The number of reasoning tokens. diff --git a/lib/openai/models/responses/tool.rb b/lib/openai/models/responses/tool.rb index 9093989e..3072312f 100644 --- a/lib/openai/models/responses/tool.rb +++ b/lib/openai/models/responses/tool.rb @@ -3,12 +3,12 @@ module OpenAI module Models module Responses - # @abstract - # # A tool that searches for relevant content from uploaded files. Learn more about # the # [file search tool](https://platform.openai.com/docs/guides/tools-file-search). - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + discriminator :type # A tool that searches for relevant content from uploaded files. @@ -28,10 +28,8 @@ class Tool < OpenAI::Union variant -> { OpenAI::Models::Responses::WebSearchTool } # @!parse - # class << self - # # @return [Array(OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool)] + # def self.variants; end end end end diff --git a/lib/openai/models/responses/tool_choice_options.rb b/lib/openai/models/responses/tool_choice_options.rb index e72582b9..00c16a94 100644 --- a/lib/openai/models/responses/tool_choice_options.rb +++ b/lib/openai/models/responses/tool_choice_options.rb @@ -3,8 +3,6 @@ module OpenAI module Models module Responses - # @abstract - # # Controls which (if any) tool is called by the model. # # `none` means the model will not call any tool and instead generates a message. @@ -13,12 +11,18 @@ module Responses # more tools. # # `required` means the model must call one or more tools. - class ToolChoiceOptions < OpenAI::Enum + module ToolChoiceOptions + extend OpenAI::Enum + NONE = :none AUTO = :auto REQUIRED = :required finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/tool_choice_types.rb b/lib/openai/models/responses/tool_choice_types.rb index 3398854c..b6041f87 100644 --- a/lib/openai/models/responses/tool_choice_types.rb +++ b/lib/openai/models/responses/tool_choice_types.rb @@ -27,8 +27,6 @@ class ToolChoiceTypes < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of hosted tool the model should to use. Learn more about # [built-in tools](https://platform.openai.com/docs/guides/tools). # @@ -37,13 +35,19 @@ class ToolChoiceTypes < OpenAI::BaseModel # - `file_search` # - `web_search_preview` # - `computer_use_preview` - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FILE_SEARCH = :file_search WEB_SEARCH_PREVIEW = :web_search_preview COMPUTER_USE_PREVIEW = :computer_use_preview WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/responses/web_search_tool.rb b/lib/openai/models/responses/web_search_tool.rb index 6a2acdc0..31542421 100644 --- a/lib/openai/models/responses/web_search_tool.rb +++ b/lib/openai/models/responses/web_search_tool.rb @@ -42,29 +42,37 @@ class WebSearchTool < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of the web search tool. One of: # # - `web_search_preview` # - `web_search_preview_2025_03_11` - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + WEB_SEARCH_PREVIEW = :web_search_preview WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11 finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - class SearchContextSize < OpenAI::Enum + module SearchContextSize + extend OpenAI::Enum + LOW = :low MEDIUM = :medium HIGH = :high finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class UserLocation < OpenAI::BaseModel diff --git a/lib/openai/models/responses_model.rb b/lib/openai/models/responses_model.rb new file mode 100644 index 00000000..a7995455 --- /dev/null +++ b/lib/openai/models/responses_model.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module ResponsesModel + extend OpenAI::Union + + variant String + + variant enum: -> { OpenAI::Models::ChatModel } + + variant const: -> { OpenAI::Models::ResponsesModel::O1_PRO } + + variant const: -> { OpenAI::Models::ResponsesModel::O1_PRO_2025_03_19 } + + variant const: -> { OpenAI::Models::ResponsesModel::COMPUTER_USE_PREVIEW } + + variant const: -> { OpenAI::Models::ResponsesModel::COMPUTER_USE_PREVIEW_2025_03_11 } + + # @!parse + # # @return [Array(String, Symbol, OpenAI::Models::ChatModel, Symbol)] + # def self.variants; end + + # @!group + + O1_PRO = :"o1-pro" + O1_PRO_2025_03_19 = :"o1-pro-2025-03-19" + COMPUTER_USE_PREVIEW = :"computer-use-preview" + COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11" + + # @!endgroup + end + end +end diff --git a/lib/openai/models/upload.rb b/lib/openai/models/upload.rb index 0e6b2be5..4f319b8c 100644 --- a/lib/openai/models/upload.rb +++ b/lib/openai/models/upload.rb @@ -76,16 +76,20 @@ class Upload < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The status of the Upload. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + PENDING = :pending COMPLETED = :completed CANCELLED = :cancelled EXPIRED = :expired finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/upload_cancel_params.rb b/lib/openai/models/upload_cancel_params.rb index 164c052a..62d1e116 100644 --- a/lib/openai/models/upload_cancel_params.rb +++ b/lib/openai/models/upload_cancel_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class UploadCancelParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/upload_complete_params.rb b/lib/openai/models/upload_complete_params.rb index 1a2b22be..866303ce 100644 --- a/lib/openai/models/upload_complete_params.rb +++ b/lib/openai/models/upload_complete_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class UploadCompleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute part_ids diff --git a/lib/openai/models/upload_create_params.rb b/lib/openai/models/upload_create_params.rb index 6e279c41..3650d2dd 100644 --- a/lib/openai/models/upload_create_params.rb +++ b/lib/openai/models/upload_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class UploadCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute bytes diff --git a/lib/openai/models/uploads/part_create_params.rb b/lib/openai/models/uploads/part_create_params.rb index a25b50cc..2d3a2fb7 100644 --- a/lib/openai/models/uploads/part_create_params.rb +++ b/lib/openai/models/uploads/part_create_params.rb @@ -5,7 +5,7 @@ module Models module Uploads class PartCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute data diff --git a/lib/openai/models/vector_store.rb b/lib/openai/models/vector_store.rb index 7593bb95..dd5df66d 100644 --- a/lib/openai/models/vector_store.rb +++ b/lib/openai/models/vector_store.rb @@ -157,17 +157,21 @@ class FileCounts < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The status of the vector store, which can be either `expired`, `in_progress`, or # `completed`. A status of `completed` indicates that the vector store is ready # for use. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + EXPIRED = :expired IN_PROGRESS = :in_progress COMPLETED = :completed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end class ExpiresAfter < OpenAI::BaseModel diff --git a/lib/openai/models/vector_store_create_params.rb b/lib/openai/models/vector_store_create_params.rb index 9197db12..43b4e601 100644 --- a/lib/openai/models/vector_store_create_params.rb +++ b/lib/openai/models/vector_store_create_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] chunking_strategy diff --git a/lib/openai/models/vector_store_delete_params.rb b/lib/openai/models/vector_store_delete_params.rb index 0d599c50..25113370 100644 --- a/lib/openai/models/vector_store_delete_params.rb +++ b/lib/openai/models/vector_store_delete_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/vector_store_list_params.rb b/lib/openai/models/vector_store_list_params.rb index ee2a79cf..614dc937 100644 --- a/lib/openai/models/vector_store_list_params.rb +++ b/lib/openai/models/vector_store_list_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -66,15 +66,19 @@ class VectorStoreListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/vector_store_retrieve_params.rb b/lib/openai/models/vector_store_retrieve_params.rb index 8051213c..60ede4d7 100644 --- a/lib/openai/models/vector_store_retrieve_params.rb +++ b/lib/openai/models/vector_store_retrieve_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!parse diff --git a/lib/openai/models/vector_store_search_params.rb b/lib/openai/models/vector_store_search_params.rb index 30d37581..c970dbc4 100644 --- a/lib/openai/models/vector_store_search_params.rb +++ b/lib/openai/models/vector_store_search_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreSearchParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute query @@ -76,27 +76,25 @@ class VectorStoreSearchParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # A query string for a search - class Query < OpenAI::Union - StringArray = OpenAI::ArrayOf[String] + module Query + extend OpenAI::Union variant String - variant OpenAI::Models::VectorStoreSearchParams::Query::StringArray + variant -> { OpenAI::Models::VectorStoreSearchParams::Query::StringArray } # @!parse - # class << self - # # @return [Array(String, Array)] - # def variants; end - # end + # # @return [Array(String, Array)] + # def self.variants; end + + StringArray = OpenAI::ArrayOf[String] end - # @abstract - # # A filter to apply based on file attributes. - class Filters < OpenAI::Union + module Filters + extend OpenAI::Union + # A filter used to compare a specified attribute key to a given value using a defined comparison operation. variant -> { OpenAI::Models::ComparisonFilter } @@ -104,10 +102,8 @@ class Filters < OpenAI::Union variant -> { OpenAI::Models::CompoundFilter } # @!parse - # class << self - # # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)] - # def variants; end - # end + # # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)] + # def self.variants; end end class RankingOptions < OpenAI::BaseModel @@ -139,12 +135,17 @@ class RankingOptions < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO = :auto DEFAULT_2024_11_15 = :"default-2024-11-15" finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/vector_store_search_response.rb b/lib/openai/models/vector_store_search_response.rb index 233cdad0..11a8b9e3 100644 --- a/lib/openai/models/vector_store_search_response.rb +++ b/lib/openai/models/vector_store_search_response.rb @@ -50,8 +50,9 @@ class VectorStoreSearchResponse < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -59,10 +60,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end class Content < OpenAI::BaseModel @@ -86,13 +85,17 @@ class Content < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # The type of content. - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + TEXT = :text finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/vector_store_update_params.rb b/lib/openai/models/vector_store_update_params.rb index 8dcdbb59..7e6fb3a6 100644 --- a/lib/openai/models/vector_store_update_params.rb +++ b/lib/openai/models/vector_store_update_params.rb @@ -4,7 +4,7 @@ module OpenAI module Models class VectorStoreUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute expires_after diff --git a/lib/openai/models/vector_stores/file_batch_cancel_params.rb b/lib/openai/models/vector_stores/file_batch_cancel_params.rb index 045c91ff..3e5971ff 100644 --- a/lib/openai/models/vector_stores/file_batch_cancel_params.rb +++ b/lib/openai/models/vector_stores/file_batch_cancel_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileBatchCancelParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id diff --git a/lib/openai/models/vector_stores/file_batch_create_params.rb b/lib/openai/models/vector_stores/file_batch_create_params.rb index e35057be..69286492 100644 --- a/lib/openai/models/vector_stores/file_batch_create_params.rb +++ b/lib/openai/models/vector_stores/file_batch_create_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileBatchCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute file_ids @@ -49,8 +49,9 @@ class FileBatchCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -58,10 +59,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/vector_stores/file_batch_list_files_params.rb b/lib/openai/models/vector_stores/file_batch_list_files_params.rb index 40629c3c..1dbc17b1 100644 --- a/lib/openai/models/vector_stores/file_batch_list_files_params.rb +++ b/lib/openai/models/vector_stores/file_batch_list_files_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileBatchListFilesParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id @@ -84,27 +84,35 @@ class FileBatchListFilesParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - class Filter < OpenAI::Enum + module Filter + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed FAILED = :failed CANCELLED = :cancelled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/vector_stores/file_batch_retrieve_params.rb b/lib/openai/models/vector_stores/file_batch_retrieve_params.rb index 9856a452..34ccee34 100644 --- a/lib/openai/models/vector_stores/file_batch_retrieve_params.rb +++ b/lib/openai/models/vector_stores/file_batch_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileBatchRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id diff --git a/lib/openai/models/vector_stores/file_content_params.rb b/lib/openai/models/vector_stores/file_content_params.rb index c5d82123..8e88a4ff 100644 --- a/lib/openai/models/vector_stores/file_content_params.rb +++ b/lib/openai/models/vector_stores/file_content_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileContentParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id diff --git a/lib/openai/models/vector_stores/file_create_params.rb b/lib/openai/models/vector_stores/file_create_params.rb index 3e7c7817..79ef17c3 100644 --- a/lib/openai/models/vector_stores/file_create_params.rb +++ b/lib/openai/models/vector_stores/file_create_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileCreateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute file_id @@ -49,8 +49,9 @@ class FileCreateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -58,10 +59,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/vector_stores/file_delete_params.rb b/lib/openai/models/vector_stores/file_delete_params.rb index 3a22fe46..8baa3964 100644 --- a/lib/openai/models/vector_stores/file_delete_params.rb +++ b/lib/openai/models/vector_stores/file_delete_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileDeleteParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id diff --git a/lib/openai/models/vector_stores/file_list_params.rb b/lib/openai/models/vector_stores/file_list_params.rb index c227d297..78acf207 100644 --- a/lib/openai/models/vector_stores/file_list_params.rb +++ b/lib/openai/models/vector_stores/file_list_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileListParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute [r] after @@ -78,27 +78,35 @@ class FileListParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - class Filter < OpenAI::Enum + module Filter + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed FAILED = :failed CANCELLED = :cancelled finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - # # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC = :asc DESC = :desc finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/models/vector_stores/file_retrieve_params.rb b/lib/openai/models/vector_stores/file_retrieve_params.rb index af408c6c..bfb3d370 100644 --- a/lib/openai/models/vector_stores/file_retrieve_params.rb +++ b/lib/openai/models/vector_stores/file_retrieve_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileRetrieveParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id diff --git a/lib/openai/models/vector_stores/file_update_params.rb b/lib/openai/models/vector_stores/file_update_params.rb index 6b9100d4..e1a477eb 100644 --- a/lib/openai/models/vector_stores/file_update_params.rb +++ b/lib/openai/models/vector_stores/file_update_params.rb @@ -5,7 +5,7 @@ module Models module VectorStores class FileUpdateParams < OpenAI::BaseModel # @!parse - # extend OpenAI::RequestParameters::Converter + # extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # @!attribute vector_store_id @@ -34,8 +34,9 @@ class FileUpdateParams < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -43,10 +44,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/vector_stores/vector_store_file.rb b/lib/openai/models/vector_stores/vector_store_file.rb index 5aa034c1..12c6f576 100644 --- a/lib/openai/models/vector_stores/vector_store_file.rb +++ b/lib/openai/models/vector_stores/vector_store_file.rb @@ -129,34 +129,43 @@ class LastError < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void - # @abstract - # # One of `server_error` or `rate_limit_exceeded`. - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR = :server_error UNSUPPORTED_FILE = :unsupported_file INVALID_FILE = :invalid_file finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end - # @abstract - # # The status of the vector store file, which can be either `in_progress`, # `completed`, `cancelled`, or `failed`. The status `completed` indicates that the # vector store file is ready for use. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed CANCELLED = :cancelled FAILED = :failed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end - # @abstract - class Attribute < OpenAI::Union + module Attribute + extend OpenAI::Union + variant String variant Float @@ -164,10 +173,8 @@ class Attribute < OpenAI::Union variant OpenAI::BooleanModel # @!parse - # class << self - # # @return [Array(String, Float, Boolean)] - # def variants; end - # end + # # @return [Array(String, Float, Boolean)] + # def self.variants; end end end end diff --git a/lib/openai/models/vector_stores/vector_store_file_batch.rb b/lib/openai/models/vector_stores/vector_store_file_batch.rb index da82a1f6..8fc405d8 100644 --- a/lib/openai/models/vector_stores/vector_store_file_batch.rb +++ b/lib/openai/models/vector_stores/vector_store_file_batch.rb @@ -101,17 +101,21 @@ class FileCounts < OpenAI::BaseModel # def initialize: (Hash | OpenAI::BaseModel) -> void end - # @abstract - # # The status of the vector store files batch, which can be either `in_progress`, # `completed`, `cancelled` or `failed`. - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS = :in_progress COMPLETED = :completed CANCELLED = :cancelled FAILED = :failed finalize! + + # @!parse + # # @return [Array] + # def self.values; end end end end diff --git a/lib/openai/page.rb b/lib/openai/page.rb index 40ccc49a..55f85755 100644 --- a/lib/openai/page.rb +++ b/lib/openai/page.rb @@ -2,33 +2,28 @@ module OpenAI # @example - # ```ruby - # if page.has_next? - # page = page.next_page - # end - # ``` + # if page.has_next? + # page = page.next_page + # end # # @example - # ```ruby - # page.auto_paging_each do |model| - # puts(model) - # end - # ``` + # page.auto_paging_each do |model| + # puts(model) + # end # # @example - # ```ruby - # models = page - # .to_enum - # .lazy - # .select { _1.object_id.even? } - # .map(&:itself) - # .take(2) - # .to_a + # models = + # page + # .to_enum + # .lazy + # .select { _1.object_id.even? } + # .map(&:itself) + # .take(2) + # .to_a # - # models => Array - # ``` + # models => Array class Page - include OpenAI::BasePage + include OpenAI::Type::BasePage # @return [Array, nil] attr_accessor :data @@ -38,7 +33,7 @@ class Page # @api private # - # @param client [OpenAI::BaseClient] + # @param client [OpenAI::Transport::BaseClient] # @param req [Hash{Symbol=>Object}] # @param headers [Hash{String=>String}, Net::HTTPHeader] # @param page_data [Array] @@ -48,7 +43,7 @@ def initialize(client:, req:, headers:, page_data:) case page_data in {data: Array | nil => data} - @data = data&.map { model.coerce(_1) } + @data = data&.map { OpenAI::Type::Converter.coerce(model, _1) } else end diff --git a/lib/openai/pooled_net_requester.rb b/lib/openai/pooled_net_requester.rb deleted file mode 100644 index 4b0ae742..00000000 --- a/lib/openai/pooled_net_requester.rb +++ /dev/null @@ -1,169 +0,0 @@ -# frozen_string_literal: true - -module OpenAI - # @api private - class PooledNetRequester - class << self - # @api private - # - # @param url [URI::Generic] - # - # @return [Net::HTTP] - def connect(url) - port = - case [url.port, url.scheme] - in [Integer, _] - url.port - in [nil, "http" | "ws"] - Net::HTTP.http_default_port - in [nil, "https" | "wss"] - Net::HTTP.https_default_port - end - - Net::HTTP.new(url.host, port).tap do - _1.use_ssl = %w[https wss].include?(url.scheme) - _1.max_retries = 0 - end - end - - # @api private - # - # @param conn [Net::HTTP] - # @param deadline [Float] - def calibrate_socket_timeout(conn, deadline) - timeout = deadline - OpenAI::Util.monotonic_secs - conn.open_timeout = conn.read_timeout = conn.write_timeout = conn.continue_timeout = timeout - end - - # @api private - # - # @param request [Hash{Symbol=>Object}] . - # - # @option request [Symbol] :method - # - # @option request [URI::Generic] :url - # - # @option request [Hash{String=>String}] :headers - # - # @param blk [Proc] - # - # @return [Net::HTTPGenericRequest] - def build_request(request, &) - method, url, headers, body = request.fetch_values(:method, :url, :headers, :body) - req = Net::HTTPGenericRequest.new( - method.to_s.upcase, - !body.nil?, - method != :head, - url.to_s - ) - - headers.each { req[_1] = _2 } - - case body - in nil - nil - in String - req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] - req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &) - in StringIO - req["content-length"] ||= body.size.to_s unless req["transfer-encoding"] - req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &) - in IO | Enumerator - req["transfer-encoding"] ||= "chunked" unless req["content-length"] - req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &) - end - - req - end - end - - # @api private - # - # @param url [URI::Generic] - # @param deadline [Float] - # @param blk [Proc] - private def with_pool(url, deadline:, &blk) - origin = OpenAI::Util.uri_origin(url) - timeout = deadline - OpenAI::Util.monotonic_secs - pool = - @mutex.synchronize do - @pools[origin] ||= ConnectionPool.new(size: @size) do - self.class.connect(url) - end - end - - pool.with(timeout: timeout, &blk) - end - - # @api private - # - # @param request [Hash{Symbol=>Object}] . - # - # @option request [Symbol] :method - # - # @option request [URI::Generic] :url - # - # @option request [Hash{String=>String}] :headers - # - # @option request [Object] :body - # - # @option request [Float] :deadline - # - # @return [Array(Integer, Net::HTTPResponse, Enumerable)] - def execute(request) - url, deadline = request.fetch_values(:url, :deadline) - - eof = false - finished = false - enum = Enumerator.new do |y| - with_pool(url, deadline: deadline) do |conn| - next if finished - - req = self.class.build_request(request) do - self.class.calibrate_socket_timeout(conn, deadline) - end - - self.class.calibrate_socket_timeout(conn, deadline) - conn.start unless conn.started? - - self.class.calibrate_socket_timeout(conn, deadline) - conn.request(req) do |rsp| - y << [conn, req, rsp] - break if finished - - rsp.read_body do |bytes| - y << bytes - break if finished - - self.class.calibrate_socket_timeout(conn, deadline) - end - eof = true - end - end - rescue Timeout::Error - raise OpenAI::APITimeoutError - end - - conn, _, response = enum.next - body = OpenAI::Util.fused_enum(enum, external: true) do - finished = true - tap do - enum.next - rescue StopIteration - nil - end - conn.finish if !eof && conn&.started? - end - [Integer(response.code), response, (response.body = body)] - end - - # @api private - # - # @param size [Integer] - def initialize(size: Etc.nprocessors) - @mutex = Mutex.new - @size = size - @pools = {} - end - end -end diff --git a/lib/openai/request_options.rb b/lib/openai/request_options.rb index a3245591..279c2936 100644 --- a/lib/openai/request_options.rb +++ b/lib/openai/request_options.rb @@ -1,39 +1,6 @@ # frozen_string_literal: true module OpenAI - # @api private - module RequestParameters - # @!parse - # # Options to specify HTTP behaviour for this request. - # # @return [OpenAI::RequestOptions, Hash{Symbol=>Object}] - # attr_accessor :request_options - - # @param mod [Module] - def self.included(mod) - return unless mod <= OpenAI::BaseModel - - mod.extend(OpenAI::RequestParameters::Converter) - mod.optional(:request_options, OpenAI::RequestOptions) - end - - # @api private - module Converter - # @api private - # - # @param params [Object] - # - # @return [Array(Object, Hash{Symbol=>Object})] - def dump_request(params) - case (dumped = dump(params)) - in Hash - [dumped.except(:request_options), dumped[:request_options]] - else - [dumped, nil] - end - end - end - end - # Specify HTTP behaviour to use for a specific request. These options supplement # or override those provided at the client level. # @@ -83,7 +50,7 @@ def self.validate!(opts) # Extra data to send with the request. These are deep merged into any data # generated as part of the normal request. # - # @return [Hash{Symbol=>Object}, nil] + # @return [Object, nil] optional :extra_body, OpenAI::HashOf[OpenAI::Unknown] # @!attribute max_retries diff --git a/lib/openai/resources/audio/speech.rb b/lib/openai/resources/audio/speech.rb index 9c5d8284..0b5bb925 100644 --- a/lib/openai/resources/audio/speech.rb +++ b/lib/openai/resources/audio/speech.rb @@ -11,13 +11,16 @@ class Speech # @option params [String] :input The text to generate audio for. The maximum length is 4096 characters. # # @option params [String, Symbol, OpenAI::Models::Audio::SpeechModel] :model One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. # - # @option params [Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice] :voice The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # @option params [String, Symbol] :voice The voice to use when generating the audio. Supported voices are `alloy`, `ash`, + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). # + # @option params [String] :instructions Control the voice of your generated audio with additional instructions. Does not + # work with `tts-1` or `tts-1-hd`. + # # @option params [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat] :response_format The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, # `wav`, and `pcm`. # @@ -26,7 +29,7 @@ class Speech # # @option params [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :request_options # - # @return [Object] + # @return [StringIO] def create(params) parsed, options = OpenAI::Models::Audio::SpeechCreateParams.dump_request(params) @client.request( @@ -34,7 +37,7 @@ def create(params) path: "audio/speech", headers: {"accept" => "application/octet-stream"}, body: parsed, - model: OpenAI::Unknown, + model: StringIO, options: options ) end diff --git a/lib/openai/resources/audio/transcriptions.rb b/lib/openai/resources/audio/transcriptions.rb index 9e291700..3c7238bf 100644 --- a/lib/openai/resources/audio/transcriptions.rb +++ b/lib/openai/resources/audio/transcriptions.rb @@ -11,8 +11,15 @@ class Transcriptions # @option params [IO, StringIO] :file The audio file object (not file name) to transcribe, in one of these formats: # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. # - # @option params [String, Symbol, OpenAI::Models::AudioModel] :model ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. + # @option params [String, Symbol, OpenAI::Models::AudioModel] :model ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + # + # @option params [Array] :include Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. # # @option params [String] :language The language of the input audio. Supplying the input language in # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) @@ -24,7 +31,8 @@ class Transcriptions # should match the audio language. # # @option params [Symbol, OpenAI::Models::AudioResponseFormat] :response_format The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. # # @option params [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the # output more random, while lower values like 0.2 will make it more focused and @@ -43,6 +51,10 @@ class Transcriptions # @return [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose] def create(params) parsed, options = OpenAI::Models::Audio::TranscriptionCreateParams.dump_request(params) + if parsed[:stream] + message = "Please use `#create_streaming` for the streaming use case." + raise ArgumentError.new(message) + end @client.request( method: :post, path: "audio/transcriptions", @@ -53,6 +65,69 @@ def create(params) ) end + # Transcribes audio into the input language. + # + # @param params [OpenAI::Models::Audio::TranscriptionCreateParams, Hash{Symbol=>Object}] . + # + # @option params [IO, StringIO] :file The audio file object (not file name) to transcribe, in one of these formats: + # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. + # + # @option params [String, Symbol, OpenAI::Models::AudioModel] :model ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + # + # @option params [Array] :include Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. + # + # @option params [String] :language The language of the input audio. Supplying the input language in + # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) + # format will improve accuracy and latency. + # + # @option params [String] :prompt An optional text to guide the model's style or continue a previous audio + # segment. The + # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) + # should match the audio language. + # + # @option params [Symbol, OpenAI::Models::AudioResponseFormat] :response_format The format of the output, in one of these options: `json`, `text`, `srt`, + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. + # + # @option params [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the + # output more random, while lower values like 0.2 will make it more focused and + # deterministic. If set to 0, the model will use + # [log probability](https://en.wikipedia.org/wiki/Log_probability) to + # automatically increase the temperature until certain thresholds are hit. + # + # @option params [Array] :timestamp_granularities The timestamp granularities to populate for this transcription. + # `response_format` must be set `verbose_json` to use timestamp granularities. + # Either or both of these options are supported: `word`, or `segment`. Note: There + # is no additional latency for segment timestamps, but generating word timestamps + # incurs additional latency. + # + # @option params [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :request_options + # + # @return [OpenAI::Stream] + def create_streaming(params) + parsed, options = OpenAI::Models::Audio::TranscriptionCreateParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create` for the non-streaming use case." + raise ArgumentError.new(message) + end + parsed.store(:stream, true) + @client.request( + method: :post, + path: "audio/transcriptions", + headers: {"content-type" => "multipart/form-data", "accept" => "text/event-stream"}, + body: parsed, + stream: OpenAI::Stream, + model: OpenAI::Models::Audio::TranscriptionStreamEvent, + options: options + ) + end + # @param client [OpenAI::Client] def initialize(client:) @client = client diff --git a/lib/openai/resources/audio/translations.rb b/lib/openai/resources/audio/translations.rb index c1de4f8e..ea8e0e4a 100644 --- a/lib/openai/resources/audio/translations.rb +++ b/lib/openai/resources/audio/translations.rb @@ -19,7 +19,7 @@ class Translations # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) # should be in English. # - # @option params [Symbol, OpenAI::Models::AudioResponseFormat] :response_format The format of the output, in one of these options: `json`, `text`, `srt`, + # @option params [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat] :response_format The format of the output, in one of these options: `json`, `text`, `srt`, # `verbose_json`, or `vtt`. # # @option params [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the diff --git a/lib/openai/resources/batches.rb b/lib/openai/resources/batches.rb index 8f0799eb..143a05ee 100644 --- a/lib/openai/resources/batches.rb +++ b/lib/openai/resources/batches.rb @@ -11,9 +11,9 @@ class Batches # is supported. # # @option params [Symbol, OpenAI::Models::BatchCreateParams::Endpoint] :endpoint The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. # # @option params [String] :input_file_id The ID of an uploaded file that contains requests for the new batch. # @@ -58,7 +58,7 @@ def create(params) def retrieve(batch_id, params = {}) @client.request( method: :get, - path: ["batches/%0s", batch_id], + path: ["batches/%1$s", batch_id], model: OpenAI::Models::Batch, options: params[:request_options] ) @@ -105,7 +105,7 @@ def list(params = {}) def cancel(batch_id, params = {}) @client.request( method: :post, - path: ["batches/%0s/cancel", batch_id], + path: ["batches/%1$s/cancel", batch_id], model: OpenAI::Models::Batch, options: params[:request_options] ) diff --git a/lib/openai/resources/beta/assistants.rb b/lib/openai/resources/beta/assistants.rb index 8fbb01b9..1557a813 100644 --- a/lib/openai/resources/beta/assistants.rb +++ b/lib/openai/resources/beta/assistants.rb @@ -101,7 +101,7 @@ def create(params) def retrieve(assistant_id, params = {}) @client.request( method: :get, - path: ["assistants/%0s", assistant_id], + path: ["assistants/%1$s", assistant_id], model: OpenAI::Models::Beta::Assistant, options: params[:request_options] ) @@ -187,7 +187,7 @@ def update(assistant_id, params = {}) parsed, options = OpenAI::Models::Beta::AssistantUpdateParams.dump_request(params) @client.request( method: :post, - path: ["assistants/%0s", assistant_id], + path: ["assistants/%1$s", assistant_id], body: parsed, model: OpenAI::Models::Beta::Assistant, options: options @@ -241,7 +241,7 @@ def list(params = {}) def delete(assistant_id, params = {}) @client.request( method: :delete, - path: ["assistants/%0s", assistant_id], + path: ["assistants/%1$s", assistant_id], model: OpenAI::Models::Beta::AssistantDeleted, options: params[:request_options] ) diff --git a/lib/openai/resources/beta/threads.rb b/lib/openai/resources/beta/threads.rb index d8f2e660..767bd13c 100644 --- a/lib/openai/resources/beta/threads.rb +++ b/lib/openai/resources/beta/threads.rb @@ -55,7 +55,7 @@ def create(params = {}) def retrieve(thread_id, params = {}) @client.request( method: :get, - path: ["threads/%0s", thread_id], + path: ["threads/%1$s", thread_id], model: OpenAI::Models::Beta::Thread, options: params[:request_options] ) @@ -86,7 +86,7 @@ def update(thread_id, params = {}) parsed, options = OpenAI::Models::Beta::ThreadUpdateParams.dump_request(params) @client.request( method: :post, - path: ["threads/%0s", thread_id], + path: ["threads/%1$s", thread_id], body: parsed, model: OpenAI::Models::Beta::Thread, options: options @@ -105,7 +105,7 @@ def update(thread_id, params = {}) def delete(thread_id, params = {}) @client.request( method: :delete, - path: ["threads/%0s", thread_id], + path: ["threads/%1$s", thread_id], model: OpenAI::Models::Beta::ThreadDeleted, options: params[:request_options] ) @@ -208,7 +208,10 @@ def delete(thread_id, params = {}) # @return [OpenAI::Models::Beta::Threads::Run] def create_and_run(params) parsed, options = OpenAI::Models::Beta::ThreadCreateAndRunParams.dump_request(params) - parsed.delete(:stream) + if parsed[:stream] + message = "Please use `#create_and_run_streaming` for the streaming use case." + raise ArgumentError.new(message) + end @client.request( method: :post, path: "threads/runs", @@ -315,6 +318,10 @@ def create_and_run(params) # @return [OpenAI::Stream] def create_and_run_streaming(params) parsed, options = OpenAI::Models::Beta::ThreadCreateAndRunParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create_and_run` for the non-streaming use case." + raise ArgumentError.new(message) + end parsed.store(:stream, true) @client.request( method: :post, diff --git a/lib/openai/resources/beta/threads/messages.rb b/lib/openai/resources/beta/threads/messages.rb index 4e5141de..fdcef361 100644 --- a/lib/openai/resources/beta/threads/messages.rb +++ b/lib/openai/resources/beta/threads/messages.rb @@ -37,7 +37,7 @@ def create(thread_id, params) parsed, options = OpenAI::Models::Beta::Threads::MessageCreateParams.dump_request(params) @client.request( method: :post, - path: ["threads/%0s/messages", thread_id], + path: ["threads/%1$s/messages", thread_id], body: parsed, model: OpenAI::Models::Beta::Threads::Message, options: options @@ -58,12 +58,13 @@ def create(thread_id, params) # @return [OpenAI::Models::Beta::Threads::Message] def retrieve(message_id, params) parsed, options = OpenAI::Models::Beta::Threads::MessageRetrieveParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["threads/%0s/messages/%1s", thread_id, message_id], + path: ["threads/%1$s/messages/%2$s", thread_id, message_id], model: OpenAI::Models::Beta::Threads::Message, options: options ) @@ -89,12 +90,13 @@ def retrieve(message_id, params) # @return [OpenAI::Models::Beta::Threads::Message] def update(message_id, params) parsed, options = OpenAI::Models::Beta::Threads::MessageUpdateParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["threads/%0s/messages/%1s", thread_id, message_id], + path: ["threads/%1$s/messages/%2$s", thread_id, message_id], body: parsed, model: OpenAI::Models::Beta::Threads::Message, options: options @@ -133,7 +135,7 @@ def list(thread_id, params = {}) parsed, options = OpenAI::Models::Beta::Threads::MessageListParams.dump_request(params) @client.request( method: :get, - path: ["threads/%0s/messages", thread_id], + path: ["threads/%1$s/messages", thread_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::Beta::Threads::Message, @@ -154,12 +156,13 @@ def list(thread_id, params = {}) # @return [OpenAI::Models::Beta::Threads::MessageDeleted] def delete(message_id, params) parsed, options = OpenAI::Models::Beta::Threads::MessageDeleteParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :delete, - path: ["threads/%0s/messages/%1s", thread_id, message_id], + path: ["threads/%1$s/messages/%2$s", thread_id, message_id], model: OpenAI::Models::Beta::Threads::MessageDeleted, options: options ) diff --git a/lib/openai/resources/beta/threads/runs.rb b/lib/openai/resources/beta/threads/runs.rb index 2f3b3b12..d67d31ee 100644 --- a/lib/openai/resources/beta/threads/runs.rb +++ b/lib/openai/resources/beta/threads/runs.rb @@ -125,11 +125,14 @@ class Runs # @return [OpenAI::Models::Beta::Threads::Run] def create(thread_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunCreateParams.dump_request(params) - parsed.delete(:stream) + if parsed[:stream] + message = "Please use `#create_streaming` for the streaming use case." + raise ArgumentError.new(message) + end query_params = [:include] @client.request( method: :post, - path: ["threads/%0s/runs", thread_id], + path: ["threads/%1$s/runs", thread_id], query: parsed.slice(*query_params), body: parsed.except(*query_params), model: OpenAI::Models::Beta::Threads::Run, @@ -254,11 +257,15 @@ def create(thread_id, params) # @return [OpenAI::Stream] def create_streaming(thread_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunCreateParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create` for the non-streaming use case." + raise ArgumentError.new(message) + end parsed.store(:stream, true) query_params = [:include] @client.request( method: :post, - path: ["threads/%0s/runs", thread_id], + path: ["threads/%1$s/runs", thread_id], query: parsed.slice(*query_params), headers: {"accept" => "text/event-stream"}, body: parsed.except(*query_params), @@ -282,12 +289,13 @@ def create_streaming(thread_id, params) # @return [OpenAI::Models::Beta::Threads::Run] def retrieve(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunRetrieveParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["threads/%0s/runs/%1s", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s", thread_id, run_id], model: OpenAI::Models::Beta::Threads::Run, options: options ) @@ -314,12 +322,13 @@ def retrieve(run_id, params) # @return [OpenAI::Models::Beta::Threads::Run] def update(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunUpdateParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["threads/%0s/runs/%1s", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s", thread_id, run_id], body: parsed, model: OpenAI::Models::Beta::Threads::Run, options: options @@ -355,7 +364,7 @@ def list(thread_id, params = {}) parsed, options = OpenAI::Models::Beta::Threads::RunListParams.dump_request(params) @client.request( method: :get, - path: ["threads/%0s/runs", thread_id], + path: ["threads/%1$s/runs", thread_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::Beta::Threads::Run, @@ -376,12 +385,13 @@ def list(thread_id, params = {}) # @return [OpenAI::Models::Beta::Threads::Run] def cancel(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunCancelParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["threads/%0s/runs/%1s/cancel", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s/cancel", thread_id, run_id], model: OpenAI::Models::Beta::Threads::Run, options: options ) @@ -407,13 +417,17 @@ def cancel(run_id, params) # @return [OpenAI::Models::Beta::Threads::Run] def submit_tool_outputs(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params) - parsed.delete(:stream) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") + if parsed[:stream] + message = "Please use `#submit_tool_outputs_streaming` for the streaming use case." + raise ArgumentError.new(message) end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["threads/%0s/runs/%1s/submit_tool_outputs", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id], body: parsed, model: OpenAI::Models::Beta::Threads::Run, options: options @@ -440,13 +454,18 @@ def submit_tool_outputs(run_id, params) # @return [OpenAI::Stream] def submit_tool_outputs_streaming(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params) - parsed.store(:stream, true) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") + unless parsed.fetch(:stream, true) + message = "Please use `#submit_tool_outputs` for the non-streaming use case." + raise ArgumentError.new(message) end + parsed.store(:stream, true) + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["threads/%0s/runs/%1s/submit_tool_outputs", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id], headers: {"accept" => "text/event-stream"}, body: parsed, stream: OpenAI::Stream, diff --git a/lib/openai/resources/beta/threads/runs/steps.rb b/lib/openai/resources/beta/threads/runs/steps.rb index d5c4ddb3..9d087222 100644 --- a/lib/openai/resources/beta/threads/runs/steps.rb +++ b/lib/openai/resources/beta/threads/runs/steps.rb @@ -30,15 +30,17 @@ class Steps # @return [OpenAI::Models::Beta::Threads::Runs::RunStep] def retrieve(step_id, params) parsed, options = OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end - run_id = parsed.delete(:run_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + run_id = + parsed.delete(:run_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["threads/%0s/runs/%1s/steps/%2s", thread_id, run_id, step_id], + path: ["threads/%1$s/runs/%2$s/steps/%3$s", thread_id, run_id, step_id], query: parsed, model: OpenAI::Models::Beta::Threads::Runs::RunStep, options: options @@ -83,12 +85,13 @@ def retrieve(step_id, params) # @return [OpenAI::CursorPage] def list(run_id, params) parsed, options = OpenAI::Models::Beta::Threads::Runs::StepListParams.dump_request(params) - thread_id = parsed.delete(:thread_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + thread_id = + parsed.delete(:thread_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["threads/%0s/runs/%1s/steps", thread_id, run_id], + path: ["threads/%1$s/runs/%2$s/steps", thread_id, run_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::Beta::Threads::Runs::RunStep, diff --git a/lib/openai/resources/chat/completions.rb b/lib/openai/resources/chat/completions.rb index 94e76ede..86c7172c 100644 --- a/lib/openai/resources/chat/completions.rb +++ b/lib/openai/resources/chat/completions.rb @@ -215,7 +215,10 @@ class Completions # @return [OpenAI::Models::Chat::ChatCompletion] def create(params) parsed, options = OpenAI::Models::Chat::CompletionCreateParams.dump_request(params) - parsed.delete(:stream) + if parsed[:stream] + message = "Please use `#create_streaming` for the streaming use case." + raise ArgumentError.new(message) + end @client.request( method: :post, path: "chat/completions", @@ -433,6 +436,10 @@ def create(params) # @return [OpenAI::Stream] def create_streaming(params) parsed, options = OpenAI::Models::Chat::CompletionCreateParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create` for the non-streaming use case." + raise ArgumentError.new(message) + end parsed.store(:stream, true) @client.request( method: :post, @@ -458,7 +465,7 @@ def create_streaming(params) def retrieve(completion_id, params = {}) @client.request( method: :get, - path: ["chat/completions/%0s", completion_id], + path: ["chat/completions/%1$s", completion_id], model: OpenAI::Models::Chat::ChatCompletion, options: params[:request_options] ) @@ -486,7 +493,7 @@ def update(completion_id, params) parsed, options = OpenAI::Models::Chat::CompletionUpdateParams.dump_request(params) @client.request( method: :post, - path: ["chat/completions/%0s", completion_id], + path: ["chat/completions/%1$s", completion_id], body: parsed, model: OpenAI::Models::Chat::ChatCompletion, options: options @@ -539,7 +546,7 @@ def list(params = {}) def delete(completion_id, params = {}) @client.request( method: :delete, - path: ["chat/completions/%0s", completion_id], + path: ["chat/completions/%1$s", completion_id], model: OpenAI::Models::Chat::ChatCompletionDeleted, options: params[:request_options] ) diff --git a/lib/openai/resources/chat/completions/messages.rb b/lib/openai/resources/chat/completions/messages.rb index decc122d..e40262ce 100644 --- a/lib/openai/resources/chat/completions/messages.rb +++ b/lib/openai/resources/chat/completions/messages.rb @@ -26,7 +26,7 @@ def list(completion_id, params = {}) parsed, options = OpenAI::Models::Chat::Completions::MessageListParams.dump_request(params) @client.request( method: :get, - path: ["chat/completions/%0s/messages", completion_id], + path: ["chat/completions/%1$s/messages", completion_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::Chat::ChatCompletionStoreMessage, diff --git a/lib/openai/resources/completions.rb b/lib/openai/resources/completions.rb index 79cc6805..2cf80ec1 100644 --- a/lib/openai/resources/completions.rb +++ b/lib/openai/resources/completions.rb @@ -115,7 +115,10 @@ class Completions # @return [OpenAI::Models::Completion] def create(params) parsed, options = OpenAI::Models::CompletionCreateParams.dump_request(params) - parsed.delete(:stream) + if parsed[:stream] + message = "Please use `#create_streaming` for the streaming use case." + raise ArgumentError.new(message) + end @client.request( method: :post, path: "completions", @@ -237,6 +240,10 @@ def create(params) # @return [OpenAI::Stream] def create_streaming(params) parsed, options = OpenAI::Models::CompletionCreateParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create` for the non-streaming use case." + raise ArgumentError.new(message) + end parsed.store(:stream, true) @client.request( method: :post, diff --git a/lib/openai/resources/files.rb b/lib/openai/resources/files.rb index 191387e3..d0253a42 100644 --- a/lib/openai/resources/files.rb +++ b/lib/openai/resources/files.rb @@ -61,7 +61,7 @@ def create(params) def retrieve(file_id, params = {}) @client.request( method: :get, - path: ["files/%0s", file_id], + path: ["files/%1$s", file_id], model: OpenAI::Models::FileObject, options: params[:request_options] ) @@ -111,7 +111,7 @@ def list(params = {}) def delete(file_id, params = {}) @client.request( method: :delete, - path: ["files/%0s", file_id], + path: ["files/%1$s", file_id], model: OpenAI::Models::FileDeleted, options: params[:request_options] ) @@ -125,13 +125,13 @@ def delete(file_id, params = {}) # # @option params [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :request_options # - # @return [Object] + # @return [StringIO] def content(file_id, params = {}) @client.request( method: :get, - path: ["files/%0s/content", file_id], + path: ["files/%1$s/content", file_id], headers: {"accept" => "application/binary"}, - model: OpenAI::Unknown, + model: StringIO, options: params[:request_options] ) end diff --git a/lib/openai/resources/fine_tuning/jobs.rb b/lib/openai/resources/fine_tuning/jobs.rb index 9d00777f..baf7a2cc 100644 --- a/lib/openai/resources/fine_tuning/jobs.rb +++ b/lib/openai/resources/fine_tuning/jobs.rb @@ -103,7 +103,7 @@ def create(params) def retrieve(fine_tuning_job_id, params = {}) @client.request( method: :get, - path: ["fine_tuning/jobs/%0s", fine_tuning_job_id], + path: ["fine_tuning/jobs/%1$s", fine_tuning_job_id], model: OpenAI::Models::FineTuning::FineTuningJob, options: params[:request_options] ) @@ -147,7 +147,7 @@ def list(params = {}) def cancel(fine_tuning_job_id, params = {}) @client.request( method: :post, - path: ["fine_tuning/jobs/%0s/cancel", fine_tuning_job_id], + path: ["fine_tuning/jobs/%1$s/cancel", fine_tuning_job_id], model: OpenAI::Models::FineTuning::FineTuningJob, options: params[:request_options] ) @@ -170,7 +170,7 @@ def list_events(fine_tuning_job_id, params = {}) parsed, options = OpenAI::Models::FineTuning::JobListEventsParams.dump_request(params) @client.request( method: :get, - path: ["fine_tuning/jobs/%0s/events", fine_tuning_job_id], + path: ["fine_tuning/jobs/%1$s/events", fine_tuning_job_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::FineTuning::FineTuningJobEvent, diff --git a/lib/openai/resources/fine_tuning/jobs/checkpoints.rb b/lib/openai/resources/fine_tuning/jobs/checkpoints.rb index cb4b3c18..ced20ee9 100644 --- a/lib/openai/resources/fine_tuning/jobs/checkpoints.rb +++ b/lib/openai/resources/fine_tuning/jobs/checkpoints.rb @@ -22,7 +22,7 @@ def list(fine_tuning_job_id, params = {}) parsed, options = OpenAI::Models::FineTuning::Jobs::CheckpointListParams.dump_request(params) @client.request( method: :get, - path: ["fine_tuning/jobs/%0s/checkpoints", fine_tuning_job_id], + path: ["fine_tuning/jobs/%1$s/checkpoints", fine_tuning_job_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint, diff --git a/lib/openai/resources/models.rb b/lib/openai/resources/models.rb index cff4bf06..937381d2 100644 --- a/lib/openai/resources/models.rb +++ b/lib/openai/resources/models.rb @@ -16,7 +16,7 @@ class Models def retrieve(model, params = {}) @client.request( method: :get, - path: ["models/%0s", model], + path: ["models/%1$s", model], model: OpenAI::Models::Model, options: params[:request_options] ) @@ -53,7 +53,7 @@ def list(params = {}) def delete(model, params = {}) @client.request( method: :delete, - path: ["models/%0s", model], + path: ["models/%1$s", model], model: OpenAI::Models::ModelDeleted, options: params[:request_options] ) diff --git a/lib/openai/resources/responses.rb b/lib/openai/resources/responses.rb index fdbe46bc..99f01ccb 100644 --- a/lib/openai/resources/responses.rb +++ b/lib/openai/resources/responses.rb @@ -49,8 +49,8 @@ class Responses # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. # # @option params [Integer, nil] :max_output_tokens An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and @@ -129,7 +129,10 @@ class Responses # @return [OpenAI::Models::Responses::Response] def create(params) parsed, options = OpenAI::Models::Responses::ResponseCreateParams.dump_request(params) - parsed.delete(:stream) + if parsed[:stream] + message = "Please use `#create_streaming` for the streaming use case." + raise ArgumentError.new(message) + end @client.request( method: :post, path: "responses", @@ -182,8 +185,8 @@ def create(params) # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. # # @option params [Integer, nil] :max_output_tokens An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and @@ -262,6 +265,10 @@ def create(params) # @return [OpenAI::Stream] def create_streaming(params) parsed, options = OpenAI::Models::Responses::ResponseCreateParams.dump_request(params) + unless parsed.fetch(:stream, true) + message = "Please use `#create` for the non-streaming use case." + raise ArgumentError.new(message) + end parsed.store(:stream, true) @client.request( method: :post, @@ -290,7 +297,7 @@ def retrieve(response_id, params = {}) parsed, options = OpenAI::Models::Responses::ResponseRetrieveParams.dump_request(params) @client.request( method: :get, - path: ["responses/%0s", response_id], + path: ["responses/%1$s", response_id], query: parsed, model: OpenAI::Models::Responses::Response, options: options @@ -309,7 +316,7 @@ def retrieve(response_id, params = {}) def delete(response_id, params = {}) @client.request( method: :delete, - path: ["responses/%0s", response_id], + path: ["responses/%1$s", response_id], model: NilClass, options: params[:request_options] ) diff --git a/lib/openai/resources/responses/input_items.rb b/lib/openai/resources/responses/input_items.rb index 1fe57b71..30f343fd 100644 --- a/lib/openai/resources/responses/input_items.rb +++ b/lib/openai/resources/responses/input_items.rb @@ -14,6 +14,9 @@ class InputItems # # @option params [String] :before An item ID to list items before, used in pagination. # + # @option params [Array] :include Additional fields to include in the response. See the `include` parameter for + # Response creation above for more information. + # # @option params [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. # @@ -24,15 +27,15 @@ class InputItems # # @option params [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :request_options # - # @return [OpenAI::CursorPage] + # @return [OpenAI::CursorPage] def list(response_id, params = {}) parsed, options = OpenAI::Models::Responses::InputItemListParams.dump_request(params) @client.request( method: :get, - path: ["responses/%0s/input_items", response_id], + path: ["responses/%1$s/input_items", response_id], query: parsed, page: OpenAI::CursorPage, - model: OpenAI::Models::Responses::ResponseItemList::Data, + model: OpenAI::Models::Responses::ResponseItem, options: options ) end diff --git a/lib/openai/resources/uploads.rb b/lib/openai/resources/uploads.rb index f72e4255..f50e95ed 100644 --- a/lib/openai/resources/uploads.rb +++ b/lib/openai/resources/uploads.rb @@ -68,7 +68,7 @@ def create(params) def cancel(upload_id, params = {}) @client.request( method: :post, - path: ["uploads/%0s/cancel", upload_id], + path: ["uploads/%1$s/cancel", upload_id], model: OpenAI::Models::Upload, options: params[:request_options] ) @@ -104,7 +104,7 @@ def complete(upload_id, params) parsed, options = OpenAI::Models::UploadCompleteParams.dump_request(params) @client.request( method: :post, - path: ["uploads/%0s/complete", upload_id], + path: ["uploads/%1$s/complete", upload_id], body: parsed, model: OpenAI::Models::Upload, options: options diff --git a/lib/openai/resources/uploads/parts.rb b/lib/openai/resources/uploads/parts.rb index b90eef15..ea9e8a5f 100644 --- a/lib/openai/resources/uploads/parts.rb +++ b/lib/openai/resources/uploads/parts.rb @@ -29,7 +29,7 @@ def create(upload_id, params) parsed, options = OpenAI::Models::Uploads::PartCreateParams.dump_request(params) @client.request( method: :post, - path: ["uploads/%0s/parts", upload_id], + path: ["uploads/%1$s/parts", upload_id], headers: {"content-type" => "multipart/form-data"}, body: parsed, model: OpenAI::Models::Uploads::UploadPart, diff --git a/lib/openai/resources/vector_stores.rb b/lib/openai/resources/vector_stores.rb index e60a1592..5d0fe33d 100644 --- a/lib/openai/resources/vector_stores.rb +++ b/lib/openai/resources/vector_stores.rb @@ -57,7 +57,7 @@ def create(params = {}) def retrieve(vector_store_id, params = {}) @client.request( method: :get, - path: ["vector_stores/%0s", vector_store_id], + path: ["vector_stores/%1$s", vector_store_id], model: OpenAI::Models::VectorStore, options: params[:request_options] ) @@ -87,7 +87,7 @@ def update(vector_store_id, params = {}) parsed, options = OpenAI::Models::VectorStoreUpdateParams.dump_request(params) @client.request( method: :post, - path: ["vector_stores/%0s", vector_store_id], + path: ["vector_stores/%1$s", vector_store_id], body: parsed, model: OpenAI::Models::VectorStore, options: options @@ -141,7 +141,7 @@ def list(params = {}) def delete(vector_store_id, params = {}) @client.request( method: :delete, - path: ["vector_stores/%0s", vector_store_id], + path: ["vector_stores/%1$s", vector_store_id], model: OpenAI::Models::VectorStoreDeleted, options: params[:request_options] ) @@ -172,7 +172,7 @@ def search(vector_store_id, params) parsed, options = OpenAI::Models::VectorStoreSearchParams.dump_request(params) @client.request( method: :post, - path: ["vector_stores/%0s/search", vector_store_id], + path: ["vector_stores/%1$s/search", vector_store_id], body: parsed, page: OpenAI::Page, model: OpenAI::Models::VectorStoreSearchResponse, diff --git a/lib/openai/resources/vector_stores/file_batches.rb b/lib/openai/resources/vector_stores/file_batches.rb index 7893fd17..1a9d1dae 100644 --- a/lib/openai/resources/vector_stores/file_batches.rb +++ b/lib/openai/resources/vector_stores/file_batches.rb @@ -30,7 +30,7 @@ def create(vector_store_id, params) parsed, options = OpenAI::Models::VectorStores::FileBatchCreateParams.dump_request(params) @client.request( method: :post, - path: ["vector_stores/%0s/file_batches", vector_store_id], + path: ["vector_stores/%1$s/file_batches", vector_store_id], body: parsed, model: OpenAI::Models::VectorStores::VectorStoreFileBatch, options: options @@ -50,12 +50,13 @@ def create(vector_store_id, params) # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch] def retrieve(batch_id, params) parsed, options = OpenAI::Models::VectorStores::FileBatchRetrieveParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["vector_stores/%0s/file_batches/%1s", vector_store_id, batch_id], + path: ["vector_stores/%1$s/file_batches/%2$s", vector_store_id, batch_id], model: OpenAI::Models::VectorStores::VectorStoreFileBatch, options: options ) @@ -75,12 +76,13 @@ def retrieve(batch_id, params) # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch] def cancel(batch_id, params) parsed, options = OpenAI::Models::VectorStores::FileBatchCancelParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["vector_stores/%0s/file_batches/%1s/cancel", vector_store_id, batch_id], + path: ["vector_stores/%1$s/file_batches/%2$s/cancel", vector_store_id, batch_id], model: OpenAI::Models::VectorStores::VectorStoreFileBatch, options: options ) @@ -118,12 +120,13 @@ def cancel(batch_id, params) # @return [OpenAI::CursorPage] def list_files(batch_id, params) parsed, options = OpenAI::Models::VectorStores::FileBatchListFilesParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["vector_stores/%0s/file_batches/%1s/files", vector_store_id, batch_id], + path: ["vector_stores/%1$s/file_batches/%2$s/files", vector_store_id, batch_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::VectorStores::VectorStoreFile, diff --git a/lib/openai/resources/vector_stores/files.rb b/lib/openai/resources/vector_stores/files.rb index 0c9ae2a5..57e9af60 100644 --- a/lib/openai/resources/vector_stores/files.rb +++ b/lib/openai/resources/vector_stores/files.rb @@ -32,7 +32,7 @@ def create(vector_store_id, params) parsed, options = OpenAI::Models::VectorStores::FileCreateParams.dump_request(params) @client.request( method: :post, - path: ["vector_stores/%0s/files", vector_store_id], + path: ["vector_stores/%1$s/files", vector_store_id], body: parsed, model: OpenAI::Models::VectorStores::VectorStoreFile, options: options @@ -52,12 +52,13 @@ def create(vector_store_id, params) # @return [OpenAI::Models::VectorStores::VectorStoreFile] def retrieve(file_id, params) parsed, options = OpenAI::Models::VectorStores::FileRetrieveParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["vector_stores/%0s/files/%1s", vector_store_id, file_id], + path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id], model: OpenAI::Models::VectorStores::VectorStoreFile, options: options ) @@ -82,12 +83,13 @@ def retrieve(file_id, params) # @return [OpenAI::Models::VectorStores::VectorStoreFile] def update(file_id, params) parsed, options = OpenAI::Models::VectorStores::FileUpdateParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :post, - path: ["vector_stores/%0s/files/%1s", vector_store_id, file_id], + path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id], body: parsed, model: OpenAI::Models::VectorStores::VectorStoreFile, options: options @@ -125,7 +127,7 @@ def list(vector_store_id, params = {}) parsed, options = OpenAI::Models::VectorStores::FileListParams.dump_request(params) @client.request( method: :get, - path: ["vector_stores/%0s/files", vector_store_id], + path: ["vector_stores/%1$s/files", vector_store_id], query: parsed, page: OpenAI::CursorPage, model: OpenAI::Models::VectorStores::VectorStoreFile, @@ -149,12 +151,13 @@ def list(vector_store_id, params = {}) # @return [OpenAI::Models::VectorStores::VectorStoreFileDeleted] def delete(file_id, params) parsed, options = OpenAI::Models::VectorStores::FileDeleteParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :delete, - path: ["vector_stores/%0s/files/%1s", vector_store_id, file_id], + path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id], model: OpenAI::Models::VectorStores::VectorStoreFileDeleted, options: options ) @@ -173,12 +176,13 @@ def delete(file_id, params) # @return [OpenAI::Page] def content(file_id, params) parsed, options = OpenAI::Models::VectorStores::FileContentParams.dump_request(params) - vector_store_id = parsed.delete(:vector_store_id) do - raise ArgumentError.new("missing required path argument #{_1}") - end + vector_store_id = + parsed.delete(:vector_store_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end @client.request( method: :get, - path: ["vector_stores/%0s/files/%1s/content", vector_store_id, file_id], + path: ["vector_stores/%1$s/files/%2$s/content", vector_store_id, file_id], page: OpenAI::Page, model: OpenAI::Models::VectorStores::FileContentResponse, options: options diff --git a/lib/openai/stream.rb b/lib/openai/stream.rb index 2d448ef0..d3be1bd5 100644 --- a/lib/openai/stream.rb +++ b/lib/openai/stream.rb @@ -2,36 +2,32 @@ module OpenAI # @example - # ```ruby - # stream.for_each do |event| - # puts(event) - # end - # ``` + # stream.each do |event| + # puts(event) + # end # # @example - # ```ruby - # events = stream - # .to_enum - # .lazy - # .select { _1.object_id.even? } - # .map(&:itself) - # .take(2) - # .to_a + # events = + # stream + # .lazy + # .select { _1.object_id.even? } + # .map(&:itself) + # .take(2) + # .to_a # - # events => Array - # ``` + # events => Array class Stream - include OpenAI::BaseStream + include OpenAI::Type::BaseStream # @api private # # @return [Enumerable] private def iterator # rubocop:disable Metrics/BlockLength - @iterator ||= OpenAI::Util.chain_fused(@messages) do |y| + @iterator ||= OpenAI::Util.chain_fused(@stream) do |y| consume = false - @messages.each do |msg| + @stream.each do |msg| next if consume case msg @@ -59,7 +55,7 @@ class Stream message: message ) in decoded - y << OpenAI::Converter.coerce(@model, decoded) + y << OpenAI::Type::Converter.coerce(@model, decoded) end else end diff --git a/lib/openai/transport/base_client.rb b/lib/openai/transport/base_client.rb new file mode 100644 index 00000000..fb9321c1 --- /dev/null +++ b/lib/openai/transport/base_client.rb @@ -0,0 +1,459 @@ +# frozen_string_literal: true + +module OpenAI + module Transport + # @api private + # + # @abstract + class BaseClient + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + # rubocop:disable Style/MutableConstant + PLATFORM_HEADERS = + { + "x-stainless-arch" => OpenAI::Util.arch, + "x-stainless-lang" => "ruby", + "x-stainless-os" => OpenAI::Util.os, + "x-stainless-package-version" => OpenAI::VERSION, + "x-stainless-runtime" => ::RUBY_ENGINE, + "x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION + } + # rubocop:enable Style/MutableConstant + + class << self + # @api private + # + # @param req [Hash{Symbol=>Object}] + # + # @raise [ArgumentError] + def validate!(req) + keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options] + case req + in Hash + req.each_key do |k| + unless keys.include?(k) + raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}") + end + end + else + raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}") + end + end + + # @api private + # + # @param status [Integer] + # @param headers [Hash{String=>String}, Net::HTTPHeader] + # + # @return [Boolean] + def should_retry?(status, headers:) + coerced = OpenAI::Util.coerce_boolean(headers["x-should-retry"]) + case [coerced, status] + in [true | false, _] + coerced + in [_, 408 | 409 | 429 | (500..)] + # retry on: + # 408: timeouts + # 409: locks + # 429: rate limits + # 500+: unknown errors + true + else + false + end + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param status [Integer] + # + # @param response_headers [Hash{String=>String}, Net::HTTPHeader] + # + # @return [Hash{Symbol=>Object}] + def follow_redirect(request, status:, response_headers:) + method, url, headers = request.fetch_values(:method, :url, :headers) + location = + Kernel.then do + URI.join(url, response_headers["location"]) + rescue ArgumentError + message = "Server responded with status #{status} but no valid location header." + raise OpenAI::APIConnectionError.new(url: url, message: message) + end + + request = {**request, url: location} + + case [url.scheme, location.scheme] + in ["https", "http"] + message = "Tried to redirect to a insecure URL" + raise OpenAI::APIConnectionError.new(url: url, message: message) + else + nil + end + + # from whatwg fetch spec + case [status, method] + in [301 | 302, :post] | [303, _] + drop = %w[content-encoding content-language content-length content-location content-type] + request = { + **request, + method: method == :head ? :head : :get, + headers: headers.except(*drop), + body: nil + } + else + end + + # from undici + if OpenAI::Util.uri_origin(url) != OpenAI::Util.uri_origin(location) + drop = %w[authorization cookie host proxy-authorization] + request = {**request, headers: request.fetch(:headers).except(*drop)} + end + + request + end + + # @api private + # + # @param status [Integer, OpenAI::APIConnectionError] + # @param stream [Enumerable, nil] + def reap_connection!(status, stream:) + case status + in (..199) | (300..499) + stream&.each { next } + in OpenAI::APIConnectionError | (500..) + OpenAI::Util.close_fused!(stream) + else + end + end + end + + # @api private + # @return [OpenAI::Transport::PooledNetRequester] + attr_accessor :requester + + # @api private + # + # @param base_url [String] + # @param timeout [Float] + # @param max_retries [Integer] + # @param initial_retry_delay [Float] + # @param max_retry_delay [Float] + # @param headers [Hash{String=>String, Integer, Array, nil}] + # @param idempotency_header [String, nil] + def initialize( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + @requester = OpenAI::Transport::PooledNetRequester.new + @headers = OpenAI::Util.normalized_headers( + self.class::PLATFORM_HEADERS, + { + "accept" => "application/json", + "content-type" => "application/json" + }, + headers + ) + @base_url = OpenAI::Util.parse_uri(base_url) + @idempotency_header = idempotency_header&.to_s&.downcase + @max_retries = max_retries + @timeout = timeout + @initial_retry_delay = initial_retry_delay + @max_retry_delay = max_retry_delay + end + + # @api private + # + # @return [Hash{String=>String}] + private def auth_headers = {} + + # @api private + # + # @return [String] + private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}" + + # @api private + # + # @param req [Hash{Symbol=>Object}] . + # + # @option req [Symbol] :method + # + # @option req [String, Array] :path + # + # @option req [Hash{String=>Array, String, nil}, nil] :query + # + # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers + # + # @option req [Object, nil] :body + # + # @option req [Symbol, nil] :unwrap + # + # @option req [Class, nil] :page + # + # @option req [Class, nil] :stream + # + # @option req [OpenAI::Type::Converter, Class, nil] :model + # + # @param opts [Hash{Symbol=>Object}] . + # + # @option opts [String, nil] :idempotency_key + # + # @option opts [Hash{String=>Array, String, nil}, nil] :extra_query + # + # @option opts [Hash{String=>String, nil}, nil] :extra_headers + # + # @option opts [Object, nil] :extra_body + # + # @option opts [Integer, nil] :max_retries + # + # @option opts [Float, nil] :timeout + # + # @return [Hash{Symbol=>Object}] + private def build_request(req, opts) + method, uninterpolated_path = req.fetch_values(:method, :path) + + path = OpenAI::Util.interpolate_path(uninterpolated_path) + + query = OpenAI::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h) + + headers = OpenAI::Util.normalized_headers( + @headers, + auth_headers, + req[:headers].to_h, + opts[:extra_headers].to_h + ) + + if @idempotency_header && + !headers.key?(@idempotency_header) && + !Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) + headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key } + end + + unless headers.key?("x-stainless-retry-count") + headers["x-stainless-retry-count"] = "0" + end + + timeout = opts.fetch(:timeout, @timeout).to_f.clamp((0..)) + unless headers.key?("x-stainless-timeout") || timeout.zero? + headers["x-stainless-timeout"] = timeout.to_s + end + + headers.reject! { |_, v| v.to_s.empty? } + + body = + case method + in :get | :head | :options | :trace + nil + else + OpenAI::Util.deep_merge(*[req[:body], opts[:extra_body]].compact) + end + + headers, encoded = OpenAI::Util.encode_content(headers, body) + { + method: method, + url: OpenAI::Util.join_parsed_uri(@base_url, {**req, path: path, query: query}), + headers: headers, + body: encoded, + max_retries: opts.fetch(:max_retries, @max_retries), + timeout: timeout + } + end + + # @api private + # + # @param headers [Hash{String=>String}] + # @param retry_count [Integer] + # + # @return [Float] + private def retry_delay(headers, retry_count:) + # Non-standard extension + span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 } + return span if span + + retry_header = headers["retry-after"] + return span if (span = Float(retry_header, exception: false)) + + span = retry_header&.then do + Time.httpdate(_1) - Time.now + rescue ArgumentError + nil + end + return span if span + + scale = retry_count**2 + jitter = 1 - (0.25 * rand) + (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param redirect_count [Integer] + # + # @param retry_count [Integer] + # + # @param send_retry_header [Boolean] + # + # @raise [OpenAI::APIError] + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + private def send_request(request, redirect_count:, retry_count:, send_retry_header:) + url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout) + input = {**request.except(:timeout), deadline: OpenAI::Util.monotonic_secs + timeout} + + if send_retry_header + headers["x-stainless-retry-count"] = retry_count.to_s + end + + begin + status, response, stream = @requester.execute(input) + rescue OpenAI::APIConnectionError => e + status = e + end + + case status + in ..299 + [status, response, stream] + in 300..399 if redirect_count >= self.class::MAX_REDIRECTS + self.class.reap_connection!(status, stream: stream) + + message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects." + raise OpenAI::APIConnectionError.new(url: url, message: message) + in 300..399 + self.class.reap_connection!(status, stream: stream) + + request = self.class.follow_redirect(request, status: status, response_headers: response) + send_request( + request, + redirect_count: redirect_count + 1, + retry_count: retry_count, + send_retry_header: send_retry_header + ) + in OpenAI::APIConnectionError if retry_count >= max_retries + raise status + in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response) + decoded = Kernel.then do + OpenAI::Util.decode_content(response, stream: stream, suppress_error: true) + ensure + self.class.reap_connection!(status, stream: stream) + end + + raise OpenAI::APIStatusError.for( + url: url, + status: status, + body: decoded, + request: nil, + response: response + ) + in (400..) | OpenAI::APIConnectionError + self.class.reap_connection!(status, stream: stream) + + delay = retry_delay(response, retry_count: retry_count) + sleep(delay) + + send_request( + request, + redirect_count: redirect_count, + retry_count: retry_count + 1, + send_retry_header: send_retry_header + ) + end + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + # + # @param req [Hash{Symbol=>Object}] . + # + # @option req [Symbol] :method + # + # @option req [String, Array] :path + # + # @option req [Hash{String=>Array, String, nil}, nil] :query + # + # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers + # + # @option req [Object, nil] :body + # + # @option req [Symbol, nil] :unwrap + # + # @option req [Class, nil] :page + # + # @option req [Class, nil] :stream + # + # @option req [OpenAI::Type::Converter, Class, nil] :model + # + # @option req [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] :options + # + # @raise [OpenAI::APIError] + # @return [Object] + def request(req) + self.class.validate!(req) + model = req.fetch(:model) { OpenAI::Unknown } + opts = req[:options].to_h + OpenAI::RequestOptions.validate!(opts) + request = build_request(req.except(:options), opts) + url = request.fetch(:url) + + # Don't send the current retry count in the headers if the caller modified the header defaults. + send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0" + status, response, stream = send_request( + request, + redirect_count: 0, + retry_count: 0, + send_retry_header: send_retry_header + ) + + decoded = OpenAI::Util.decode_content(response, stream: stream) + case req + in { stream: Class => st } + st.new(model: model, url: url, status: status, response: response, stream: decoded) + in { page: Class => page } + page.new(client: self, req: req, headers: response, page_data: decoded) + else + unwrapped = OpenAI::Util.dig(decoded, req[:unwrap]) + OpenAI::Type::Converter.coerce(model, unwrapped) + end + end + + # @return [String] + def inspect + # rubocop:disable Layout/LineLength + base_url = OpenAI::Util.unparse_uri(@base_url) + "#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{base_url} max_retries=#{@max_retries} timeout=#{@timeout}>" + # rubocop:enable Layout/LineLength + end + end + end +end diff --git a/lib/openai/transport/pooled_net_requester.rb b/lib/openai/transport/pooled_net_requester.rb new file mode 100644 index 00000000..57c8bf5e --- /dev/null +++ b/lib/openai/transport/pooled_net_requester.rb @@ -0,0 +1,182 @@ +# frozen_string_literal: true + +module OpenAI + module Transport + # @api private + class PooledNetRequester + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + class << self + # @api private + # + # @param url [URI::Generic] + # + # @return [Net::HTTP] + def connect(url) + port = + case [url.port, url.scheme] + in [Integer, _] + url.port + in [nil, "http" | "ws"] + Net::HTTP.http_default_port + in [nil, "https" | "wss"] + Net::HTTP.https_default_port + end + + Net::HTTP.new(url.host, port).tap do + _1.use_ssl = %w[https wss].include?(url.scheme) + _1.max_retries = 0 + end + end + + # @api private + # + # @param conn [Net::HTTP] + # @param deadline [Float] + def calibrate_socket_timeout(conn, deadline) + timeout = deadline - OpenAI::Util.monotonic_secs + conn.open_timeout = conn.read_timeout = conn.write_timeout = conn.continue_timeout = timeout + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @param blk [Proc] + # + # @yieldparam [String] + # @return [Net::HTTPGenericRequest] + def build_request(request, &blk) + method, url, headers, body = request.fetch_values(:method, :url, :headers, :body) + req = Net::HTTPGenericRequest.new( + method.to_s.upcase, + !body.nil?, + method != :head, + url.to_s + ) + + headers.each { req[_1] = _2 } + + case body + in nil + nil + in String + req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] + req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &blk) + in StringIO + req["content-length"] ||= body.size.to_s unless req["transfer-encoding"] + req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &blk) + in IO | Enumerator + req["transfer-encoding"] ||= "chunked" unless req["content-length"] + req.body_stream = OpenAI::Util::ReadIOAdapter.new(body, &blk) + end + + req + end + end + + # @api private + # + # @param url [URI::Generic] + # @param deadline [Float] + # @param blk [Proc] + # + # @raise [Timeout::Error] + # @yieldparam [Net::HTTP] + private def with_pool(url, deadline:, &blk) + origin = OpenAI::Util.uri_origin(url) + timeout = deadline - OpenAI::Util.monotonic_secs + pool = + @mutex.synchronize do + @pools[origin] ||= ConnectionPool.new(size: @size) do + self.class.connect(url) + end + end + + pool.with(timeout: timeout, &blk) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Float] :deadline + # + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + def execute(request) + url, deadline = request.fetch_values(:url, :deadline) + + eof = false + finished = false + enum = Enumerator.new do |y| + with_pool(url, deadline: deadline) do |conn| + next if finished + + req = self.class.build_request(request) do + self.class.calibrate_socket_timeout(conn, deadline) + end + + self.class.calibrate_socket_timeout(conn, deadline) + unless conn.started? + conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT + conn.start + end + + self.class.calibrate_socket_timeout(conn, deadline) + conn.request(req) do |rsp| + y << [conn, req, rsp] + break if finished + + rsp.read_body do |bytes| + y << bytes + break if finished + + self.class.calibrate_socket_timeout(conn, deadline) + end + eof = true + end + end + rescue Timeout::Error + raise OpenAI::APITimeoutError + end + + conn, _, response = enum.next + body = OpenAI::Util.fused_enum(enum, external: true) do + finished = true + tap do + enum.next + rescue StopIteration + nil + end + conn.finish if !eof && conn&.started? + end + [Integer(response.code), response, (response.body = body)] + end + + # @api private + # + # @param size [Integer] + def initialize(size: Etc.nprocessors) + @mutex = Mutex.new + @size = size + @pools = {} + end + end + end +end diff --git a/lib/openai/type.rb b/lib/openai/type.rb new file mode 100644 index 00000000..f4b8345c --- /dev/null +++ b/lib/openai/type.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module OpenAI + Unknown = OpenAI::Type::Unknown + + BooleanModel = OpenAI::Type::BooleanModel + + Enum = OpenAI::Type::Enum + + Union = OpenAI::Type::Union + + ArrayOf = OpenAI::Type::ArrayOf + + HashOf = OpenAI::Type::HashOf + + BaseModel = OpenAI::Type::BaseModel + + RequestParameters = OpenAI::Type::RequestParameters + + # This module contains various type declarations. + module Type + end +end diff --git a/lib/openai/type/array_of.rb b/lib/openai/type/array_of.rb new file mode 100644 index 00000000..35bb520d --- /dev/null +++ b/lib/openai/type/array_of.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # @abstract + # + # Array of items of a given type. + class ArrayOf + include OpenAI::Type::Converter + + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def self.[](type_info, spec = {}) = new(type_info, spec) + + # @param other [Object] + # + # @return [Boolean] + def ===(other) = other.is_a?(Array) && other.all?(item_type) + + # @param other [Object] + # + # @return [Boolean] + def ==(other) + other.is_a?(OpenAI::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type + end + + # @api private + # + # @param value [Enumerable, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Array, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Array) + exactness[:no] += 1 + return value + end + + target = item_type + exactness[:yes] += 1 + value + .map do |item| + case [nilable?, item] + in [true, nil] + exactness[:yes] += 1 + nil + else + OpenAI::Type::Converter.coerce(target, item, state: state) + end + end + end + + # @api private + # + # @param value [Enumerable, Object] + # + # @return [Array, Object] + def dump(value) + target = item_type + value.is_a?(Array) ? value.map { OpenAI::Type::Converter.dump(target, _1) } : super + end + + # @api private + # + # @return [OpenAI::Type::Converter, Class] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = OpenAI::Type::Converter.type_info(type_info || spec) + @nilable = spec[:nil?] + end + end + end +end diff --git a/lib/openai/type/base_model.rb b/lib/openai/type/base_model.rb new file mode 100644 index 00000000..57f628f0 --- /dev/null +++ b/lib/openai/type/base_model.rb @@ -0,0 +1,357 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @abstract + # + # @example + # # `comparison_filter` is a `OpenAI::Models::ComparisonFilter` + # comparison_filter => { + # key: key, + # type: type, + # value: value + # } + class BaseModel + extend OpenAI::Type::Converter + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def known_fields + @known_fields ||= (self < OpenAI::BaseModel ? superclass.known_fields.dup : {}) + end + + # @api private + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def fields + known_fields.transform_values do |field| + {**field.except(:type_fn), type: field.fetch(:type_fn).call} + end + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param required [Boolean] + # + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def add_field(name_sym, required:, type_info:, spec:) + type_fn, info = + case type_info + in Proc | OpenAI::Type::Converter | Class + [OpenAI::Type::Converter.type_info({**spec, union: type_info}), spec] + in Hash + [OpenAI::Type::Converter.type_info(type_info), type_info] + end + + setter = "#{name_sym}=" + api_name = info.fetch(:api_name, name_sym) + nilable = info[:nil?] + const = required && !nilable ? info.fetch(:const, OpenAI::Util::OMIT) : OpenAI::Util::OMIT + + [name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym) + + known_fields[name_sym] = + { + mode: @mode, + api_name: api_name, + required: required, + nilable: nilable, + const: const, + type_fn: type_fn + } + + define_method(setter) { @data.store(name_sym, _1) } + + define_method(name_sym) do + target = type_fn.call + value = @data.fetch(name_sym) { const == OpenAI::Util::OMIT ? nil : const } + state = {strictness: :strong, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + if (nilable || !required) && value.nil? + nil + else + OpenAI::Type::Converter.coerce( + target, + value, + state: state + ) + end + rescue StandardError + cls = self.class.name.split("::").last + # rubocop:disable Layout/LineLength + message = "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}. To get the unparsed API response, use #{cls}[:#{__method__}]." + # rubocop:enable Layout/LineLength + raise OpenAI::ConversionError.new(message) + end + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def required(name_sym, type_info, spec = {}) + add_field(name_sym, required: true, type_info: type_info, spec: spec) + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def optional(name_sym, type_info, spec = {}) + add_field(name_sym, required: false, type_info: type_info, spec: spec) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + # + # @param blk [Proc] + private def request_only(&blk) + @mode = :dump + blk.call + ensure + @mode = nil + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + # + # @param blk [Proc] + private def response_only(&blk) + @mode = :coerce + blk.call + ensure + @mode = nil + end + + # @param other [Object] + # + # @return [Boolean] + def ==(other) = other.is_a?(Class) && other <= OpenAI::BaseModel && other.fields == fields + end + + # @param other [Object] + # + # @return [Boolean] + def ==(other) = self.class == other.class && @data == other.to_h + + class << self + # @api private + # + # @param value [OpenAI::BaseModel, Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [OpenAI::BaseModel, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + if value.is_a?(self.class) + exactness[:yes] += 1 + return value + end + + unless (val = OpenAI::Util.coerce_hash(value)).is_a?(Hash) + exactness[:no] += 1 + return value + end + exactness[:yes] += 1 + + keys = val.keys.to_set + instance = new + data = instance.to_h + + # rubocop:disable Metrics/BlockLength + fields.each do |name, field| + mode, required, target = field.fetch_values(:mode, :required, :type) + api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const) + + unless val.key?(api_name) + if required && mode != :dump && const == OpenAI::Util::OMIT + exactness[nilable ? :maybe : :no] += 1 + else + exactness[:yes] += 1 + end + next + end + + item = val.fetch(api_name) + keys.delete(api_name) + + converted = + if item.nil? && (nilable || !required) + exactness[nilable ? :yes : :maybe] += 1 + nil + else + coerced = OpenAI::Type::Converter.coerce(target, item, state: state) + case target + in OpenAI::Type::Converter | Symbol + coerced + else + item + end + end + data.store(name, converted) + end + # rubocop:enable Metrics/BlockLength + + keys.each { data.store(_1, val.fetch(_1)) } + instance + end + + # @api private + # + # @param value [OpenAI::BaseModel, Object] + # + # @return [Hash{Object=>Object}, Object] + def dump(value) + unless (coerced = OpenAI::Util.coerce_hash(value)).is_a?(Hash) + return super + end + + acc = {} + + coerced.each do |key, val| + name = key.is_a?(String) ? key.to_sym : key + case (field = known_fields[name]) + in nil + acc.store(name, super(val)) + else + mode, api_name, type_fn = field.fetch_values(:mode, :api_name, :type_fn) + case mode + in :coerce + next + else + target = type_fn.call + acc.store(api_name, OpenAI::Type::Converter.dump(target, val)) + end + end + end + + known_fields.each_value do |field| + mode, api_name, const = field.fetch_values(:mode, :api_name, :const) + next if mode == :coerce || acc.key?(api_name) || const == OpenAI::Util::OMIT + acc.store(api_name, const) + end + + acc + end + end + + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + # + # @param key [Symbol] + # + # @return [Object, nil] + def [](key) + unless key.instance_of?(Symbol) + raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}") + end + + @data[key] + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + # + # @return [Hash{Symbol=>Object}] + def to_h = @data + + alias_method :to_hash, :to_h + + # @param keys [Array, nil] + # + # @return [Hash{Symbol=>Object}] + def deconstruct_keys(keys) + (keys || self.class.known_fields.keys) + .filter_map do |k| + unless self.class.known_fields.key?(k) + next + end + + [k, public_send(k)] + end + .to_h + end + + # Create a new instance of a model. + # + # @param data [Hash{Symbol=>Object}, OpenAI::BaseModel] + def initialize(data = {}) + case OpenAI::Util.coerce_hash(data) + in Hash => coerced + @data = coerced + else + raise ArgumentError.new("Expected a #{Hash} or #{OpenAI::BaseModel}, got #{data.inspect}") + end + end + + # @return [String] + def inspect + rows = self.class.known_fields.keys.map do + "#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}" + rescue OpenAI::ConversionError + "#{_1}=#{@data.fetch(_1)}" + end + "#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>" + end + end + end +end diff --git a/lib/openai/type/base_page.rb b/lib/openai/type/base_page.rb new file mode 100644 index 00000000..5f9ee0fa --- /dev/null +++ b/lib/openai/type/base_page.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @example + # if page.has_next? + # page = page.next_page + # end + # + # @example + # page.auto_paging_each do |completion| + # puts(completion) + # end + # + # @example + # completions = + # page + # .to_enum + # .lazy + # .select { _1.object_id.even? } + # .map(&:itself) + # .take(2) + # .to_a + # + # completions => Array + module BasePage + # rubocop:disable Lint/UnusedMethodArgument + + # @return [Boolean] + def next_page? = (raise NotImplementedError) + + # @raise [OpenAI::APIError] + # @return [OpenAI::Type::BasePage] + def next_page = (raise NotImplementedError) + + # @param blk [Proc] + # + # @return [void] + def auto_paging_each(&blk) = (raise NotImplementedError) + + # @return [Enumerable] + def to_enum = super(:auto_paging_each) + + alias_method :enum_for, :to_enum + + # @api private + # + # @param client [OpenAI::Transport::BaseClient] + # @param req [Hash{Symbol=>Object}] + # @param headers [Hash{String=>String}, Net::HTTPHeader] + # @param page_data [Object] + def initialize(client:, req:, headers:, page_data:) + @client = client + @req = req + super() + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end +end diff --git a/lib/openai/type/base_stream.rb b/lib/openai/type/base_stream.rb new file mode 100644 index 00000000..98f2b576 --- /dev/null +++ b/lib/openai/type/base_stream.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @example + # stream.each do |chunk| + # puts(chunk) + # end + # + # @example + # chunks = + # stream + # .lazy + # .select { _1.object_id.even? } + # .map(&:itself) + # .take(2) + # .to_a + # + # chunks => Array + module BaseStream + include Enumerable + + # @return [void] + def close = OpenAI::Util.close_fused!(@iterator) + + # @api private + # + # @return [Enumerable] + private def iterator = (raise NotImplementedError) + + # @param blk [Proc] + # + # @return [void] + def each(&blk) + unless block_given? + raise ArgumentError.new("A block must be given to ##{__method__}") + end + @iterator.each(&blk) + end + + # @return [Enumerator] + def to_enum = @iterator + + alias_method :enum_for, :to_enum + + # @api private + # + # @param model [Class, OpenAI::Type::Converter] + # @param url [URI::Generic] + # @param status [Integer] + # @param response [Net::HTTPResponse] + # @param stream [Enumerable] + def initialize(model:, url:, status:, response:, stream:) + @model = model + @url = url + @status = status + @response = response + @stream = stream + @iterator = iterator + end + end + end +end diff --git a/lib/openai/type/boolean_model.rb b/lib/openai/type/boolean_model.rb new file mode 100644 index 00000000..9ee84edd --- /dev/null +++ b/lib/openai/type/boolean_model.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # @abstract + # + # Ruby has no Boolean class; this is something for models to refer to. + class BooleanModel + extend OpenAI::Type::Converter + + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = other == true || other == false + + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= OpenAI::BooleanModel + + class << self + # @api private + # + # @param value [Boolean, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Boolean, Object] + def coerce(value, state:) + state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1 + value + end + + # @!parse + # # @api private + # # + # # @param value [Boolean, Object] + # # + # # @return [Boolean, Object] + # def dump(value) = super + end + end + end +end diff --git a/lib/openai/type/converter.rb b/lib/openai/type/converter.rb new file mode 100644 index 00000000..8a4739ea --- /dev/null +++ b/lib/openai/type/converter.rb @@ -0,0 +1,217 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # rubocop:disable Metrics/ModuleLength + # @api private + module Converter + # rubocop:disable Lint/UnusedMethodArgument + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) = (raise NotImplementedError) + + # @api private + # + # @param value [Object] + # + # @return [Object] + def dump(value) + case value + in Array + value.map { OpenAI::Unknown.dump(_1) } + in Hash + value.transform_values { OpenAI::Unknown.dump(_1) } + in OpenAI::BaseModel + value.class.dump(value) + else + value + end + end + + # rubocop:enable Lint/UnusedMethodArgument + + class << self + # @api private + # + # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [Proc] + def type_info(spec) + case spec + in Proc + spec + in Hash + type_info(spec.slice(:const, :enum, :union).first&.last) + in true | false + -> { OpenAI::BooleanModel } + in OpenAI::Type::Converter | Class | Symbol + -> { spec } + in NilClass | Integer | Float + -> { spec.class } + end + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + # + # @param target [OpenAI::Type::Converter, Class] + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`, or `:strong`. This informs the + # coercion strategy when we have to decide between multiple possible conversion + # targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # - `:strong`: the conversion must be exact, with no coercion, and raise an error + # if not possible. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce( + target, + value, + state: {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + ) + # rubocop:disable Lint/SuppressedException + # rubocop:disable Metrics/BlockNesting + strictness, exactness = state.fetch_values(:strictness, :exactness) + + case target + in OpenAI::Type::Converter + return target.coerce(value, state: state) + in Class + if value.is_a?(target) + exactness[:yes] += 1 + return value + end + + case target + in -> { _1 <= NilClass } + exactness[value.nil? ? :yes : :maybe] += 1 + return nil + in -> { _1 <= Integer } + if value.is_a?(Integer) + exactness[:yes] += 1 + return value + elsif strictness == :strong + message = "no implicit conversion of #{value.class} into #{target.inspect}" + raise TypeError.new(message) + else + Kernel.then do + return Integer(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError + end + end + in -> { _1 <= Float } + if value.is_a?(Numeric) + exactness[:yes] += 1 + return Float(value) + elsif strictness == :strong + message = "no implicit conversion of #{value.class} into #{target.inspect}" + raise TypeError.new(message) + else + Kernel.then do + return Float(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError + end + end + in -> { _1 <= String } + case value + in String | Symbol | Numeric + exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1 + return value.to_s + else + if strictness == :strong + message = "no implicit conversion of #{value.class} into #{target.inspect}" + raise TypeError.new(message) + end + end + in -> { _1 <= Date || _1 <= Time } + Kernel.then do + return target.parse(value).tap { exactness[:yes] += 1 } + rescue ArgumentError, TypeError => e + raise e if strictness == :strong + end + in -> { _1 <= IO } if value.is_a?(String) + exactness[:yes] += 1 + return StringIO.new(value.b) + else + end + in Symbol + if (value.is_a?(Symbol) || value.is_a?(String)) && value.to_sym == target + exactness[:yes] += 1 + return target + elsif strictness == :strong + message = "cannot convert non-matching #{value.class} into #{target.inspect}" + raise ArgumentError.new(message) + end + else + end + + exactness[:no] += 1 + value + # rubocop:enable Metrics/BlockNesting + # rubocop:enable Lint/SuppressedException + end + + # @api private + # + # @param target [OpenAI::Type::Converter, Class] + # @param value [Object] + # + # @return [Object] + def dump(target, value) + target.is_a?(OpenAI::Type::Converter) ? target.dump(value) : OpenAI::Unknown.dump(value) + end + end + end + # rubocop:enable Metrics/ModuleLength + end +end diff --git a/lib/openai/type/enum.rb b/lib/openai/type/enum.rb new file mode 100644 index 00000000..2518da97 --- /dev/null +++ b/lib/openai/type/enum.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + # + # @example + # # `chat_model` is a `OpenAI::Models::ChatModel` + # case chat_model + # when OpenAI::Models::ChatModel::O3_MINI + # # ... + # when OpenAI::Models::ChatModel::O3_MINI_2025_01_31 + # # ... + # when OpenAI::Models::ChatModel::O1 + # # ... + # else + # puts(chat_model) + # end + # + # @example + # case chat_model + # in :"o3-mini" + # # ... + # in :"o3-mini-2025-01-31" + # # ... + # in :o1 + # # ... + # else + # puts(chat_model) + # end + module Enum + include OpenAI::Type::Converter + + # All of the valid Symbol values for this enum. + # + # @return [Array] + def values = (@values ||= constants.map { const_get(_1) }) + + # @api private + # + # Guard against thread safety issues by instantiating `@values`. + private def finalize! = values + + # @param other [Object] + # + # @return [Boolean] + def ===(other) = values.include?(other) + + # @param other [Object] + # + # @return [Boolean] + def ==(other) + other.is_a?(Module) && other.singleton_class <= OpenAI::Enum && other.values.to_set == values.to_set + end + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + # + # @param value [String, Symbol, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Symbol, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + val = value.is_a?(String) ? value.to_sym : value + + if values.include?(val) + exactness[:yes] += 1 + val + else + exactness[values.first&.class == val.class ? :maybe : :no] += 1 + value + end + end + + # @!parse + # # @api private + # # + # # @param value [Symbol, Object] + # # + # # @return [Symbol, Object] + # def dump(value) = super + end + end +end diff --git a/lib/openai/type/hash_of.rb b/lib/openai/type/hash_of.rb new file mode 100644 index 00000000..b6760886 --- /dev/null +++ b/lib/openai/type/hash_of.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # @abstract + # + # Hash of items of a given type. + class HashOf + include OpenAI::Type::Converter + + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def self.[](type_info, spec = {}) = new(type_info, spec) + + # @param other [Object] + # + # @return [Boolean] + def ===(other) + type = item_type + case other + in Hash + other.all? do |key, val| + case [key, val] + in [Symbol | String, ^type] + true + else + false + end + end + else + false + end + end + + # @param other [Object] + # + # @return [Boolean] + def ==(other) + other.is_a?(OpenAI::HashOf) && other.nilable? == nilable? && other.item_type == item_type + end + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Hash{Symbol=>Object}, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Hash) + exactness[:no] += 1 + return value + end + + target = item_type + exactness[:yes] += 1 + value + .to_h do |key, val| + k = key.is_a?(String) ? key.to_sym : key + v = + case [nilable?, val] + in [true, nil] + exactness[:yes] += 1 + nil + else + OpenAI::Type::Converter.coerce(target, val, state: state) + end + + exactness[:no] += 1 unless k.is_a?(Symbol) + [k, v] + end + end + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @return [Hash{Symbol=>Object}, Object] + def dump(value) + target = item_type + value.is_a?(Hash) ? value.transform_values { OpenAI::Type::Converter.dump(target, _1) } : super + end + + # @api private + # + # @return [OpenAI::Type::Converter, Class] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = OpenAI::Type::Converter.type_info(type_info || spec) + @nilable = spec[:nil?] + end + end + end +end diff --git a/lib/openai/type/request_parameters.rb b/lib/openai/type/request_parameters.rb new file mode 100644 index 00000000..3d4e267e --- /dev/null +++ b/lib/openai/type/request_parameters.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + module RequestParameters + # @!parse + # # Options to specify HTTP behaviour for this request. + # # @return [OpenAI::RequestOptions, Hash{Symbol=>Object}] + # attr_accessor :request_options + + # @param mod [Module] + def self.included(mod) + return unless mod <= OpenAI::BaseModel + + mod.extend(OpenAI::Type::RequestParameters::Converter) + mod.optional(:request_options, OpenAI::RequestOptions) + end + + # @api private + module Converter + # @api private + # + # @param params [Object] + # + # @return [Array(Object, Hash{Symbol=>Object})] + def dump_request(params) + case (dumped = dump(params)) + in Hash + [dumped.except(:request_options), dumped[:request_options]] + else + [dumped, nil] + end + end + end + end + end +end diff --git a/lib/openai/type/union.rb b/lib/openai/type/union.rb new file mode 100644 index 00000000..da0bde31 --- /dev/null +++ b/lib/openai/type/union.rb @@ -0,0 +1,210 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # @example + # # `chat_completion_content_part` is a `OpenAI::Models::Chat::ChatCompletionContentPart` + # case chat_completion_content_part + # when OpenAI::Models::Chat::ChatCompletionContentPartText + # puts(chat_completion_content_part.text) + # when OpenAI::Models::Chat::ChatCompletionContentPartImage + # puts(chat_completion_content_part.image_url) + # when OpenAI::Models::Chat::ChatCompletionContentPartInputAudio + # puts(chat_completion_content_part.input_audio) + # else + # puts(chat_completion_content_part) + # end + # + # @example + # case chat_completion_content_part + # in {type: :text, text: text} + # puts(text) + # in {type: :image_url, image_url: image_url} + # puts(image_url) + # in {type: :input_audio, input_audio: input_audio} + # puts(input_audio) + # else + # puts(chat_completion_content_part) + # end + module Union + include OpenAI::Type::Converter + + # @api private + # + # All of the specified variant info for this union. + # + # @return [Array] + private def known_variants = (@known_variants ||= []) + + # @api private + # + # @return [Array] + protected def derefed_variants + @known_variants.map { |key, variant_fn| [key, variant_fn.call] } + end + + # All of the specified variants for this union. + # + # @return [Array] + def variants = derefed_variants.map(&:last) + + # @api private + # + # @param property [Symbol] + private def discriminator(property) + case property + in Symbol + @discriminator = property + end + end + + # @api private + # + # @param key [Symbol, Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def variant(key, spec = nil) + variant_info = + case key + in Symbol + [key, OpenAI::Type::Converter.type_info(spec)] + in Proc | OpenAI::Type::Converter | Class | Hash + [nil, OpenAI::Type::Converter.type_info(key)] + end + + known_variants << variant_info + end + + # @api private + # + # @param value [Object] + # + # @return [OpenAI::Type::Converter, Class, nil] + private def resolve_variant(value) + case [@discriminator, value] + in [_, OpenAI::BaseModel] + value.class + in [Symbol, Hash] + key = value.fetch(@discriminator) do + value.fetch(@discriminator.to_s, OpenAI::Util::OMIT) + end + + return nil if key == OpenAI::Util::OMIT + + key = key.to_sym if key.is_a?(String) + known_variants.find { |k,| k == key }&.last&.call + else + nil + end + end + + # rubocop:disable Style/HashEachMethods + # rubocop:disable Style/CaseEquality + + # @param other [Object] + # + # @return [Boolean] + def ===(other) + known_variants.any? do |_, variant_fn| + variant_fn.call === other + end + end + + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Layout/LineLength + other.is_a?(Module) && other.singleton_class <= OpenAI::Union && other.derefed_variants == derefed_variants + # rubocop:enable Layout/LineLength + end + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + if (target = resolve_variant(value)) + return OpenAI::Type::Converter.coerce(target, value, state: state) + end + + strictness = state.fetch(:strictness) + exactness = state.fetch(:exactness) + state[:strictness] = strictness == :strong ? true : strictness + + alternatives = [] + known_variants.each do |_, variant_fn| + target = variant_fn.call + exact = state[:exactness] = {yes: 0, no: 0, maybe: 0} + state[:branched] += 1 + + coerced = OpenAI::Type::Converter.coerce(target, value, state: state) + yes, no, maybe = exact.values + if (no + maybe).zero? || (!strictness && yes.positive?) + exact.each { exactness[_1] += _2 } + state[:exactness] = exactness + return coerced + elsif maybe.positive? + alternatives << [[-yes, -maybe, no], exact, coerced] + end + end + + case alternatives.sort_by(&:first) + in [] + exactness[:no] += 1 + if strictness == :strong + message = "no possible conversion of #{value.class} into a variant of #{target.inspect}" + raise ArgumentError.new(message) + end + value + in [[_, exact, coerced], *] + exact.each { exactness[_1] += _2 } + coerced + end + .tap { state[:exactness] = exactness } + ensure + state[:strictness] = strictness + end + + # @api private + # + # @param value [Object] + # + # @return [Object] + def dump(value) + if (target = resolve_variant(value)) + return OpenAI::Type::Converter.dump(target, value) + end + + known_variants.each do + target = _2.call + return OpenAI::Type::Converter.dump(target, value) if target === value + end + + super + end + + # rubocop:enable Style/CaseEquality + # rubocop:enable Style/HashEachMethods + end + end +end diff --git a/lib/openai/type/unknown.rb b/lib/openai/type/unknown.rb new file mode 100644 index 00000000..7cb2567d --- /dev/null +++ b/lib/openai/type/unknown.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module OpenAI + module Type + # @api private + # + # @abstract + # + # When we don't know what to expect for the value. + class Unknown + extend OpenAI::Type::Converter + + # rubocop:disable Lint/UnusedMethodArgument + + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = true + + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= OpenAI::Unknown + + class << self + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean, :strong] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + state.fetch(:exactness)[:yes] += 1 + value + end + + # @!parse + # # @api private + # # + # # @param value [Object] + # # + # # @return [Object] + # def dump(value) = super + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end +end diff --git a/lib/openai/util.rb b/lib/openai/util.rb index ef208d81..8a4b693f 100644 --- a/lib/openai/util.rb +++ b/lib/openai/util.rb @@ -75,7 +75,7 @@ def primitive?(input) def coerce_boolean(input) case input.is_a?(String) ? input.downcase : input in Numeric - !input.zero? + input.nonzero? in "true" true in "false" @@ -165,14 +165,12 @@ class << self private def deep_merge_lr(lhs, rhs, concat: false) case [lhs, rhs, concat] in [Hash, Hash, _] - # rubocop:disable Style/YodaCondition - rhs_cleaned = rhs.reject { |_, val| OMIT == val } + rhs_cleaned = rhs.reject { _2 == OpenAI::Util::OMIT } lhs - .reject { |key, _| OMIT == rhs[key] } + .reject { |key, _| rhs[key] == OpenAI::Util::OMIT } .merge(rhs_cleaned) do |_, old_val, new_val| deep_merge_lr(old_val, new_val, concat: concat) end - # rubocop:enable Style/YodaCondition in [Array, Array, true] lhs.concat(rhs) else @@ -255,9 +253,9 @@ def interpolate_path(path) path in [] "" - in [String, *interpolations] + in [String => p, *interpolations] encoded = interpolations.map { ERB::Util.url_encode(_1) } - path.first % encoded + format(p, *encoded) end end end @@ -367,13 +365,14 @@ class << self # @return [Hash{String=>String}] def normalized_headers(*headers) {}.merge(*headers.compact).to_h do |key, val| - case val - in Array - val.map { _1.to_s.strip }.join(", ") - else - val&.to_s&.strip - end - [key.downcase, val] + value = + case val + in Array + val.map { _1.to_s.strip }.join(", ") + else + val&.to_s&.strip + end + [key.downcase, value] end end end @@ -428,6 +427,8 @@ def read(max_len = nil, out_string = nil) # # @param stream [String, IO, StringIO, Enumerable] # @param blk [Proc] + # + # @yieldparam [String] def initialize(stream, &blk) @stream = stream.is_a?(String) ? StringIO.new(stream) : stream @buf = String.new.b @@ -438,6 +439,7 @@ def initialize(stream, &blk) class << self # @param blk [Proc] # + # @yieldparam [Enumerator::Yielder] # @return [Enumerable] def string_io(&blk) Enumerator.new do |y| @@ -452,6 +454,8 @@ def string_io(&blk) end class << self + # rubocop:disable Naming/MethodParameterName + # @api private # # @param y [Enumerator::Yielder] @@ -490,6 +494,8 @@ class << self y << "\r\n" end + # rubocop:enable Naming/MethodParameterName + # @api private # # @param body [Object] @@ -628,6 +634,7 @@ def close_fused!(enum) # @param enum [Enumerable, nil] # @param blk [Proc] # + # @yieldparam [Enumerator::Yielder] # @return [Enumerable] def chain_fused(enum, &blk) iter = Enumerator.new { blk.call(_1) } diff --git a/lib/openai/version.rb b/lib/openai/version.rb index 8175d17f..148d7830 100644 --- a/lib/openai/version.rb +++ b/lib/openai/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module OpenAI - VERSION = "0.1.0-alpha.2" + VERSION = "0.1.0-alpha.3" end diff --git a/manifest.yaml b/manifest.yaml index fa9c3e5e..556686f5 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,4 +1,5 @@ dependencies: + - English - cgi - date - erb diff --git a/openai.gemspec b/openai.gemspec index e2cf1559..60a53a67 100644 --- a/openai.gemspec +++ b/openai.gemspec @@ -12,8 +12,8 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ["README.md"] s.required_ruby_version = ">= 3.0.0" s.add_dependency "connection_pool" - s.homepage = "https://gemdocs.org/gems/openai/latest" + s.homepage = "https://gemdocs.org/gems/openai" s.metadata["homepage_uri"] = s.homepage s.metadata["source_code_uri"] = "https://github.com/openai/openai-ruby" - s.metadata["rubygems_mfa_required"] = "false" + s.metadata["rubygems_mfa_required"] = false.to_s end diff --git a/rbi/lib/openai/base_client.rbi b/rbi/lib/openai/base_client.rbi deleted file mode 100644 index e4208ab7..00000000 --- a/rbi/lib/openai/base_client.rbi +++ /dev/null @@ -1,197 +0,0 @@ -# typed: strong - -module OpenAI - # @api private - class BaseClient - abstract! - - RequestComponentsShape = T.type_alias do - { - method: Symbol, - path: T.any(String, T::Array[String]), - query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), - headers: T.nilable( - T::Hash[String, - T.nilable( - T.any( - String, - Integer, - T::Array[T.nilable(T.any(String, Integer))] - ) - )] - ), - body: T.nilable(T.anything), - unwrap: T.nilable(Symbol), - page: T.nilable(T::Class[OpenAI::BasePage[OpenAI::BaseModel]]), - stream: T.nilable(T::Class[OpenAI::BaseStream[T.anything, OpenAI::BaseModel]]), - model: T.nilable(OpenAI::Converter::Input), - options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - } - end - - RequestInputShape = T.type_alias do - { - method: Symbol, - url: URI::Generic, - headers: T::Hash[String, String], - body: T.anything, - max_retries: Integer, - timeout: Float - } - end - - MAX_REDIRECTS = 20 - - PLATFORM_HEADERS = T::Hash[String, String] - - class << self - # @api private - sig { params(req: OpenAI::BaseClient::RequestComponentsShape).void } - def validate!(req) - end - - # @api private - sig do - params(status: Integer, headers: T.any(T::Hash[String, String], Net::HTTPHeader)).returns(T::Boolean) - end - def should_retry?(status, headers:) - end - - # @api private - sig do - params( - request: OpenAI::BaseClient::RequestInputShape, - status: Integer, - response_headers: T.any(T::Hash[String, String], Net::HTTPHeader) - ) - .returns(OpenAI::BaseClient::RequestInputShape) - end - def follow_redirect(request, status:, response_headers:) - end - - # @api private - sig do - params( - status: T.any(Integer, OpenAI::APIConnectionError), - stream: T.nilable(T::Enumerable[String]) - ).void - end - def reap_connection!(status, stream:) - end - end - - sig { returns(T.anything) } - def requester - end - - sig { params(_: T.anything).returns(T.anything) } - def requester=(_) - end - - # @api private - sig do - params( - base_url: String, - timeout: Float, - max_retries: Integer, - initial_retry_delay: Float, - max_retry_delay: Float, - headers: T::Hash[String, - T.nilable(T.any(String, Integer, T::Array[T.nilable(T.any(String, Integer))]))], - idempotency_header: T.nilable(String) - ) - .returns(T.attached_class) - end - def self.new( - base_url:, - timeout: 0.0, - max_retries: 0, - initial_retry_delay: 0.0, - max_retry_delay: 0.0, - headers: {}, - idempotency_header: nil - ) - end - - # @api private - sig { overridable.returns(T::Hash[String, String]) } - private def auth_headers - end - - # @api private - sig { returns(String) } - private def generate_idempotency_key - end - - # @api private - sig do - overridable - .params(req: OpenAI::BaseClient::RequestComponentsShape, opts: T::Hash[Symbol, T.anything]) - .returns(OpenAI::BaseClient::RequestInputShape) - end - private def build_request(req, opts) - end - - # @api private - sig { params(headers: T::Hash[String, String], retry_count: Integer).returns(Float) } - private def retry_delay(headers, retry_count:) - end - - # @api private - sig do - params( - request: OpenAI::BaseClient::RequestInputShape, - redirect_count: Integer, - retry_count: Integer, - send_retry_header: T::Boolean - ) - .returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) - end - private def send_request(request, redirect_count:, retry_count:, send_retry_header:) - end - - # Execute the request specified by `req`. This is the method that all resource - # methods call into. - sig do - params( - method: Symbol, - path: T.any(String, T::Array[String]), - query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), - headers: T.nilable( - T::Hash[String, - T.nilable( - T.any( - String, - Integer, - T::Array[T.nilable(T.any(String, Integer))] - ) - )] - ), - body: T.nilable(T.anything), - unwrap: T.nilable(Symbol), - page: T.nilable(T::Class[OpenAI::BasePage[OpenAI::BaseModel]]), - stream: T.nilable(T::Class[OpenAI::BaseStream[T.anything, OpenAI::BaseModel]]), - model: T.nilable(OpenAI::Converter::Input), - options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - ) - .returns(T.anything) - end - def request( - method, - path, - query: {}, - headers: {}, - body: nil, - unwrap: nil, - page: nil, - stream: nil, - model: OpenAI::Unknown, - options: {} - ) - end - - sig { returns(String) } - def inspect - end - end -end diff --git a/rbi/lib/openai/base_model.rbi b/rbi/lib/openai/base_model.rbi deleted file mode 100644 index 8840d3a8..00000000 --- a/rbi/lib/openai/base_model.rbi +++ /dev/null @@ -1,617 +0,0 @@ -# typed: strong - -module OpenAI - # @api private - module Converter - Input = T.type_alias { T.any(OpenAI::Converter, T::Class[T.anything]) } - - # @api private - sig { overridable.params(value: T.anything).returns(T.anything) } - def coerce(value) - end - - # @api private - sig { overridable.params(value: T.anything).returns(T.anything) } - def dump(value) - end - - # @api private - sig do - overridable - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - - class << self - # @api private - sig do - params( - spec: T.any( - { - const: T.nilable(T.any(NilClass, T::Boolean, Integer, Float, Symbol)), - enum: T.nilable(T.proc.returns(OpenAI::Converter::Input)), - union: T.nilable(T.proc.returns(OpenAI::Converter::Input)) - }, - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ) - ) - .returns(T.proc.returns(T.anything).void) - end - def self.type_info(spec) - end - - # @api private - # - # Based on `target`, transform `value` into `target`, to the extent possible: - # - # 1. if the given `value` conforms to `target` already, return the given `value` - # 2. if it's possible and safe to convert the given `value` to `target`, then the - # converted value - # 3. otherwise, the given `value` unaltered - sig { params(target: OpenAI::Converter::Input, value: T.anything).returns(T.anything) } - def self.coerce(target, value) - end - - # @api private - sig { params(target: OpenAI::Converter::Input, value: T.anything).returns(T.anything) } - def self.dump(target, value) - end - - # @api private - # - # The underlying algorithm for computing maximal compatibility is subject to - # future improvements. - # - # Similar to `#.coerce`, used to determine the best union variant to decode into. - # - # 1. determine if strict-ish coercion is possible - # 2. return either result of successful coercion or if loose coercion is possible - # 3. return a score for recursively tallied count for fields that can be coerced - sig { params(target: OpenAI::Converter::Input, value: T.anything).returns(T.anything) } - def self.try_strict_coerce(target, value) - end - end - end - - # @api private - # - # When we don't know what to expect for the value. - class Unknown - extend OpenAI::Converter - - abstract! - final! - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def self.===(other) - end - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def self.==(other) - end - - class << self - # @api private - sig(:final) { override.params(value: T.anything).returns(T.anything) } - def coerce(value) - end - - # @api private - sig(:final) { override.params(value: T.anything).returns(T.anything) } - def dump(value) - end - - # @api private - sig(:final) do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - end - end - - # @api private - # - # Ruby has no Boolean class; this is something for models to refer to. - class BooleanModel - extend OpenAI::Converter - - abstract! - final! - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def self.===(other) - end - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def self.==(other) - end - - class << self - # @api private - sig(:final) do - override.params(value: T.any(T::Boolean, T.anything)).returns(T.any(T::Boolean, T.anything)) - end - def coerce(value) - end - - # @api private - sig(:final) do - override.params(value: T.any(T::Boolean, T.anything)).returns(T.any(T::Boolean, T.anything)) - end - def dump(value) - end - - # @api private - sig(:final) do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - end - end - - # @api private - # - # A value from among a specified list of options. OpenAPI enum values map to Ruby - # values in the SDK as follows: - # - # 1. boolean => true | false - # 2. integer => Integer - # 3. float => Float - # 4. string => Symbol - # - # We can therefore convert string values to Symbols, but can't convert other - # values safely. - class Enum - extend OpenAI::Converter - - abstract! - - Value = type_template(:out) - - class << self - # All of the valid Symbol values for this enum. - sig { overridable.returns(T::Array[Value]) } - def values - end - - # @api private - # - # Guard against thread safety issues by instantiating `@values`. - sig { void } - private def finalize! - end - end - - sig { params(other: T.anything).returns(T::Boolean) } - def self.===(other) - end - - sig { params(other: T.anything).returns(T::Boolean) } - def self.==(other) - end - - class << self - # @api private - sig { override.params(value: T.any(String, Symbol, T.anything)).returns(T.any(Symbol, T.anything)) } - def coerce(value) - end - - # @api private - sig { override.params(value: T.any(Symbol, T.anything)).returns(T.any(Symbol, T.anything)) } - def dump(value) - end - - # @api private - sig do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - end - end - - # @api private - class Union - extend OpenAI::Converter - - abstract! - - Variants = type_template(:out) - - class << self - # @api private - # - # All of the specified variant info for this union. - sig { returns(T::Array[[T.nilable(Symbol), T.proc.returns(Variants)]]) } - private def known_variants - end - - # @api private - sig { returns(T::Array[[T.nilable(Symbol), Variants]]) } - protected def derefed_variants - end - - # All of the specified variants for this union. - sig { overridable.returns(T::Array[Variants]) } - def variants - end - - # @api private - sig { params(property: Symbol).void } - private def discriminator(property) - end - - # @api private - sig do - params( - key: T.any(Symbol, T::Hash[Symbol, T.anything], T.proc.returns(Variants), Variants), - spec: T.any(T::Hash[Symbol, T.anything], T.proc.returns(Variants), Variants) - ) - .void - end - private def variant(key, spec = nil) - end - - # @api private - sig { params(value: T.anything).returns(T.nilable(Variants)) } - private def resolve_variant(value) - end - end - - sig { params(other: T.anything).returns(T::Boolean) } - def self.===(other) - end - - sig { params(other: T.anything).returns(T::Boolean) } - def self.==(other) - end - - class << self - # @api private - sig { override.params(value: T.anything).returns(T.anything) } - def coerce(value) - end - - # @api private - sig { override.params(value: T.anything).returns(T.anything) } - def dump(value) - end - - # @api private - sig do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - end - end - - # @api private - # - # Array of items of a given type. - class ArrayOf - include OpenAI::Converter - - abstract! - final! - - Elem = type_member(:out) - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def ===(other) - end - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def ==(other) - end - - # @api private - sig(:final) do - override - .params(value: T.any(T::Enumerable[T.anything], T.anything)) - .returns(T.any(T::Array[T.anything], T.anything)) - end - def coerce(value) - end - - # @api private - sig(:final) do - override - .params(value: T.any(T::Enumerable[T.anything], T.anything)) - .returns(T.any(T::Array[T.anything], T.anything)) - end - def dump(value) - end - - # @api private - sig(:final) do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - - # @api private - sig(:final) { returns(Elem) } - protected def item_type - end - - # @api private - sig(:final) do - params( - type_info: T.any( - T::Hash[Symbol, T.anything], - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ), - spec: T::Hash[Symbol, T.anything] - ) - .returns(T.attached_class) - end - def self.new(type_info, spec = {}) - end - end - - # @api private - # - # Hash of items of a given type. - class HashOf - include OpenAI::Converter - - abstract! - final! - - Elem = type_member(:out) - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def ===(other) - end - - sig(:final) { params(other: T.anything).returns(T::Boolean) } - def ==(other) - end - - # @api private - sig(:final) do - override - .params(value: T.any(T::Hash[T.anything, T.anything], T.anything)) - .returns(T.any(T::Hash[Symbol, T.anything], T.anything)) - end - def coerce(value) - end - - # @api private - sig(:final) do - override - .params(value: T.any(T::Hash[T.anything, T.anything], T.anything)) - .returns(T.any(T::Hash[Symbol, T.anything], T.anything)) - end - def dump(value) - end - - # @api private - sig(:final) do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - - # @api private - sig(:final) { returns(Elem) } - protected def item_type - end - - # @api private - sig(:final) do - params( - type_info: T.any( - T::Hash[Symbol, T.anything], - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ), - spec: T::Hash[Symbol, T.anything] - ) - .returns(T.attached_class) - end - def self.new(type_info, spec = {}) - end - end - - class BaseModel - extend OpenAI::Converter - - abstract! - - KnownFieldShape = T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean} } - - class << self - # @api private - # - # Assumes superclass fields are totally defined before fields are accessed / - # defined on subclasses. - sig do - returns( - T::Hash[Symbol, - T.all( - OpenAI::BaseModel::KnownFieldShape, - {type_fn: T.proc.returns(OpenAI::Converter::Input)} - )] - ) - end - def known_fields - end - - # @api private - sig do - returns(T::Hash[Symbol, T.all(OpenAI::BaseModel::KnownFieldShape, {type: OpenAI::Converter::Input})]) - end - def fields - end - - # @api private - sig { returns(T::Hash[Symbol, T.proc.returns(T::Class[T.anything])]) } - def defaults - end - - # @api private - sig do - params( - name_sym: Symbol, - required: T::Boolean, - type_info: T.any( - { - const: T.nilable(T.any(NilClass, T::Boolean, Integer, Float, Symbol)), - enum: T.nilable(T.proc.returns(OpenAI::Converter::Input)), - union: T.nilable(T.proc.returns(OpenAI::Converter::Input)), - api_name: Symbol, - nil?: T::Boolean - }, - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ), - spec: T::Hash[Symbol, T.anything] - ) - .void - end - private def add_field(name_sym, required:, type_info:, spec:) - end - - # @api private - sig do - params( - name_sym: Symbol, - type_info: T.any( - T::Hash[Symbol, T.anything], - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ), - spec: T::Hash[Symbol, T.anything] - ) - .void - end - def required(name_sym, type_info, spec = {}) - end - - # @api private - sig do - params( - name_sym: Symbol, - type_info: T.any( - T::Hash[Symbol, T.anything], - T.proc.returns(OpenAI::Converter::Input), - OpenAI::Converter::Input - ), - spec: T::Hash[Symbol, T.anything] - ) - .void - end - def optional(name_sym, type_info, spec = {}) - end - - # @api private - # - # `request_only` attributes not excluded from `.#coerce` when receiving responses - # even if well behaved servers should not send them - sig { params(blk: T.proc.void).void } - private def request_only(&blk) - end - - # @api private - # - # `response_only` attributes are omitted from `.#dump` when making requests - sig { params(blk: T.proc.void).void } - private def response_only(&blk) - end - end - - sig { params(other: T.anything).returns(T::Boolean) } - def ==(other) - end - - class << self - # @api private - sig do - override - .params(value: T.any(OpenAI::BaseModel, T::Hash[T.anything, T.anything], T.anything)) - .returns(T.any(T.attached_class, T.anything)) - end - def coerce(value) - end - - # @api private - sig do - override - .params(value: T.any(T.attached_class, T.anything)) - .returns(T.any(T::Hash[T.anything, T.anything], T.anything)) - end - def dump(value) - end - - # @api private - sig do - override - .params(value: T.anything) - .returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer])) - end - def try_strict_coerce(value) - end - end - - # Returns the raw value associated with the given key, if found. Otherwise, nil is - # returned. - # - # It is valid to lookup keys that are not in the API spec, for example to access - # undocumented features. This method does not parse response data into - # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. - sig { params(key: Symbol).returns(T.nilable(T.anything)) } - def [](key) - end - - # Returns a Hash of the data underlying this object. O(1) - # - # Keys are Symbols and values are the raw values from the response. The return - # value indicates which values were ever set on the object. i.e. there will be a - # key in this hash if they ever were, even if the set value was nil. - # - # This method is not recursive. The returned value is shared by the object, so it - # should not be mutated. - sig { overridable.returns(T::Hash[Symbol, T.anything]) } - def to_h - end - - alias_method :to_hash, :to_h - - sig { params(keys: T.nilable(T::Array[Symbol])).returns(T::Hash[Symbol, T.anything]) } - def deconstruct_keys(keys) - end - - # Create a new instance of a model. - sig { params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns(T.attached_class) } - def self.new(data = {}) - end - - sig { returns(String) } - def to_s - end - - sig { returns(String) } - def inspect - end - end -end diff --git a/rbi/lib/openai/base_page.rbi b/rbi/lib/openai/base_page.rbi deleted file mode 100644 index c5dc2a2d..00000000 --- a/rbi/lib/openai/base_page.rbi +++ /dev/null @@ -1,38 +0,0 @@ -# typed: strong - -module OpenAI - module BasePage - Elem = type_member(:out) - - sig { overridable.returns(T::Boolean) } - def next_page? - end - - sig { overridable.returns(T.self_type) } - def next_page - end - - sig { overridable.params(blk: T.proc.params(arg0: Elem).void).void } - def auto_paging_each(&blk) - end - - sig { returns(T::Enumerable[Elem]) } - def to_enum - end - - alias_method :enum_for, :to_enum - - # @api private - sig do - params( - client: OpenAI::BaseClient, - req: OpenAI::BaseClient::RequestComponentsShape, - headers: T.any(T::Hash[String, String], Net::HTTPHeader), - page_data: T.anything - ) - .void - end - def initialize(client:, req:, headers:, page_data:) - end - end -end diff --git a/rbi/lib/openai/base_stream.rbi b/rbi/lib/openai/base_stream.rbi deleted file mode 100644 index c5f6c58e..00000000 --- a/rbi/lib/openai/base_stream.rbi +++ /dev/null @@ -1,41 +0,0 @@ -# typed: strong - -module OpenAI - module BaseStream - Message = type_member(:in) - Elem = type_member(:out) - - sig { void } - def close - end - - # @api private - sig { overridable.returns(T::Enumerable[Elem]) } - private def iterator - end - - sig { params(blk: T.proc.params(arg0: Elem).void).void } - def for_each(&blk) - end - - sig { returns(T::Enumerable[Elem]) } - def to_enum - end - - alias_method :enum_for, :to_enum - - # @api private - sig do - params( - model: T.any(T::Class[T.anything], OpenAI::Converter), - url: URI::Generic, - status: Integer, - response: Net::HTTPResponse, - messages: T::Enumerable[Message] - ) - .void - end - def initialize(model:, url:, status:, response:, messages:) - end - end -end diff --git a/rbi/lib/openai/client.rbi b/rbi/lib/openai/client.rbi index 2d8c31bf..5f320546 100644 --- a/rbi/lib/openai/client.rbi +++ b/rbi/lib/openai/client.rbi @@ -1,7 +1,7 @@ # typed: strong module OpenAI - class Client < OpenAI::BaseClient + class Client < OpenAI::Transport::BaseClient DEFAULT_MAX_RETRIES = 2 DEFAULT_TIMEOUT_IN_SECONDS = T.let(600.0, Float) @@ -11,72 +11,55 @@ module OpenAI DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float) sig { returns(String) } - def api_key - end + attr_reader :api_key sig { returns(T.nilable(String)) } - def organization - end + attr_reader :organization sig { returns(T.nilable(String)) } - def project - end + attr_reader :project sig { returns(OpenAI::Resources::Completions) } - def completions - end + attr_reader :completions sig { returns(OpenAI::Resources::Chat) } - def chat - end + attr_reader :chat sig { returns(OpenAI::Resources::Embeddings) } - def embeddings - end + attr_reader :embeddings sig { returns(OpenAI::Resources::Files) } - def files - end + attr_reader :files sig { returns(OpenAI::Resources::Images) } - def images - end + attr_reader :images sig { returns(OpenAI::Resources::Audio) } - def audio - end + attr_reader :audio sig { returns(OpenAI::Resources::Moderations) } - def moderations - end + attr_reader :moderations sig { returns(OpenAI::Resources::Models) } - def models - end + attr_reader :models sig { returns(OpenAI::Resources::FineTuning) } - def fine_tuning - end + attr_reader :fine_tuning sig { returns(OpenAI::Resources::VectorStores) } - def vector_stores - end + attr_reader :vector_stores sig { returns(OpenAI::Resources::Beta) } - def beta - end + attr_reader :beta sig { returns(OpenAI::Resources::Batches) } - def batches - end + attr_reader :batches sig { returns(OpenAI::Resources::Uploads) } - def uploads - end + attr_reader :uploads sig { returns(OpenAI::Resources::Responses) } - def responses - end + attr_reader :responses # @api private sig { override.returns(T::Hash[String, String]) } diff --git a/rbi/lib/openai/cursor_page.rbi b/rbi/lib/openai/cursor_page.rbi index c40bab43..e167d210 100644 --- a/rbi/lib/openai/cursor_page.rbi +++ b/rbi/lib/openai/cursor_page.rbi @@ -2,24 +2,18 @@ module OpenAI class CursorPage - include OpenAI::BasePage + include OpenAI::Type::BasePage Elem = type_member sig { returns(T.nilable(T::Array[Elem])) } - def data - end - - sig { params(_: T.nilable(T::Array[Elem])).returns(T.nilable(T::Array[Elem])) } - def data=(_) - end + attr_accessor :data sig { returns(T::Boolean) } - def has_more - end + attr_accessor :has_more - sig { params(_: T::Boolean).returns(T::Boolean) } - def has_more=(_) + sig { returns(String) } + def inspect end end end diff --git a/rbi/lib/openai/errors.rbi b/rbi/lib/openai/errors.rbi index 56d79f0b..e010e283 100644 --- a/rbi/lib/openai/errors.rbi +++ b/rbi/lib/openai/errors.rbi @@ -3,12 +3,7 @@ module OpenAI class Error < StandardError sig { returns(T.nilable(StandardError)) } - def cause - end - - sig { params(_: T.nilable(StandardError)).returns(T.nilable(StandardError)) } - def cause=(_) - end + attr_accessor :cause end class ConversionError < OpenAI::Error @@ -16,52 +11,22 @@ module OpenAI class APIError < OpenAI::Error sig { returns(URI::Generic) } - def url - end - - sig { params(_: URI::Generic).returns(URI::Generic) } - def url=(_) - end + attr_accessor :url sig { returns(T.nilable(Integer)) } - def status - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def status=(_) - end + attr_accessor :status sig { returns(T.nilable(T.anything)) } - def body - end - - sig { params(_: T.nilable(T.anything)).returns(T.nilable(T.anything)) } - def body=(_) - end + attr_accessor :body sig { returns(T.nilable(String)) } - def code - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def code=(_) - end + attr_accessor :code sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param sig { returns(T.nilable(String)) } - def type - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def type=(_) - end + attr_accessor :type # @api private sig do @@ -81,44 +46,19 @@ module OpenAI class APIConnectionError < OpenAI::APIError sig { void } - def status - end - - sig { params(_: NilClass).void } - def status=(_) - end + attr_accessor :status sig { void } - def body - end - - sig { params(_: NilClass).void } - def body=(_) - end + attr_accessor :body sig { void } - def code - end - - sig { params(_: NilClass).void } - def code=(_) - end + attr_accessor :code sig { void } - def param - end - - sig { params(_: NilClass).void } - def param=(_) - end + attr_accessor :param sig { void } - def type - end - - sig { params(_: NilClass).void } - def type=(_) - end + attr_accessor :type # @api private sig do @@ -170,36 +110,16 @@ module OpenAI end sig { returns(Integer) } - def status - end - - sig { params(_: Integer).returns(Integer) } - def status=(_) - end + attr_accessor :status sig { returns(T.nilable(String)) } - def code - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def code=(_) - end + attr_accessor :code sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param sig { returns(T.nilable(String)) } - def type - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def type=(_) - end + attr_accessor :type # @api private sig do diff --git a/rbi/lib/openai/extern.rbi b/rbi/lib/openai/extern.rbi deleted file mode 100644 index e5e18a8d..00000000 --- a/rbi/lib/openai/extern.rbi +++ /dev/null @@ -1,7 +0,0 @@ -# typed: strong - -module OpenAI - # @api private - module Extern - end -end diff --git a/rbi/lib/openai/models/all_models.rbi b/rbi/lib/openai/models/all_models.rbi new file mode 100644 index 00000000..f6a5bf8e --- /dev/null +++ b/rbi/lib/openai/models/all_models.rbi @@ -0,0 +1,22 @@ +# typed: strong + +module OpenAI + module Models + module AllModels + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::AllModels::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::AllModels) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::AllModels::TaggedSymbol) } + + O1_PRO = T.let(:"o1-pro", OpenAI::Models::AllModels::TaggedSymbol) + O1_PRO_2025_03_19 = T.let(:"o1-pro-2025-03-19", OpenAI::Models::AllModels::TaggedSymbol) + COMPUTER_USE_PREVIEW = T.let(:"computer-use-preview", OpenAI::Models::AllModels::TaggedSymbol) + COMPUTER_USE_PREVIEW_2025_03_11 = + T.let(:"computer-use-preview-2025-03-11", OpenAI::Models::AllModels::TaggedSymbol) + end + end +end diff --git a/rbi/lib/openai/models/audio/speech_create_params.rbi b/rbi/lib/openai/models/audio/speech_create_params.rbi index 043a7179..cd1f2343 100644 --- a/rbi/lib/openai/models/audio/speech_create_params.rbi +++ b/rbi/lib/openai/models/audio/speech_create_params.rbi @@ -4,72 +4,70 @@ module OpenAI module Models module Audio class SpeechCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The text to generate audio for. The maximum length is 4096 characters. sig { returns(String) } - def input - end - - sig { params(_: String).returns(String) } - def input=(_) - end + attr_accessor :input # One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. + sig { returns(T.any(String, OpenAI::Models::Audio::SpeechModel::OrSymbol)) } + attr_accessor :model # The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). - sig { returns(Symbol) } - def voice - end + sig { returns(T.any(String, OpenAI::Models::Audio::SpeechCreateParams::Voice::OrSymbol)) } + attr_accessor :voice - sig { params(_: Symbol).returns(Symbol) } - def voice=(_) - end + # Control the voice of your generated audio with additional instructions. Does not + # work with `tts-1` or `tts-1-hd`. + sig { returns(T.nilable(String)) } + attr_reader :instructions + + sig { params(instructions: String).void } + attr_writer :instructions # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, # `wav`, and `pcm`. - sig { returns(T.nilable(Symbol)) } - def response_format - end + sig { returns(T.nilable(OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::OrSymbol)) } + attr_reader :response_format - sig { params(_: Symbol).returns(Symbol) } - def response_format=(_) - end + sig { params(response_format: OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::OrSymbol).void } + attr_writer :response_format # The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is # the default. sig { returns(T.nilable(Float)) } - def speed - end + attr_reader :speed - sig { params(_: Float).returns(Float) } - def speed=(_) - end + sig { params(speed: Float).void } + attr_writer :speed sig do params( input: String, - model: T.any(String, Symbol), - voice: Symbol, - response_format: Symbol, + model: T.any(String, OpenAI::Models::Audio::SpeechModel::OrSymbol), + voice: T.any(String, OpenAI::Models::Audio::SpeechCreateParams::Voice::OrSymbol), + instructions: String, + response_format: OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::OrSymbol, speed: Float, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(input:, model:, voice:, response_format: nil, speed: nil, request_options: {}) + def self.new( + input:, + model:, + voice:, + instructions: nil, + response_format: nil, + speed: nil, + request_options: {} + ) end sig do @@ -77,9 +75,10 @@ module OpenAI .returns( { input: String, - model: T.any(String, Symbol), - voice: Symbol, - response_format: Symbol, + model: T.any(String, OpenAI::Models::Audio::SpeechModel::OrSymbol), + voice: T.any(String, OpenAI::Models::Audio::SpeechCreateParams::Voice::OrSymbol), + instructions: String, + response_format: OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::OrSymbol, speed: Float, request_options: OpenAI::RequestOptions } @@ -89,46 +88,61 @@ module OpenAI end # One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` - class Model < OpenAI::Union - abstract! + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::Audio::SpeechModel::OrSymbol]) } + def self.variants + end end # The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). - class Voice < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - ALLOY = :alloy - ASH = :ash - CORAL = :coral - ECHO = :echo - FABLE = :fable - ONYX = :onyx - NOVA = :nova - SAGE = :sage - SHIMMER = :shimmer + module Voice + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::Audio::SpeechCreateParams::Voice::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) } + + ALLOY = T.let(:alloy, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + ASH = T.let(:ash, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + BALLAD = T.let(:ballad, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + CORAL = T.let(:coral, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + ECHO = T.let(:echo, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + FABLE = T.let(:fable, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + ONYX = T.let(:onyx, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + NOVA = T.let(:nova, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + SAGE = T.let(:sage, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + SHIMMER = T.let(:shimmer, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) + VERSE = T.let(:verse, OpenAI::Models::Audio::SpeechCreateParams::Voice::TaggedSymbol) end # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, # `wav`, and `pcm`. - class ResponseFormat < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - MP3 = :mp3 - OPUS = :opus - AAC = :aac - FLAC = :flac - WAV = :wav - PCM = :pcm + module ResponseFormat + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) } + + MP3 = T.let(:mp3, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + OPUS = T.let(:opus, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + AAC = T.let(:aac, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + FLAC = T.let(:flac, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + WAV = T.let(:wav, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + PCM = T.let(:pcm, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/audio/speech_model.rbi b/rbi/lib/openai/models/audio/speech_model.rbi index f465baf8..14159fd5 100644 --- a/rbi/lib/openai/models/audio/speech_model.rbi +++ b/rbi/lib/openai/models/audio/speech_model.rbi @@ -3,13 +3,19 @@ module OpenAI module Models module Audio - class SpeechModel < OpenAI::Enum - abstract! + module SpeechModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Audio::SpeechModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Audio::SpeechModel::TaggedSymbol) } - TTS_1 = :"tts-1" - TTS_1_HD = :"tts-1-hd" + TTS_1 = T.let(:"tts-1", OpenAI::Models::Audio::SpeechModel::TaggedSymbol) + TTS_1_HD = T.let(:"tts-1-hd", OpenAI::Models::Audio::SpeechModel::TaggedSymbol) + GPT_4O_MINI_TTS = T.let(:"gpt-4o-mini-tts", OpenAI::Models::Audio::SpeechModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Audio::SpeechModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/audio/transcription.rbi b/rbi/lib/openai/models/audio/transcription.rbi index bc8940ae..92154d33 100644 --- a/rbi/lib/openai/models/audio/transcription.rbi +++ b/rbi/lib/openai/models/audio/transcription.rbi @@ -6,22 +6,66 @@ module OpenAI class Transcription < OpenAI::BaseModel # The transcribed text. sig { returns(String) } - def text - end + attr_accessor :text + + # The log probabilities of the tokens in the transcription. Only returned with the + # models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added + # to the `include` array. + sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::Transcription::Logprob])) } + attr_reader :logprobs - sig { params(_: String).returns(String) } - def text=(_) + sig do + params(logprobs: T::Array[T.any(OpenAI::Models::Audio::Transcription::Logprob, OpenAI::Util::AnyHash)]) + .void end + attr_writer :logprobs # Represents a transcription response returned by model, based on the provided # input. - sig { params(text: String).returns(T.attached_class) } - def self.new(text:) + sig do + params( + text: String, + logprobs: T::Array[T.any(OpenAI::Models::Audio::Transcription::Logprob, OpenAI::Util::AnyHash)] + ) + .returns(T.attached_class) + end + def self.new(text:, logprobs: nil) end - sig { override.returns({text: String}) } + sig { override.returns({text: String, logprobs: T::Array[OpenAI::Models::Audio::Transcription::Logprob]}) } def to_hash end + + class Logprob < OpenAI::BaseModel + # The token in the transcription. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :token + + # The bytes of the token. + sig { returns(T.nilable(T::Array[Float])) } + attr_reader :bytes + + sig { params(bytes: T::Array[Float]).void } + attr_writer :bytes + + # The log probability of the token. + sig { returns(T.nilable(Float)) } + attr_reader :logprob + + sig { params(logprob: Float).void } + attr_writer :logprob + + sig { params(token: String, bytes: T::Array[Float], logprob: Float).returns(T.attached_class) } + def self.new(token: nil, bytes: nil, logprob: nil) + end + + sig { override.returns({token: String, bytes: T::Array[Float], logprob: Float}) } + def to_hash + end + end end end end diff --git a/rbi/lib/openai/models/audio/transcription_create_params.rbi b/rbi/lib/openai/models/audio/transcription_create_params.rbi index 29ecd8fb..a4cfde33 100644 --- a/rbi/lib/openai/models/audio/transcription_create_params.rbi +++ b/rbi/lib/openai/models/audio/transcription_create_params.rbi @@ -4,61 +4,58 @@ module OpenAI module Models module Audio class TranscriptionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The audio file object (not file name) to transcribe, in one of these formats: # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. sig { returns(T.any(IO, StringIO)) } - def file - end + attr_accessor :file - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def file=(_) - end + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + sig { returns(T.any(String, OpenAI::Models::AudioModel::OrSymbol)) } + attr_accessor :model - # ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. - sig { returns(T.any(String, Symbol)) } - def model - end + # Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. + sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol])) } + attr_reader :include - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { params(include: T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol]).void } + attr_writer :include # The language of the input audio. Supplying the input language in # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) # format will improve accuracy and latency. sig { returns(T.nilable(String)) } - def language - end + attr_reader :language - sig { params(_: String).returns(String) } - def language=(_) - end + sig { params(language: String).void } + attr_writer :language # An optional text to guide the model's style or continue a previous audio # segment. The # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) # should match the audio language. sig { returns(T.nilable(String)) } - def prompt - end + attr_reader :prompt - sig { params(_: String).returns(String) } - def prompt=(_) - end + sig { params(prompt: String).void } + attr_writer :prompt # The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. - sig { returns(T.nilable(Symbol)) } - def response_format - end + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. + sig { returns(T.nilable(OpenAI::Models::AudioResponseFormat::OrSymbol)) } + attr_reader :response_format - sig { params(_: Symbol).returns(Symbol) } - def response_format=(_) - end + sig { params(response_format: OpenAI::Models::AudioResponseFormat::OrSymbol).void } + attr_writer :response_format # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the # output more random, while lower values like 0.2 will make it more focused and @@ -66,42 +63,49 @@ module OpenAI # [log probability](https://en.wikipedia.org/wiki/Log_probability) to # automatically increase the temperature until certain thresholds are hit. sig { returns(T.nilable(Float)) } - def temperature - end + attr_reader :temperature - sig { params(_: Float).returns(Float) } - def temperature=(_) - end + sig { params(temperature: Float).void } + attr_writer :temperature # The timestamp granularities to populate for this transcription. # `response_format` must be set `verbose_json` to use timestamp granularities. # Either or both of these options are supported: `word`, or `segment`. Note: There # is no additional latency for segment timestamps, but generating word timestamps # incurs additional latency. - sig { returns(T.nilable(T::Array[Symbol])) } - def timestamp_granularities + sig do + returns( + T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol]) + ) end + attr_reader :timestamp_granularities - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def timestamp_granularities=(_) + sig do + params( + timestamp_granularities: T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol] + ) + .void end + attr_writer :timestamp_granularities sig do params( file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), + include: T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol], language: String, prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::AudioResponseFormat::OrSymbol, temperature: Float, - timestamp_granularities: T::Array[Symbol], - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + timestamp_granularities: T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol], + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end def self.new( file:, model:, + include: nil, language: nil, prompt: nil, response_format: nil, @@ -116,12 +120,13 @@ module OpenAI .returns( { file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), + include: T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol], language: String, prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::AudioResponseFormat::OrSymbol, temperature: Float, - timestamp_granularities: T::Array[Symbol], + timestamp_granularities: T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol], request_options: OpenAI::RequestOptions } ) @@ -129,21 +134,35 @@ module OpenAI def to_hash end - # ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. - class Model < OpenAI::Union - abstract! + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::AudioModel::OrSymbol]) } + def self.variants + end end - class TimestampGranularity < OpenAI::Enum - abstract! + module TimestampGranularity + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + WORD = T.let(:word, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::TaggedSymbol) + SEGMENT = + T.let(:segment, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::TaggedSymbol) - WORD = :word - SEGMENT = :segment + sig do + override + .returns(T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/audio/transcription_create_response.rbi b/rbi/lib/openai/models/audio/transcription_create_response.rbi index c414dc3d..482495e5 100644 --- a/rbi/lib/openai/models/audio/transcription_create_response.rbi +++ b/rbi/lib/openai/models/audio/transcription_create_response.rbi @@ -5,10 +5,12 @@ module OpenAI module Audio # Represents a transcription response returned by model, based on the provided # input. - class TranscriptionCreateResponse < OpenAI::Union - abstract! + module TranscriptionCreateResponse + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)} } + sig { override.returns([OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/audio/transcription_include.rbi b/rbi/lib/openai/models/audio/transcription_include.rbi new file mode 100644 index 00000000..b9eb4918 --- /dev/null +++ b/rbi/lib/openai/models/audio/transcription_include.rbi @@ -0,0 +1,20 @@ +# typed: strong + +module OpenAI + module Models + module Audio + module TranscriptionInclude + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Audio::TranscriptionInclude) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Audio::TranscriptionInclude::TaggedSymbol) } + + LOGPROBS = T.let(:logprobs, OpenAI::Models::Audio::TranscriptionInclude::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Audio::TranscriptionInclude::TaggedSymbol]) } + def self.values + end + end + end + end +end diff --git a/rbi/lib/openai/models/audio/transcription_segment.rbi b/rbi/lib/openai/models/audio/transcription_segment.rbi index 92a534a2..96cdfd4e 100644 --- a/rbi/lib/openai/models/audio/transcription_segment.rbi +++ b/rbi/lib/openai/models/audio/transcription_segment.rbi @@ -6,96 +6,46 @@ module OpenAI class TranscriptionSegment < OpenAI::BaseModel # Unique identifier of the segment. sig { returns(Integer) } - def id - end - - sig { params(_: Integer).returns(Integer) } - def id=(_) - end + attr_accessor :id # Average logprob of the segment. If the value is lower than -1, consider the # logprobs failed. sig { returns(Float) } - def avg_logprob - end - - sig { params(_: Float).returns(Float) } - def avg_logprob=(_) - end + attr_accessor :avg_logprob # Compression ratio of the segment. If the value is greater than 2.4, consider the # compression failed. sig { returns(Float) } - def compression_ratio - end - - sig { params(_: Float).returns(Float) } - def compression_ratio=(_) - end + attr_accessor :compression_ratio # End time of the segment in seconds. sig { returns(Float) } - def end_ - end - - sig { params(_: Float).returns(Float) } - def end_=(_) - end + attr_accessor :end_ # Probability of no speech in the segment. If the value is higher than 1.0 and the # `avg_logprob` is below -1, consider this segment silent. sig { returns(Float) } - def no_speech_prob - end - - sig { params(_: Float).returns(Float) } - def no_speech_prob=(_) - end + attr_accessor :no_speech_prob # Seek offset of the segment. sig { returns(Integer) } - def seek - end - - sig { params(_: Integer).returns(Integer) } - def seek=(_) - end + attr_accessor :seek # Start time of the segment in seconds. sig { returns(Float) } - def start - end - - sig { params(_: Float).returns(Float) } - def start=(_) - end + attr_accessor :start # Temperature parameter used for generating the segment. sig { returns(Float) } - def temperature - end - - sig { params(_: Float).returns(Float) } - def temperature=(_) - end + attr_accessor :temperature # Text content of the segment. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Array of token IDs for the text content. sig { returns(T::Array[Integer]) } - def tokens - end - - sig { params(_: T::Array[Integer]).returns(T::Array[Integer]) } - def tokens=(_) - end + attr_accessor :tokens sig do params( @@ -112,7 +62,18 @@ module OpenAI ) .returns(T.attached_class) end - def self.new(id:, avg_logprob:, compression_ratio:, end_:, no_speech_prob:, seek:, start:, temperature:, text:, tokens:) + def self.new( + id:, + avg_logprob:, + compression_ratio:, + end_:, + no_speech_prob:, + seek:, + start:, + temperature:, + text:, + tokens: + ) end sig do diff --git a/rbi/lib/openai/models/audio/transcription_stream_event.rbi b/rbi/lib/openai/models/audio/transcription_stream_event.rbi new file mode 100644 index 00000000..82ef83d4 --- /dev/null +++ b/rbi/lib/openai/models/audio/transcription_stream_event.rbi @@ -0,0 +1,24 @@ +# typed: strong + +module OpenAI + module Models + module Audio + # Emitted when there is an additional text delta. This is also the first event + # emitted when the transcription starts. Only emitted when you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `Stream` parameter set to `true`. + module TranscriptionStreamEvent + extend OpenAI::Union + + sig do + override + .returns( + [OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/lib/openai/models/audio/transcription_text_delta_event.rbi b/rbi/lib/openai/models/audio/transcription_text_delta_event.rbi new file mode 100644 index 00000000..0e61bfb0 --- /dev/null +++ b/rbi/lib/openai/models/audio/transcription_text_delta_event.rbi @@ -0,0 +1,86 @@ +# typed: strong + +module OpenAI + module Models + module Audio + class TranscriptionTextDeltaEvent < OpenAI::BaseModel + # The text delta that was additionally transcribed. + sig { returns(String) } + attr_accessor :delta + + # The type of the event. Always `transcript.text.delta`. + sig { returns(Symbol) } + attr_accessor :type + + # The log probabilities of the delta. Only included if you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `include[]` parameter set to `logprobs`. + sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob])) } + attr_reader :logprobs + + sig do + params( + logprobs: T::Array[T.any(OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob, OpenAI::Util::AnyHash)] + ) + .void + end + attr_writer :logprobs + + # Emitted when there is an additional text delta. This is also the first event + # emitted when the transcription starts. Only emitted when you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `Stream` parameter set to `true`. + sig do + params( + delta: String, + logprobs: T::Array[T.any(OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob, OpenAI::Util::AnyHash)], + type: Symbol + ) + .returns(T.attached_class) + end + def self.new(delta:, logprobs: nil, type: :"transcript.text.delta") + end + + sig do + override + .returns( + {delta: String, type: Symbol, logprobs: T::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob]} + ) + end + def to_hash + end + + class Logprob < OpenAI::BaseModel + # The token that was used to generate the log probability. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :token + + # The bytes that were used to generate the log probability. + sig { returns(T.nilable(T::Array[T.anything])) } + attr_reader :bytes + + sig { params(bytes: T::Array[T.anything]).void } + attr_writer :bytes + + # The log probability of the token. + sig { returns(T.nilable(Float)) } + attr_reader :logprob + + sig { params(logprob: Float).void } + attr_writer :logprob + + sig { params(token: String, bytes: T::Array[T.anything], logprob: Float).returns(T.attached_class) } + def self.new(token: nil, bytes: nil, logprob: nil) + end + + sig { override.returns({token: String, bytes: T::Array[T.anything], logprob: Float}) } + def to_hash + end + end + end + end + end +end diff --git a/rbi/lib/openai/models/audio/transcription_text_done_event.rbi b/rbi/lib/openai/models/audio/transcription_text_done_event.rbi new file mode 100644 index 00000000..ecfd6f55 --- /dev/null +++ b/rbi/lib/openai/models/audio/transcription_text_done_event.rbi @@ -0,0 +1,87 @@ +# typed: strong + +module OpenAI + module Models + module Audio + class TranscriptionTextDoneEvent < OpenAI::BaseModel + # The text that was transcribed. + sig { returns(String) } + attr_accessor :text + + # The type of the event. Always `transcript.text.done`. + sig { returns(Symbol) } + attr_accessor :type + + # The log probabilities of the individual tokens in the transcription. Only + # included if you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `include[]` parameter set to `logprobs`. + sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob])) } + attr_reader :logprobs + + sig do + params( + logprobs: T::Array[T.any(OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob, OpenAI::Util::AnyHash)] + ) + .void + end + attr_writer :logprobs + + # Emitted when the transcription is complete. Contains the complete transcription + # text. Only emitted when you + # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) + # with the `Stream` parameter set to `true`. + sig do + params( + text: String, + logprobs: T::Array[T.any(OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob, OpenAI::Util::AnyHash)], + type: Symbol + ) + .returns(T.attached_class) + end + def self.new(text:, logprobs: nil, type: :"transcript.text.done") + end + + sig do + override + .returns( + {text: String, type: Symbol, logprobs: T::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob]} + ) + end + def to_hash + end + + class Logprob < OpenAI::BaseModel + # The token that was used to generate the log probability. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :token + + # The bytes that were used to generate the log probability. + sig { returns(T.nilable(T::Array[T.anything])) } + attr_reader :bytes + + sig { params(bytes: T::Array[T.anything]).void } + attr_writer :bytes + + # The log probability of the token. + sig { returns(T.nilable(Float)) } + attr_reader :logprob + + sig { params(logprob: Float).void } + attr_writer :logprob + + sig { params(token: String, bytes: T::Array[T.anything], logprob: Float).returns(T.attached_class) } + def self.new(token: nil, bytes: nil, logprob: nil) + end + + sig { override.returns({token: String, bytes: T::Array[T.anything], logprob: Float}) } + def to_hash + end + end + end + end + end +end diff --git a/rbi/lib/openai/models/audio/transcription_verbose.rbi b/rbi/lib/openai/models/audio/transcription_verbose.rbi index 55eb1b23..004b1ec3 100644 --- a/rbi/lib/openai/models/audio/transcription_verbose.rbi +++ b/rbi/lib/openai/models/audio/transcription_verbose.rbi @@ -6,54 +6,29 @@ module OpenAI class TranscriptionVerbose < OpenAI::BaseModel # The duration of the input audio. sig { returns(Float) } - def duration - end - - sig { params(_: Float).returns(Float) } - def duration=(_) - end + attr_accessor :duration # The language of the input audio. sig { returns(String) } - def language - end - - sig { params(_: String).returns(String) } - def language=(_) - end + attr_accessor :language # The transcribed text. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Segments of the transcribed text and their corresponding details. sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionSegment])) } - def segments - end + attr_reader :segments - sig do - params(_: T::Array[OpenAI::Models::Audio::TranscriptionSegment]) - .returns(T::Array[OpenAI::Models::Audio::TranscriptionSegment]) - end - def segments=(_) - end + sig { params(segments: T::Array[T.any(OpenAI::Models::Audio::TranscriptionSegment, OpenAI::Util::AnyHash)]).void } + attr_writer :segments # Extracted words and their corresponding timestamps. sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionWord])) } - def words - end + attr_reader :words - sig do - params(_: T::Array[OpenAI::Models::Audio::TranscriptionWord]) - .returns(T::Array[OpenAI::Models::Audio::TranscriptionWord]) - end - def words=(_) - end + sig { params(words: T::Array[T.any(OpenAI::Models::Audio::TranscriptionWord, OpenAI::Util::AnyHash)]).void } + attr_writer :words # Represents a verbose json transcription response returned by model, based on the # provided input. @@ -62,8 +37,8 @@ module OpenAI duration: Float, language: String, text: String, - segments: T::Array[OpenAI::Models::Audio::TranscriptionSegment], - words: T::Array[OpenAI::Models::Audio::TranscriptionWord] + segments: T::Array[T.any(OpenAI::Models::Audio::TranscriptionSegment, OpenAI::Util::AnyHash)], + words: T::Array[T.any(OpenAI::Models::Audio::TranscriptionWord, OpenAI::Util::AnyHash)] ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/audio/transcription_word.rbi b/rbi/lib/openai/models/audio/transcription_word.rbi index a3be4b46..c6adc3b1 100644 --- a/rbi/lib/openai/models/audio/transcription_word.rbi +++ b/rbi/lib/openai/models/audio/transcription_word.rbi @@ -6,30 +6,15 @@ module OpenAI class TranscriptionWord < OpenAI::BaseModel # End time of the word in seconds. sig { returns(Float) } - def end_ - end - - sig { params(_: Float).returns(Float) } - def end_=(_) - end + attr_accessor :end_ # Start time of the word in seconds. sig { returns(Float) } - def start - end - - sig { params(_: Float).returns(Float) } - def start=(_) - end + attr_accessor :start # The text content of the word. sig { returns(String) } - def word - end - - sig { params(_: String).returns(String) } - def word=(_) - end + attr_accessor :word sig { params(end_: Float, start: Float, word: String).returns(T.attached_class) } def self.new(end_:, start:, word:) diff --git a/rbi/lib/openai/models/audio/translation.rbi b/rbi/lib/openai/models/audio/translation.rbi index b9650fa4..07767362 100644 --- a/rbi/lib/openai/models/audio/translation.rbi +++ b/rbi/lib/openai/models/audio/translation.rbi @@ -5,12 +5,7 @@ module OpenAI module Audio class Translation < OpenAI::BaseModel sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text sig { params(text: String).returns(T.attached_class) } def self.new(text:) diff --git a/rbi/lib/openai/models/audio/translation_create_params.rbi b/rbi/lib/openai/models/audio/translation_create_params.rbi index fb5d4a71..1f264107 100644 --- a/rbi/lib/openai/models/audio/translation_create_params.rbi +++ b/rbi/lib/openai/models/audio/translation_create_params.rbi @@ -4,50 +4,36 @@ module OpenAI module Models module Audio class TranslationCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The audio file object (not file name) translate, in one of these formats: flac, # mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. sig { returns(T.any(IO, StringIO)) } - def file - end - - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def file=(_) - end + attr_accessor :file # ID of the model to use. Only `whisper-1` (which is powered by our open source # Whisper V2 model) is currently available. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::AudioModel::OrSymbol)) } + attr_accessor :model # An optional text to guide the model's style or continue a previous audio # segment. The # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) # should be in English. sig { returns(T.nilable(String)) } - def prompt - end + attr_reader :prompt - sig { params(_: String).returns(String) } - def prompt=(_) - end + sig { params(prompt: String).void } + attr_writer :prompt # The format of the output, in one of these options: `json`, `text`, `srt`, # `verbose_json`, or `vtt`. - sig { returns(T.nilable(Symbol)) } - def response_format - end + sig { returns(T.nilable(OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::OrSymbol)) } + attr_reader :response_format - sig { params(_: Symbol).returns(Symbol) } - def response_format=(_) - end + sig { params(response_format: OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::OrSymbol).void } + attr_writer :response_format # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the # output more random, while lower values like 0.2 will make it more focused and @@ -55,21 +41,19 @@ module OpenAI # [log probability](https://en.wikipedia.org/wiki/Log_probability) to # automatically increase the temperature until certain thresholds are hit. sig { returns(T.nilable(Float)) } - def temperature - end + attr_reader :temperature - sig { params(_: Float).returns(Float) } - def temperature=(_) - end + sig { params(temperature: Float).void } + attr_writer :temperature sig do params( file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::OrSymbol, temperature: Float, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -81,9 +65,9 @@ module OpenAI .returns( { file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::OrSymbol, temperature: Float, request_options: OpenAI::RequestOptions } @@ -94,10 +78,34 @@ module OpenAI # ID of the model to use. Only `whisper-1` (which is powered by our open source # Whisper V2 model) is currently available. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::AudioModel::OrSymbol]) } + def self.variants + end + end + + # The format of the output, in one of these options: `json`, `text`, `srt`, + # `verbose_json`, or `vtt`. + module ResponseFormat + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) } + + JSON = T.let(:json, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) + TEXT = T.let(:text, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) + SRT = T.let(:srt, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) + VERBOSE_JSON = + T.let(:verbose_json, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) + VTT = T.let(:vtt, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol) - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns(T::Array[OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/audio/translation_create_response.rbi b/rbi/lib/openai/models/audio/translation_create_response.rbi index 79ac8c66..8c9c9851 100644 --- a/rbi/lib/openai/models/audio/translation_create_response.rbi +++ b/rbi/lib/openai/models/audio/translation_create_response.rbi @@ -3,10 +3,12 @@ module OpenAI module Models module Audio - class TranslationCreateResponse < OpenAI::Union - abstract! + module TranslationCreateResponse + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)} } + sig { override.returns([OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/audio/translation_verbose.rbi b/rbi/lib/openai/models/audio/translation_verbose.rbi index bceb7944..f12cba37 100644 --- a/rbi/lib/openai/models/audio/translation_verbose.rbi +++ b/rbi/lib/openai/models/audio/translation_verbose.rbi @@ -6,49 +6,29 @@ module OpenAI class TranslationVerbose < OpenAI::BaseModel # The duration of the input audio. sig { returns(Float) } - def duration - end - - sig { params(_: Float).returns(Float) } - def duration=(_) - end + attr_accessor :duration # The language of the output translation (always `english`). sig { returns(String) } - def language - end - - sig { params(_: String).returns(String) } - def language=(_) - end + attr_accessor :language # The translated text. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Segments of the translated text and their corresponding details. sig { returns(T.nilable(T::Array[OpenAI::Models::Audio::TranscriptionSegment])) } - def segments - end + attr_reader :segments - sig do - params(_: T::Array[OpenAI::Models::Audio::TranscriptionSegment]) - .returns(T::Array[OpenAI::Models::Audio::TranscriptionSegment]) - end - def segments=(_) - end + sig { params(segments: T::Array[T.any(OpenAI::Models::Audio::TranscriptionSegment, OpenAI::Util::AnyHash)]).void } + attr_writer :segments sig do params( duration: Float, language: String, text: String, - segments: T::Array[OpenAI::Models::Audio::TranscriptionSegment] + segments: T::Array[T.any(OpenAI::Models::Audio::TranscriptionSegment, OpenAI::Util::AnyHash)] ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/audio_model.rbi b/rbi/lib/openai/models/audio_model.rbi index 85348552..eb369760 100644 --- a/rbi/lib/openai/models/audio_model.rbi +++ b/rbi/lib/openai/models/audio_model.rbi @@ -2,12 +2,19 @@ module OpenAI module Models - class AudioModel < OpenAI::Enum - abstract! + module AudioModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::AudioModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::AudioModel::TaggedSymbol) } - WHISPER_1 = :"whisper-1" + WHISPER_1 = T.let(:"whisper-1", OpenAI::Models::AudioModel::TaggedSymbol) + GPT_4O_TRANSCRIBE = T.let(:"gpt-4o-transcribe", OpenAI::Models::AudioModel::TaggedSymbol) + GPT_4O_MINI_TRANSCRIBE = T.let(:"gpt-4o-mini-transcribe", OpenAI::Models::AudioModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::AudioModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/audio_response_format.rbi b/rbi/lib/openai/models/audio_response_format.rbi index fb54aad0..dc544cfd 100644 --- a/rbi/lib/openai/models/audio_response_format.rbi +++ b/rbi/lib/openai/models/audio_response_format.rbi @@ -3,17 +3,23 @@ module OpenAI module Models # The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. - class AudioResponseFormat < OpenAI::Enum - abstract! + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. + module AudioResponseFormat + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::AudioResponseFormat) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::AudioResponseFormat::TaggedSymbol) } - JSON = :json - TEXT = :text - SRT = :srt - VERBOSE_JSON = :verbose_json - VTT = :vtt + JSON = T.let(:json, OpenAI::Models::AudioResponseFormat::TaggedSymbol) + TEXT = T.let(:text, OpenAI::Models::AudioResponseFormat::TaggedSymbol) + SRT = T.let(:srt, OpenAI::Models::AudioResponseFormat::TaggedSymbol) + VERBOSE_JSON = T.let(:verbose_json, OpenAI::Models::AudioResponseFormat::TaggedSymbol) + VTT = T.let(:vtt, OpenAI::Models::AudioResponseFormat::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::AudioResponseFormat::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/auto_file_chunking_strategy_param.rbi b/rbi/lib/openai/models/auto_file_chunking_strategy_param.rbi index b1d97ad3..43d54634 100644 --- a/rbi/lib/openai/models/auto_file_chunking_strategy_param.rbi +++ b/rbi/lib/openai/models/auto_file_chunking_strategy_param.rbi @@ -5,12 +5,7 @@ module OpenAI class AutoFileChunkingStrategyParam < OpenAI::BaseModel # Always `auto`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of # `800` and `chunk_overlap_tokens` of `400`. diff --git a/rbi/lib/openai/models/batch.rbi b/rbi/lib/openai/models/batch.rbi index 699d0782..6e8237c7 100644 --- a/rbi/lib/openai/models/batch.rbi +++ b/rbi/lib/openai/models/batch.rbi @@ -4,155 +4,100 @@ module OpenAI module Models class Batch < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The time frame within which the batch should be processed. sig { returns(String) } - def completion_window - end - - sig { params(_: String).returns(String) } - def completion_window=(_) - end + attr_accessor :completion_window # The Unix timestamp (in seconds) for when the batch was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The OpenAI API endpoint used by the batch. sig { returns(String) } - def endpoint - end - - sig { params(_: String).returns(String) } - def endpoint=(_) - end + attr_accessor :endpoint # The ID of the input file for the batch. sig { returns(String) } - def input_file_id - end - - sig { params(_: String).returns(String) } - def input_file_id=(_) - end + attr_accessor :input_file_id # The object type, which is always `batch`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The current status of the batch. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Batch::Status::TaggedSymbol) } + attr_accessor :status # The Unix timestamp (in seconds) for when the batch was cancelled. sig { returns(T.nilable(Integer)) } - def cancelled_at - end + attr_reader :cancelled_at - sig { params(_: Integer).returns(Integer) } - def cancelled_at=(_) - end + sig { params(cancelled_at: Integer).void } + attr_writer :cancelled_at # The Unix timestamp (in seconds) for when the batch started cancelling. sig { returns(T.nilable(Integer)) } - def cancelling_at - end + attr_reader :cancelling_at - sig { params(_: Integer).returns(Integer) } - def cancelling_at=(_) - end + sig { params(cancelling_at: Integer).void } + attr_writer :cancelling_at # The Unix timestamp (in seconds) for when the batch was completed. sig { returns(T.nilable(Integer)) } - def completed_at - end + attr_reader :completed_at - sig { params(_: Integer).returns(Integer) } - def completed_at=(_) - end + sig { params(completed_at: Integer).void } + attr_writer :completed_at # The ID of the file containing the outputs of requests with errors. sig { returns(T.nilable(String)) } - def error_file_id - end + attr_reader :error_file_id - sig { params(_: String).returns(String) } - def error_file_id=(_) - end + sig { params(error_file_id: String).void } + attr_writer :error_file_id sig { returns(T.nilable(OpenAI::Models::Batch::Errors)) } - def errors - end + attr_reader :errors - sig { params(_: OpenAI::Models::Batch::Errors).returns(OpenAI::Models::Batch::Errors) } - def errors=(_) - end + sig { params(errors: T.any(OpenAI::Models::Batch::Errors, OpenAI::Util::AnyHash)).void } + attr_writer :errors # The Unix timestamp (in seconds) for when the batch expired. sig { returns(T.nilable(Integer)) } - def expired_at - end + attr_reader :expired_at - sig { params(_: Integer).returns(Integer) } - def expired_at=(_) - end + sig { params(expired_at: Integer).void } + attr_writer :expired_at # The Unix timestamp (in seconds) for when the batch will expire. sig { returns(T.nilable(Integer)) } - def expires_at - end + attr_reader :expires_at - sig { params(_: Integer).returns(Integer) } - def expires_at=(_) - end + sig { params(expires_at: Integer).void } + attr_writer :expires_at # The Unix timestamp (in seconds) for when the batch failed. sig { returns(T.nilable(Integer)) } - def failed_at - end + attr_reader :failed_at - sig { params(_: Integer).returns(Integer) } - def failed_at=(_) - end + sig { params(failed_at: Integer).void } + attr_writer :failed_at # The Unix timestamp (in seconds) for when the batch started finalizing. sig { returns(T.nilable(Integer)) } - def finalizing_at - end + attr_reader :finalizing_at - sig { params(_: Integer).returns(Integer) } - def finalizing_at=(_) - end + sig { params(finalizing_at: Integer).void } + attr_writer :finalizing_at # The Unix timestamp (in seconds) for when the batch started processing. sig { returns(T.nilable(Integer)) } - def in_progress_at - end + attr_reader :in_progress_at - sig { params(_: Integer).returns(Integer) } - def in_progress_at=(_) - end + sig { params(in_progress_at: Integer).void } + attr_writer :in_progress_at # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -160,31 +105,22 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The ID of the file containing the outputs of successfully executed requests. sig { returns(T.nilable(String)) } - def output_file_id - end + attr_reader :output_file_id - sig { params(_: String).returns(String) } - def output_file_id=(_) - end + sig { params(output_file_id: String).void } + attr_writer :output_file_id # The request counts for different statuses within the batch. sig { returns(T.nilable(OpenAI::Models::BatchRequestCounts)) } - def request_counts - end + attr_reader :request_counts - sig { params(_: OpenAI::Models::BatchRequestCounts).returns(OpenAI::Models::BatchRequestCounts) } - def request_counts=(_) - end + sig { params(request_counts: T.any(OpenAI::Models::BatchRequestCounts, OpenAI::Util::AnyHash)).void } + attr_writer :request_counts sig do params( @@ -193,20 +129,20 @@ module OpenAI created_at: Integer, endpoint: String, input_file_id: String, - status: Symbol, + status: OpenAI::Models::Batch::Status::OrSymbol, cancelled_at: Integer, cancelling_at: Integer, completed_at: Integer, error_file_id: String, - errors: OpenAI::Models::Batch::Errors, + errors: T.any(OpenAI::Models::Batch::Errors, OpenAI::Util::AnyHash), expired_at: Integer, expires_at: Integer, failed_at: Integer, finalizing_at: Integer, in_progress_at: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), output_file_id: String, - request_counts: OpenAI::Models::BatchRequestCounts, + request_counts: T.any(OpenAI::Models::BatchRequestCounts, OpenAI::Util::AnyHash), object: Symbol ) .returns(T.attached_class) @@ -245,7 +181,7 @@ module OpenAI endpoint: String, input_file_id: String, object: Symbol, - status: Symbol, + status: OpenAI::Models::Batch::Status::TaggedSymbol, cancelled_at: Integer, cancelling_at: Integer, completed_at: Integer, @@ -256,7 +192,7 @@ module OpenAI failed_at: Integer, finalizing_at: Integer, in_progress_at: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), output_file_id: String, request_counts: OpenAI::Models::BatchRequestCounts } @@ -266,40 +202,44 @@ module OpenAI end # The current status of the batch. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - VALIDATING = :validating - FAILED = :failed - IN_PROGRESS = :in_progress - FINALIZING = :finalizing - COMPLETED = :completed - EXPIRED = :expired - CANCELLING = :cancelling - CANCELLED = :cancelled + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Batch::Status) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Batch::Status::TaggedSymbol) } + + VALIDATING = T.let(:validating, OpenAI::Models::Batch::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Batch::Status::TaggedSymbol) + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Batch::Status::TaggedSymbol) + FINALIZING = T.let(:finalizing, OpenAI::Models::Batch::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Batch::Status::TaggedSymbol) + EXPIRED = T.let(:expired, OpenAI::Models::Batch::Status::TaggedSymbol) + CANCELLING = T.let(:cancelling, OpenAI::Models::Batch::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::Batch::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Batch::Status::TaggedSymbol]) } + def self.values + end end class Errors < OpenAI::BaseModel sig { returns(T.nilable(T::Array[OpenAI::Models::BatchError])) } - def data - end + attr_reader :data - sig { params(_: T::Array[OpenAI::Models::BatchError]).returns(T::Array[OpenAI::Models::BatchError]) } - def data=(_) - end + sig { params(data: T::Array[T.any(OpenAI::Models::BatchError, OpenAI::Util::AnyHash)]).void } + attr_writer :data # The object type, which is always `list`. sig { returns(T.nilable(String)) } - def object - end + attr_reader :object - sig { params(_: String).returns(String) } - def object=(_) - end + sig { params(object: String).void } + attr_writer :object - sig { params(data: T::Array[OpenAI::Models::BatchError], object: String).returns(T.attached_class) } + sig do + params(data: T::Array[T.any(OpenAI::Models::BatchError, OpenAI::Util::AnyHash)], object: String) + .returns(T.attached_class) + end def self.new(data: nil, object: nil) end diff --git a/rbi/lib/openai/models/batch_cancel_params.rbi b/rbi/lib/openai/models/batch_cancel_params.rbi index fba65e6e..3abd1e78 100644 --- a/rbi/lib/openai/models/batch_cancel_params.rbi +++ b/rbi/lib/openai/models/batch_cancel_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class BatchCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/batch_create_params.rbi b/rbi/lib/openai/models/batch_create_params.rbi index 17c682c5..bc8dd159 100644 --- a/rbi/lib/openai/models/batch_create_params.rbi +++ b/rbi/lib/openai/models/batch_create_params.rbi @@ -3,30 +3,20 @@ module OpenAI module Models class BatchCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The time frame within which the batch should be processed. Currently only `24h` # is supported. - sig { returns(Symbol) } - def completion_window - end - - sig { params(_: Symbol).returns(Symbol) } - def completion_window=(_) - end + sig { returns(OpenAI::Models::BatchCreateParams::CompletionWindow::OrSymbol) } + attr_accessor :completion_window # The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. - sig { returns(Symbol) } - def endpoint - end - - sig { params(_: Symbol).returns(Symbol) } - def endpoint=(_) - end + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. + sig { returns(OpenAI::Models::BatchCreateParams::Endpoint::OrSymbol) } + attr_accessor :endpoint # The ID of an uploaded file that contains requests for the new batch. # @@ -38,12 +28,7 @@ module OpenAI # and must be uploaded with the purpose `batch`. The file can contain up to 50,000 # requests, and can be up to 200 MB in size. sig { returns(String) } - def input_file_id - end - - sig { params(_: String).returns(String) } - def input_file_id=(_) - end + attr_accessor :input_file_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -51,21 +36,16 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( - completion_window: Symbol, - endpoint: Symbol, + completion_window: OpenAI::Models::BatchCreateParams::CompletionWindow::OrSymbol, + endpoint: OpenAI::Models::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -76,10 +56,10 @@ module OpenAI override .returns( { - completion_window: Symbol, - endpoint: Symbol, + completion_window: OpenAI::Models::BatchCreateParams::CompletionWindow::OrSymbol, + endpoint: OpenAI::Models::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), request_options: OpenAI::RequestOptions } ) @@ -89,26 +69,39 @@ module OpenAI # The time frame within which the batch should be processed. Currently only `24h` # is supported. - class CompletionWindow < OpenAI::Enum - abstract! + module CompletionWindow + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow::TaggedSymbol) } - NUMBER_24H = :"24h" + NUMBER_24H = T.let(:"24h", OpenAI::Models::BatchCreateParams::CompletionWindow::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::BatchCreateParams::CompletionWindow::TaggedSymbol]) } + def self.values + end end # The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. - class Endpoint < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - V1_CHAT_COMPLETIONS = :"/v1/chat/completions" - V1_EMBEDDINGS = :"/v1/embeddings" - V1_COMPLETIONS = :"/v1/completions" + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. + module Endpoint + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::BatchCreateParams::Endpoint) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol) } + + V1_RESPONSES = T.let(:"/v1/responses", OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol) + V1_CHAT_COMPLETIONS = + T.let(:"/v1/chat/completions", OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol) + V1_EMBEDDINGS = T.let(:"/v1/embeddings", OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol) + V1_COMPLETIONS = T.let(:"/v1/completions", OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::BatchCreateParams::Endpoint::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/batch_error.rbi b/rbi/lib/openai/models/batch_error.rbi index ded1e3bb..261a3ac1 100644 --- a/rbi/lib/openai/models/batch_error.rbi +++ b/rbi/lib/openai/models/batch_error.rbi @@ -5,39 +5,25 @@ module OpenAI class BatchError < OpenAI::BaseModel # An error code identifying the error type. sig { returns(T.nilable(String)) } - def code - end + attr_reader :code - sig { params(_: String).returns(String) } - def code=(_) - end + sig { params(code: String).void } + attr_writer :code # The line number of the input file where the error occurred, if applicable. sig { returns(T.nilable(Integer)) } - def line - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def line=(_) - end + attr_accessor :line # A human-readable message providing more details about the error. sig { returns(T.nilable(String)) } - def message - end + attr_reader :message - sig { params(_: String).returns(String) } - def message=(_) - end + sig { params(message: String).void } + attr_writer :message # The name of the parameter that caused the error, if applicable. sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param sig do params(code: String, line: T.nilable(Integer), message: String, param: T.nilable(String)) diff --git a/rbi/lib/openai/models/batch_list_params.rbi b/rbi/lib/openai/models/batch_list_params.rbi index 8a8368b8..571dd654 100644 --- a/rbi/lib/openai/models/batch_list_params.rbi +++ b/rbi/lib/openai/models/batch_list_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class BatchListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -11,28 +11,24 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit sig do params( after: String, limit: Integer, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/batch_request_counts.rbi b/rbi/lib/openai/models/batch_request_counts.rbi index df746c81..03b6cecc 100644 --- a/rbi/lib/openai/models/batch_request_counts.rbi +++ b/rbi/lib/openai/models/batch_request_counts.rbi @@ -5,30 +5,15 @@ module OpenAI class BatchRequestCounts < OpenAI::BaseModel # Number of requests that have been completed successfully. sig { returns(Integer) } - def completed - end - - sig { params(_: Integer).returns(Integer) } - def completed=(_) - end + attr_accessor :completed # Number of requests that have failed. sig { returns(Integer) } - def failed - end - - sig { params(_: Integer).returns(Integer) } - def failed=(_) - end + attr_accessor :failed # Total number of requests in the batch. sig { returns(Integer) } - def total - end - - sig { params(_: Integer).returns(Integer) } - def total=(_) - end + attr_accessor :total # The request counts for different statuses within the batch. sig { params(completed: Integer, failed: Integer, total: Integer).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/batch_retrieve_params.rbi b/rbi/lib/openai/models/batch_retrieve_params.rbi index 56cbcb05..b984cd5d 100644 --- a/rbi/lib/openai/models/batch_retrieve_params.rbi +++ b/rbi/lib/openai/models/batch_retrieve_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class BatchRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/beta/assistant.rbi b/rbi/lib/openai/models/beta/assistant.rbi index c6f6f83f..e5fcf3bc 100644 --- a/rbi/lib/openai/models/beta/assistant.rbi +++ b/rbi/lib/openai/models/beta/assistant.rbi @@ -6,40 +6,20 @@ module OpenAI class Assistant < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the assistant was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The description of the assistant. The maximum length is 512 characters. sig { returns(T.nilable(String)) } - def description - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def description=(_) - end + attr_accessor :description # The system instructions that the assistant uses. The maximum length is 256,000 # characters. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -47,13 +27,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to @@ -61,30 +36,15 @@ module OpenAI # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The name of the assistant. The maximum length is 256 characters. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name # The object type, which is always `assistant`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # A list of tool enabled on the assistant. There can be a maximum of 128 tools per # assistant. Tools can be of types `code_interpreter`, `file_search`, or @@ -100,31 +60,7 @@ module OpenAI ] ) end - def tools - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - end - def tools=(_) - end + attr_accessor :tools # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -158,59 +94,28 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires # a list of file IDs, while the `file_search` tool requires a list of vector store # IDs. sig { returns(T.nilable(OpenAI::Models::Beta::Assistant::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::Assistant::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::Assistant::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::Assistant::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -218,12 +123,7 @@ module OpenAI # # We generally recommend altering this or temperature but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # Represents an `assistant` that can call the model and use tools. sig do @@ -232,12 +132,13 @@ module OpenAI created_at: Integer, description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, name: T.nilable(String), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) @@ -246,12 +147,13 @@ module OpenAI T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_resources: T.nilable(OpenAI::Models::Beta::Assistant::ToolResources), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::Assistant::ToolResources, OpenAI::Util::AnyHash)), top_p: T.nilable(Float), object: Symbol ) @@ -282,7 +184,7 @@ module OpenAI created_at: Integer, description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, name: T.nilable(String), object: Symbol, @@ -312,26 +214,26 @@ module OpenAI class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::Assistant::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::Assistant::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::Assistant::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::Assistant::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires @@ -339,8 +241,8 @@ module OpenAI # IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::Assistant::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::Assistant::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -364,12 +266,10 @@ module OpenAI # available to the `code_interpreter`` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -386,12 +286,10 @@ module OpenAI # attached to this assistant. There can be a maximum of 1 vector store attached to # the assistant. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids sig { params(vector_store_ids: T::Array[String]).returns(T.attached_class) } def self.new(vector_store_ids: nil) diff --git a/rbi/lib/openai/models/beta/assistant_create_params.rbi b/rbi/lib/openai/models/beta/assistant_create_params.rbi index 44da54e2..75169d1b 100644 --- a/rbi/lib/openai/models/beta/assistant_create_params.rbi +++ b/rbi/lib/openai/models/beta/assistant_create_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Beta class AssistantCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # ID of the model to use. You can use the @@ -12,32 +12,17 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::ChatModel::OrSymbol)) } + attr_accessor :model # The description of the assistant. The maximum length is 512 characters. sig { returns(T.nilable(String)) } - def description - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def description=(_) - end + attr_accessor :description # The system instructions that the assistant uses. The maximum length is 256,000 # characters. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -45,22 +30,12 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The name of the assistant. The maximum length is 256 characters. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name # **o-series models only** # @@ -68,13 +43,8 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - sig { returns(T.nilable(Symbol)) } - def reasoning_effort - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def reasoning_effort=(_) - end + sig { returns(T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol)) } + attr_accessor :reasoning_effort # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -108,59 +78,28 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires # a list of file IDs, while the `file_search` tool requires a list of vector store # IDs. sig { returns(T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources # A list of tool enabled on the assistant. There can be a maximum of 128 tools per # assistant. Tools can be of types `code_interpreter`, `file_search`, or @@ -178,31 +117,22 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -210,40 +140,37 @@ module OpenAI # # We generally recommend altering this or temperature but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_resources: T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources, OpenAI::Util::AnyHash)), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ], top_p: T.nilable(Float), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -267,12 +194,12 @@ module OpenAI override .returns( { - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, @@ -303,34 +230,36 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol]) } + def self.variants + end end class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires @@ -338,8 +267,8 @@ module OpenAI # IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -363,12 +292,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -385,12 +312,10 @@ module OpenAI # attached to this assistant. There can be a maximum of 1 vector store attached to # the assistant. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids # A helper to create a # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) @@ -401,20 +326,30 @@ module OpenAI T.nilable(T::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore]) ) end - def vector_stores - end + attr_reader :vector_stores sig do - params(_: T::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore]) - .returns(T::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore]) - end - def vector_stores=(_) + params( + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash + ) + ] + ) + .void end + attr_writer :vector_stores sig do params( vector_store_ids: T::Array[String], - vector_stores: T::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore] + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash + ) + ] ) .returns(T.attached_class) end @@ -446,36 +381,28 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ) ) - .returns( - T.any( - OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to # add to the vector store. There can be a maximum of 10000 files in a vector # store. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -483,22 +410,18 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( chunking_strategy: T.any( OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -514,7 +437,7 @@ module OpenAI OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -523,27 +446,13 @@ module OpenAI # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - } - end + module ChunkingStrategy + extend OpenAI::Union class Auto < OpenAI::BaseModel # Always `auto`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of # `800` and `chunk_overlap_tokens` of `400`. @@ -562,32 +471,29 @@ module OpenAI OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static ) end - def static - end + attr_reader :static sig do params( - _: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static - ) - .returns( - OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static + static: T.any( + OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash ) + ) + .void end - def static=(_) - end + attr_writer :static # Always `static`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( - static: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + static: T.any( + OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -612,22 +518,12 @@ module OpenAI # # Note that the overlap must not exceed half of `max_chunk_size_tokens`. sig { returns(Integer) } - def chunk_overlap_tokens - end - - sig { params(_: Integer).returns(Integer) } - def chunk_overlap_tokens=(_) - end + attr_accessor :chunk_overlap_tokens # The maximum number of tokens in each chunk. The default value is `800`. The # minimum value is `100` and the maximum value is `4096`. sig { returns(Integer) } - def max_chunk_size_tokens - end - - sig { params(_: Integer).returns(Integer) } - def max_chunk_size_tokens=(_) - end + attr_accessor :max_chunk_size_tokens sig do params( @@ -643,6 +539,15 @@ module OpenAI end end end + + sig do + override + .returns( + [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/assistant_delete_params.rbi b/rbi/lib/openai/models/beta/assistant_delete_params.rbi index f6e02e32..ca945e48 100644 --- a/rbi/lib/openai/models/beta/assistant_delete_params.rbi +++ b/rbi/lib/openai/models/beta/assistant_delete_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Beta class AssistantDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/beta/assistant_deleted.rbi b/rbi/lib/openai/models/beta/assistant_deleted.rbi index bf4cde08..c5b56819 100644 --- a/rbi/lib/openai/models/beta/assistant_deleted.rbi +++ b/rbi/lib/openai/models/beta/assistant_deleted.rbi @@ -5,28 +5,13 @@ module OpenAI module Beta class AssistantDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"assistant.deleted") diff --git a/rbi/lib/openai/models/beta/assistant_list_params.rbi b/rbi/lib/openai/models/beta/assistant_list_params.rbi index bb11fb1b..1657931e 100644 --- a/rbi/lib/openai/models/beta/assistant_list_params.rbi +++ b/rbi/lib/openai/models/beta/assistant_list_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Beta class AssistantListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -12,52 +12,44 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Beta::AssistantListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Beta::AssistantListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Beta::AssistantListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -71,7 +63,7 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::AssistantListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -81,13 +73,18 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::AssistantListParams::Order) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::AssistantListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Beta::AssistantListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Beta::AssistantListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Beta::AssistantListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/assistant_response_format_option.rbi b/rbi/lib/openai/models/beta/assistant_response_format_option.rbi index ae4f724e..a44a0adc 100644 --- a/rbi/lib/openai/models/beta/assistant_response_format_option.rbi +++ b/rbi/lib/openai/models/beta/assistant_response_format_option.rbi @@ -23,18 +23,16 @@ module OpenAI # the message content may be partially cut off if `finish_reason="length"`, which # indicates the generation exceeded `max_tokens` or the conversation exceeded the # max context length. - class AssistantResponseFormatOption < OpenAI::Union - abstract! + module AssistantResponseFormatOption + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema + sig do + override + .returns( + [Symbol, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/assistant_retrieve_params.rbi b/rbi/lib/openai/models/beta/assistant_retrieve_params.rbi index 493dc3a9..cb2206a7 100644 --- a/rbi/lib/openai/models/beta/assistant_retrieve_params.rbi +++ b/rbi/lib/openai/models/beta/assistant_retrieve_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Beta class AssistantRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/beta/assistant_stream_event.rbi b/rbi/lib/openai/models/beta/assistant_stream_event.rbi index e84d0007..5aa7ac81 100644 --- a/rbi/lib/openai/models/beta/assistant_stream_event.rbi +++ b/rbi/lib/openai/models/beta/assistant_stream_event.rbi @@ -23,72 +23,39 @@ module OpenAI # gracefully in your code. See the # [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) # to learn how to integrate the Assistants API with streaming. - class AssistantStreamEvent < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, - OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, - OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent - ) - } - end + module AssistantStreamEvent + extend OpenAI::Union class ThreadCreated < OpenAI::BaseModel # Represents a thread that contains # [messages](https://platform.openai.com/docs/api-reference/messages). sig { returns(OpenAI::Models::Beta::Thread) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Thread).returns(OpenAI::Models::Beta::Thread) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Thread, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Whether to enable input audio transcription. sig { returns(T.nilable(T::Boolean)) } - def enabled - end + attr_reader :enabled - sig { params(_: T::Boolean).returns(T::Boolean) } - def enabled=(_) - end + sig { params(enabled: T::Boolean).void } + attr_writer :enabled # Occurs when a new # [thread](https://platform.openai.com/docs/api-reference/threads/object) is # created. - sig { params(data: OpenAI::Models::Beta::Thread, enabled: T::Boolean, event: Symbol).returns(T.attached_class) } + sig do + params( + data: T.any(OpenAI::Models::Beta::Thread, OpenAI::Util::AnyHash), + enabled: T::Boolean, + event: Symbol + ) + .returns(T.attached_class) + end def self.new(data:, enabled: nil, event: :"thread.created") end @@ -101,24 +68,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a new # [run](https://platform.openai.com/docs/api-reference/runs/object) is created. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.created") end @@ -131,24 +94,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `queued` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.queued") end @@ -161,24 +120,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to an `in_progress` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.in_progress") end @@ -191,24 +146,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `requires_action` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.requires_action") end @@ -221,24 +172,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.completed") end @@ -251,24 +198,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # ends with status `incomplete`. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.incomplete") end @@ -281,24 +224,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # fails. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.failed") end @@ -311,24 +250,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `cancelling` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.cancelling") end @@ -341,24 +276,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # is cancelled. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.cancelled") end @@ -371,24 +302,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # expires. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.expired") end @@ -400,28 +327,21 @@ module OpenAI class ThreadRunStepCreated < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is created. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.created") end @@ -433,28 +353,21 @@ module OpenAI class ThreadRunStepInProgress < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # moves to an `in_progress` state. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.in_progress") end @@ -467,29 +380,22 @@ module OpenAI # Represents a run step delta i.e. any changed fields on a run step during # streaming. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when parts of a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # are being streamed. sig do - params(data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, event: Symbol) + params( + data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, OpenAI::Util::AnyHash), + event: Symbol + ) .returns(T.attached_class) end def self.new(data:, event: :"thread.run.step.delta") @@ -503,28 +409,21 @@ module OpenAI class ThreadRunStepCompleted < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.completed") end @@ -536,28 +435,21 @@ module OpenAI class ThreadRunStepFailed < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # fails. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.failed") end @@ -569,28 +461,21 @@ module OpenAI class ThreadRunStepCancelled < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is cancelled. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.cancelled") end @@ -602,28 +487,21 @@ module OpenAI class ThreadRunStepExpired < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # expires. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.expired") end @@ -636,25 +514,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # created. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.created") end @@ -667,25 +541,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) moves # to an `in_progress` state. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.in_progress") end @@ -698,28 +568,24 @@ module OpenAI # Represents a message delta i.e. any changed fields on a message during # streaming. sig { returns(OpenAI::Models::Beta::Threads::MessageDeltaEvent) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::MessageDeltaEvent) - .returns(OpenAI::Models::Beta::Threads::MessageDeltaEvent) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::MessageDeltaEvent, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when parts of a # [Message](https://platform.openai.com/docs/api-reference/messages/object) are # being streamed. - sig { params(data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, event: Symbol).returns(T.attached_class) } + sig do + params( + data: T.any(OpenAI::Models::Beta::Threads::MessageDeltaEvent, OpenAI::Util::AnyHash), + event: Symbol + ) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.delta") end @@ -732,25 +598,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # completed. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.completed") end @@ -763,25 +625,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) ends # before it is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.incomplete") end @@ -792,25 +650,21 @@ module OpenAI class ErrorEvent < OpenAI::BaseModel sig { returns(OpenAI::Models::ErrorObject) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::ErrorObject).returns(OpenAI::Models::ErrorObject) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::ErrorObject, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when an # [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs. # This can happen due to an internal server error or a timeout. - sig { params(data: OpenAI::Models::ErrorObject, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::ErrorObject, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :error) end @@ -818,6 +672,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/assistant_tool.rbi b/rbi/lib/openai/models/beta/assistant_tool.rbi index af9e9f94..f9ca4d29 100644 --- a/rbi/lib/openai/models/beta/assistant_tool.rbi +++ b/rbi/lib/openai/models/beta/assistant_tool.rbi @@ -3,17 +3,16 @@ module OpenAI module Models module Beta - class AssistantTool < OpenAI::Union - abstract! + module AssistantTool + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/assistant_tool_choice.rbi b/rbi/lib/openai/models/beta/assistant_tool_choice.rbi index 84562850..eaf93e66 100644 --- a/rbi/lib/openai/models/beta/assistant_tool_choice.rbi +++ b/rbi/lib/openai/models/beta/assistant_tool_choice.rbi @@ -5,46 +5,54 @@ module OpenAI module Beta class AssistantToolChoice < OpenAI::BaseModel # The type of the tool. If type is `function`, the function name must be set - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Beta::AssistantToolChoice::Type::OrSymbol) } + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::AssistantToolChoiceFunction)) } - def function - end + attr_reader :function - sig do - params(_: OpenAI::Models::Beta::AssistantToolChoiceFunction) - .returns(OpenAI::Models::Beta::AssistantToolChoiceFunction) - end - def function=(_) - end + sig { params(function: T.any(OpenAI::Models::Beta::AssistantToolChoiceFunction, OpenAI::Util::AnyHash)).void } + attr_writer :function # Specifies a tool the model should use. Use to force the model to call a specific # tool. sig do - params(type: Symbol, function: OpenAI::Models::Beta::AssistantToolChoiceFunction).returns(T.attached_class) + params( + type: OpenAI::Models::Beta::AssistantToolChoice::Type::OrSymbol, + function: T.any(OpenAI::Models::Beta::AssistantToolChoiceFunction, OpenAI::Util::AnyHash) + ) + .returns(T.attached_class) end def self.new(type:, function: nil) end - sig { override.returns({type: Symbol, function: OpenAI::Models::Beta::AssistantToolChoiceFunction}) } + sig do + override + .returns( + { + type: OpenAI::Models::Beta::AssistantToolChoice::Type::OrSymbol, + function: OpenAI::Models::Beta::AssistantToolChoiceFunction + } + ) + end def to_hash end # The type of the tool. If type is `function`, the function name must be set - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::AssistantToolChoice::Type) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + FUNCTION = T.let(:function, OpenAI::Models::Beta::AssistantToolChoice::Type::TaggedSymbol) + CODE_INTERPRETER = + T.let(:code_interpreter, OpenAI::Models::Beta::AssistantToolChoice::Type::TaggedSymbol) + FILE_SEARCH = T.let(:file_search, OpenAI::Models::Beta::AssistantToolChoice::Type::TaggedSymbol) - FUNCTION = :function - CODE_INTERPRETER = :code_interpreter - FILE_SEARCH = :file_search + sig { override.returns(T::Array[OpenAI::Models::Beta::AssistantToolChoice::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/assistant_tool_choice_function.rbi b/rbi/lib/openai/models/beta/assistant_tool_choice_function.rbi index 6e594ce1..084e57a8 100644 --- a/rbi/lib/openai/models/beta/assistant_tool_choice_function.rbi +++ b/rbi/lib/openai/models/beta/assistant_tool_choice_function.rbi @@ -6,12 +6,7 @@ module OpenAI class AssistantToolChoiceFunction < OpenAI::BaseModel # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name sig { params(name: String).returns(T.attached_class) } def self.new(name:) diff --git a/rbi/lib/openai/models/beta/assistant_tool_choice_option.rbi b/rbi/lib/openai/models/beta/assistant_tool_choice_option.rbi index 552ca737..0df3bce3 100644 --- a/rbi/lib/openai/models/beta/assistant_tool_choice_option.rbi +++ b/rbi/lib/openai/models/beta/assistant_tool_choice_option.rbi @@ -10,23 +10,36 @@ module OpenAI # to the user. Specifying a particular tool like `{"type": "file_search"}` or # `{"type": "function", "function": {"name": "my_function"}}` forces the model to # call that tool. - class AssistantToolChoiceOption < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)} } + module AssistantToolChoiceOption + extend OpenAI::Union # `none` means the model will not call any tools and instead generates a message. # `auto` means the model can pick between generating a message or calling one or # more tools. `required` means the model must call one or more tools before # responding to the user. - class Auto < OpenAI::Enum - abstract! + module Auto + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + NONE = T.let(:none, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol) + AUTO = T.let(:auto, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol) + REQUIRED = T.let(:required, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol) - NONE = :none - AUTO = :auto - REQUIRED = :required + sig { override.returns(T::Array[OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol]) } + def self.values + end + end + + sig do + override + .returns( + [OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, OpenAI::Models::Beta::AssistantToolChoice] + ) + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/assistant_update_params.rbi b/rbi/lib/openai/models/beta/assistant_update_params.rbi index e05cff62..874e84be 100644 --- a/rbi/lib/openai/models/beta/assistant_update_params.rbi +++ b/rbi/lib/openai/models/beta/assistant_update_params.rbi @@ -4,27 +4,17 @@ module OpenAI module Models module Beta class AssistantUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The description of the assistant. The maximum length is 512 characters. sig { returns(T.nilable(String)) } - def description - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def description=(_) - end + attr_accessor :description # The system instructions that the assistant uses. The maximum length is 256,000 # characters. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -32,35 +22,23 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol))) } + attr_reader :model - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { params(model: T.any(String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol)).void } + attr_writer :model # The name of the assistant. The maximum length is 256 characters. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name # **o-series models only** # @@ -68,13 +46,8 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - sig { returns(T.nilable(Symbol)) } - def reasoning_effort - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def reasoning_effort=(_) - end + sig { returns(T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol)) } + attr_accessor :reasoning_effort # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -108,59 +81,28 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires # a list of file IDs, while the `file_search` tool requires a list of vector store # IDs. sig { returns(T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources # A list of tool enabled on the assistant. There can be a maximum of 128 tools per # assistant. Tools can be of types `code_interpreter`, `file_search`, or @@ -178,31 +120,22 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -210,40 +143,37 @@ module OpenAI # # We generally recommend altering this or temperature but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p sig do params( description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.any(String, Symbol), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.any(String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_resources: T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, OpenAI::Util::AnyHash)), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ], top_p: T.nilable(Float), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -269,10 +199,10 @@ module OpenAI { description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.any(String, Symbol), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.any(String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, @@ -303,34 +233,90 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::AssistantUpdateParams::Model) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) } + + O3_MINI = T.let(:"o3-mini", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + O3_MINI_2025_01_31 = + T.let(:"o3-mini-2025-01-31", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + O1 = T.let(:o1, OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + O1_2024_12_17 = T.let(:"o1-2024-12-17", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O = T.let(:"gpt-4o", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O_2024_11_20 = + T.let(:"gpt-4o-2024-11-20", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O_2024_08_06 = + T.let(:"gpt-4o-2024-08-06", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O_2024_05_13 = + T.let(:"gpt-4o-2024-05-13", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O_MINI = T.let(:"gpt-4o-mini", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4O_MINI_2024_07_18 = + T.let(:"gpt-4o-mini-2024-07-18", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_5_PREVIEW = + T.let(:"gpt-4.5-preview", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_5_PREVIEW_2025_02_27 = + T.let(:"gpt-4.5-preview-2025-02-27", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_TURBO = T.let(:"gpt-4-turbo", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_TURBO_2024_04_09 = + T.let(:"gpt-4-turbo-2024-04-09", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_0125_PREVIEW = + T.let(:"gpt-4-0125-preview", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_TURBO_PREVIEW = + T.let(:"gpt-4-turbo-preview", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_1106_PREVIEW = + T.let(:"gpt-4-1106-preview", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_VISION_PREVIEW = + T.let(:"gpt-4-vision-preview", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4 = T.let(:"gpt-4", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_0314 = T.let(:"gpt-4-0314", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_0613 = T.let(:"gpt-4-0613", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_32K = T.let(:"gpt-4-32k", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_32K_0314 = + T.let(:"gpt-4-32k-0314", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_4_32K_0613 = + T.let(:"gpt-4-32k-0613", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO = T.let(:"gpt-3.5-turbo", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO_16K = + T.let(:"gpt-3.5-turbo-16k", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO_0613 = + T.let(:"gpt-3.5-turbo-0613", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO_1106 = + T.let(:"gpt-3.5-turbo-1106", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO_0125 = + T.let(:"gpt-3.5-turbo-0125", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) + GPT_3_5_TURBO_16K_0613 = + T.let(:"gpt-3.5-turbo-16k-0613", OpenAI::Models::Beta::AssistantUpdateParams::Model::TaggedSymbol) end class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires @@ -338,8 +324,8 @@ module OpenAI # IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -364,12 +350,10 @@ module OpenAI # to the `code_interpreter` tool. There can be a maximum of 20 files associated # with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -386,12 +370,10 @@ module OpenAI # attached to this assistant. There can be a maximum of 1 vector store attached to # the assistant. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids sig { params(vector_store_ids: T::Array[String]).returns(T.attached_class) } def self.new(vector_store_ids: nil) diff --git a/rbi/lib/openai/models/beta/code_interpreter_tool.rbi b/rbi/lib/openai/models/beta/code_interpreter_tool.rbi index ba0e9924..3e68afee 100644 --- a/rbi/lib/openai/models/beta/code_interpreter_tool.rbi +++ b/rbi/lib/openai/models/beta/code_interpreter_tool.rbi @@ -6,12 +6,7 @@ module OpenAI class CodeInterpreterTool < OpenAI::BaseModel # The type of tool being defined: `code_interpreter` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :code_interpreter) diff --git a/rbi/lib/openai/models/beta/file_search_tool.rbi b/rbi/lib/openai/models/beta/file_search_tool.rbi index ce4b782a..4823e922 100644 --- a/rbi/lib/openai/models/beta/file_search_tool.rbi +++ b/rbi/lib/openai/models/beta/file_search_tool.rbi @@ -6,27 +6,20 @@ module OpenAI class FileSearchTool < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Overrides for the file search tool. sig { returns(T.nilable(OpenAI::Models::Beta::FileSearchTool::FileSearch)) } - def file_search - end + attr_reader :file_search - sig do - params(_: OpenAI::Models::Beta::FileSearchTool::FileSearch) - .returns(OpenAI::Models::Beta::FileSearchTool::FileSearch) - end - def file_search=(_) - end + sig { params(file_search: T.any(OpenAI::Models::Beta::FileSearchTool::FileSearch, OpenAI::Util::AnyHash)).void } + attr_writer :file_search sig do - params(file_search: OpenAI::Models::Beta::FileSearchTool::FileSearch, type: Symbol) + params( + file_search: T.any(OpenAI::Models::Beta::FileSearchTool::FileSearch, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(file_search: nil, type: :file_search) @@ -46,12 +39,10 @@ module OpenAI # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. sig { returns(T.nilable(Integer)) } - def max_num_results - end + attr_reader :max_num_results - sig { params(_: Integer).returns(Integer) } - def max_num_results=(_) - end + sig { params(max_num_results: Integer).void } + attr_writer :max_num_results # The ranking options for the file search. If not specified, the file search tool # will use the `auto` ranker and a score_threshold of 0. @@ -60,21 +51,21 @@ module OpenAI # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. sig { returns(T.nilable(OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions)) } - def ranking_options - end + attr_reader :ranking_options sig do - params(_: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions) - .returns(OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions) - end - def ranking_options=(_) + params( + ranking_options: T.any(OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :ranking_options # Overrides for the file search tool. sig do params( max_num_results: Integer, - ranking_options: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions + ranking_options: T.any(OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -94,22 +85,15 @@ module OpenAI # The score threshold for the file search. All values must be a floating point # number between 0 and 1. sig { returns(Float) } - def score_threshold - end - - sig { params(_: Float).returns(Float) } - def score_threshold=(_) - end + attr_accessor :score_threshold # The ranker to use for the file search. If not specified will use the `auto` # ranker. - sig { returns(T.nilable(Symbol)) } - def ranker - end + sig { returns(T.nilable(OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::OrSymbol)) } + attr_reader :ranker - sig { params(_: Symbol).returns(Symbol) } - def ranker=(_) - end + sig { params(ranker: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::OrSymbol).void } + attr_writer :ranker # The ranking options for the file search. If not specified, the file search tool # will use the `auto` ranker and a score_threshold of 0. @@ -117,23 +101,52 @@ module OpenAI # See the # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. - sig { params(score_threshold: Float, ranker: Symbol).returns(T.attached_class) } + sig do + params( + score_threshold: Float, + ranker: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::OrSymbol + ) + .returns(T.attached_class) + end def self.new(score_threshold:, ranker: nil) end - sig { override.returns({score_threshold: Float, ranker: Symbol}) } + sig do + override + .returns( + { + score_threshold: Float, + ranker: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::OrSymbol + } + ) + end def to_hash end # The ranker to use for the file search. If not specified will use the `auto` # ranker. - class Ranker < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - AUTO = :auto - DEFAULT_2024_08_21 = :default_2024_08_21 + module Ranker + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::TaggedSymbol) } + + AUTO = + T.let(:auto, OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::TaggedSymbol) + DEFAULT_2024_08_21 = + T.let( + :default_2024_08_21, + OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::TaggedSymbol + ) + + sig do + override + .returns(T::Array[OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/function_tool.rbi b/rbi/lib/openai/models/beta/function_tool.rbi index 645a4c1c..b12da233 100644 --- a/rbi/lib/openai/models/beta/function_tool.rbi +++ b/rbi/lib/openai/models/beta/function_tool.rbi @@ -5,23 +5,19 @@ module OpenAI module Beta class FunctionTool < OpenAI::BaseModel sig { returns(OpenAI::Models::FunctionDefinition) } - def function - end + attr_reader :function - sig { params(_: OpenAI::Models::FunctionDefinition).returns(OpenAI::Models::FunctionDefinition) } - def function=(_) - end + sig { params(function: T.any(OpenAI::Models::FunctionDefinition, OpenAI::Util::AnyHash)).void } + attr_writer :function # The type of tool being defined: `function` sig { returns(Symbol) } - def type - end + attr_accessor :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) + sig do + params(function: T.any(OpenAI::Models::FunctionDefinition, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) end - - sig { params(function: OpenAI::Models::FunctionDefinition, type: Symbol).returns(T.attached_class) } def self.new(function:, type: :function) end diff --git a/rbi/lib/openai/models/beta/message_stream_event.rbi b/rbi/lib/openai/models/beta/message_stream_event.rbi index ef592ec4..d141e77e 100644 --- a/rbi/lib/openai/models/beta/message_stream_event.rbi +++ b/rbi/lib/openai/models/beta/message_stream_event.rbi @@ -6,44 +6,28 @@ module OpenAI # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # created. - class MessageStreamEvent < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, - OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, - OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, - OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, - OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete - ) - } - end + module MessageStreamEvent + extend OpenAI::Union class ThreadMessageCreated < OpenAI::BaseModel # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # created. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.created") end @@ -56,25 +40,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) moves # to an `in_progress` state. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.in_progress") end @@ -87,28 +67,24 @@ module OpenAI # Represents a message delta i.e. any changed fields on a message during # streaming. sig { returns(OpenAI::Models::Beta::Threads::MessageDeltaEvent) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::MessageDeltaEvent) - .returns(OpenAI::Models::Beta::Threads::MessageDeltaEvent) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::MessageDeltaEvent, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when parts of a # [Message](https://platform.openai.com/docs/api-reference/messages/object) are # being streamed. - sig { params(data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, event: Symbol).returns(T.attached_class) } + sig do + params( + data: T.any(OpenAI::Models::Beta::Threads::MessageDeltaEvent, OpenAI::Util::AnyHash), + event: Symbol + ) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.delta") end @@ -121,25 +97,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) is # completed. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.completed") end @@ -152,25 +124,21 @@ module OpenAI # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Message) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Message).returns(OpenAI::Models::Beta::Threads::Message) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [message](https://platform.openai.com/docs/api-reference/messages/object) ends # before it is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Message, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Message, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.message.incomplete") end @@ -178,6 +146,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/run_step_stream_event.rbi b/rbi/lib/openai/models/beta/run_step_stream_event.rbi index 40de2bea..18316a2b 100644 --- a/rbi/lib/openai/models/beta/run_step_stream_event.rbi +++ b/rbi/lib/openai/models/beta/run_step_stream_event.rbi @@ -6,48 +6,27 @@ module OpenAI # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is created. - class RunStepStreamEvent < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, - OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired - ) - } - end + module RunStepStreamEvent + extend OpenAI::Union class ThreadRunStepCreated < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is created. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.created") end @@ -59,28 +38,21 @@ module OpenAI class ThreadRunStepInProgress < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # moves to an `in_progress` state. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.in_progress") end @@ -93,29 +65,22 @@ module OpenAI # Represents a run step delta i.e. any changed fields on a run step during # streaming. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when parts of a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # are being streamed. sig do - params(data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, event: Symbol) + params( + data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, OpenAI::Util::AnyHash), + event: Symbol + ) .returns(T.attached_class) end def self.new(data:, event: :"thread.run.step.delta") @@ -129,28 +94,21 @@ module OpenAI class ThreadRunStepCompleted < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.completed") end @@ -162,28 +120,21 @@ module OpenAI class ThreadRunStepFailed < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # fails. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.failed") end @@ -195,28 +146,21 @@ module OpenAI class ThreadRunStepCancelled < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # is cancelled. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.cancelled") end @@ -228,28 +172,21 @@ module OpenAI class ThreadRunStepExpired < OpenAI::BaseModel # Represents a step in execution of a run. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep) } - def data - end + attr_reader :data - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStep) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) - end - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) # expires. - sig { params(data: OpenAI::Models::Beta::Threads::Runs::RunStep, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Runs::RunStep, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.step.expired") end @@ -257,6 +194,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/run_stream_event.rbi b/rbi/lib/openai/models/beta/run_stream_event.rbi index fb5ba148..48a1e1c2 100644 --- a/rbi/lib/openai/models/beta/run_stream_event.rbi +++ b/rbi/lib/openai/models/beta/run_stream_event.rbi @@ -5,48 +5,27 @@ module OpenAI module Beta # Occurs when a new # [run](https://platform.openai.com/docs/api-reference/runs/object) is created. - class RunStreamEvent < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, - OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired - ) - } - end + module RunStreamEvent + extend OpenAI::Union class ThreadRunCreated < OpenAI::BaseModel # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a new # [run](https://platform.openai.com/docs/api-reference/runs/object) is created. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.created") end @@ -59,24 +38,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `queued` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.queued") end @@ -89,24 +64,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to an `in_progress` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.in_progress") end @@ -119,24 +90,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `requires_action` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.requires_action") end @@ -149,24 +116,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # is completed. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.completed") end @@ -179,24 +142,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # ends with status `incomplete`. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.incomplete") end @@ -209,24 +168,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # fails. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.failed") end @@ -239,24 +194,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # moves to a `cancelling` status. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.cancelling") end @@ -269,24 +220,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # is cancelled. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.cancelled") end @@ -299,24 +246,20 @@ module OpenAI # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). sig { returns(OpenAI::Models::Beta::Threads::Run) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Threads::Run).returns(OpenAI::Models::Beta::Threads::Run) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) # expires. - sig { params(data: OpenAI::Models::Beta::Threads::Run, event: Symbol).returns(T.attached_class) } + sig do + params(data: T.any(OpenAI::Models::Beta::Threads::Run, OpenAI::Util::AnyHash), event: Symbol) + .returns(T.attached_class) + end def self.new(data:, event: :"thread.run.expired") end @@ -324,6 +267,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/thread.rbi b/rbi/lib/openai/models/beta/thread.rbi index 799f589a..9061c27f 100644 --- a/rbi/lib/openai/models/beta/thread.rbi +++ b/rbi/lib/openai/models/beta/thread.rbi @@ -6,21 +6,11 @@ module OpenAI class Thread < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the thread was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -28,37 +18,27 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The object type, which is always `thread`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the # `code_interpreter` tool requires a list of file IDs, while the `file_search` # tool requires a list of vector store IDs. sig { returns(T.nilable(OpenAI::Models::Beta::Thread::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::Thread::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::Thread::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::Thread::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources # Represents a thread that contains # [messages](https://platform.openai.com/docs/api-reference/messages). @@ -66,8 +46,8 @@ module OpenAI params( id: String, created_at: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::Thread::ToolResources), + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::Thread::ToolResources, OpenAI::Util::AnyHash)), object: Symbol ) .returns(T.attached_class) @@ -81,7 +61,7 @@ module OpenAI { id: String, created_at: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), object: Symbol, tool_resources: T.nilable(OpenAI::Models::Beta::Thread::ToolResources) } @@ -92,26 +72,24 @@ module OpenAI class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::Thread::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::Thread::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::Thread::ToolResources::FileSearch) - end - def file_search=(_) + params(file_search: T.any(OpenAI::Models::Beta::Thread::ToolResources::FileSearch, OpenAI::Util::AnyHash)) + .void end + attr_writer :file_search # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the @@ -119,8 +97,8 @@ module OpenAI # tool requires a list of vector store IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::Thread::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::Thread::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -144,12 +122,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -166,12 +142,10 @@ module OpenAI # attached to this thread. There can be a maximum of 1 vector store attached to # the thread. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids sig { params(vector_store_ids: T::Array[String]).returns(T.attached_class) } def self.new(vector_store_ids: nil) diff --git a/rbi/lib/openai/models/beta/thread_create_and_run_params.rbi b/rbi/lib/openai/models/beta/thread_create_and_run_params.rbi index 60679618..5d33277e 100644 --- a/rbi/lib/openai/models/beta/thread_create_and_run_params.rbi +++ b/rbi/lib/openai/models/beta/thread_create_and_run_params.rbi @@ -4,29 +4,19 @@ module OpenAI module Models module Beta class ThreadCreateAndRunParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The ID of the # [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to # execute this run. sig { returns(String) } - def assistant_id - end - - sig { params(_: String).returns(String) } - def assistant_id=(_) - end + attr_accessor :assistant_id # Override the default system message of the assistant. This is useful for # modifying the behavior on a per-run basis. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # The maximum number of completion tokens that may be used over the course of the # run. The run will make a best effort to use only the number of completion tokens @@ -34,12 +24,7 @@ module OpenAI # completion tokens specified, the run will end with status `incomplete`. See # `incomplete_details` for more info. sig { returns(T.nilable(Integer)) } - def max_completion_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_completion_tokens=(_) - end + attr_accessor :max_completion_tokens # The maximum number of prompt tokens that may be used over the course of the run. # The run will make a best effort to use only the number of prompt tokens @@ -47,12 +32,7 @@ module OpenAI # prompt tokens specified, the run will end with status `incomplete`. See # `incomplete_details` for more info. sig { returns(T.nilable(Integer)) } - def max_prompt_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_prompt_tokens=(_) - end + attr_accessor :max_prompt_tokens # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -60,36 +40,24 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end - - sig { params(_: T.nilable(T.any(String, Symbol))).returns(T.nilable(T.any(String, Symbol))) } - def model=(_) - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol))) } + attr_accessor :model # Whether to enable # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) # during tool use. sig { returns(T.nilable(T::Boolean)) } - def parallel_tool_calls - end + attr_reader :parallel_tool_calls - sig { params(_: T::Boolean).returns(T::Boolean) } - def parallel_tool_calls=(_) - end + sig { params(parallel_tool_calls: T::Boolean).void } + attr_writer :parallel_tool_calls # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -123,57 +91,21 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # Options to create a new thread. If no thread is provided when running a request, # an empty thread will be created. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread)) } - def thread - end + attr_reader :thread - sig do - params(_: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread) - .returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread) - end - def thread=(_) - end + sig { params(thread: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, OpenAI::Util::AnyHash)).void } + attr_writer :thread # Controls which (if any) tool is called by the model. `none` means the model will # not call any tools and instead generates a message. `auto` is the default value @@ -182,31 +114,32 @@ module OpenAI # to the user. Specifying a particular tool like `{"type": "file_search"}` or # `{"type": "function", "function": {"name": "my_function"}}` forces the model to # call that tool. - sig { returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) } - def tool_choice - end - sig do - params(_: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - .returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - end - def tool_choice=(_) + returns( + T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice + ) + ) + ) end + attr_accessor :tool_choice # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires # a list of file IDs, while the `file_search` tool requires a list of vector store # IDs. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources # Override the tools the assistant can use for this run. This is useful for # modifying the behavior on a per-run basis. @@ -223,35 +156,7 @@ module OpenAI ) ) end - def tools - end - - sig do - params( - _: T.nilable( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - ) - .returns( - T.nilable( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - ) - end - def tools=(_) - end + attr_accessor :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -259,25 +164,22 @@ module OpenAI # # We generally recommend altering this or temperature but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy)) } - def truncation_strategy - end + attr_reader :truncation_strategy sig do - params(_: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy)) - .returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy)) - end - def truncation_strategy=(_) + params( + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, OpenAI::Util::AnyHash) + ) + ) + .void end + attr_writer :truncation_strategy sig do params( @@ -285,33 +187,43 @@ module OpenAI instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources), + thread: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, OpenAI::Util::AnyHash), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, OpenAI::Util::AnyHash)), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -343,8 +255,8 @@ module OpenAI instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, response_format: T.nilable( T.any( @@ -356,7 +268,12 @@ module OpenAI ), temperature: T.nilable(Float), thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice + ) + ), tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources), tools: T.nilable( T::Array[ @@ -380,25 +297,27 @@ module OpenAI # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol]) } + def self.variants + end end class Thread < OpenAI::BaseModel # A list of [messages](https://platform.openai.com/docs/api-reference/messages) to # start the thread with. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message])) } - def messages - end + attr_reader :messages sig do - params(_: T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message]) - .returns(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message]) - end - def messages=(_) + params( + messages: T::Array[T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :messages # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -406,36 +325,35 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the # `code_interpreter` tool requires a list of file IDs, while the `file_search` # tool requires a list of vector store IDs. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources, OpenAI::Util::AnyHash) + ) + ) + .void end + attr_writer :tool_resources # Options to create a new thread. If no thread is provided when running a request, # an empty thread will be created. sig do params( - messages: T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message], - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources) + messages: T::Array[T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message, OpenAI::Util::AnyHash)], + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources, OpenAI::Util::AnyHash) + ) ) .returns(T.attached_class) end @@ -447,7 +365,7 @@ module OpenAI .returns( { messages: T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message], - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources) } ) @@ -471,37 +389,7 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - .returns( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - end - def content=(_) - end + attr_accessor :content # The role of the entity that is creating the message. Allowed values include: # @@ -509,27 +397,12 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::OrSymbol) } + attr_accessor :role # A list of files attached to the message, and the tools they should be added to. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment])) } - def attachments - end - - sig do - params( - _: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]) - ) - .returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment])) - end - def attachments=(_) - end + attr_accessor :attachments # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -537,13 +410,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( @@ -552,14 +420,17 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam ) ] ), - role: Symbol, - attachments: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + role: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::OrSymbol, + attachments: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -580,9 +451,9 @@ module OpenAI ) ] ), - role: Symbol, + role: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::OrSymbol, attachments: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -590,33 +461,32 @@ module OpenAI end # The text contents of the message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Models::Beta::Threads::ImageURLContentBlock, + OpenAI::Models::Beta::Threads::TextContentBlockParam + ) + ] ] ) - } + end + def self.variants end - MessageContentPartParamArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam + MessageContentPartParamArray = + T.let( + OpenAI::ArrayOf[union: OpenAI::Models::Beta::Threads::MessageContentPartParam], + OpenAI::Type::Converter ) - ] - end end # The role of the entity that is creating the message. Allowed values include: @@ -625,24 +495,33 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::TaggedSymbol) } - USER = :user - ASSISTANT = :assistant + USER = T.let(:user, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::TaggedSymbol) + ASSISTANT = + T.let(:assistant, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role::TaggedSymbol]) + end + def self.values + end end class Attachment < OpenAI::BaseModel # The ID of the file to attach to the message. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The tools to add this file to. sig do @@ -657,29 +536,21 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools sig do params( @@ -687,6 +558,7 @@ module OpenAI tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch ) ] @@ -713,27 +585,13 @@ module OpenAI def to_hash end - class Tool < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch - ) - } - end + module Tool + extend OpenAI::Union class FileSearch < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :file_search) @@ -743,32 +601,47 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch] + ) + end + def self.variants + end end end end class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :file_search # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the @@ -776,8 +649,14 @@ module OpenAI # tool requires a list of vector store IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch + code_interpreter: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, + OpenAI::Util::AnyHash + ), + file_search: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch, + OpenAI::Util::AnyHash + ) ) .returns(T.attached_class) end @@ -801,12 +680,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -823,12 +700,10 @@ module OpenAI # attached to this thread. There can be a maximum of 1 vector store attached to # the thread. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids # A helper to create a # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) @@ -841,24 +716,30 @@ module OpenAI ) ) end - def vector_stores - end + attr_reader :vector_stores sig do params( - _: T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] - ) - .returns( - T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash ) + ] + ) + .void end - def vector_stores=(_) - end + attr_writer :vector_stores sig do params( vector_store_ids: T::Array[String], - vector_stores: T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash + ) + ] ) .returns(T.attached_class) end @@ -890,36 +771,28 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ) ) - .returns( - T.any( - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to # add to the vector store. There can be a maximum of 10000 files in a vector # store. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -927,22 +800,18 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( chunking_strategy: T.any( OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -958,7 +827,7 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -967,27 +836,13 @@ module OpenAI # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - } - end + module ChunkingStrategy + extend OpenAI::Union class Auto < OpenAI::BaseModel # Always `auto`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of # `800` and `chunk_overlap_tokens` of `400`. @@ -1006,32 +861,29 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static ) end - def static - end + attr_reader :static sig do params( - _: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static - ) - .returns( - OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static + static: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash ) + ) + .void end - def static=(_) - end + attr_writer :static # Always `static`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( - static: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + static: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -1056,22 +908,12 @@ module OpenAI # # Note that the overlap must not exceed half of `max_chunk_size_tokens`. sig { returns(Integer) } - def chunk_overlap_tokens - end - - sig { params(_: Integer).returns(Integer) } - def chunk_overlap_tokens=(_) - end + attr_accessor :chunk_overlap_tokens # The maximum number of tokens in each chunk. The default value is `800`. The # minimum value is `100` and the maximum value is `4096`. sig { returns(Integer) } - def max_chunk_size_tokens - end - - sig { params(_: Integer).returns(Integer) } - def max_chunk_size_tokens=(_) - end + attr_accessor :max_chunk_size_tokens sig do params( @@ -1089,6 +931,15 @@ module OpenAI end end end + + sig do + override + .returns( + [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + ) + end + def self.variants + end end end end @@ -1097,26 +948,29 @@ module OpenAI class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are used by the assistant's tools. The resources are # specific to the type of tool. For example, the `code_interpreter` tool requires @@ -1124,8 +978,11 @@ module OpenAI # IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch + code_interpreter: T.any( + OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, + OpenAI::Util::AnyHash + ), + file_search: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -1149,12 +1006,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -1171,12 +1026,10 @@ module OpenAI # attached to this assistant. There can be a maximum of 1 vector store attached to # the assistant. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids sig { params(vector_store_ids: T::Array[String]).returns(T.attached_class) } def self.new(vector_store_ids: nil) @@ -1188,17 +1041,16 @@ module OpenAI end end - class Tool < OpenAI::Union - abstract! + module Tool + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] ) - } + end + def self.variants end end @@ -1207,31 +1059,35 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::OrSymbol) } + attr_accessor :type # The number of most recent messages from the thread when constructing the context # for the run. sig { returns(T.nilable(Integer)) } - def last_messages - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def last_messages=(_) - end + attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. - sig { params(type: Symbol, last_messages: T.nilable(Integer)).returns(T.attached_class) } + sig do + params( + type: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::OrSymbol, + last_messages: T.nilable(Integer) + ) + .returns(T.attached_class) + end def self.new(type:, last_messages: nil) end - sig { override.returns({type: Symbol, last_messages: T.nilable(Integer)}) } + sig do + override + .returns( + { + type: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::OrSymbol, + last_messages: T.nilable(Integer) + } + ) + end def to_hash end @@ -1239,13 +1095,28 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } + module Type + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::TaggedSymbol) } + + AUTO = + T.let(:auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::TaggedSymbol) + LAST_MESSAGES = + T.let( + :last_messages, + OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::TaggedSymbol + ) - AUTO = :auto - LAST_MESSAGES = :last_messages + sig do + override + .returns(T::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/thread_create_params.rbi b/rbi/lib/openai/models/beta/thread_create_params.rbi index 94c632cf..5115f982 100644 --- a/rbi/lib/openai/models/beta/thread_create_params.rbi +++ b/rbi/lib/openai/models/beta/thread_create_params.rbi @@ -4,21 +4,21 @@ module OpenAI module Models module Beta class ThreadCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A list of [messages](https://platform.openai.com/docs/api-reference/messages) to # start the thread with. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message])) } - def messages - end + attr_reader :messages sig do - params(_: T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message]) - .returns(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message]) - end - def messages=(_) + params( + messages: T::Array[T.any(OpenAI::Models::Beta::ThreadCreateParams::Message, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :messages # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -26,35 +26,30 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the # `code_interpreter` tool requires a list of file IDs, while the `file_search` # tool requires a list of vector store IDs. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources sig do params( - messages: T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + messages: T::Array[T.any(OpenAI::Models::Beta::ThreadCreateParams::Message, OpenAI::Util::AnyHash)], + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources, OpenAI::Util::AnyHash)), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -66,7 +61,7 @@ module OpenAI .returns( { messages: T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources), request_options: OpenAI::RequestOptions } @@ -91,37 +86,7 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - .returns( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - end - def content=(_) - end + attr_accessor :content # The role of the entity that is creating the message. Allowed values include: # @@ -129,25 +94,12 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Beta::ThreadCreateParams::Message::Role::OrSymbol) } + attr_accessor :role # A list of files attached to the message, and the tools they should be added to. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment])) } - def attachments - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment])) - .returns(T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment])) - end - def attachments=(_) - end + attr_accessor :attachments # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -155,13 +107,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( @@ -170,14 +117,17 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam ) ] ), - role: Symbol, - attachments: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + role: OpenAI::Models::Beta::ThreadCreateParams::Message::Role::OrSymbol, + attachments: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -198,9 +148,9 @@ module OpenAI ) ] ), - role: Symbol, + role: OpenAI::Models::Beta::ThreadCreateParams::Message::Role::OrSymbol, attachments: T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -208,33 +158,32 @@ module OpenAI end # The text contents of the message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Models::Beta::Threads::ImageURLContentBlock, + OpenAI::Models::Beta::Threads::TextContentBlockParam + ) + ] ] ) - } + end + def self.variants end - MessageContentPartParamArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam + MessageContentPartParamArray = + T.let( + OpenAI::ArrayOf[union: OpenAI::Models::Beta::Threads::MessageContentPartParam], + OpenAI::Type::Converter ) - ] - end end # The role of the entity that is creating the message. Allowed values include: @@ -243,24 +192,28 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role::TaggedSymbol) } - USER = :user - ASSISTANT = :assistant + USER = T.let(:user, OpenAI::Models::Beta::ThreadCreateParams::Message::Role::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Beta::ThreadCreateParams::Message::Role::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Role::TaggedSymbol]) } + def self.values + end end class Attachment < OpenAI::BaseModel # The ID of the file to attach to the message. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The tools to add this file to. sig do @@ -275,29 +228,21 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools sig do params( @@ -305,6 +250,7 @@ module OpenAI tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch ) ] @@ -331,27 +277,13 @@ module OpenAI def to_hash end - class Tool < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch - ) - } - end + module Tool + extend OpenAI::Union class FileSearch < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :file_search) @@ -361,32 +293,41 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch] + ) + end + def self.variants + end end end end class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the @@ -394,8 +335,8 @@ module OpenAI # tool requires a list of vector store IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -419,12 +360,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -441,12 +380,10 @@ module OpenAI # attached to this thread. There can be a maximum of 1 vector store attached to # the thread. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids # A helper to create a # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) @@ -457,20 +394,30 @@ module OpenAI T.nilable(T::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore]) ) end - def vector_stores - end + attr_reader :vector_stores sig do - params(_: T::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore]) - .returns(T::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore]) - end - def vector_stores=(_) + params( + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash + ) + ] + ) + .void end + attr_writer :vector_stores sig do params( vector_store_ids: T::Array[String], - vector_stores: T::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] + vector_stores: T::Array[ + T.any( + OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore, + OpenAI::Util::AnyHash + ) + ] ) .returns(T.attached_class) end @@ -502,36 +449,28 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ) ) - .returns( - T.any( - OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to # add to the vector store. There can be a maximum of 10000 files in a vector # store. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -539,22 +478,18 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( chunking_strategy: T.any( OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -570,7 +505,7 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static ), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -579,27 +514,13 @@ module OpenAI # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. - class ChunkingStrategy < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, - OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - ) - } - end + module ChunkingStrategy + extend OpenAI::Union class Auto < OpenAI::BaseModel # Always `auto`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of # `800` and `chunk_overlap_tokens` of `400`. @@ -618,32 +539,29 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static ) end - def static - end + attr_reader :static sig do params( - _: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static - ) - .returns( - OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static + static: T.any( + OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash ) + ) + .void end - def static=(_) - end + attr_writer :static # Always `static`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( - static: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + static: T.any( + OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -668,22 +586,12 @@ module OpenAI # # Note that the overlap must not exceed half of `max_chunk_size_tokens`. sig { returns(Integer) } - def chunk_overlap_tokens - end - - sig { params(_: Integer).returns(Integer) } - def chunk_overlap_tokens=(_) - end + attr_accessor :chunk_overlap_tokens # The maximum number of tokens in each chunk. The default value is `800`. The # minimum value is `100` and the maximum value is `4096`. sig { returns(Integer) } - def max_chunk_size_tokens - end - - sig { params(_: Integer).returns(Integer) } - def max_chunk_size_tokens=(_) - end + attr_accessor :max_chunk_size_tokens sig do params( @@ -699,6 +607,15 @@ module OpenAI end end end + + sig do + override + .returns( + [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/thread_delete_params.rbi b/rbi/lib/openai/models/beta/thread_delete_params.rbi index a47b1e53..0b43e22c 100644 --- a/rbi/lib/openai/models/beta/thread_delete_params.rbi +++ b/rbi/lib/openai/models/beta/thread_delete_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Beta class ThreadDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/beta/thread_deleted.rbi b/rbi/lib/openai/models/beta/thread_deleted.rbi index 1ca71e29..cc908f49 100644 --- a/rbi/lib/openai/models/beta/thread_deleted.rbi +++ b/rbi/lib/openai/models/beta/thread_deleted.rbi @@ -5,28 +5,13 @@ module OpenAI module Beta class ThreadDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"thread.deleted") diff --git a/rbi/lib/openai/models/beta/thread_retrieve_params.rbi b/rbi/lib/openai/models/beta/thread_retrieve_params.rbi index 07f1e477..436ff67f 100644 --- a/rbi/lib/openai/models/beta/thread_retrieve_params.rbi +++ b/rbi/lib/openai/models/beta/thread_retrieve_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Beta class ThreadRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/beta/thread_stream_event.rbi b/rbi/lib/openai/models/beta/thread_stream_event.rbi index b7db3495..53d58531 100644 --- a/rbi/lib/openai/models/beta/thread_stream_event.rbi +++ b/rbi/lib/openai/models/beta/thread_stream_event.rbi @@ -7,34 +7,32 @@ module OpenAI # Represents a thread that contains # [messages](https://platform.openai.com/docs/api-reference/messages). sig { returns(OpenAI::Models::Beta::Thread) } - def data - end + attr_reader :data - sig { params(_: OpenAI::Models::Beta::Thread).returns(OpenAI::Models::Beta::Thread) } - def data=(_) - end + sig { params(data: T.any(OpenAI::Models::Beta::Thread, OpenAI::Util::AnyHash)).void } + attr_writer :data sig { returns(Symbol) } - def event - end - - sig { params(_: Symbol).returns(Symbol) } - def event=(_) - end + attr_accessor :event # Whether to enable input audio transcription. sig { returns(T.nilable(T::Boolean)) } - def enabled - end + attr_reader :enabled - sig { params(_: T::Boolean).returns(T::Boolean) } - def enabled=(_) - end + sig { params(enabled: T::Boolean).void } + attr_writer :enabled # Occurs when a new # [thread](https://platform.openai.com/docs/api-reference/threads/object) is # created. - sig { params(data: OpenAI::Models::Beta::Thread, enabled: T::Boolean, event: Symbol).returns(T.attached_class) } + sig do + params( + data: T.any(OpenAI::Models::Beta::Thread, OpenAI::Util::AnyHash), + enabled: T::Boolean, + event: Symbol + ) + .returns(T.attached_class) + end def self.new(data:, enabled: nil, event: :"thread.created") end diff --git a/rbi/lib/openai/models/beta/thread_update_params.rbi b/rbi/lib/openai/models/beta/thread_update_params.rbi index 2748a8cc..227c5099 100644 --- a/rbi/lib/openai/models/beta/thread_update_params.rbi +++ b/rbi/lib/openai/models/beta/thread_update_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Beta class ThreadUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Set of 16 key-value pairs that can be attached to an object. This can be useful @@ -13,34 +13,29 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the # `code_interpreter` tool requires a list of file IDs, while the `file_search` # tool requires a list of vector store IDs. sig { returns(T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources)) } - def tool_resources - end + attr_reader :tool_resources sig do - params(_: T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources)) - .returns(T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources)) - end - def tool_resources=(_) + params( + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :tool_resources sig do params( - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, OpenAI::Util::AnyHash)), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -51,7 +46,7 @@ module OpenAI override .returns( { - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), tool_resources: T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources), request_options: OpenAI::RequestOptions } @@ -62,26 +57,26 @@ module OpenAI class ToolResources < OpenAI::BaseModel sig { returns(T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter) - .returns(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter sig { returns(T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch)) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch) - .returns(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # A set of resources that are made available to the assistant's tools in this # thread. The resources are specific to the type of tool. For example, the @@ -89,8 +84,8 @@ module OpenAI # tool requires a list of vector store IDs. sig do params( - code_interpreter: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch + code_interpreter: T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, OpenAI::Util::AnyHash), + file_search: T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -114,12 +109,10 @@ module OpenAI # available to the `code_interpreter` tool. There can be a maximum of 20 files # associated with the tool. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids sig { params(file_ids: T::Array[String]).returns(T.attached_class) } def self.new(file_ids: nil) @@ -136,12 +129,10 @@ module OpenAI # attached to this thread. There can be a maximum of 1 vector store attached to # the thread. sig { returns(T.nilable(T::Array[String])) } - def vector_store_ids - end + attr_reader :vector_store_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + sig { params(vector_store_ids: T::Array[String]).void } + attr_writer :vector_store_ids sig { params(vector_store_ids: T::Array[String]).returns(T.attached_class) } def self.new(vector_store_ids: nil) diff --git a/rbi/lib/openai/models/beta/threads/annotation.rbi b/rbi/lib/openai/models/beta/threads/annotation.rbi index dc7434e2..02f8a33e 100644 --- a/rbi/lib/openai/models/beta/threads/annotation.rbi +++ b/rbi/lib/openai/models/beta/threads/annotation.rbi @@ -7,16 +7,16 @@ module OpenAI # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant # uses the "file_search" tool to search files. - class Annotation < OpenAI::Union - abstract! + module Annotation + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::FileCitationAnnotation, - OpenAI::Models::Beta::Threads::FilePathAnnotation + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/annotation_delta.rbi b/rbi/lib/openai/models/beta/threads/annotation_delta.rbi index 32598149..133c007f 100644 --- a/rbi/lib/openai/models/beta/threads/annotation_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/annotation_delta.rbi @@ -7,16 +7,16 @@ module OpenAI # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant # uses the "file_search" tool to search files. - class AnnotationDelta < OpenAI::Union - abstract! + module AnnotationDelta + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, - OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/file_citation_annotation.rbi b/rbi/lib/openai/models/beta/threads/file_citation_annotation.rbi index 75c0a985..c8f84631 100644 --- a/rbi/lib/openai/models/beta/threads/file_citation_annotation.rbi +++ b/rbi/lib/openai/models/beta/threads/file_citation_annotation.rbi @@ -6,49 +6,29 @@ module OpenAI module Threads class FileCitationAnnotation < OpenAI::BaseModel sig { returns(Integer) } - def end_index - end - - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + attr_accessor :end_index sig { returns(OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation) } - def file_citation - end + attr_reader :file_citation sig do - params(_: OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation) - .returns(OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation) - end - def file_citation=(_) + params( + file_citation: T.any(OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_citation sig { returns(Integer) } - def start_index - end - - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + attr_accessor :start_index # The text in the message content that needs to be replaced. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Always `file_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant @@ -56,7 +36,7 @@ module OpenAI sig do params( end_index: Integer, - file_citation: OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation, + file_citation: T.any(OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation, OpenAI::Util::AnyHash), start_index: Integer, text: String, type: Symbol @@ -84,12 +64,7 @@ module OpenAI class FileCitation < OpenAI::BaseModel # The ID of the specific File the citation is from. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id sig { params(file_id: String).returns(T.attached_class) } def self.new(file_id:) diff --git a/rbi/lib/openai/models/beta/threads/file_citation_delta_annotation.rbi b/rbi/lib/openai/models/beta/threads/file_citation_delta_annotation.rbi index 7031c979..dd7bb7b4 100644 --- a/rbi/lib/openai/models/beta/threads/file_citation_delta_annotation.rbi +++ b/rbi/lib/openai/models/beta/threads/file_citation_delta_annotation.rbi @@ -7,57 +7,41 @@ module OpenAI class FileCitationDeltaAnnotation < OpenAI::BaseModel # The index of the annotation in the text content part. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `file_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(Integer)) } - def end_index - end + attr_reader :end_index - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + sig { params(end_index: Integer).void } + attr_writer :end_index sig { returns(T.nilable(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation)) } - def file_citation - end + attr_reader :file_citation sig do - params(_: OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation) - .returns(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation) - end - def file_citation=(_) + params( + file_citation: T.any(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_citation sig { returns(T.nilable(Integer)) } - def start_index - end + attr_reader :start_index - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + sig { params(start_index: Integer).void } + attr_writer :start_index # The text in the message content that needs to be replaced. sig { returns(T.nilable(String)) } - def text - end + attr_reader :text - sig { params(_: String).returns(String) } - def text=(_) - end + sig { params(text: String).void } + attr_writer :text # A citation within the message that points to a specific quote from a specific # File associated with the assistant or the message. Generated when the assistant @@ -66,14 +50,21 @@ module OpenAI params( index: Integer, end_index: Integer, - file_citation: OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, + file_citation: T.any(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, OpenAI::Util::AnyHash), start_index: Integer, text: String, type: Symbol ) .returns(T.attached_class) end - def self.new(index:, end_index: nil, file_citation: nil, start_index: nil, text: nil, type: :file_citation) + def self.new( + index:, + end_index: nil, + file_citation: nil, + start_index: nil, + text: nil, + type: :file_citation + ) end sig do @@ -95,21 +86,17 @@ module OpenAI class FileCitation < OpenAI::BaseModel # The ID of the specific File the citation is from. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The specific quote in the file. sig { returns(T.nilable(String)) } - def quote - end + attr_reader :quote - sig { params(_: String).returns(String) } - def quote=(_) - end + sig { params(quote: String).void } + attr_writer :quote sig { params(file_id: String, quote: String).returns(T.attached_class) } def self.new(file_id: nil, quote: nil) diff --git a/rbi/lib/openai/models/beta/threads/file_path_annotation.rbi b/rbi/lib/openai/models/beta/threads/file_path_annotation.rbi index c5e902d9..33a5f4e1 100644 --- a/rbi/lib/openai/models/beta/threads/file_path_annotation.rbi +++ b/rbi/lib/openai/models/beta/threads/file_path_annotation.rbi @@ -6,56 +6,36 @@ module OpenAI module Threads class FilePathAnnotation < OpenAI::BaseModel sig { returns(Integer) } - def end_index - end - - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + attr_accessor :end_index sig { returns(OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath) } - def file_path - end + attr_reader :file_path sig do - params(_: OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath) - .returns(OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath) - end - def file_path=(_) + params( + file_path: T.any(OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_path sig { returns(Integer) } - def start_index - end - - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + attr_accessor :start_index # The text in the message content that needs to be replaced. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Always `file_path`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A URL for the file that's generated when the assistant used the # `code_interpreter` tool to generate a file. sig do params( end_index: Integer, - file_path: OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath, + file_path: T.any(OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath, OpenAI::Util::AnyHash), start_index: Integer, text: String, type: Symbol @@ -83,12 +63,7 @@ module OpenAI class FilePath < OpenAI::BaseModel # The ID of the file that was generated. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id sig { params(file_id: String).returns(T.attached_class) } def self.new(file_id:) diff --git a/rbi/lib/openai/models/beta/threads/file_path_delta_annotation.rbi b/rbi/lib/openai/models/beta/threads/file_path_delta_annotation.rbi index 3da258f2..7c79aae6 100644 --- a/rbi/lib/openai/models/beta/threads/file_path_delta_annotation.rbi +++ b/rbi/lib/openai/models/beta/threads/file_path_delta_annotation.rbi @@ -7,57 +7,41 @@ module OpenAI class FilePathDeltaAnnotation < OpenAI::BaseModel # The index of the annotation in the text content part. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `file_path`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(Integer)) } - def end_index - end + attr_reader :end_index - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + sig { params(end_index: Integer).void } + attr_writer :end_index sig { returns(T.nilable(OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath)) } - def file_path - end + attr_reader :file_path sig do - params(_: OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath) - .returns(OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath) - end - def file_path=(_) + params( + file_path: T.any(OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_path sig { returns(T.nilable(Integer)) } - def start_index - end + attr_reader :start_index - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + sig { params(start_index: Integer).void } + attr_writer :start_index # The text in the message content that needs to be replaced. sig { returns(T.nilable(String)) } - def text - end + attr_reader :text - sig { params(_: String).returns(String) } - def text=(_) - end + sig { params(text: String).void } + attr_writer :text # A URL for the file that's generated when the assistant used the # `code_interpreter` tool to generate a file. @@ -65,7 +49,7 @@ module OpenAI params( index: Integer, end_index: Integer, - file_path: OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, + file_path: T.any(OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, OpenAI::Util::AnyHash), start_index: Integer, text: String, type: Symbol @@ -94,12 +78,10 @@ module OpenAI class FilePath < OpenAI::BaseModel # The ID of the file that was generated. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id sig { params(file_id: String).returns(T.attached_class) } def self.new(file_id: nil) diff --git a/rbi/lib/openai/models/beta/threads/image_file.rbi b/rbi/lib/openai/models/beta/threads/image_file.rbi index 879b0320..4a97f32e 100644 --- a/rbi/lib/openai/models/beta/threads/image_file.rbi +++ b/rbi/lib/openai/models/beta/threads/image_file.rbi @@ -9,41 +9,42 @@ module OpenAI # in the message content. Set `purpose="vision"` when uploading the File if you # need to later display the file content. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - sig { returns(T.nilable(Symbol)) } - def detail - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageFile::Detail::OrSymbol)) } + attr_reader :detail - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) - end + sig { params(detail: OpenAI::Models::Beta::Threads::ImageFile::Detail::OrSymbol).void } + attr_writer :detail - sig { params(file_id: String, detail: Symbol).returns(T.attached_class) } + sig do + params(file_id: String, detail: OpenAI::Models::Beta::Threads::ImageFile::Detail::OrSymbol) + .returns(T.attached_class) + end def self.new(file_id:, detail: nil) end - sig { override.returns({file_id: String, detail: Symbol}) } + sig { override.returns({file_id: String, detail: OpenAI::Models::Beta::Threads::ImageFile::Detail::OrSymbol}) } def to_hash end # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - class Detail < OpenAI::Enum - abstract! + module Detail + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::ImageFile::Detail) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::ImageFile::Detail::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::Beta::Threads::ImageFile::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Beta::Threads::ImageFile::Detail::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Beta::Threads::ImageFile::Detail::TaggedSymbol) - AUTO = :auto - LOW = :low - HIGH = :high + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::ImageFile::Detail::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/image_file_content_block.rbi b/rbi/lib/openai/models/beta/threads/image_file_content_block.rbi index 281b7cb7..18986902 100644 --- a/rbi/lib/openai/models/beta/threads/image_file_content_block.rbi +++ b/rbi/lib/openai/models/beta/threads/image_file_content_block.rbi @@ -6,25 +6,21 @@ module OpenAI module Threads class ImageFileContentBlock < OpenAI::BaseModel sig { returns(OpenAI::Models::Beta::Threads::ImageFile) } - def image_file - end + attr_reader :image_file - sig { params(_: OpenAI::Models::Beta::Threads::ImageFile).returns(OpenAI::Models::Beta::Threads::ImageFile) } - def image_file=(_) - end + sig { params(image_file: T.any(OpenAI::Models::Beta::Threads::ImageFile, OpenAI::Util::AnyHash)).void } + attr_writer :image_file # Always `image_file`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - sig { params(image_file: OpenAI::Models::Beta::Threads::ImageFile, type: Symbol).returns(T.attached_class) } + sig do + params(image_file: T.any(OpenAI::Models::Beta::Threads::ImageFile, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(image_file:, type: :image_file) end diff --git a/rbi/lib/openai/models/beta/threads/image_file_delta.rbi b/rbi/lib/openai/models/beta/threads/image_file_delta.rbi index 89c10a01..f2b98ec3 100644 --- a/rbi/lib/openai/models/beta/threads/image_file_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/image_file_delta.rbi @@ -7,43 +7,51 @@ module OpenAI class ImageFileDelta < OpenAI::BaseModel # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - sig { returns(T.nilable(Symbol)) } - def detail - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol)) } + attr_reader :detail - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) - end + sig { params(detail: OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::OrSymbol).void } + attr_writer :detail # The [File](https://platform.openai.com/docs/api-reference/files) ID of the image # in the message content. Set `purpose="vision"` when uploading the File if you # need to later display the file content. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id - sig { params(detail: Symbol, file_id: String).returns(T.attached_class) } + sig do + params(detail: OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::OrSymbol, file_id: String) + .returns(T.attached_class) + end def self.new(detail: nil, file_id: nil) end - sig { override.returns({detail: Symbol, file_id: String}) } + sig do + override + .returns({detail: OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol, file_id: String}) + end def to_hash end # Specifies the detail level of the image if specified by the user. `low` uses # fewer tokens, you can opt in to high resolution using `high`. - class Detail < OpenAI::Enum - abstract! + module Detail + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol) - AUTO = :auto - LOW = :low - HIGH = :high + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::ImageFileDelta::Detail::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/image_file_delta_block.rbi b/rbi/lib/openai/models/beta/threads/image_file_delta_block.rbi index 9dba68e1..3dcd3939 100644 --- a/rbi/lib/openai/models/beta/threads/image_file_delta_block.rbi +++ b/rbi/lib/openai/models/beta/threads/image_file_delta_block.rbi @@ -7,37 +7,26 @@ module OpenAI class ImageFileDeltaBlock < OpenAI::BaseModel # The index of the content part in the message. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `image_file`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageFileDelta)) } - def image_file - end + attr_reader :image_file - sig do - params(_: OpenAI::Models::Beta::Threads::ImageFileDelta) - .returns(OpenAI::Models::Beta::Threads::ImageFileDelta) - end - def image_file=(_) - end + sig { params(image_file: T.any(OpenAI::Models::Beta::Threads::ImageFileDelta, OpenAI::Util::AnyHash)).void } + attr_writer :image_file # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. sig do - params(index: Integer, image_file: OpenAI::Models::Beta::Threads::ImageFileDelta, type: Symbol) + params( + index: Integer, + image_file: T.any(OpenAI::Models::Beta::Threads::ImageFileDelta, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(index:, image_file: nil, type: :image_file) diff --git a/rbi/lib/openai/models/beta/threads/image_url.rbi b/rbi/lib/openai/models/beta/threads/image_url.rbi index e4aa98eb..732b0f05 100644 --- a/rbi/lib/openai/models/beta/threads/image_url.rbi +++ b/rbi/lib/openai/models/beta/threads/image_url.rbi @@ -8,41 +8,42 @@ module OpenAI # The external URL of the image, must be a supported image types: jpeg, jpg, png, # gif, webp. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. Default value is `auto` - sig { returns(T.nilable(Symbol)) } - def detail - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageURL::Detail::OrSymbol)) } + attr_reader :detail - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) - end + sig { params(detail: OpenAI::Models::Beta::Threads::ImageURL::Detail::OrSymbol).void } + attr_writer :detail - sig { params(url: String, detail: Symbol).returns(T.attached_class) } + sig do + params(url: String, detail: OpenAI::Models::Beta::Threads::ImageURL::Detail::OrSymbol) + .returns(T.attached_class) + end def self.new(url:, detail: nil) end - sig { override.returns({url: String, detail: Symbol}) } + sig { override.returns({url: String, detail: OpenAI::Models::Beta::Threads::ImageURL::Detail::OrSymbol}) } def to_hash end # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. Default value is `auto` - class Detail < OpenAI::Enum - abstract! + module Detail + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::ImageURL::Detail) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::ImageURL::Detail::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::Beta::Threads::ImageURL::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Beta::Threads::ImageURL::Detail::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Beta::Threads::ImageURL::Detail::TaggedSymbol) - AUTO = :auto - LOW = :low - HIGH = :high + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::ImageURL::Detail::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/image_url_content_block.rbi b/rbi/lib/openai/models/beta/threads/image_url_content_block.rbi index a6c65020..2c1839ed 100644 --- a/rbi/lib/openai/models/beta/threads/image_url_content_block.rbi +++ b/rbi/lib/openai/models/beta/threads/image_url_content_block.rbi @@ -6,24 +6,20 @@ module OpenAI module Threads class ImageURLContentBlock < OpenAI::BaseModel sig { returns(OpenAI::Models::Beta::Threads::ImageURL) } - def image_url - end + attr_reader :image_url - sig { params(_: OpenAI::Models::Beta::Threads::ImageURL).returns(OpenAI::Models::Beta::Threads::ImageURL) } - def image_url=(_) - end + sig { params(image_url: T.any(OpenAI::Models::Beta::Threads::ImageURL, OpenAI::Util::AnyHash)).void } + attr_writer :image_url # The type of the content part. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # References an image URL in the content of a message. - sig { params(image_url: OpenAI::Models::Beta::Threads::ImageURL, type: Symbol).returns(T.attached_class) } + sig do + params(image_url: T.any(OpenAI::Models::Beta::Threads::ImageURL, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(image_url:, type: :image_url) end diff --git a/rbi/lib/openai/models/beta/threads/image_url_delta.rbi b/rbi/lib/openai/models/beta/threads/image_url_delta.rbi index a300a59e..281a3d35 100644 --- a/rbi/lib/openai/models/beta/threads/image_url_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/image_url_delta.rbi @@ -7,42 +7,49 @@ module OpenAI class ImageURLDelta < OpenAI::BaseModel # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. - sig { returns(T.nilable(Symbol)) } - def detail - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol)) } + attr_reader :detail - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) - end + sig { params(detail: OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::OrSymbol).void } + attr_writer :detail # The URL of the image, must be a supported image types: jpeg, jpg, png, gif, # webp. sig { returns(T.nilable(String)) } - def url - end + attr_reader :url - sig { params(_: String).returns(String) } - def url=(_) - end + sig { params(url: String).void } + attr_writer :url - sig { params(detail: Symbol, url: String).returns(T.attached_class) } + sig do + params(detail: OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::OrSymbol, url: String) + .returns(T.attached_class) + end def self.new(detail: nil, url: nil) end - sig { override.returns({detail: Symbol, url: String}) } + sig do + override.returns({detail: OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol, url: String}) + end def to_hash end # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in # to high resolution using `high`. - class Detail < OpenAI::Enum - abstract! + module Detail + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol) - AUTO = :auto - LOW = :low - HIGH = :high + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::ImageURLDelta::Detail::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/image_url_delta_block.rbi b/rbi/lib/openai/models/beta/threads/image_url_delta_block.rbi index 9f8e8803..664de983 100644 --- a/rbi/lib/openai/models/beta/threads/image_url_delta_block.rbi +++ b/rbi/lib/openai/models/beta/threads/image_url_delta_block.rbi @@ -7,36 +7,25 @@ module OpenAI class ImageURLDeltaBlock < OpenAI::BaseModel # The index of the content part in the message. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `image_url`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::Threads::ImageURLDelta)) } - def image_url - end + attr_reader :image_url - sig do - params(_: OpenAI::Models::Beta::Threads::ImageURLDelta) - .returns(OpenAI::Models::Beta::Threads::ImageURLDelta) - end - def image_url=(_) - end + sig { params(image_url: T.any(OpenAI::Models::Beta::Threads::ImageURLDelta, OpenAI::Util::AnyHash)).void } + attr_writer :image_url # References an image URL in the content of a message. sig do - params(index: Integer, image_url: OpenAI::Models::Beta::Threads::ImageURLDelta, type: Symbol) + params( + index: Integer, + image_url: T.any(OpenAI::Models::Beta::Threads::ImageURLDelta, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(index:, image_url: nil, type: :image_url) diff --git a/rbi/lib/openai/models/beta/threads/message.rbi b/rbi/lib/openai/models/beta/threads/message.rbi index b79d9945..875f4bcc 100644 --- a/rbi/lib/openai/models/beta/threads/message.rbi +++ b/rbi/lib/openai/models/beta/threads/message.rbi @@ -7,44 +7,21 @@ module OpenAI class Message < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # If applicable, the ID of the # [assistant](https://platform.openai.com/docs/api-reference/assistants) that # authored this message. sig { returns(T.nilable(String)) } - def assistant_id - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def assistant_id=(_) - end + attr_accessor :assistant_id # A list of files attached to the message, and the tools they were added to. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Message::Attachment])) } - def attachments - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Beta::Threads::Message::Attachment])) - .returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Message::Attachment])) - end - def attachments=(_) - end + attr_accessor :attachments # The Unix timestamp (in seconds) for when the message was completed. sig { returns(T.nilable(Integer)) } - def completed_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def completed_at=(_) - end + attr_accessor :completed_at # The content of the message in array of text and/or images. sig do @@ -59,63 +36,27 @@ module OpenAI ] ) end - def content - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlock, - OpenAI::Models::Beta::Threads::RefusalContentBlock - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlock, - OpenAI::Models::Beta::Threads::RefusalContentBlock - ) - ] - ) - end - def content=(_) - end + attr_accessor :content # The Unix timestamp (in seconds) for when the message was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The Unix timestamp (in seconds) for when the message was marked as incomplete. sig { returns(T.nilable(Integer)) } - def incomplete_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def incomplete_at=(_) - end + attr_accessor :incomplete_at # On an incomplete message, details about why the message is incomplete. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Message::IncompleteDetails)) } - def incomplete_details - end + attr_reader :incomplete_details sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Message::IncompleteDetails)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Message::IncompleteDetails)) - end - def incomplete_details=(_) + params( + incomplete_details: T.nilable(T.any(OpenAI::Models::Beta::Threads::Message::IncompleteDetails, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :incomplete_details # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -123,62 +64,32 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The object type, which is always `thread.message`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The entity that produced the message. One of `user` or `assistant`. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol) } + attr_accessor :role # The ID of the [run](https://platform.openai.com/docs/api-reference/runs) # associated with the creation of this message. Value is `null` when messages are # created manually using the create message or create thread endpoints. sig { returns(T.nilable(String)) } - def run_id - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def run_id=(_) - end + attr_accessor :run_id # The status of the message, which can be either `in_progress`, `incomplete`, or # `completed`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol) } + attr_accessor :status # The [thread](https://platform.openai.com/docs/api-reference/threads) ID that # this message belongs to. sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # Represents a message within a # [thread](https://platform.openai.com/docs/api-reference/threads). @@ -186,11 +97,12 @@ module OpenAI params( id: String, assistant_id: T.nilable(String), - attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::Message::Attachment]), + attachments: T.nilable(T::Array[T.any(OpenAI::Models::Beta::Threads::Message::Attachment, OpenAI::Util::AnyHash)]), completed_at: T.nilable(Integer), content: T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock @@ -198,11 +110,11 @@ module OpenAI ], created_at: Integer, incomplete_at: T.nilable(Integer), - incomplete_details: T.nilable(OpenAI::Models::Beta::Threads::Message::IncompleteDetails), - metadata: T.nilable(OpenAI::Models::Metadata), - role: Symbol, + incomplete_details: T.nilable(T.any(OpenAI::Models::Beta::Threads::Message::IncompleteDetails, OpenAI::Util::AnyHash)), + metadata: T.nilable(T::Hash[Symbol, String]), + role: OpenAI::Models::Beta::Threads::Message::Role::OrSymbol, run_id: T.nilable(String), - status: Symbol, + status: OpenAI::Models::Beta::Threads::Message::Status::OrSymbol, thread_id: String, object: Symbol ) @@ -245,11 +157,11 @@ module OpenAI created_at: Integer, incomplete_at: T.nilable(Integer), incomplete_details: T.nilable(OpenAI::Models::Beta::Threads::Message::IncompleteDetails), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), object: Symbol, - role: Symbol, + role: OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol, run_id: T.nilable(String), - status: Symbol, + status: OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol, thread_id: String } ) @@ -260,12 +172,10 @@ module OpenAI class Attachment < OpenAI::BaseModel # The ID of the file to attach to the message. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The tools to add this file to. sig do @@ -280,29 +190,21 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools sig do params( @@ -310,6 +212,7 @@ module OpenAI tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly ) ] @@ -336,27 +239,13 @@ module OpenAI def to_hash end - class Tool < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly - ) - } - end + module Tool + extend OpenAI::Union class AssistantToolsFileSearchTypeOnly < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :file_search) @@ -366,62 +255,95 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly] + ) + end + def self.variants + end end end class IncompleteDetails < OpenAI::BaseModel # The reason the message is incomplete. - sig { returns(Symbol) } - def reason - end - - sig { params(_: Symbol).returns(Symbol) } - def reason=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) } + attr_accessor :reason # On an incomplete message, details about why the message is incomplete. - sig { params(reason: Symbol).returns(T.attached_class) } + sig do + params(reason: OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::OrSymbol) + .returns(T.attached_class) + end def self.new(reason:) end - sig { override.returns({reason: Symbol}) } + sig do + override.returns({reason: OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol}) + end def to_hash end # The reason the message is incomplete. - class Reason < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - CONTENT_FILTER = :content_filter - MAX_TOKENS = :max_tokens - RUN_CANCELLED = :run_cancelled - RUN_EXPIRED = :run_expired - RUN_FAILED = :run_failed + module Reason + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) } + + CONTENT_FILTER = + T.let(:content_filter, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) + MAX_TOKENS = + T.let(:max_tokens, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) + RUN_CANCELLED = + T.let(:run_cancelled, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) + RUN_EXPIRED = + T.let(:run_expired, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) + RUN_FAILED = + T.let(:run_failed, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol) + + sig do + override.returns(T::Array[OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason::TaggedSymbol]) + end + def self.values + end end end # The entity that produced the message. One of `user` or `assistant`. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Message::Role) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = T.let(:user, OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol) - USER = :user - ASSISTANT = :assistant + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Message::Role::TaggedSymbol]) } + def self.values + end end # The status of the message, which can be either `in_progress`, `incomplete`, or # `completed`. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Message::Status) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol) + INCOMPLETE = T.let(:incomplete, OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - INCOMPLETE = :incomplete - COMPLETED = :completed + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Message::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/message_content.rbi b/rbi/lib/openai/models/beta/threads/message_content.rbi index 7bc0759c..3b799135 100644 --- a/rbi/lib/openai/models/beta/threads/message_content.rbi +++ b/rbi/lib/openai/models/beta/threads/message_content.rbi @@ -6,18 +6,16 @@ module OpenAI module Threads # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContent < OpenAI::Union - abstract! + module MessageContent + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlock, - OpenAI::Models::Beta::Threads::RefusalContentBlock + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/message_content_delta.rbi b/rbi/lib/openai/models/beta/threads/message_content_delta.rbi index 09915e69..7cfeab9e 100644 --- a/rbi/lib/openai/models/beta/threads/message_content_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/message_content_delta.rbi @@ -6,18 +6,16 @@ module OpenAI module Threads # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContentDelta < OpenAI::Union - abstract! + module MessageContentDelta + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, - OpenAI::Models::Beta::Threads::TextDeltaBlock, - OpenAI::Models::Beta::Threads::RefusalDeltaBlock, - OpenAI::Models::Beta::Threads::ImageURLDeltaBlock + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/message_content_part_param.rbi b/rbi/lib/openai/models/beta/threads/message_content_part_param.rbi index fe9ae396..e2e3c952 100644 --- a/rbi/lib/openai/models/beta/threads/message_content_part_param.rbi +++ b/rbi/lib/openai/models/beta/threads/message_content_part_param.rbi @@ -6,17 +6,16 @@ module OpenAI module Threads # References an image [File](https://platform.openai.com/docs/api-reference/files) # in the content of a message. - class MessageContentPartParam < OpenAI::Union - abstract! + module MessageContentPartParam + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/message_create_params.rbi b/rbi/lib/openai/models/beta/threads/message_create_params.rbi index 0783f811..2045cd26 100644 --- a/rbi/lib/openai/models/beta/threads/message_create_params.rbi +++ b/rbi/lib/openai/models/beta/threads/message_create_params.rbi @@ -5,7 +5,7 @@ module OpenAI module Beta module Threads class MessageCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The text contents of the message. @@ -23,37 +23,7 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - .returns( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - end - def content=(_) - end + attr_accessor :content # The role of the entity that is creating the message. Allowed values include: # @@ -61,25 +31,12 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::MessageCreateParams::Role::OrSymbol) } + attr_accessor :role # A list of files attached to the message, and the tools they should be added to. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment])) } - def attachments - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment])) - .returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment])) - end - def attachments=(_) - end + attr_accessor :attachments # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -87,13 +44,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( @@ -102,15 +54,18 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam ) ] ), - role: Symbol, - attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + role: OpenAI::Models::Beta::Threads::MessageCreateParams::Role::OrSymbol, + attachments: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -131,9 +86,9 @@ module OpenAI ) ] ), - role: Symbol, + role: OpenAI::Models::Beta::Threads::MessageCreateParams::Role::OrSymbol, attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), request_options: OpenAI::RequestOptions } ) @@ -142,33 +97,32 @@ module OpenAI end # The text contents of the message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Models::Beta::Threads::ImageURLContentBlock, + OpenAI::Models::Beta::Threads::TextContentBlockParam + ) + ] ] ) - } + end + def self.variants end - MessageContentPartParamArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam + MessageContentPartParamArray = + T.let( + OpenAI::ArrayOf[union: OpenAI::Models::Beta::Threads::MessageContentPartParam], + OpenAI::Type::Converter ) - ] - end end # The role of the entity that is creating the message. Allowed values include: @@ -177,24 +131,28 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::MessageCreateParams::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::MessageCreateParams::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = T.let(:user, OpenAI::Models::Beta::Threads::MessageCreateParams::Role::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Beta::Threads::MessageCreateParams::Role::TaggedSymbol) - USER = :user - ASSISTANT = :assistant + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Role::TaggedSymbol]) } + def self.values + end end class Attachment < OpenAI::BaseModel # The ID of the file to attach to the message. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The tools to add this file to. sig do @@ -209,29 +167,21 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools sig do params( @@ -239,6 +189,7 @@ module OpenAI tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch ) ] @@ -265,27 +216,13 @@ module OpenAI def to_hash end - class Tool < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch - ) - } - end + module Tool + extend OpenAI::Union class FileSearch < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :file_search) @@ -295,6 +232,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/threads/message_delete_params.rbi b/rbi/lib/openai/models/beta/threads/message_delete_params.rbi index 8ef23891..1149a983 100644 --- a/rbi/lib/openai/models/beta/threads/message_delete_params.rbi +++ b/rbi/lib/openai/models/beta/threads/message_delete_params.rbi @@ -5,25 +5,14 @@ module OpenAI module Beta module Threads class MessageDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id sig do - params( - thread_id: String, - request_options: T.any( - OpenAI::RequestOptions, - T::Hash[Symbol, T.anything] - ) - ) + params(thread_id: String, request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) .returns(T.attached_class) end def self.new(thread_id:, request_options: {}) diff --git a/rbi/lib/openai/models/beta/threads/message_deleted.rbi b/rbi/lib/openai/models/beta/threads/message_deleted.rbi index 9684886b..df1dc2e2 100644 --- a/rbi/lib/openai/models/beta/threads/message_deleted.rbi +++ b/rbi/lib/openai/models/beta/threads/message_deleted.rbi @@ -6,28 +6,13 @@ module OpenAI module Threads class MessageDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"thread.message.deleted") diff --git a/rbi/lib/openai/models/beta/threads/message_delta.rbi b/rbi/lib/openai/models/beta/threads/message_delta.rbi index 7883727c..a89cb0f3 100644 --- a/rbi/lib/openai/models/beta/threads/message_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/message_delta.rbi @@ -20,42 +20,30 @@ module OpenAI ) ) end - def content - end + attr_reader :content sig do params( - _: T::Array[ + content: T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, - OpenAI::Models::Beta::Threads::TextDeltaBlock, - OpenAI::Models::Beta::Threads::RefusalDeltaBlock, - OpenAI::Models::Beta::Threads::ImageURLDeltaBlock - ) - ] - ) - end - def content=(_) + .void end + attr_writer :content # The entity that produced the message. One of `user` or `assistant`. - sig { returns(T.nilable(Symbol)) } - def role - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol)) } + attr_reader :role - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { params(role: OpenAI::Models::Beta::Threads::MessageDelta::Role::OrSymbol).void } + attr_writer :role # The delta containing the fields that have changed on the Message. sig do @@ -63,12 +51,13 @@ module OpenAI content: T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock ) ], - role: Symbol + role: OpenAI::Models::Beta::Threads::MessageDelta::Role::OrSymbol ) .returns(T.attached_class) end @@ -87,7 +76,7 @@ module OpenAI OpenAI::Models::Beta::Threads::ImageURLDeltaBlock ) ], - role: Symbol + role: OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol } ) end @@ -95,13 +84,19 @@ module OpenAI end # The entity that produced the message. One of `user` or `assistant`. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::MessageDelta::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = T.let(:user, OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol) - USER = :user - ASSISTANT = :assistant + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::MessageDelta::Role::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/message_delta_event.rbi b/rbi/lib/openai/models/beta/threads/message_delta_event.rbi index 5df8b179..5ac1d6f1 100644 --- a/rbi/lib/openai/models/beta/threads/message_delta_event.rbi +++ b/rbi/lib/openai/models/beta/threads/message_delta_event.rbi @@ -7,37 +7,27 @@ module OpenAI class MessageDeltaEvent < OpenAI::BaseModel # The identifier of the message, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The delta containing the fields that have changed on the Message. sig { returns(OpenAI::Models::Beta::Threads::MessageDelta) } - def delta - end + attr_reader :delta - sig do - params(_: OpenAI::Models::Beta::Threads::MessageDelta).returns(OpenAI::Models::Beta::Threads::MessageDelta) - end - def delta=(_) - end + sig { params(delta: T.any(OpenAI::Models::Beta::Threads::MessageDelta, OpenAI::Util::AnyHash)).void } + attr_writer :delta # The object type, which is always `thread.message.delta`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # Represents a message delta i.e. any changed fields on a message during # streaming. sig do - params(id: String, delta: OpenAI::Models::Beta::Threads::MessageDelta, object: Symbol) + params( + id: String, + delta: T.any(OpenAI::Models::Beta::Threads::MessageDelta, OpenAI::Util::AnyHash), + object: Symbol + ) .returns(T.attached_class) end def self.new(id:, delta:, object: :"thread.message.delta") diff --git a/rbi/lib/openai/models/beta/threads/message_list_params.rbi b/rbi/lib/openai/models/beta/threads/message_list_params.rbi index 4b93b0c8..545445aa 100644 --- a/rbi/lib/openai/models/beta/threads/message_list_params.rbi +++ b/rbi/lib/openai/models/beta/threads/message_list_params.rbi @@ -5,7 +5,7 @@ module OpenAI module Beta module Threads class MessageListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -13,62 +13,52 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::MessageListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Beta::Threads::MessageListParams::Order::OrSymbol).void } + attr_writer :order # Filter messages by the run ID that generated them. sig { returns(T.nilable(String)) } - def run_id - end + attr_reader :run_id - sig { params(_: String).returns(String) } - def run_id=(_) - end + sig { params(run_id: String).void } + attr_writer :run_id sig do params( after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::Threads::MessageListParams::Order::OrSymbol, run_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -82,7 +72,7 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::Threads::MessageListParams::Order::OrSymbol, run_id: String, request_options: OpenAI::RequestOptions } @@ -93,13 +83,19 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Beta::Threads::MessageListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Beta::Threads::MessageListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::MessageListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/message_retrieve_params.rbi b/rbi/lib/openai/models/beta/threads/message_retrieve_params.rbi index 19dca144..e2f6c363 100644 --- a/rbi/lib/openai/models/beta/threads/message_retrieve_params.rbi +++ b/rbi/lib/openai/models/beta/threads/message_retrieve_params.rbi @@ -5,25 +5,14 @@ module OpenAI module Beta module Threads class MessageRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id sig do - params( - thread_id: String, - request_options: T.any( - OpenAI::RequestOptions, - T::Hash[Symbol, T.anything] - ) - ) + params(thread_id: String, request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) .returns(T.attached_class) end def self.new(thread_id:, request_options: {}) diff --git a/rbi/lib/openai/models/beta/threads/message_update_params.rbi b/rbi/lib/openai/models/beta/threads/message_update_params.rbi index f2d3e73a..6af1915e 100644 --- a/rbi/lib/openai/models/beta/threads/message_update_params.rbi +++ b/rbi/lib/openai/models/beta/threads/message_update_params.rbi @@ -5,16 +5,11 @@ module OpenAI module Beta module Threads class MessageUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -22,19 +17,14 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( thread_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -44,7 +34,11 @@ module OpenAI sig do override .returns( - {thread_id: String, metadata: T.nilable(OpenAI::Models::Metadata), request_options: OpenAI::RequestOptions} + { + thread_id: String, + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: OpenAI::RequestOptions + } ) end def to_hash diff --git a/rbi/lib/openai/models/beta/threads/refusal_content_block.rbi b/rbi/lib/openai/models/beta/threads/refusal_content_block.rbi index c2179549..b9350051 100644 --- a/rbi/lib/openai/models/beta/threads/refusal_content_block.rbi +++ b/rbi/lib/openai/models/beta/threads/refusal_content_block.rbi @@ -6,21 +6,11 @@ module OpenAI module Threads class RefusalContentBlock < OpenAI::BaseModel sig { returns(String) } - def refusal - end - - sig { params(_: String).returns(String) } - def refusal=(_) - end + attr_accessor :refusal # Always `refusal`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The refusal content generated by the assistant. sig { params(refusal: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/beta/threads/refusal_delta_block.rbi b/rbi/lib/openai/models/beta/threads/refusal_delta_block.rbi index 87dd9957..72b6092e 100644 --- a/rbi/lib/openai/models/beta/threads/refusal_delta_block.rbi +++ b/rbi/lib/openai/models/beta/threads/refusal_delta_block.rbi @@ -7,29 +7,17 @@ module OpenAI class RefusalDeltaBlock < OpenAI::BaseModel # The index of the refusal part in the message. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `refusal`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(String)) } - def refusal - end + attr_reader :refusal - sig { params(_: String).returns(String) } - def refusal=(_) - end + sig { params(refusal: String).void } + attr_writer :refusal # The refusal content that is part of a message. sig { params(index: Integer, refusal: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/beta/threads/required_action_function_tool_call.rbi b/rbi/lib/openai/models/beta/threads/required_action_function_tool_call.rbi index ef418354..f8511f4f 100644 --- a/rbi/lib/openai/models/beta/threads/required_action_function_tool_call.rbi +++ b/rbi/lib/openai/models/beta/threads/required_action_function_tool_call.rbi @@ -10,40 +10,30 @@ module OpenAI # [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) # endpoint. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The function definition. sig { returns(OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function) - .returns(OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function # The type of tool call the output is required for. For now, this is always # `function`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Tool call objects sig do params( id: String, - function: OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function, + function: T.any(OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -63,21 +53,11 @@ module OpenAI class Function < OpenAI::BaseModel # The arguments that the model expects you to pass to the function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The name of the function. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The function definition. sig { params(arguments: String, name: String).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/beta/threads/run.rbi b/rbi/lib/openai/models/beta/threads/run.rbi index 94002e57..9a5ebeb1 100644 --- a/rbi/lib/openai/models/beta/threads/run.rbi +++ b/rbi/lib/openai/models/beta/threads/run.rbi @@ -7,124 +7,72 @@ module OpenAI class Run < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The ID of the # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for # execution of this run. sig { returns(String) } - def assistant_id - end - - sig { params(_: String).returns(String) } - def assistant_id=(_) - end + attr_accessor :assistant_id # The Unix timestamp (in seconds) for when the run was cancelled. sig { returns(T.nilable(Integer)) } - def cancelled_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def cancelled_at=(_) - end + attr_accessor :cancelled_at # The Unix timestamp (in seconds) for when the run was completed. sig { returns(T.nilable(Integer)) } - def completed_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def completed_at=(_) - end + attr_accessor :completed_at # The Unix timestamp (in seconds) for when the run was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The Unix timestamp (in seconds) for when the run will expire. sig { returns(T.nilable(Integer)) } - def expires_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def expires_at=(_) - end + attr_accessor :expires_at # The Unix timestamp (in seconds) for when the run failed. sig { returns(T.nilable(Integer)) } - def failed_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def failed_at=(_) - end + attr_accessor :failed_at # Details on why the run is incomplete. Will be `null` if the run is not # incomplete. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::IncompleteDetails)) } - def incomplete_details - end + attr_reader :incomplete_details sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Run::IncompleteDetails)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Run::IncompleteDetails)) - end - def incomplete_details=(_) + params( + incomplete_details: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::IncompleteDetails, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :incomplete_details # The instructions that the # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for # this run. sig { returns(String) } - def instructions - end - - sig { params(_: String).returns(String) } - def instructions=(_) - end + attr_accessor :instructions # The last error associated with this run. Will be `null` if there are no errors. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::LastError)) } - def last_error - end + attr_reader :last_error sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Run::LastError)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Run::LastError)) - end - def last_error=(_) + params(last_error: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::LastError, OpenAI::Util::AnyHash))) + .void end + attr_writer :last_error # The maximum number of completion tokens specified to have been used over the # course of the run. sig { returns(T.nilable(Integer)) } - def max_completion_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_completion_tokens=(_) - end + attr_accessor :max_completion_tokens # The maximum number of prompt tokens specified to have been used over the course # of the run. sig { returns(T.nilable(Integer)) } - def max_prompt_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_prompt_tokens=(_) - end + attr_accessor :max_prompt_tokens # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -132,57 +80,37 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The model that the # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for # this run. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always `thread.run`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # Whether to enable # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) # during tool use. sig { returns(T::Boolean) } - def parallel_tool_calls - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def parallel_tool_calls=(_) - end + attr_accessor :parallel_tool_calls # Details on the action required to continue the run. Will be `null` if no action # is required. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::RequiredAction)) } - def required_action - end + attr_reader :required_action sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Run::RequiredAction)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Run::RequiredAction)) - end - def required_action=(_) + params( + required_action: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::RequiredAction, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :required_action # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -216,63 +144,22 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # The Unix timestamp (in seconds) for when the run was started. sig { returns(T.nilable(Integer)) } - def started_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def started_at=(_) - end + attr_accessor :started_at # The status of the run, which can be either `queued`, `in_progress`, # `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, # `incomplete`, or `expired`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) } + attr_accessor :status # The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) # that was executed on as a part of this run. sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # Controls which (if any) tool is called by the model. `none` means the model will # not call any tools and instead generates a message. `auto` is the default value @@ -281,16 +168,17 @@ module OpenAI # to the user. Specifying a particular tool like `{"type": "file_search"}` or # `{"type": "function", "function": {"name": "my_function"}}` forces the model to # call that tool. - sig { returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) } - def tool_choice - end - sig do - params(_: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - .returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - end - def tool_choice=(_) + returns( + T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol, + OpenAI::Models::Beta::AssistantToolChoice + ) + ) + ) end + attr_accessor :tool_choice # The list of tools that the # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for @@ -306,75 +194,36 @@ module OpenAI ] ) end - def tools - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - end - def tools=(_) - end + attr_accessor :tools # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::TruncationStrategy)) } - def truncation_strategy - end + attr_reader :truncation_strategy sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Run::TruncationStrategy)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Run::TruncationStrategy)) - end - def truncation_strategy=(_) + params( + truncation_strategy: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::TruncationStrategy, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :truncation_strategy # Usage statistics related to the run. This value will be `null` if the run is not # in a terminal state (i.e. `in_progress`, `queued`, etc.). sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::Usage)) } - def usage - end + attr_reader :usage - sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Run::Usage)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Run::Usage)) - end - def usage=(_) - end + sig { params(usage: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::Usage, OpenAI::Util::AnyHash))).void } + attr_writer :usage # The sampling temperature used for this run. If not set, defaults to 1. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # The nucleus sampling value used for this run. If not set, defaults to 1. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # Represents an execution run on a # [thread](https://platform.openai.com/docs/api-reference/threads). @@ -387,36 +236,44 @@ module OpenAI created_at: Integer, expires_at: T.nilable(Integer), failed_at: T.nilable(Integer), - incomplete_details: T.nilable(OpenAI::Models::Beta::Threads::Run::IncompleteDetails), + incomplete_details: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::IncompleteDetails, OpenAI::Util::AnyHash)), instructions: String, - last_error: T.nilable(OpenAI::Models::Beta::Threads::Run::LastError), + last_error: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::LastError, OpenAI::Util::AnyHash)), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, parallel_tool_calls: T::Boolean, - required_action: T.nilable(OpenAI::Models::Beta::Threads::Run::RequiredAction), + required_action: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::RequiredAction, OpenAI::Util::AnyHash)), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), started_at: T.nilable(Integer), - status: Symbol, + status: OpenAI::Models::Beta::Threads::RunStatus::OrSymbol, thread_id: String, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ], - truncation_strategy: T.nilable(OpenAI::Models::Beta::Threads::Run::TruncationStrategy), - usage: T.nilable(OpenAI::Models::Beta::Threads::Run::Usage), + truncation_strategy: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::TruncationStrategy, OpenAI::Util::AnyHash)), + usage: T.nilable(T.any(OpenAI::Models::Beta::Threads::Run::Usage, OpenAI::Util::AnyHash)), temperature: T.nilable(Float), top_p: T.nilable(Float), object: Symbol @@ -470,7 +327,7 @@ module OpenAI last_error: T.nilable(OpenAI::Models::Beta::Threads::Run::LastError), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, object: Symbol, parallel_tool_calls: T::Boolean, @@ -484,9 +341,14 @@ module OpenAI ) ), started_at: T.nilable(Integer), - status: Symbol, + status: OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol, thread_id: String, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::TaggedSymbol, + OpenAI::Models::Beta::AssistantToolChoice + ) + ), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, @@ -507,103 +369,112 @@ module OpenAI class IncompleteDetails < OpenAI::BaseModel # The reason why the run is incomplete. This will point to which specific token # limit was reached over the course of the run. - sig { returns(T.nilable(Symbol)) } - def reason - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol)) } + attr_reader :reason - sig { params(_: Symbol).returns(Symbol) } - def reason=(_) - end + sig { params(reason: OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::OrSymbol).void } + attr_writer :reason # Details on why the run is incomplete. Will be `null` if the run is not # incomplete. - sig { params(reason: Symbol).returns(T.attached_class) } + sig do + params(reason: OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::OrSymbol) + .returns(T.attached_class) + end def self.new(reason: nil) end - sig { override.returns({reason: Symbol}) } + sig { override.returns({reason: OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol}) } def to_hash end # The reason why the run is incomplete. This will point to which specific token # limit was reached over the course of the run. - class Reason < OpenAI::Enum - abstract! + module Reason + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MAX_COMPLETION_TOKENS = + T.let(:max_completion_tokens, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol) + MAX_PROMPT_TOKENS = + T.let(:max_prompt_tokens, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol) - MAX_COMPLETION_TOKENS = :max_completion_tokens - MAX_PROMPT_TOKENS = :max_prompt_tokens + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason::TaggedSymbol]) } + def self.values + end end end class LastError < OpenAI::BaseModel # One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - sig { returns(Symbol) } - def code - end - - sig { params(_: Symbol).returns(Symbol) } - def code=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol) } + attr_accessor :code # A human-readable description of the error. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The last error associated with this run. Will be `null` if there are no errors. - sig { params(code: Symbol, message: String).returns(T.attached_class) } + sig do + params(code: OpenAI::Models::Beta::Threads::Run::LastError::Code::OrSymbol, message: String) + .returns(T.attached_class) + end def self.new(code:, message:) end - sig { override.returns({code: Symbol, message: String}) } + sig do + override + .returns({code: OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol, message: String}) + end def to_hash end # One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - class Code < OpenAI::Enum - abstract! + module Code + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Run::LastError::Code) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + SERVER_ERROR = T.let(:server_error, OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol) + RATE_LIMIT_EXCEEDED = + T.let(:rate_limit_exceeded, OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol) + INVALID_PROMPT = + T.let(:invalid_prompt, OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol) - SERVER_ERROR = :server_error - RATE_LIMIT_EXCEEDED = :rate_limit_exceeded - INVALID_PROMPT = :invalid_prompt + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Run::LastError::Code::TaggedSymbol]) } + def self.values + end end end class RequiredAction < OpenAI::BaseModel # Details on the tool outputs needed for this run to continue. sig { returns(OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs) } - def submit_tool_outputs - end + attr_reader :submit_tool_outputs sig do - params(_: OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs) - .returns(OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs) - end - def submit_tool_outputs=(_) + params( + submit_tool_outputs: T.any(OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :submit_tool_outputs # For now, this is always `submit_tool_outputs`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Details on the action required to continue the run. Will be `null` if no action # is required. sig do params( - submit_tool_outputs: OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs, + submit_tool_outputs: T.any(OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -623,19 +494,13 @@ module OpenAI class SubmitToolOutputs < OpenAI::BaseModel # A list of the relevant tool calls. sig { returns(T::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall]) } - def tool_calls - end - - sig do - params(_: T::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall]) - .returns(T::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall]) - end - def tool_calls=(_) - end + attr_accessor :tool_calls # Details on the tool outputs needed for this run to continue. sig do - params(tool_calls: T::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall]) + params( + tool_calls: T::Array[T.any(OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall, OpenAI::Util::AnyHash)] + ) .returns(T.attached_class) end def self.new(tool_calls:) @@ -652,31 +517,35 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol) } + attr_accessor :type # The number of most recent messages from the thread when constructing the context # for the run. sig { returns(T.nilable(Integer)) } - def last_messages - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def last_messages=(_) - end + attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. - sig { params(type: Symbol, last_messages: T.nilable(Integer)).returns(T.attached_class) } + sig do + params( + type: OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::OrSymbol, + last_messages: T.nilable(Integer) + ) + .returns(T.attached_class) + end def self.new(type:, last_messages: nil) end - sig { override.returns({type: Symbol, last_messages: T.nilable(Integer)}) } + sig do + override + .returns( + { + type: OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol, + last_messages: T.nilable(Integer) + } + ) + end def to_hash end @@ -684,43 +553,36 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol) } - AUTO = :auto - LAST_MESSAGES = :last_messages + AUTO = T.let(:auto, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol) + LAST_MESSAGES = + T.let(:last_messages, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type::TaggedSymbol]) } + def self.values + end end end class Usage < OpenAI::BaseModel # Number of completion tokens used over the course of the run. sig { returns(Integer) } - def completion_tokens - end - - sig { params(_: Integer).returns(Integer) } - def completion_tokens=(_) - end + attr_accessor :completion_tokens # Number of prompt tokens used over the course of the run. sig { returns(Integer) } - def prompt_tokens - end - - sig { params(_: Integer).returns(Integer) } - def prompt_tokens=(_) - end + attr_accessor :prompt_tokens # Total number of tokens used (prompt + completion). sig { returns(Integer) } - def total_tokens - end - - sig { params(_: Integer).returns(Integer) } - def total_tokens=(_) - end + attr_accessor :total_tokens # Usage statistics related to the run. This value will be `null` if the run is not # in a terminal state (i.e. `in_progress`, `queued`, etc.). diff --git a/rbi/lib/openai/models/beta/threads/run_cancel_params.rbi b/rbi/lib/openai/models/beta/threads/run_cancel_params.rbi index 119500b5..c84678a8 100644 --- a/rbi/lib/openai/models/beta/threads/run_cancel_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_cancel_params.rbi @@ -5,25 +5,14 @@ module OpenAI module Beta module Threads class RunCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id sig do - params( - thread_id: String, - request_options: T.any( - OpenAI::RequestOptions, - T::Hash[Symbol, T.anything] - ) - ) + params(thread_id: String, request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) .returns(T.attached_class) end def self.new(thread_id:, request_options: {}) diff --git a/rbi/lib/openai/models/beta/threads/run_create_params.rbi b/rbi/lib/openai/models/beta/threads/run_create_params.rbi index dc48611b..1fb7e4b3 100644 --- a/rbi/lib/openai/models/beta/threads/run_create_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_create_params.rbi @@ -5,19 +5,14 @@ module OpenAI module Beta module Threads class RunCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The ID of the # [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to # execute this run. sig { returns(String) } - def assistant_id - end - - sig { params(_: String).returns(String) } - def assistant_id=(_) - end + attr_accessor :assistant_id # A list of additional fields to include in the response. Currently the only # supported value is `step_details.tool_calls[*].file_search.results[*].content` @@ -26,47 +21,27 @@ module OpenAI # See the # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. - sig { returns(T.nilable(T::Array[Symbol])) } - def include - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol])) } + attr_reader :include - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def include=(_) - end + sig { params(include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol]).void } + attr_writer :include # Appends additional instructions at the end of the instructions for the run. This # is useful for modifying the behavior on a per-run basis without overriding other # instructions. sig { returns(T.nilable(String)) } - def additional_instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def additional_instructions=(_) - end + attr_accessor :additional_instructions # Adds additional messages to the thread before creating the run. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage])) } - def additional_messages - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage])) - .returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage])) - end - def additional_messages=(_) - end + attr_accessor :additional_messages # Overrides the # [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) # of the assistant. This is useful for modifying the behavior on a per-run basis. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # The maximum number of completion tokens that may be used over the course of the # run. The run will make a best effort to use only the number of completion tokens @@ -74,12 +49,7 @@ module OpenAI # completion tokens specified, the run will end with status `incomplete`. See # `incomplete_details` for more info. sig { returns(T.nilable(Integer)) } - def max_completion_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_completion_tokens=(_) - end + attr_accessor :max_completion_tokens # The maximum number of prompt tokens that may be used over the course of the run. # The run will make a best effort to use only the number of prompt tokens @@ -87,12 +57,7 @@ module OpenAI # prompt tokens specified, the run will end with status `incomplete`. See # `incomplete_details` for more info. sig { returns(T.nilable(Integer)) } - def max_prompt_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_prompt_tokens=(_) - end + attr_accessor :max_prompt_tokens # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -100,36 +65,24 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end - - sig { params(_: T.nilable(T.any(String, Symbol))).returns(T.nilable(T.any(String, Symbol))) } - def model=(_) - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol))) } + attr_accessor :model # Whether to enable # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) # during tool use. sig { returns(T.nilable(T::Boolean)) } - def parallel_tool_calls - end + attr_reader :parallel_tool_calls - sig { params(_: T::Boolean).returns(T::Boolean) } - def parallel_tool_calls=(_) - end + sig { params(parallel_tool_calls: T::Boolean).void } + attr_writer :parallel_tool_calls # **o-series models only** # @@ -137,13 +90,8 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - sig { returns(T.nilable(Symbol)) } - def reasoning_effort - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def reasoning_effort=(_) - end + sig { returns(T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol)) } + attr_accessor :reasoning_effort # Specifies the format that the model must output. Compatible with # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), @@ -177,44 +125,13 @@ module OpenAI ) ) end - def response_format - end - - sig do - params( - _: T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - .returns( - T.nilable( - T.any( - Symbol, - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONObject, - OpenAI::Models::ResponseFormatJSONSchema - ) - ) - ) - end - def response_format=(_) - end + attr_accessor :response_format # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # Controls which (if any) tool is called by the model. `none` means the model will # not call any tools and instead generates a message. `auto` is the default value @@ -223,38 +140,23 @@ module OpenAI # to the user. Specifying a particular tool like `{"type": "file_search"}` or # `{"type": "function", "function": {"name": "my_function"}}` forces the model to # call that tool. - sig { returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) } - def tool_choice - end - - sig do - params(_: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - .returns(T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice))) - end - def tool_choice=(_) - end - - # Override the tools the assistant can use for this run. This is useful for - # modifying the behavior on a per-run basis. sig do returns( T.nilable( - T::Array[ T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice ) - ] ) ) end - def tools - end + attr_accessor :tool_choice + # Override the tools the assistant can use for this run. This is useful for + # modifying the behavior on a per-run basis. sig do - params( - _: T.nilable( + returns( + T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, @@ -264,20 +166,8 @@ module OpenAI ] ) ) - .returns( - T.nilable( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::FileSearchTool, - OpenAI::Models::Beta::FunctionTool - ) - ] - ) - ) - end - def tools=(_) end + attr_accessor :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -285,61 +175,70 @@ module OpenAI # # We generally recommend altering this or temperature but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy)) } - def truncation_strategy - end + attr_reader :truncation_strategy sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy)) - end - def truncation_strategy=(_) + params( + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, OpenAI::Util::AnyHash) + ) + ) + .void end + attr_writer :truncation_strategy sig do params( assistant_id: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], additional_instructions: T.nilable(String), - additional_messages: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]), + additional_messages: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage, OpenAI::Util::AnyHash)] + ), instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -370,16 +269,16 @@ module OpenAI .returns( { assistant_id: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], additional_instructions: T.nilable(String), additional_messages: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]), instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, @@ -389,7 +288,12 @@ module OpenAI ) ), temperature: T.nilable(Float), - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice + ) + ), tools: T.nilable( T::Array[ T.any( @@ -424,37 +328,7 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - .returns( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) - ] - ) - ) - end - def content=(_) - end + attr_accessor :content # The role of the entity that is creating the message. Allowed values include: # @@ -462,13 +336,8 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::OrSymbol) } + attr_accessor :role # A list of files attached to the message, and the tools they should be added to. sig do @@ -476,19 +345,7 @@ module OpenAI T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]) ) end - def attachments - end - - sig do - params( - _: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]) - ) - .returns( - T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]) - ) - end - def attachments=(_) - end + attr_accessor :attachments # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -496,13 +353,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( @@ -511,14 +363,22 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam ) ] ), - role: Symbol, - attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + role: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::OrSymbol, + attachments: T.nilable( + T::Array[ + T.any( + OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment, + OpenAI::Util::AnyHash + ) + ] + ), + metadata: T.nilable(T::Hash[Symbol, String]) ) .returns(T.attached_class) end @@ -539,9 +399,9 @@ module OpenAI ) ] ), - role: Symbol, + role: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::OrSymbol, attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata) + metadata: T.nilable(T::Hash[Symbol, String]) } ) end @@ -549,33 +409,32 @@ module OpenAI end # The text contents of the message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam - ) + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Models::Beta::Threads::ImageURLContentBlock, + OpenAI::Models::Beta::Threads::TextContentBlockParam + ) + ] ] ) - } + end + def self.variants end - MessageContentPartParamArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::ImageFileContentBlock, - OpenAI::Models::Beta::Threads::ImageURLContentBlock, - OpenAI::Models::Beta::Threads::TextContentBlockParam + MessageContentPartParamArray = + T.let( + OpenAI::ArrayOf[union: OpenAI::Models::Beta::Threads::MessageContentPartParam], + OpenAI::Type::Converter ) - ] - end end # The role of the entity that is creating the message. Allowed values include: @@ -584,24 +443,34 @@ module OpenAI # most cases to represent user-generated messages. # - `assistant`: Indicates the message is generated by the assistant. Use this # value to insert messages from the assistant into the conversation. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = + T.let(:user, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::TaggedSymbol) + ASSISTANT = + T.let(:assistant, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::TaggedSymbol) - USER = :user - ASSISTANT = :assistant + sig do + override + .returns(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role::TaggedSymbol]) + end + def self.values + end end class Attachment < OpenAI::BaseModel # The ID of the file to attach to the message. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The tools to add this file to. sig do @@ -616,29 +485,21 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools sig do params( @@ -646,6 +507,7 @@ module OpenAI tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch ) ] @@ -672,27 +534,13 @@ module OpenAI def to_hash end - class Tool < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::CodeInterpreterTool, - OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch - ) - } - end + module Tool + extend OpenAI::Union class FileSearch < OpenAI::BaseModel # The type of tool being defined: `file_search` sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(type: Symbol).returns(T.attached_class) } def self.new(type: :file_search) @@ -702,6 +550,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch] + ) + end + def self.variants + end end end end @@ -710,10 +567,12 @@ module OpenAI # be used to execute this run. If a value is provided here, it will override the # model associated with the assistant. If not, the model associated with the # assistant will be used. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol]) } + def self.variants + end end class TruncationStrategy < OpenAI::BaseModel @@ -721,31 +580,35 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::OrSymbol) } + attr_accessor :type # The number of most recent messages from the thread when constructing the context # for the run. sig { returns(T.nilable(Integer)) } - def last_messages - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def last_messages=(_) - end + attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. - sig { params(type: Symbol, last_messages: T.nilable(Integer)).returns(T.attached_class) } + sig do + params( + type: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::OrSymbol, + last_messages: T.nilable(Integer) + ) + .returns(T.attached_class) + end def self.new(type:, last_messages: nil) end - sig { override.returns({type: Symbol, last_messages: T.nilable(Integer)}) } + sig do + override + .returns( + { + type: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::OrSymbol, + last_messages: T.nilable(Integer) + } + ) + end def to_hash end @@ -753,13 +616,28 @@ module OpenAI # `last_messages`, the thread will be truncated to the n most recent messages in # the thread. When set to `auto`, messages in the middle of the thread will be # dropped to fit the context length of the model, `max_prompt_tokens`. - class Type < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } + module Type + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::TaggedSymbol) } + + AUTO = + T.let(:auto, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::TaggedSymbol) + LAST_MESSAGES = + T.let( + :last_messages, + OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::TaggedSymbol + ) - AUTO = :auto - LAST_MESSAGES = :last_messages + sig do + override + .returns(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/run_list_params.rbi b/rbi/lib/openai/models/beta/threads/run_list_params.rbi index 44ca10d2..d6f27922 100644 --- a/rbi/lib/openai/models/beta/threads/run_list_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_list_params.rbi @@ -5,7 +5,7 @@ module OpenAI module Beta module Threads class RunListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -13,52 +13,44 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::RunListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Beta::Threads::RunListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Beta::Threads::RunListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -72,7 +64,7 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::Threads::RunListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -82,13 +74,19 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::RunListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::RunListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Beta::Threads::RunListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Beta::Threads::RunListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::RunListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/run_retrieve_params.rbi b/rbi/lib/openai/models/beta/threads/run_retrieve_params.rbi index fa5675d0..24cfa0e3 100644 --- a/rbi/lib/openai/models/beta/threads/run_retrieve_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_retrieve_params.rbi @@ -5,25 +5,14 @@ module OpenAI module Beta module Threads class RunRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id sig do - params( - thread_id: String, - request_options: T.any( - OpenAI::RequestOptions, - T::Hash[Symbol, T.anything] - ) - ) + params(thread_id: String, request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) .returns(T.attached_class) end def self.new(thread_id:, request_options: {}) diff --git a/rbi/lib/openai/models/beta/threads/run_status.rbi b/rbi/lib/openai/models/beta/threads/run_status.rbi index 76ada3f1..243f07b9 100644 --- a/rbi/lib/openai/models/beta/threads/run_status.rbi +++ b/rbi/lib/openai/models/beta/threads/run_status.rbi @@ -7,20 +7,25 @@ module OpenAI # The status of the run, which can be either `queued`, `in_progress`, # `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, # `incomplete`, or `expired`. - class RunStatus < OpenAI::Enum - abstract! + module RunStatus + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::RunStatus) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) } - QUEUED = :queued - IN_PROGRESS = :in_progress - REQUIRES_ACTION = :requires_action - CANCELLING = :cancelling - CANCELLED = :cancelled - FAILED = :failed - COMPLETED = :completed - INCOMPLETE = :incomplete - EXPIRED = :expired + QUEUED = T.let(:queued, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + REQUIRES_ACTION = T.let(:requires_action, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + CANCELLING = T.let(:cancelling, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + INCOMPLETE = T.let(:incomplete, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + EXPIRED = T.let(:expired, OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::RunStatus::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rbi b/rbi/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rbi index 0a39a132..98e8df09 100644 --- a/rbi/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rbi @@ -5,34 +5,21 @@ module OpenAI module Beta module Threads class RunSubmitToolOutputsParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # A list of tools for which the outputs are being submitted. sig { returns(T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput]) } - def tool_outputs - end - - sig do - params(_: T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput]) - .returns(T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput]) - end - def tool_outputs=(_) - end + attr_accessor :tool_outputs sig do params( thread_id: String, - tool_outputs: T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + tool_outputs: T::Array[T.any(OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput, OpenAI::Util::AnyHash)], + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -55,22 +42,18 @@ module OpenAI class ToolOutput < OpenAI::BaseModel # The output of the tool call to be submitted to continue the run. sig { returns(T.nilable(String)) } - def output - end + attr_reader :output - sig { params(_: String).returns(String) } - def output=(_) - end + sig { params(output: String).void } + attr_writer :output # The ID of the tool call in the `required_action` object within the run object # the output is being submitted for. sig { returns(T.nilable(String)) } - def tool_call_id - end + attr_reader :tool_call_id - sig { params(_: String).returns(String) } - def tool_call_id=(_) - end + sig { params(tool_call_id: String).void } + attr_writer :tool_call_id sig { params(output: String, tool_call_id: String).returns(T.attached_class) } def self.new(output: nil, tool_call_id: nil) diff --git a/rbi/lib/openai/models/beta/threads/run_update_params.rbi b/rbi/lib/openai/models/beta/threads/run_update_params.rbi index d01aa52d..1067298a 100644 --- a/rbi/lib/openai/models/beta/threads/run_update_params.rbi +++ b/rbi/lib/openai/models/beta/threads/run_update_params.rbi @@ -5,16 +5,11 @@ module OpenAI module Beta module Threads class RunUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -22,19 +17,14 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( thread_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -44,7 +34,11 @@ module OpenAI sig do override .returns( - {thread_id: String, metadata: T.nilable(OpenAI::Models::Metadata), request_options: OpenAI::RequestOptions} + { + thread_id: String, + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: OpenAI::RequestOptions + } ) end def to_hash diff --git a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_logs.rbi b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_logs.rbi index a6c26d19..76b660b5 100644 --- a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_logs.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_logs.rbi @@ -8,30 +8,18 @@ module OpenAI class CodeInterpreterLogs < OpenAI::BaseModel # The index of the output in the outputs array. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `logs`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The text output from the Code Interpreter tool call. sig { returns(T.nilable(String)) } - def logs - end + attr_reader :logs - sig { params(_: String).returns(String) } - def logs=(_) - end + sig { params(logs: String).void } + attr_writer :logs # Text output from the Code Interpreter tool call as part of a run step. sig { params(index: Integer, logs: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rbi b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rbi index d598eb87..3d0e6331 100644 --- a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rbi @@ -8,37 +8,27 @@ module OpenAI class CodeInterpreterOutputImage < OpenAI::BaseModel # The index of the output in the outputs array. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `image`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image)) } - def image - end + attr_reader :image sig do - params(_: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image) - .returns(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image) - end - def image=(_) + params( + image: T.any(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :image sig do params( index: Integer, - image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, + image: T.any(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -59,12 +49,10 @@ module OpenAI # The [file](https://platform.openai.com/docs/api-reference/files) ID of the # image. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id sig { params(file_id: String).returns(T.attached_class) } def self.new(file_id: nil) diff --git a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rbi b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rbi index 4ddb7b18..6720ae9a 100644 --- a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rbi @@ -8,40 +8,36 @@ module OpenAI class CodeInterpreterToolCall < OpenAI::BaseModel # The ID of the tool call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Code Interpreter tool call definition. sig { returns(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter) - .returns(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :code_interpreter # The type of tool call. This is always going to be `code_interpreter` for this # type of tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Details of the Code Interpreter tool call the run step was involved in. sig do params( id: String, - code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter, + code_interpreter: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -65,12 +61,7 @@ module OpenAI class CodeInterpreter < OpenAI::BaseModel # The input to the Code Interpreter tool call. sig { returns(String) } - def input - end - - sig { params(_: String).returns(String) } - def input=(_) - end + attr_accessor :input # The outputs from the Code Interpreter tool call. Code Interpreter can output one # or more items, including text (`logs`) or images (`image`). Each of these are @@ -85,29 +76,7 @@ module OpenAI ] ) end - def outputs - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image - ) - ] - ) - end - def outputs=(_) - end + attr_accessor :outputs # The Code Interpreter tool call definition. sig do @@ -116,6 +85,7 @@ module OpenAI outputs: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image ) ] @@ -143,36 +113,17 @@ module OpenAI end # Text output from the Code Interpreter tool call as part of a run step. - class Output < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image - ) - } - end + module Output + extend OpenAI::Union class Logs < OpenAI::BaseModel # The text output from the Code Interpreter tool call. sig { returns(String) } - def logs - end - - sig { params(_: String).returns(String) } - def logs=(_) - end + attr_accessor :logs # Always `logs`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Text output from the Code Interpreter tool call as part of a run step. sig { params(logs: String, type: Symbol).returns(T.attached_class) } @@ -190,32 +141,29 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image ) end - def image - end + attr_reader :image sig do params( - _: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image - ) - .returns( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image + image: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image, + OpenAI::Util::AnyHash ) + ) + .void end - def image=(_) - end + attr_writer :image # Always `image`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( - image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image, + image: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -239,12 +187,7 @@ module OpenAI # The [file](https://platform.openai.com/docs/api-reference/files) ID of the # image. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id sig { params(file_id: String).returns(T.attached_class) } def self.new(file_id:) @@ -255,6 +198,15 @@ module OpenAI end end end + + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbi index 76d2e5d9..627f5f07 100644 --- a/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbi @@ -8,50 +8,44 @@ module OpenAI class CodeInterpreterToolCallDelta < OpenAI::BaseModel # The index of the tool call in the tool calls array. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of tool call. This is always going to be `code_interpreter` for this # type of tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The ID of the tool call. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id # The Code Interpreter tool call definition. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter)) } - def code_interpreter - end + attr_reader :code_interpreter sig do - params(_: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter) - .returns(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter) - end - def code_interpreter=(_) + params( + code_interpreter: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :code_interpreter # Details of the Code Interpreter tool call the run step was involved in. sig do params( index: Integer, id: String, - code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, + code_interpreter: T.any( + OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -76,12 +70,10 @@ module OpenAI class CodeInterpreter < OpenAI::BaseModel # The input to the Code Interpreter tool call. sig { returns(T.nilable(String)) } - def input - end + attr_reader :input - sig { params(_: String).returns(String) } - def input=(_) - end + sig { params(input: String).void } + attr_writer :input # The outputs from the Code Interpreter tool call. Code Interpreter can output one # or more items, including text (`logs`) or images (`image`). Each of these are @@ -98,29 +90,21 @@ module OpenAI ) ) end - def outputs - end + attr_reader :outputs sig do params( - _: T::Array[ + outputs: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage - ) - ] - ) - end - def outputs=(_) + .void end + attr_writer :outputs # The Code Interpreter tool call definition. sig do @@ -129,6 +113,7 @@ module OpenAI outputs: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage ) ] @@ -156,16 +141,16 @@ module OpenAI end # Text output from the Code Interpreter tool call as part of a run step. - class Output < OpenAI::Union - abstract! + module Output + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call.rbi b/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call.rbi index b4f818ee..ee1a666e 100644 --- a/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call.rbi @@ -8,39 +8,29 @@ module OpenAI class FileSearchToolCall < OpenAI::BaseModel # The ID of the tool call object. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # For now, this is always going to be an empty object. sig { returns(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch) } - def file_search - end + attr_reader :file_search sig do - params(_: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch) - .returns(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch) - end - def file_search=(_) + params( + file_search: T.any(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_search # The type of tool call. This is always going to be `file_search` for this type of # tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( id: String, - file_search: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch, + file_search: T.any(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -60,33 +50,39 @@ module OpenAI class FileSearch < OpenAI::BaseModel # The ranking options for the file search. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions)) } - def ranking_options - end + attr_reader :ranking_options sig do - params(_: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions) - .returns(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions) - end - def ranking_options=(_) + params( + ranking_options: T.any( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :ranking_options # The results of the file search. sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result])) } - def results - end + attr_reader :results sig do - params(_: T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result]) - .returns(T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result]) - end - def results=(_) + params( + results: T::Array[T.any(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :results # For now, this is always going to be an empty object. sig do params( - ranking_options: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, - results: T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result] + ranking_options: T.any( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, + OpenAI::Util::AnyHash + ), + results: T::Array[T.any(OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result, OpenAI::Util::AnyHash)] ) .returns(T.attached_class) end @@ -108,73 +104,91 @@ module OpenAI class RankingOptions < OpenAI::BaseModel # The ranker to use for the file search. If not specified will use the `auto` # ranker. - sig { returns(Symbol) } - def ranker - end - - sig { params(_: Symbol).returns(Symbol) } - def ranker=(_) + sig do + returns( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol + ) end + attr_accessor :ranker # The score threshold for the file search. All values must be a floating point # number between 0 and 1. sig { returns(Float) } - def score_threshold - end - - sig { params(_: Float).returns(Float) } - def score_threshold=(_) - end + attr_accessor :score_threshold # The ranking options for the file search. - sig { params(ranker: Symbol, score_threshold: Float).returns(T.attached_class) } + sig do + params( + ranker: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::OrSymbol, + score_threshold: Float + ) + .returns(T.attached_class) + end def self.new(ranker:, score_threshold:) end - sig { override.returns({ranker: Symbol, score_threshold: Float}) } + sig do + override + .returns( + { + ranker: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol, + score_threshold: Float + } + ) + end def to_hash end # The ranker to use for the file search. If not specified will use the `auto` # ranker. - class Ranker < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } + module Ranker + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker) } + OrSymbol = + T.type_alias do + T.any( + Symbol, + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol + ) + end + + AUTO = + T.let( + :auto, + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol + ) + DEFAULT_2024_08_21 = + T.let( + :default_2024_08_21, + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol + ) - AUTO = :auto - DEFAULT_2024_08_21 = :default_2024_08_21 + sig do + override + .returns( + T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker::TaggedSymbol] + ) + end + def self.values + end end end class Result < OpenAI::BaseModel # The ID of the file that result was found in. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The name of the file that result was found in. sig { returns(String) } - def file_name - end - - sig { params(_: String).returns(String) } - def file_name=(_) - end + attr_accessor :file_name # The score of the result. All values must be a floating point number between 0 # and 1. sig { returns(Float) } - def score - end - - sig { params(_: Float).returns(Float) } - def score=(_) - end + attr_accessor :score # The content of the result that was found. The content is only included if # requested via the include query parameter. @@ -183,15 +197,20 @@ module OpenAI T.nilable(T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content]) ) end - def content - end + attr_reader :content sig do - params(_: T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content]) - .returns(T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content]) - end - def content=(_) + params( + content: T::Array[ + T.any( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content, + OpenAI::Util::AnyHash + ) + ] + ) + .void end + attr_writer :content # A result instance of the file search. sig do @@ -199,7 +218,12 @@ module OpenAI file_id: String, file_name: String, score: Float, - content: T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content] + content: T::Array[ + T.any( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content, + OpenAI::Util::AnyHash + ) + ] ) .returns(T.attached_class) end @@ -223,37 +247,79 @@ module OpenAI class Content < OpenAI::BaseModel # The text content of the file. sig { returns(T.nilable(String)) } - def text - end + attr_reader :text - sig { params(_: String).returns(String) } - def text=(_) - end + sig { params(text: String).void } + attr_writer :text # The type of the content. - sig { returns(T.nilable(Symbol)) } - def type + sig do + returns( + T.nilable( + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::TaggedSymbol + ) + ) end + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) + sig do + params( + type: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::OrSymbol + ) + .void end + attr_writer :type - sig { params(text: String, type: Symbol).returns(T.attached_class) } + sig do + params( + text: String, + type: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::OrSymbol + ) + .returns(T.attached_class) + end def self.new(text: nil, type: nil) end - sig { override.returns({text: String, type: Symbol}) } + sig do + override + .returns( + { + text: String, + type: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::TaggedSymbol + } + ) + end def to_hash end # The type of the content. - class Type < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - TEXT = :text + module Type + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type) } + OrSymbol = + T.type_alias do + T.any( + Symbol, + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::TaggedSymbol + ) + end + + TEXT = + T.let( + :text, + OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::TaggedSymbol + ) + + sig do + override + .returns( + T::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type::TaggedSymbol] + ) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rbi index 4986a86f..8dda0ce6 100644 --- a/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rbi @@ -8,40 +8,23 @@ module OpenAI class FileSearchToolCallDelta < OpenAI::BaseModel # For now, this is always going to be an empty object. sig { returns(T.anything) } - def file_search - end - - sig { params(_: T.anything).returns(T.anything) } - def file_search=(_) - end + attr_accessor :file_search # The index of the tool call in the tool calls array. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of tool call. This is always going to be `file_search` for this type of # tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The ID of the tool call object. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id sig do params( diff --git a/rbi/lib/openai/models/beta/threads/runs/function_tool_call.rbi b/rbi/lib/openai/models/beta/threads/runs/function_tool_call.rbi index 2fbc10a5..3e337e83 100644 --- a/rbi/lib/openai/models/beta/threads/runs/function_tool_call.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/function_tool_call.rbi @@ -8,39 +8,29 @@ module OpenAI class FunctionToolCall < OpenAI::BaseModel # The ID of the tool call object. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The definition of the function that was called. sig { returns(OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function) - .returns(OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function # The type of tool call. This is always going to be `function` for this type of # tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do params( id: String, - function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function, + function: T.any(OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -60,32 +50,17 @@ module OpenAI class Function < OpenAI::BaseModel # The arguments passed to the function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The name of the function. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The output of the function. This will be `null` if the outputs have not been # [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) # yet. sig { returns(T.nilable(String)) } - def output - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def output=(_) - end + attr_accessor :output # The definition of the function that was called. sig do diff --git a/rbi/lib/openai/models/beta/threads/runs/function_tool_call_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/function_tool_call_delta.rbi index c026f468..04b5a69e 100644 --- a/rbi/lib/openai/models/beta/threads/runs/function_tool_call_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/function_tool_call_delta.rbi @@ -8,49 +8,37 @@ module OpenAI class FunctionToolCallDelta < OpenAI::BaseModel # The index of the tool call in the tool calls array. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of tool call. This is always going to be `function` for this type of # tool call. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The ID of the tool call object. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id # The definition of the function that was called. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function)) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function) - .returns(OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function sig do params( index: Integer, id: String, - function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, + function: T.any(OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) @@ -75,32 +63,23 @@ module OpenAI class Function < OpenAI::BaseModel # The arguments passed to the function. sig { returns(T.nilable(String)) } - def arguments - end + attr_reader :arguments - sig { params(_: String).returns(String) } - def arguments=(_) - end + sig { params(arguments: String).void } + attr_writer :arguments # The name of the function. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # The output of the function. This will be `null` if the outputs have not been # [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) # yet. sig { returns(T.nilable(String)) } - def output - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def output=(_) - end + attr_accessor :output # The definition of the function that was called. sig do diff --git a/rbi/lib/openai/models/beta/threads/runs/message_creation_step_details.rbi b/rbi/lib/openai/models/beta/threads/runs/message_creation_step_details.rbi index ba7932c9..8a929854 100644 --- a/rbi/lib/openai/models/beta/threads/runs/message_creation_step_details.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/message_creation_step_details.rbi @@ -7,29 +7,30 @@ module OpenAI module Runs class MessageCreationStepDetails < OpenAI::BaseModel sig { returns(OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation) } - def message_creation - end + attr_reader :message_creation sig do - params(_: OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation) - .returns(OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation) - end - def message_creation=(_) + params( + message_creation: T.any( + OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :message_creation # Always `message_creation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Details of the message creation by the run step. sig do params( - message_creation: OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation, + message_creation: T.any( + OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -52,12 +53,7 @@ module OpenAI class MessageCreation < OpenAI::BaseModel # The ID of the message that was created by this run step. sig { returns(String) } - def message_id - end - - sig { params(_: String).returns(String) } - def message_id=(_) - end + attr_accessor :message_id sig { params(message_id: String).returns(T.attached_class) } def self.new(message_id:) diff --git a/rbi/lib/openai/models/beta/threads/runs/run_step.rbi b/rbi/lib/openai/models/beta/threads/runs/run_step.rbi index c4e9125c..79a32996 100644 --- a/rbi/lib/openai/models/beta/threads/runs/run_step.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/run_step.rbi @@ -4,88 +4,51 @@ module OpenAI module Models module Beta module Threads - RunStep = T.type_alias { Runs::RunStep } - module Runs class RunStep < OpenAI::BaseModel # The identifier of the run step, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The ID of the # [assistant](https://platform.openai.com/docs/api-reference/assistants) # associated with the run step. sig { returns(String) } - def assistant_id - end - - sig { params(_: String).returns(String) } - def assistant_id=(_) - end + attr_accessor :assistant_id # The Unix timestamp (in seconds) for when the run step was cancelled. sig { returns(T.nilable(Integer)) } - def cancelled_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def cancelled_at=(_) - end + attr_accessor :cancelled_at # The Unix timestamp (in seconds) for when the run step completed. sig { returns(T.nilable(Integer)) } - def completed_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def completed_at=(_) - end + attr_accessor :completed_at # The Unix timestamp (in seconds) for when the run step was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The Unix timestamp (in seconds) for when the run step expired. A step is # considered expired if the parent run is expired. sig { returns(T.nilable(Integer)) } - def expired_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def expired_at=(_) - end + attr_accessor :expired_at # The Unix timestamp (in seconds) for when the run step failed. sig { returns(T.nilable(Integer)) } - def failed_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def failed_at=(_) - end + attr_accessor :failed_at # The last error associated with this run step. Will be `null` if there are no # errors. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError)) } - def last_error - end + attr_reader :last_error sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError)) - end - def last_error=(_) + params( + last_error: T.nilable(T.any(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :last_error # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -93,42 +56,22 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The object type, which is always `thread.run.step`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that # this run step is a part of. sig { returns(String) } - def run_id - end - - sig { params(_: String).returns(String) } - def run_id=(_) - end + attr_accessor :run_id # The status of the run step, which can be either `in_progress`, `cancelled`, # `failed`, `completed`, or `expired`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) } + attr_accessor :status # The details of the run step. sig do @@ -139,57 +82,29 @@ module OpenAI ) ) end - def step_details - end - - sig do - params( - _: T.any( - OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, - OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails - ) - ) - .returns( - T.any( - OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, - OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails - ) - ) - end - def step_details=(_) - end + attr_accessor :step_details # The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) # that was run. sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # The type of run step, which can be either `message_creation` or `tool_calls`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol) } + attr_accessor :type # Usage statistics related to the run step. This value will be `null` while the # run step's status is `in_progress`. sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage)) } - def usage - end + attr_reader :usage sig do - params(_: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage)) - .returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage)) - end - def usage=(_) + params( + usage: T.nilable(T.any(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :usage # Represents a step in execution of a run. sig do @@ -201,17 +116,18 @@ module OpenAI created_at: Integer, expired_at: T.nilable(Integer), failed_at: T.nilable(Integer), - last_error: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError), - metadata: T.nilable(OpenAI::Models::Metadata), + last_error: T.nilable(T.any(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError, OpenAI::Util::AnyHash)), + metadata: T.nilable(T::Hash[Symbol, String]), run_id: String, - status: Symbol, + status: OpenAI::Models::Beta::Threads::Runs::RunStep::Status::OrSymbol, step_details: T.any( OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails ), thread_id: String, - type: Symbol, - usage: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage), + type: OpenAI::Models::Beta::Threads::Runs::RunStep::Type::OrSymbol, + usage: T.nilable(T.any(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage, OpenAI::Util::AnyHash)), object: Symbol ) .returns(T.attached_class) @@ -248,16 +164,16 @@ module OpenAI expired_at: T.nilable(Integer), failed_at: T.nilable(Integer), last_error: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), object: Symbol, run_id: String, - status: Symbol, + status: OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol, step_details: T.any( OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails ), thread_id: String, - type: Symbol, + type: OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol, usage: T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStep::Usage) } ) @@ -267,109 +183,114 @@ module OpenAI class LastError < OpenAI::BaseModel # One of `server_error` or `rate_limit_exceeded`. - sig { returns(Symbol) } - def code - end - - sig { params(_: Symbol).returns(Symbol) } - def code=(_) - end + sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol) } + attr_accessor :code # A human-readable description of the error. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The last error associated with this run step. Will be `null` if there are no # errors. - sig { params(code: Symbol, message: String).returns(T.attached_class) } + sig do + params(code: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::OrSymbol, message: String) + .returns(T.attached_class) + end def self.new(code:, message:) end - sig { override.returns({code: Symbol, message: String}) } + sig do + override + .returns( + {code: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol, message: String} + ) + end def to_hash end # One of `server_error` or `rate_limit_exceeded`. - class Code < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - SERVER_ERROR = :server_error - RATE_LIMIT_EXCEEDED = :rate_limit_exceeded + module Code + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol) } + + SERVER_ERROR = + T.let(:server_error, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol) + RATE_LIMIT_EXCEEDED = + T.let(:rate_limit_exceeded, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code::TaggedSymbol]) } + def self.values + end end end # The status of the run step, which can be either `in_progress`, `cancelled`, # `failed`, `completed`, or `expired`. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) } - IN_PROGRESS = :in_progress - CANCELLED = :cancelled - FAILED = :failed - COMPLETED = :completed - EXPIRED = :expired + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) + EXPIRED = T.let(:expired, OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::Status::TaggedSymbol]) } + def self.values + end end # The details of the run step. - class StepDetails < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, - OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails + module StepDetails + extend OpenAI::Union + + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails] ) - } + end + def self.variants end end # The type of run step, which can be either `message_creation` or `tool_calls`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MESSAGE_CREATION = + T.let(:message_creation, OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol) + TOOL_CALLS = T.let(:tool_calls, OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol) - MESSAGE_CREATION = :message_creation - TOOL_CALLS = :tool_calls + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::Type::TaggedSymbol]) } + def self.values + end end class Usage < OpenAI::BaseModel # Number of completion tokens used over the course of the run step. sig { returns(Integer) } - def completion_tokens - end - - sig { params(_: Integer).returns(Integer) } - def completion_tokens=(_) - end + attr_accessor :completion_tokens # Number of prompt tokens used over the course of the run step. sig { returns(Integer) } - def prompt_tokens - end - - sig { params(_: Integer).returns(Integer) } - def prompt_tokens=(_) - end + attr_accessor :prompt_tokens # Total number of tokens used (prompt + completion). sig { returns(Integer) } - def total_tokens - end - - sig { params(_: Integer).returns(Integer) } - def total_tokens=(_) - end + attr_accessor :total_tokens # Usage statistics related to the run step. This value will be `null` while the # run step's status is `in_progress`. @@ -391,6 +312,8 @@ module OpenAI end end end + + RunStep = Runs::RunStep end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/run_step_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/run_step_delta.rbi index cb3b9c62..19089bfb 100644 --- a/rbi/lib/openai/models/beta/threads/runs/run_step_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/run_step_delta.rbi @@ -4,8 +4,6 @@ module OpenAI module Models module Beta module Threads - RunStepDelta = T.type_alias { Runs::RunStepDelta } - module Runs class RunStepDelta < OpenAI::BaseModel # The details of the run step. @@ -19,31 +17,26 @@ module OpenAI ) ) end - def step_details - end + attr_reader :step_details sig do params( - _: T.any( + step_details: T.any( OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject ) ) - .returns( - T.any( - OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, - OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject - ) - ) - end - def step_details=(_) + .void end + attr_writer :step_details # The delta containing the fields that have changed on the run step. sig do params( step_details: T.any( OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject ) ) @@ -67,20 +60,22 @@ module OpenAI end # The details of the run step. - class StepDetails < OpenAI::Union - abstract! + module StepDetails + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, - OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject] ) - } + end + def self.variants end end end end + + RunStepDelta = Runs::RunStepDelta end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/run_step_delta_event.rbi b/rbi/lib/openai/models/beta/threads/runs/run_step_delta_event.rbi index 7cc4a3fb..08c7adf8 100644 --- a/rbi/lib/openai/models/beta/threads/runs/run_step_delta_event.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/run_step_delta_event.rbi @@ -4,44 +4,31 @@ module OpenAI module Models module Beta module Threads - RunStepDeltaEvent = T.type_alias { Runs::RunStepDeltaEvent } - module Runs class RunStepDeltaEvent < OpenAI::BaseModel # The identifier of the run step, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The delta containing the fields that have changed on the run step. sig { returns(OpenAI::Models::Beta::Threads::Runs::RunStepDelta) } - def delta - end + attr_reader :delta - sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStepDelta) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStepDelta) - end - def delta=(_) - end + sig { params(delta: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDelta, OpenAI::Util::AnyHash)).void } + attr_writer :delta # The object type, which is always `thread.run.step.delta`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # Represents a run step delta i.e. any changed fields on a run step during # streaming. sig do - params(id: String, delta: OpenAI::Models::Beta::Threads::Runs::RunStepDelta, object: Symbol) + params( + id: String, + delta: T.any(OpenAI::Models::Beta::Threads::Runs::RunStepDelta, OpenAI::Util::AnyHash), + object: Symbol + ) .returns(T.attached_class) end def self.new(id:, delta:, object: :"thread.run.step.delta") @@ -52,6 +39,8 @@ module OpenAI end end end + + RunStepDeltaEvent = Runs::RunStepDeltaEvent end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rbi index 02216a5c..a13b01a2 100644 --- a/rbi/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rbi @@ -4,34 +4,33 @@ module OpenAI module Models module Beta module Threads - RunStepDeltaMessageDelta = T.type_alias { Runs::RunStepDeltaMessageDelta } - module Runs class RunStepDeltaMessageDelta < OpenAI::BaseModel # Always `message_creation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation)) } - def message_creation - end + attr_reader :message_creation sig do - params(_: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation) - .returns(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation) - end - def message_creation=(_) + params( + message_creation: T.any( + OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :message_creation # Details of the message creation by the run step. sig do params( - message_creation: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, + message_creation: T.any( + OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -54,12 +53,10 @@ module OpenAI class MessageCreation < OpenAI::BaseModel # The ID of the message that was created by this run step. sig { returns(T.nilable(String)) } - def message_id - end + attr_reader :message_id - sig { params(_: String).returns(String) } - def message_id=(_) - end + sig { params(message_id: String).void } + attr_writer :message_id sig { params(message_id: String).returns(T.attached_class) } def self.new(message_id: nil) @@ -71,6 +68,8 @@ module OpenAI end end end + + RunStepDeltaMessageDelta = Runs::RunStepDeltaMessageDelta end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/run_step_include.rbi b/rbi/lib/openai/models/beta/threads/runs/run_step_include.rbi index 9fd4c51e..23cf6a3b 100644 --- a/rbi/lib/openai/models/beta/threads/runs/run_step_include.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/run_step_include.rbi @@ -4,17 +4,27 @@ module OpenAI module Models module Beta module Threads - RunStepInclude = T.type_alias { Runs::RunStepInclude } - module Runs - class RunStepInclude < OpenAI::Enum - abstract! + module RunStepInclude + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT = + T.let( + :"step_details.tool_calls[*].file_search.results[*].content", + OpenAI::Models::Beta::Threads::Runs::RunStepInclude::TaggedSymbol + ) - STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT = :"step_details.tool_calls[*].file_search.results[*].content" + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::TaggedSymbol]) } + def self.values + end end end + + RunStepInclude = Runs::RunStepInclude end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/step_list_params.rbi b/rbi/lib/openai/models/beta/threads/runs/step_list_params.rbi index 73059bac..bdb4424d 100644 --- a/rbi/lib/openai/models/beta/threads/runs/step_list_params.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/step_list_params.rbi @@ -6,40 +6,31 @@ module OpenAI module Threads module Runs class StepListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id # A cursor for use in pagination. `after` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # A list of additional fields to include in the response. Currently the only # supported value is `step_details.tool_calls[*].file_search.results[*].content` @@ -48,47 +39,49 @@ module OpenAI # See the # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. - sig { returns(T.nilable(T::Array[Symbol])) } - def include - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol])) } + attr_reader :include - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def include=(_) - end + sig { params(include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol]).void } + attr_writer :include # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::OrSymbol).void } + attr_writer :order sig do params( thread_id: String, after: String, before: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(thread_id:, after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {}) + def self.new( + thread_id:, + after: nil, + before: nil, + include: nil, + limit: nil, + order: nil, + request_options: {} + ) end sig do @@ -98,9 +91,9 @@ module OpenAI thread_id: String, after: String, before: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -110,13 +103,19 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/step_retrieve_params.rbi b/rbi/lib/openai/models/beta/threads/runs/step_retrieve_params.rbi index 71dc2e52..15b2fdd2 100644 --- a/rbi/lib/openai/models/beta/threads/runs/step_retrieve_params.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/step_retrieve_params.rbi @@ -6,24 +6,14 @@ module OpenAI module Threads module Runs class StepRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def thread_id - end - - sig { params(_: String).returns(String) } - def thread_id=(_) - end + attr_accessor :thread_id sig { returns(String) } - def run_id - end - - sig { params(_: String).returns(String) } - def run_id=(_) - end + attr_accessor :run_id # A list of additional fields to include in the response. Currently the only # supported value is `step_details.tool_calls[*].file_search.results[*].content` @@ -32,20 +22,18 @@ module OpenAI # See the # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) # for more information. - sig { returns(T.nilable(T::Array[Symbol])) } - def include - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol])) } + attr_reader :include - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def include=(_) - end + sig { params(include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol]).void } + attr_writer :include sig do params( thread_id: String, run_id: String, - include: T::Array[Symbol], - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -58,7 +46,7 @@ module OpenAI { thread_id: String, run_id: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], request_options: OpenAI::RequestOptions } ) diff --git a/rbi/lib/openai/models/beta/threads/runs/tool_call.rbi b/rbi/lib/openai/models/beta/threads/runs/tool_call.rbi index e3f26a25..22b596d5 100644 --- a/rbi/lib/openai/models/beta/threads/runs/tool_call.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/tool_call.rbi @@ -6,17 +6,16 @@ module OpenAI module Threads module Runs # Details of the Code Interpreter tool call the run step was involved in. - class ToolCall < OpenAI::Union - abstract! + module ToolCall + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, - OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, - OpenAI::Models::Beta::Threads::Runs::FunctionToolCall + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/tool_call_delta.rbi b/rbi/lib/openai/models/beta/threads/runs/tool_call_delta.rbi index 8169ef81..8af6cb90 100644 --- a/rbi/lib/openai/models/beta/threads/runs/tool_call_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/tool_call_delta.rbi @@ -6,17 +6,16 @@ module OpenAI module Threads module Runs # Details of the Code Interpreter tool call the run step was involved in. - class ToolCallDelta < OpenAI::Union - abstract! + module ToolCallDelta + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, - OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, - OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta + sig do + override + .returns( + [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/beta/threads/runs/tool_call_delta_object.rbi b/rbi/lib/openai/models/beta/threads/runs/tool_call_delta_object.rbi index 3258b9d6..c4833e7c 100644 --- a/rbi/lib/openai/models/beta/threads/runs/tool_call_delta_object.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/tool_call_delta_object.rbi @@ -8,12 +8,7 @@ module OpenAI class ToolCallDeltaObject < OpenAI::BaseModel # Always `tool_calls`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An array of tool calls the run step was involved in. These can be associated # with one of three types of tools: `code_interpreter`, `file_search`, or @@ -31,31 +26,22 @@ module OpenAI ) ) end - def tool_calls - end + attr_reader :tool_calls sig do params( - _: T::Array[ + tool_calls: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, - OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, - OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta - ) - ] - ) - end - def tool_calls=(_) + .void end + attr_writer :tool_calls # Details of the tool call. sig do @@ -63,6 +49,7 @@ module OpenAI tool_calls: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta ) diff --git a/rbi/lib/openai/models/beta/threads/runs/tool_calls_step_details.rbi b/rbi/lib/openai/models/beta/threads/runs/tool_calls_step_details.rbi index 3ad8cc7f..0dade5cb 100644 --- a/rbi/lib/openai/models/beta/threads/runs/tool_calls_step_details.rbi +++ b/rbi/lib/openai/models/beta/threads/runs/tool_calls_step_details.rbi @@ -20,40 +20,11 @@ module OpenAI ] ) end - def tool_calls - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, - OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, - OpenAI::Models::Beta::Threads::Runs::FunctionToolCall - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, - OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, - OpenAI::Models::Beta::Threads::Runs::FunctionToolCall - ) - ] - ) - end - def tool_calls=(_) - end + attr_accessor :tool_calls # Always `tool_calls`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Details of the tool call. sig do @@ -61,6 +32,7 @@ module OpenAI tool_calls: T::Array[ T.any( OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall ) diff --git a/rbi/lib/openai/models/beta/threads/text.rbi b/rbi/lib/openai/models/beta/threads/text.rbi index 0ba8015c..9dd44292 100644 --- a/rbi/lib/openai/models/beta/threads/text.rbi +++ b/rbi/lib/openai/models/beta/threads/text.rbi @@ -15,44 +15,18 @@ module OpenAI ] ) end - def annotations - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Beta::Threads::FileCitationAnnotation, - OpenAI::Models::Beta::Threads::FilePathAnnotation - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::FileCitationAnnotation, - OpenAI::Models::Beta::Threads::FilePathAnnotation - ) - ] - ) - end - def annotations=(_) - end + attr_accessor :annotations # The data that makes up the text. sig { returns(String) } - def value - end - - sig { params(_: String).returns(String) } - def value=(_) - end + attr_accessor :value sig do params( annotations: T::Array[ T.any( OpenAI::Models::Beta::Threads::FileCitationAnnotation, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::FilePathAnnotation ) ], diff --git a/rbi/lib/openai/models/beta/threads/text_content_block.rbi b/rbi/lib/openai/models/beta/threads/text_content_block.rbi index 5a3f345f..18c16ea3 100644 --- a/rbi/lib/openai/models/beta/threads/text_content_block.rbi +++ b/rbi/lib/openai/models/beta/threads/text_content_block.rbi @@ -6,24 +6,20 @@ module OpenAI module Threads class TextContentBlock < OpenAI::BaseModel sig { returns(OpenAI::Models::Beta::Threads::Text) } - def text - end + attr_reader :text - sig { params(_: OpenAI::Models::Beta::Threads::Text).returns(OpenAI::Models::Beta::Threads::Text) } - def text=(_) - end + sig { params(text: T.any(OpenAI::Models::Beta::Threads::Text, OpenAI::Util::AnyHash)).void } + attr_writer :text # Always `text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The text content that is part of a message. - sig { params(text: OpenAI::Models::Beta::Threads::Text, type: Symbol).returns(T.attached_class) } + sig do + params(text: T.any(OpenAI::Models::Beta::Threads::Text, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(text:, type: :text) end diff --git a/rbi/lib/openai/models/beta/threads/text_content_block_param.rbi b/rbi/lib/openai/models/beta/threads/text_content_block_param.rbi index 58764a6f..f59cbbd5 100644 --- a/rbi/lib/openai/models/beta/threads/text_content_block_param.rbi +++ b/rbi/lib/openai/models/beta/threads/text_content_block_param.rbi @@ -7,21 +7,11 @@ module OpenAI class TextContentBlockParam < OpenAI::BaseModel # Text content to be sent to the model sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Always `text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The text content that is part of a message. sig { params(text: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/beta/threads/text_delta.rbi b/rbi/lib/openai/models/beta/threads/text_delta.rbi index 12996683..2f225af3 100644 --- a/rbi/lib/openai/models/beta/threads/text_delta.rbi +++ b/rbi/lib/openai/models/beta/threads/text_delta.rbi @@ -17,44 +17,35 @@ module OpenAI ) ) end - def annotations - end + attr_reader :annotations sig do params( - _: T::Array[ + annotations: T::Array[ T.any( OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, - OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation - ) - ] - ) - end - def annotations=(_) + .void end + attr_writer :annotations # The data that makes up the text. sig { returns(T.nilable(String)) } - def value - end + attr_reader :value - sig { params(_: String).returns(String) } - def value=(_) - end + sig { params(value: String).void } + attr_writer :value sig do params( annotations: T::Array[ T.any( OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation ) ], diff --git a/rbi/lib/openai/models/beta/threads/text_delta_block.rbi b/rbi/lib/openai/models/beta/threads/text_delta_block.rbi index 80145b24..0e37546f 100644 --- a/rbi/lib/openai/models/beta/threads/text_delta_block.rbi +++ b/rbi/lib/openai/models/beta/threads/text_delta_block.rbi @@ -7,33 +7,25 @@ module OpenAI class TextDeltaBlock < OpenAI::BaseModel # The index of the content part in the message. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Always `text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { returns(T.nilable(OpenAI::Models::Beta::Threads::TextDelta)) } - def text - end + attr_reader :text - sig { params(_: OpenAI::Models::Beta::Threads::TextDelta).returns(OpenAI::Models::Beta::Threads::TextDelta) } - def text=(_) - end + sig { params(text: T.any(OpenAI::Models::Beta::Threads::TextDelta, OpenAI::Util::AnyHash)).void } + attr_writer :text # The text content that is part of a message. sig do - params(index: Integer, text: OpenAI::Models::Beta::Threads::TextDelta, type: Symbol) + params( + index: Integer, + text: T.any(OpenAI::Models::Beta::Threads::TextDelta, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(index:, text: nil, type: :text) diff --git a/rbi/lib/openai/models/chat/chat_completion.rbi b/rbi/lib/openai/models/chat/chat_completion.rbi index c68e3594..1fea8214 100644 --- a/rbi/lib/openai/models/chat/chat_completion.rbi +++ b/rbi/lib/openai/models/chat/chat_completion.rbi @@ -2,100 +2,61 @@ module OpenAI module Models - ChatCompletion = T.type_alias { Chat::ChatCompletion } - module Chat class ChatCompletion < OpenAI::BaseModel # A unique identifier for the chat completion. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # A list of chat completion choices. Can be more than one if `n` is greater # than 1. sig { returns(T::Array[OpenAI::Models::Chat::ChatCompletion::Choice]) } - def choices - end - - sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletion::Choice]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletion::Choice]) - end - def choices=(_) - end + attr_accessor :choices # The Unix timestamp (in seconds) of when the chat completion was created. sig { returns(Integer) } - def created - end - - sig { params(_: Integer).returns(Integer) } - def created=(_) - end + attr_accessor :created # The model used for the chat completion. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always `chat.completion`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The service tier used for processing the request. - sig { returns(T.nilable(Symbol)) } - def service_tier - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def service_tier=(_) - end + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol)) } + attr_accessor :service_tier # This fingerprint represents the backend configuration that the model runs with. # # Can be used in conjunction with the `seed` request parameter to understand when # backend changes have been made that might impact determinism. sig { returns(T.nilable(String)) } - def system_fingerprint - end + attr_reader :system_fingerprint - sig { params(_: String).returns(String) } - def system_fingerprint=(_) - end + sig { params(system_fingerprint: String).void } + attr_writer :system_fingerprint # Usage statistics for the completion request. sig { returns(T.nilable(OpenAI::Models::CompletionUsage)) } - def usage - end + attr_reader :usage - sig { params(_: OpenAI::Models::CompletionUsage).returns(OpenAI::Models::CompletionUsage) } - def usage=(_) - end + sig { params(usage: T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash)).void } + attr_writer :usage # Represents a chat completion response returned by model, based on the provided # input. sig do params( id: String, - choices: T::Array[OpenAI::Models::Chat::ChatCompletion::Choice], + choices: T::Array[T.any(OpenAI::Models::Chat::ChatCompletion::Choice, OpenAI::Util::AnyHash)], created: Integer, model: String, - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::ChatCompletion::ServiceTier::OrSymbol), system_fingerprint: String, - usage: OpenAI::Models::CompletionUsage, + usage: T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash), object: Symbol ) .returns(T.attached_class) @@ -121,7 +82,7 @@ module OpenAI created: Integer, model: String, object: Symbol, - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol), system_fingerprint: String, usage: OpenAI::Models::CompletionUsage } @@ -137,52 +98,38 @@ module OpenAI # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - sig { returns(Symbol) } - def finish_reason - end - - sig { params(_: Symbol).returns(Symbol) } - def finish_reason=(_) - end + sig { returns(OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) } + attr_accessor :finish_reason # The index of the choice in the list of choices. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Log probability information for the choice. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs)) } - def logprobs - end + attr_reader :logprobs sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs)) - end - def logprobs=(_) + params( + logprobs: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :logprobs # A chat completion message generated by the model. sig { returns(OpenAI::Models::Chat::ChatCompletionMessage) } - def message - end + attr_reader :message - sig do - params(_: OpenAI::Models::Chat::ChatCompletionMessage).returns(OpenAI::Models::Chat::ChatCompletionMessage) - end - def message=(_) - end + sig { params(message: T.any(OpenAI::Models::Chat::ChatCompletionMessage, OpenAI::Util::AnyHash)).void } + attr_writer :message sig do params( - finish_reason: Symbol, + finish_reason: OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::OrSymbol, index: Integer, - logprobs: T.nilable(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs), - message: OpenAI::Models::Chat::ChatCompletionMessage + logprobs: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, OpenAI::Util::AnyHash)), + message: T.any(OpenAI::Models::Chat::ChatCompletionMessage, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -193,7 +140,7 @@ module OpenAI override .returns( { - finish_reason: Symbol, + finish_reason: OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol, index: Integer, logprobs: T.nilable(OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs), message: OpenAI::Models::Chat::ChatCompletionMessage @@ -209,48 +156,40 @@ module OpenAI # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - class FinishReason < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - STOP = :stop - LENGTH = :length - TOOL_CALLS = :tool_calls - CONTENT_FILTER = :content_filter - FUNCTION_CALL = :function_call + module FinishReason + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) } + + STOP = T.let(:stop, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) + LENGTH = T.let(:length, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) + TOOL_CALLS = T.let(:tool_calls, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) + CONTENT_FILTER = + T.let(:content_filter, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) + FUNCTION_CALL = + T.let(:function_call, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol]) } + def self.values + end end class Logprobs < OpenAI::BaseModel # A list of message content tokens with log probability information. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) } - def content - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - .returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - end - def content=(_) - end + attr_accessor :content # A list of message refusal tokens with log probability information. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) } - def refusal - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - .returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - end - def refusal=(_) - end + attr_accessor :refusal # Log probability information for the choice. sig do params( - content: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]), - refusal: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]) + content: T.nilable(T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTokenLogprob, OpenAI::Util::AnyHash)]), + refusal: T.nilable(T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTokenLogprob, OpenAI::Util::AnyHash)]) ) .returns(T.attached_class) end @@ -272,15 +211,23 @@ module OpenAI end # The service tier used for processing the request. - class ServiceTier < OpenAI::Enum - abstract! + module ServiceTier + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletion::ServiceTier) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol) } - SCALE = :scale - DEFAULT = :default + SCALE = T.let(:scale, OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol) + DEFAULT = T.let(:default, OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletion::ServiceTier::TaggedSymbol]) } + def self.values + end end end end + + ChatCompletion = Chat::ChatCompletion end end diff --git a/rbi/lib/openai/models/chat/chat_completion_assistant_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_assistant_message_param.rbi index 624890ee..65806b1f 100644 --- a/rbi/lib/openai/models/chat/chat_completion_assistant_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_assistant_message_param.rbi @@ -2,31 +2,24 @@ module OpenAI module Models - ChatCompletionAssistantMessageParam = T.type_alias { Chat::ChatCompletionAssistantMessageParam } - module Chat class ChatCompletionAssistantMessageParam < OpenAI::BaseModel # The role of the messages author, in this case `assistant`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # Data about a previous audio response from the model. # [Learn more](https://platform.openai.com/docs/guides/audio). sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio)) } - def audio - end + attr_reader :audio sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio)) - end - def audio=(_) + params( + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :audio # The contents of the assistant message. Required unless `tool_calls` or # `function_call` is specified. @@ -45,108 +38,82 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.nilable( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartRefusal - ) - ] - ) - ) - ) - .returns( - T.nilable( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartRefusal - ) - ] - ) - ) - ) - end - def content=(_) - end + attr_accessor :content # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall)) } - def function_call - end + attr_reader :function_call sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall)) - end - def function_call=(_) + params( + function_call: T.nilable( + T.any(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, OpenAI::Util::AnyHash) + ) + ) + .void end + attr_writer :function_call # An optional name for the participant. Provides the model information to # differentiate between participants of the same role. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # The refusal message by the assistant. sig { returns(T.nilable(String)) } - def refusal - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def refusal=(_) - end + attr_accessor :refusal # The tool calls generated by the model, such as function calls. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall])) } - def tool_calls - end + attr_reader :tool_calls sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall]) - end - def tool_calls=(_) + params( + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :tool_calls # Messages sent by the model in response to user messages. sig do params( - audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio), + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, OpenAI::Util::AnyHash)), content: T.nilable( T.any( String, T::Array[ T.any( OpenAI::Models::Chat::ChatCompletionContentPartText, + OpenAI::Util::AnyHash, OpenAI::Models::Chat::ChatCompletionContentPartRefusal ) ] ) ), - function_call: T.nilable(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall), + function_call: T.nilable( + T.any(OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, OpenAI::Util::AnyHash) + ), name: String, refusal: T.nilable(String), - tool_calls: T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall, OpenAI::Util::AnyHash)], role: Symbol ) .returns(T.attached_class) end - def self.new(audio: nil, content: nil, function_call: nil, name: nil, refusal: nil, tool_calls: nil, role: :assistant) + def self.new( + audio: nil, + content: nil, + function_call: nil, + name: nil, + refusal: nil, + tool_calls: nil, + role: :assistant + ) end sig do @@ -179,12 +146,7 @@ module OpenAI class Audio < OpenAI::BaseModel # Unique identifier for a previous audio response from the model. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # Data about a previous audio response from the model. # [Learn more](https://platform.openai.com/docs/guides/audio). @@ -199,46 +161,46 @@ module OpenAI # The contents of the assistant message. Required unless `tool_calls` or # `function_call` is specified. - class Content < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartRefusal - ) - ] - ) - } - end - - ArrayOfContentPartArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartRefusal - ) - ] - end + module Content + extend OpenAI::Union # Learn about # [text inputs](https://platform.openai.com/docs/guides/text-generation). - class ArrayOfContentPart < OpenAI::Union - abstract! + module ArrayOfContentPart + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartRefusal + sig do + override + .returns( + [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal] ) - } end + def self.variants + end + end + + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Chat::ChatCompletionContentPartText, + OpenAI::Models::Chat::ChatCompletionContentPartRefusal + ) + ] + ] + ) end + def self.variants + end + + ArrayOfContentPartArray = + T.let( + OpenAI::ArrayOf[union: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart], + OpenAI::Type::Converter + ) end class FunctionCall < OpenAI::BaseModel @@ -247,21 +209,11 @@ module OpenAI # hallucinate parameters not defined by your function schema. Validate the # arguments in your code before calling your function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. @@ -275,5 +227,7 @@ module OpenAI end end end + + ChatCompletionAssistantMessageParam = Chat::ChatCompletionAssistantMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_audio.rbi b/rbi/lib/openai/models/chat/chat_completion_audio.rbi index 489f4145..7cd9cc72 100644 --- a/rbi/lib/openai/models/chat/chat_completion_audio.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_audio.rbi @@ -2,47 +2,25 @@ module OpenAI module Models - ChatCompletionAudio = T.type_alias { Chat::ChatCompletionAudio } - module Chat class ChatCompletionAudio < OpenAI::BaseModel # Unique identifier for this audio response. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # Base64 encoded audio bytes generated by the model, in the format specified in # the request. sig { returns(String) } - def data - end - - sig { params(_: String).returns(String) } - def data=(_) - end + attr_accessor :data # The Unix timestamp (in seconds) for when this audio response will no longer be # accessible on the server for use in multi-turn conversations. sig { returns(Integer) } - def expires_at - end - - sig { params(_: Integer).returns(Integer) } - def expires_at=(_) - end + attr_accessor :expires_at # Transcript of the audio generated by the model. sig { returns(String) } - def transcript - end - - sig { params(_: String).returns(String) } - def transcript=(_) - end + attr_accessor :transcript # If the audio output modality is requested, this object contains data about the # audio response from the model. @@ -58,5 +36,7 @@ module OpenAI end end end + + ChatCompletionAudio = Chat::ChatCompletionAudio end end diff --git a/rbi/lib/openai/models/chat/chat_completion_audio_param.rbi b/rbi/lib/openai/models/chat/chat_completion_audio_param.rbi index 0af4b8ee..d59ea97b 100644 --- a/rbi/lib/openai/models/chat/chat_completion_audio_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_audio_param.rbi @@ -2,72 +2,91 @@ module OpenAI module Models - ChatCompletionAudioParam = T.type_alias { Chat::ChatCompletionAudioParam } - module Chat class ChatCompletionAudioParam < OpenAI::BaseModel # Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, # or `pcm16`. - sig { returns(Symbol) } - def format_ - end - - sig { params(_: Symbol).returns(Symbol) } - def format_=(_) - end + sig { returns(OpenAI::Models::Chat::ChatCompletionAudioParam::Format::OrSymbol) } + attr_accessor :format_ # The voice the model uses to respond. Supported voices are `alloy`, `ash`, # `ballad`, `coral`, `echo`, `sage`, and `shimmer`. - sig { returns(Symbol) } - def voice - end - - sig { params(_: Symbol).returns(Symbol) } - def voice=(_) - end + sig { returns(T.any(String, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::OrSymbol)) } + attr_accessor :voice # Parameters for audio output. Required when audio output is requested with # `modalities: ["audio"]`. # [Learn more](https://platform.openai.com/docs/guides/audio). - sig { params(format_: Symbol, voice: Symbol).returns(T.attached_class) } + sig do + params( + format_: OpenAI::Models::Chat::ChatCompletionAudioParam::Format::OrSymbol, + voice: T.any(String, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::OrSymbol) + ) + .returns(T.attached_class) + end def self.new(format_:, voice:) end - sig { override.returns({format_: Symbol, voice: Symbol}) } + sig do + override + .returns( + { + format_: OpenAI::Models::Chat::ChatCompletionAudioParam::Format::OrSymbol, + voice: T.any(String, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::OrSymbol) + } + ) + end def to_hash end # Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, # or `pcm16`. - class Format < OpenAI::Enum - abstract! + module Format + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Format) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) } - WAV = :wav - MP3 = :mp3 - FLAC = :flac - OPUS = :opus - PCM16 = :pcm16 + WAV = T.let(:wav, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) + MP3 = T.let(:mp3, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) + FLAC = T.let(:flac, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) + OPUS = T.let(:opus, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) + PCM16 = T.let(:pcm16, OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionAudioParam::Format::TaggedSymbol]) } + def self.values + end end # The voice the model uses to respond. Supported voices are `alloy`, `ash`, # `ballad`, `coral`, `echo`, `sage`, and `shimmer`. - class Voice < OpenAI::Enum - abstract! + module Voice + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::OrSymbol]) } + def self.variants + end - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) } - ALLOY = :alloy - ASH = :ash - BALLAD = :ballad - CORAL = :coral - ECHO = :echo - SAGE = :sage - SHIMMER = :shimmer - VERSE = :verse + ALLOY = T.let(:alloy, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + ASH = T.let(:ash, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + BALLAD = T.let(:ballad, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + CORAL = T.let(:coral, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + ECHO = T.let(:echo, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + FABLE = T.let(:fable, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + ONYX = T.let(:onyx, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + NOVA = T.let(:nova, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + SAGE = T.let(:sage, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + SHIMMER = T.let(:shimmer, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) + VERSE = T.let(:verse, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) end end end + + ChatCompletionAudioParam = Chat::ChatCompletionAudioParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_chunk.rbi b/rbi/lib/openai/models/chat/chat_completion_chunk.rbi index 9595e84a..56e76f39 100644 --- a/rbi/lib/openai/models/chat/chat_completion_chunk.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_chunk.rbi @@ -2,92 +2,56 @@ module OpenAI module Models - ChatCompletionChunk = T.type_alias { Chat::ChatCompletionChunk } - module Chat class ChatCompletionChunk < OpenAI::BaseModel # A unique identifier for the chat completion. Each chunk has the same ID. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # A list of chat completion choices. Can contain more than one elements if `n` is # greater than 1. Can also be empty for the last chunk if you set # `stream_options: {"include_usage": true}`. sig { returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice]) } - def choices - end - - sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice]) - end - def choices=(_) - end + attr_accessor :choices # The Unix timestamp (in seconds) of when the chat completion was created. Each # chunk has the same timestamp. sig { returns(Integer) } - def created - end - - sig { params(_: Integer).returns(Integer) } - def created=(_) - end + attr_accessor :created # The model to generate the completion. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always `chat.completion.chunk`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The service tier used for processing the request. - sig { returns(T.nilable(Symbol)) } - def service_tier - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def service_tier=(_) - end + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol)) } + attr_accessor :service_tier # This fingerprint represents the backend configuration that the model runs with. # Can be used in conjunction with the `seed` request parameter to understand when # backend changes have been made that might impact determinism. sig { returns(T.nilable(String)) } - def system_fingerprint - end + attr_reader :system_fingerprint - sig { params(_: String).returns(String) } - def system_fingerprint=(_) - end + sig { params(system_fingerprint: String).void } + attr_writer :system_fingerprint # An optional field that will only be present when you set # `stream_options: {"include_usage": true}` in your request. When present, it - # contains a null value except for the last chunk which contains the token usage - # statistics for the entire request. + # contains a null value **except for the last chunk** which contains the token + # usage statistics for the entire request. + # + # **NOTE:** If the stream is interrupted or cancelled, you may not receive the + # final usage chunk which contains the total token usage for the request. sig { returns(T.nilable(OpenAI::Models::CompletionUsage)) } - def usage - end + attr_reader :usage - sig { params(_: T.nilable(OpenAI::Models::CompletionUsage)).returns(T.nilable(OpenAI::Models::CompletionUsage)) } - def usage=(_) - end + sig { params(usage: T.nilable(T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash))).void } + attr_writer :usage # Represents a streamed chunk of a chat completion response returned by the model, # based on the provided input. @@ -95,12 +59,12 @@ module OpenAI sig do params( id: String, - choices: T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice], + choices: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice, OpenAI::Util::AnyHash)], created: Integer, model: String, - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::OrSymbol), system_fingerprint: String, - usage: T.nilable(OpenAI::Models::CompletionUsage), + usage: T.nilable(T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash)), object: Symbol ) .returns(T.attached_class) @@ -126,7 +90,7 @@ module OpenAI created: Integer, model: String, object: Symbol, - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol), system_fingerprint: String, usage: T.nilable(OpenAI::Models::CompletionUsage) } @@ -138,15 +102,10 @@ module OpenAI class Choice < OpenAI::BaseModel # A chat completion delta generated by streamed model responses. sig { returns(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta) } - def delta - end + attr_reader :delta - sig do - params(_: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta) - .returns(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta) - end - def delta=(_) - end + sig { params(delta: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, OpenAI::Util::AnyHash)).void } + attr_writer :delta # The reason the model stopped generating tokens. This will be `stop` if the model # hit a natural stop point or a provided stop sequence, `length` if the maximum @@ -154,41 +113,31 @@ module OpenAI # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - sig { returns(T.nilable(Symbol)) } - def finish_reason - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def finish_reason=(_) - end + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol)) } + attr_accessor :finish_reason # The index of the choice in the list of choices. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # Log probability information for the choice. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs)) } - def logprobs - end + attr_reader :logprobs sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs)) - end - def logprobs=(_) + params( + logprobs: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :logprobs sig do params( - delta: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, - finish_reason: T.nilable(Symbol), + delta: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, OpenAI::Util::AnyHash), + finish_reason: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::OrSymbol), index: Integer, - logprobs: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs) + logprobs: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs, OpenAI::Util::AnyHash)) ) .returns(T.attached_class) end @@ -200,7 +149,7 @@ module OpenAI .returns( { delta: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, - finish_reason: T.nilable(Symbol), + finish_reason: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol), index: Integer, logprobs: T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs) } @@ -212,63 +161,51 @@ module OpenAI class Delta < OpenAI::BaseModel # The contents of the chunk message. sig { returns(T.nilable(String)) } - def content - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def content=(_) - end + attr_accessor :content # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall)) } - def function_call - end + attr_reader :function_call sig do - params(_: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall) - .returns(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall) - end - def function_call=(_) + params( + function_call: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function_call # The refusal message generated by the model. sig { returns(T.nilable(String)) } - def refusal - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def refusal=(_) - end + attr_accessor :refusal # The role of the author of this message. - sig { returns(T.nilable(Symbol)) } - def role - end + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol)) } + attr_reader :role - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { params(role: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::OrSymbol).void } + attr_writer :role sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall])) } - def tool_calls - end + attr_reader :tool_calls sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall]) - end - def tool_calls=(_) + params( + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :tool_calls # A chat completion delta generated by streamed model responses. sig do params( content: T.nilable(String), - function_call: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, + function_call: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, OpenAI::Util::AnyHash), refusal: T.nilable(String), - role: Symbol, - tool_calls: T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] + role: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::OrSymbol, + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall, OpenAI::Util::AnyHash)] ) .returns(T.attached_class) end @@ -282,7 +219,7 @@ module OpenAI content: T.nilable(String), function_call: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, refusal: T.nilable(String), - role: Symbol, + role: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol, tool_calls: T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] } ) @@ -296,21 +233,17 @@ module OpenAI # hallucinate parameters not defined by your function schema. Validate the # arguments in your code before calling your function. sig { returns(T.nilable(String)) } - def arguments - end + attr_reader :arguments - sig { params(_: String).returns(String) } - def arguments=(_) - end + sig { params(arguments: String).void } + attr_writer :arguments # The name of the function to call. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. @@ -324,62 +257,62 @@ module OpenAI end # The role of the author of this message. - class Role < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - DEVELOPER = :developer - SYSTEM = :system - USER = :user - ASSISTANT = :assistant - TOOL = :tool + module Role + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) } + + DEVELOPER = + T.let(:developer, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) + SYSTEM = T.let(:system, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) + USER = T.let(:user, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) + ASSISTANT = + T.let(:assistant, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) + TOOL = T.let(:tool, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role::TaggedSymbol]) } + def self.values + end end class ToolCall < OpenAI::BaseModel sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The ID of the tool call. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function)) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function) - .returns(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function # The type of the tool. Currently, only `function` is supported. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::TaggedSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::OrSymbol).void } + attr_writer :type sig do params( index: Integer, id: String, - function: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, - type: Symbol + function: T.any(OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, OpenAI::Util::AnyHash), + type: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::OrSymbol ) .returns(T.attached_class) end @@ -393,7 +326,7 @@ module OpenAI index: Integer, id: String, function: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, - type: Symbol + type: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::TaggedSymbol } ) end @@ -406,21 +339,17 @@ module OpenAI # hallucinate parameters not defined by your function schema. Validate the # arguments in your code before calling your function. sig { returns(T.nilable(String)) } - def arguments - end + attr_reader :arguments - sig { params(_: String).returns(String) } - def arguments=(_) - end + sig { params(arguments: String).void } + attr_writer :arguments # The name of the function to call. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name sig { params(arguments: String, name: String).returns(T.attached_class) } def self.new(arguments: nil, name: nil) @@ -432,12 +361,23 @@ module OpenAI end # The type of the tool. Currently, only `function` is supported. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + FUNCTION = + T.let(:function, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::TaggedSymbol) - FUNCTION = :function + sig do + override + .returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type::TaggedSymbol]) + end + def self.values + end end end end @@ -448,48 +388,42 @@ module OpenAI # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. - class FinishReason < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - STOP = :stop - LENGTH = :length - TOOL_CALLS = :tool_calls - CONTENT_FILTER = :content_filter - FUNCTION_CALL = :function_call + module FinishReason + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) } + + STOP = T.let(:stop, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) + LENGTH = T.let(:length, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) + TOOL_CALLS = + T.let(:tool_calls, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) + CONTENT_FILTER = + T.let(:content_filter, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) + FUNCTION_CALL = + T.let(:function_call, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason::TaggedSymbol]) } + def self.values + end end class Logprobs < OpenAI::BaseModel # A list of message content tokens with log probability information. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) } - def content - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - .returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - end - def content=(_) - end + attr_accessor :content # A list of message refusal tokens with log probability information. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) } - def refusal - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - .returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob])) - end - def refusal=(_) - end + attr_accessor :refusal # Log probability information for the choice. sig do params( - content: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]), - refusal: T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]) + content: T.nilable(T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTokenLogprob, OpenAI::Util::AnyHash)]), + refusal: T.nilable(T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTokenLogprob, OpenAI::Util::AnyHash)]) ) .returns(T.attached_class) end @@ -511,15 +445,23 @@ module OpenAI end # The service tier used for processing the request. - class ServiceTier < OpenAI::Enum - abstract! + module ServiceTier + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol) } - SCALE = :scale - DEFAULT = :default + SCALE = T.let(:scale, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol) + DEFAULT = T.let(:default, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol]) } + def self.values + end end end end + + ChatCompletionChunk = Chat::ChatCompletionChunk end end diff --git a/rbi/lib/openai/models/chat/chat_completion_content_part.rbi b/rbi/lib/openai/models/chat/chat_completion_content_part.rbi index a36f38f5..bf1e89a6 100644 --- a/rbi/lib/openai/models/chat/chat_completion_content_part.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_content_part.rbi @@ -2,50 +2,33 @@ module OpenAI module Models - ChatCompletionContentPart = T.type_alias { Chat::ChatCompletionContentPart } - module Chat # Learn about # [text inputs](https://platform.openai.com/docs/guides/text-generation). - class ChatCompletionContentPart < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartImage, - OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, - OpenAI::Models::Chat::ChatCompletionContentPart::File - ) - } - end + module ChatCompletionContentPart + extend OpenAI::Union class File < OpenAI::BaseModel sig { returns(OpenAI::Models::Chat::ChatCompletionContentPart::File::File) } - def file - end + attr_reader :file sig do - params(_: OpenAI::Models::Chat::ChatCompletionContentPart::File::File) - .returns(OpenAI::Models::Chat::ChatCompletionContentPart::File::File) - end - def file=(_) + params(file: T.any(OpenAI::Models::Chat::ChatCompletionContentPart::File::File, OpenAI::Util::AnyHash)) + .void end + attr_writer :file # The type of the content part. Always `file`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text # generation. sig do - params(file: OpenAI::Models::Chat::ChatCompletionContentPart::File::File, type: Symbol) + params( + file: T.any(OpenAI::Models::Chat::ChatCompletionContentPart::File::File, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(file:, type: :file) @@ -59,41 +42,46 @@ module OpenAI # The base64 encoded file data, used when passing the file to the model as a # string. sig { returns(T.nilable(String)) } - def file_data - end + attr_reader :file_data - sig { params(_: String).returns(String) } - def file_data=(_) - end + sig { params(file_data: String).void } + attr_writer :file_data # The ID of an uploaded file to use as input. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The name of the file, used when passing the file to the model as a string. sig { returns(T.nilable(String)) } - def file_name - end + attr_reader :filename - sig { params(_: String).returns(String) } - def file_name=(_) - end + sig { params(filename: String).void } + attr_writer :filename - sig { params(file_data: String, file_id: String, file_name: String).returns(T.attached_class) } - def self.new(file_data: nil, file_id: nil, file_name: nil) + sig { params(file_data: String, file_id: String, filename: String).returns(T.attached_class) } + def self.new(file_data: nil, file_id: nil, filename: nil) end - sig { override.returns({file_data: String, file_id: String, file_name: String}) } + sig { override.returns({file_data: String, file_id: String, filename: String}) } def to_hash end end end + + sig do + override + .returns( + [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File] + ) + end + def self.variants + end end end + + ChatCompletionContentPart = Chat::ChatCompletionContentPart end end diff --git a/rbi/lib/openai/models/chat/chat_completion_content_part_image.rbi b/rbi/lib/openai/models/chat/chat_completion_content_part_image.rbi index 56a6931a..4a3b9252 100644 --- a/rbi/lib/openai/models/chat/chat_completion_content_part_image.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_content_part_image.rbi @@ -2,33 +2,29 @@ module OpenAI module Models - ChatCompletionContentPartImage = T.type_alias { Chat::ChatCompletionContentPartImage } - module Chat class ChatCompletionContentPartImage < OpenAI::BaseModel sig { returns(OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL) } - def image_url - end + attr_reader :image_url sig do - params(_: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL) - .returns(OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL) - end - def image_url=(_) + params( + image_url: T.any(OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :image_url # The type of the content part. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Learn about [image inputs](https://platform.openai.com/docs/guides/vision). sig do - params(image_url: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL, type: Symbol) + params( + image_url: T.any(OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(image_url:, type: :image_url) @@ -43,44 +39,60 @@ module OpenAI class ImageURL < OpenAI::BaseModel # Either a URL of the image or the base64 encoded image data. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # Specifies the detail level of the image. Learn more in the # [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding). - sig { returns(T.nilable(Symbol)) } - def detail - end - - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) + sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::OrSymbol)) } + attr_reader :detail + + sig { params(detail: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::OrSymbol).void } + attr_writer :detail + + sig do + params( + url: String, + detail: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::OrSymbol + ) + .returns(T.attached_class) end - - sig { params(url: String, detail: Symbol).returns(T.attached_class) } def self.new(url:, detail: nil) end - sig { override.returns({url: String, detail: Symbol}) } + sig do + override + .returns( + {url: String, detail: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::OrSymbol} + ) + end def to_hash end # Specifies the detail level of the image. Learn more in the # [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding). - class Detail < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - AUTO = :auto - LOW = :low - HIGH = :high + module Detail + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::TaggedSymbol) } + + AUTO = T.let(:auto, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail::TaggedSymbol]) + end + def self.values + end end end end end + + ChatCompletionContentPartImage = Chat::ChatCompletionContentPartImage end end diff --git a/rbi/lib/openai/models/chat/chat_completion_content_part_input_audio.rbi b/rbi/lib/openai/models/chat/chat_completion_content_part_input_audio.rbi index 83e891b0..d3e09c2d 100644 --- a/rbi/lib/openai/models/chat/chat_completion_content_part_input_audio.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_content_part_input_audio.rbi @@ -2,33 +2,29 @@ module OpenAI module Models - ChatCompletionContentPartInputAudio = T.type_alias { Chat::ChatCompletionContentPartInputAudio } - module Chat class ChatCompletionContentPartInputAudio < OpenAI::BaseModel sig { returns(OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio) } - def input_audio - end + attr_reader :input_audio sig do - params(_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio) - .returns(OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio) - end - def input_audio=(_) + params( + input_audio: T.any(OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :input_audio # The type of the content part. Always `input_audio`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). sig do - params(input_audio: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio, type: Symbol) + params( + input_audio: T.any(OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(input_audio:, type: :input_audio) @@ -46,41 +42,61 @@ module OpenAI class InputAudio < OpenAI::BaseModel # Base64 encoded audio data. sig { returns(String) } - def data - end - - sig { params(_: String).returns(String) } - def data=(_) - end + attr_accessor :data # The format of the encoded audio data. Currently supports "wav" and "mp3". - sig { returns(Symbol) } - def format_ - end + sig { returns(OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::OrSymbol) } + attr_accessor :format_ - sig { params(_: Symbol).returns(Symbol) } - def format_=(_) + sig do + params( + data: String, + format_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::OrSymbol + ) + .returns(T.attached_class) end - - sig { params(data: String, format_: Symbol).returns(T.attached_class) } def self.new(data:, format_:) end - sig { override.returns({data: String, format_: Symbol}) } + sig do + override + .returns( + { + data: String, + format_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::OrSymbol + } + ) + end def to_hash end # The format of the encoded audio data. Currently supports "wav" and "mp3". - class Format < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - WAV = :wav - MP3 = :mp3 + module Format + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::TaggedSymbol) } + + WAV = + T.let(:wav, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::TaggedSymbol) + MP3 = + T.let(:mp3, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::TaggedSymbol) + + sig do + override + .returns( + T::Array[OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format::TaggedSymbol] + ) + end + def self.values + end end end end end + + ChatCompletionContentPartInputAudio = Chat::ChatCompletionContentPartInputAudio end end diff --git a/rbi/lib/openai/models/chat/chat_completion_content_part_refusal.rbi b/rbi/lib/openai/models/chat/chat_completion_content_part_refusal.rbi index 392ce584..788cfecf 100644 --- a/rbi/lib/openai/models/chat/chat_completion_content_part_refusal.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_content_part_refusal.rbi @@ -2,27 +2,15 @@ module OpenAI module Models - ChatCompletionContentPartRefusal = T.type_alias { Chat::ChatCompletionContentPartRefusal } - module Chat class ChatCompletionContentPartRefusal < OpenAI::BaseModel # The refusal message generated by the model. sig { returns(String) } - def refusal - end - - sig { params(_: String).returns(String) } - def refusal=(_) - end + attr_accessor :refusal # The type of the content part. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(refusal: String, type: Symbol).returns(T.attached_class) } def self.new(refusal:, type: :refusal) @@ -33,5 +21,7 @@ module OpenAI end end end + + ChatCompletionContentPartRefusal = Chat::ChatCompletionContentPartRefusal end end diff --git a/rbi/lib/openai/models/chat/chat_completion_content_part_text.rbi b/rbi/lib/openai/models/chat/chat_completion_content_part_text.rbi index 1154a72d..1cb1a46c 100644 --- a/rbi/lib/openai/models/chat/chat_completion_content_part_text.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_content_part_text.rbi @@ -2,27 +2,15 @@ module OpenAI module Models - ChatCompletionContentPartText = T.type_alias { Chat::ChatCompletionContentPartText } - module Chat class ChatCompletionContentPartText < OpenAI::BaseModel # The text content. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of the content part. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Learn about # [text inputs](https://platform.openai.com/docs/guides/text-generation). @@ -35,5 +23,7 @@ module OpenAI end end end + + ChatCompletionContentPartText = Chat::ChatCompletionContentPartText end end diff --git a/rbi/lib/openai/models/chat/chat_completion_deleted.rbi b/rbi/lib/openai/models/chat/chat_completion_deleted.rbi index 72764c05..9affbd35 100644 --- a/rbi/lib/openai/models/chat/chat_completion_deleted.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_deleted.rbi @@ -2,36 +2,19 @@ module OpenAI module Models - ChatCompletionDeleted = T.type_alias { Chat::ChatCompletionDeleted } - module Chat class ChatCompletionDeleted < OpenAI::BaseModel # The ID of the chat completion that was deleted. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # Whether the chat completion was deleted. sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted # The type of object being deleted. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"chat.completion.deleted") @@ -42,5 +25,7 @@ module OpenAI end end end + + ChatCompletionDeleted = Chat::ChatCompletionDeleted end end diff --git a/rbi/lib/openai/models/chat/chat_completion_developer_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_developer_message_param.rbi index d5dca054..ef698edc 100644 --- a/rbi/lib/openai/models/chat/chat_completion_developer_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_developer_message_param.rbi @@ -2,47 +2,30 @@ module OpenAI module Models - ChatCompletionDeveloperMessageParam = T.type_alias { Chat::ChatCompletionDeveloperMessageParam } - module Chat class ChatCompletionDeveloperMessageParam < OpenAI::BaseModel # The contents of the developer message. sig { returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) } - def content - end - - sig do - params(_: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - .returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - end - def content=(_) - end + attr_accessor :content # The role of the messages author, in this case `developer`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # An optional name for the participant. Provides the model information to # differentiate between participants of the same role. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # Developer-provided instructions that the model should follow, regardless of # messages sent by the user. With o1 models and newer, `developer` messages # replace the previous `system` messages. sig do params( - content: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]), + content: T.any(String, T::Array[T.any(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Util::AnyHash)]), name: String, role: Symbol ) @@ -65,14 +48,19 @@ module OpenAI end # The contents of the developer message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])} } + sig { override.returns([String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]]) } + def self.variants + end - ChatCompletionContentPartTextArray = T.type_alias { T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] } + ChatCompletionContentPartTextArray = + T.let(OpenAI::ArrayOf[OpenAI::Models::Chat::ChatCompletionContentPartText], OpenAI::Type::Converter) end end end + + ChatCompletionDeveloperMessageParam = Chat::ChatCompletionDeveloperMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_function_call_option.rbi b/rbi/lib/openai/models/chat/chat_completion_function_call_option.rbi index a17d3350..11ce4c45 100644 --- a/rbi/lib/openai/models/chat/chat_completion_function_call_option.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_function_call_option.rbi @@ -2,18 +2,11 @@ module OpenAI module Models - ChatCompletionFunctionCallOption = T.type_alias { Chat::ChatCompletionFunctionCallOption } - module Chat class ChatCompletionFunctionCallOption < OpenAI::BaseModel # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # Specifying a particular function via `{"name": "my_function"}` forces the model # to call that function. @@ -26,5 +19,7 @@ module OpenAI end end end + + ChatCompletionFunctionCallOption = Chat::ChatCompletionFunctionCallOption end end diff --git a/rbi/lib/openai/models/chat/chat_completion_function_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_function_message_param.rbi index 1c035a2e..43ae6ea4 100644 --- a/rbi/lib/openai/models/chat/chat_completion_function_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_function_message_param.rbi @@ -2,36 +2,19 @@ module OpenAI module Models - ChatCompletionFunctionMessageParam = T.type_alias { Chat::ChatCompletionFunctionMessageParam } - module Chat class ChatCompletionFunctionMessageParam < OpenAI::BaseModel # The contents of the function message. sig { returns(T.nilable(String)) } - def content - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def content=(_) - end + attr_accessor :content # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The role of the messages author, in this case `function`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role sig { params(content: T.nilable(String), name: String, role: Symbol).returns(T.attached_class) } def self.new(content:, name:, role: :function) @@ -42,5 +25,7 @@ module OpenAI end end end + + ChatCompletionFunctionMessageParam = Chat::ChatCompletionFunctionMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_message.rbi b/rbi/lib/openai/models/chat/chat_completion_message.rbi index a54250d7..190244ae 100644 --- a/rbi/lib/openai/models/chat/chat_completion_message.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_message.rbi @@ -2,103 +2,89 @@ module OpenAI module Models - ChatCompletionMessage = T.type_alias { Chat::ChatCompletionMessage } - module Chat class ChatCompletionMessage < OpenAI::BaseModel # The contents of the message. sig { returns(T.nilable(String)) } - def content - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def content=(_) - end + attr_accessor :content # The refusal message generated by the model. sig { returns(T.nilable(String)) } - def refusal - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def refusal=(_) - end + attr_accessor :refusal # The role of the author of this message. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # Annotations for the message, when applicable, as when using the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation])) } - def annotations - end + attr_reader :annotations sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation]) - end - def annotations=(_) + params( + annotations: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessage::Annotation, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :annotations # If the audio output modality is requested, this object contains data about the # audio response from the model. # [Learn more](https://platform.openai.com/docs/guides/audio). sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAudio)) } - def audio - end + attr_reader :audio - sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionAudio)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAudio)) - end - def audio=(_) - end + sig { params(audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudio, OpenAI::Util::AnyHash))).void } + attr_writer :audio # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall)) } - def function_call - end + attr_reader :function_call sig do - params(_: OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall) - .returns(OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall) - end - def function_call=(_) + params( + function_call: T.any(OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function_call # The tool calls generated by the model, such as function calls. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall])) } - def tool_calls - end + attr_reader :tool_calls sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall]) - end - def tool_calls=(_) + params( + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :tool_calls # A chat completion message generated by the model. sig do params( content: T.nilable(String), refusal: T.nilable(String), - annotations: T::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation], - audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAudio), - function_call: OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, - tool_calls: T::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], + annotations: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessage::Annotation, OpenAI::Util::AnyHash)], + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudio, OpenAI::Util::AnyHash)), + function_call: T.any(OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, OpenAI::Util::AnyHash), + tool_calls: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall, OpenAI::Util::AnyHash)], role: Symbol ) .returns(T.attached_class) end - def self.new(content:, refusal:, annotations: nil, audio: nil, function_call: nil, tool_calls: nil, role: :assistant) + def self.new( + content:, + refusal:, + annotations: nil, + audio: nil, + function_call: nil, + tool_calls: nil, + role: :assistant + ) end sig do @@ -121,28 +107,26 @@ module OpenAI class Annotation < OpenAI::BaseModel # The type of the URL citation. Always `url_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A URL citation when using web search. sig { returns(OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation) } - def url_citation - end + attr_reader :url_citation sig do - params(_: OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation) - .returns(OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation) - end - def url_citation=(_) + params( + url_citation: T.any(OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :url_citation # A URL citation when using web search. sig do - params(url_citation: OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation, type: Symbol) + params( + url_citation: T.any(OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(url_citation:, type: :url_citation) @@ -160,39 +144,19 @@ module OpenAI class URLCitation < OpenAI::BaseModel # The index of the last character of the URL citation in the message. sig { returns(Integer) } - def end_index - end - - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + attr_accessor :end_index # The index of the first character of the URL citation in the message. sig { returns(Integer) } - def start_index - end - - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + attr_accessor :start_index # The title of the web resource. sig { returns(String) } - def title - end - - sig { params(_: String).returns(String) } - def title=(_) - end + attr_accessor :title # The URL of the web resource. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # A URL citation when using web search. sig do @@ -218,21 +182,11 @@ module OpenAI # hallucinate parameters not defined by your function schema. Validate the # arguments in your code before calling your function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # Deprecated and replaced by `tool_calls`. The name and arguments of a function # that should be called, as generated by the model. @@ -246,5 +200,7 @@ module OpenAI end end end + + ChatCompletionMessage = Chat::ChatCompletionMessage end end diff --git a/rbi/lib/openai/models/chat/chat_completion_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_message_param.rbi index 97d8192e..a5792ca5 100644 --- a/rbi/lib/openai/models/chat/chat_completion_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_message_param.rbi @@ -2,28 +2,24 @@ module OpenAI module Models - ChatCompletionMessageParam = T.type_alias { Chat::ChatCompletionMessageParam } - module Chat # Developer-provided instructions that the model should follow, regardless of # messages sent by the user. With o1 models and newer, `developer` messages # replace the previous `system` messages. - class ChatCompletionMessageParam < OpenAI::Union - abstract! + module ChatCompletionMessageParam + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, - OpenAI::Models::Chat::ChatCompletionSystemMessageParam, - OpenAI::Models::Chat::ChatCompletionUserMessageParam, - OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, - OpenAI::Models::Chat::ChatCompletionToolMessageParam, - OpenAI::Models::Chat::ChatCompletionFunctionMessageParam + sig do + override + .returns( + [OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam] ) - } + end + def self.variants end end end + + ChatCompletionMessageParam = Chat::ChatCompletionMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_message_tool_call.rbi b/rbi/lib/openai/models/chat/chat_completion_message_tool_call.rbi index fadd4257..851dff7f 100644 --- a/rbi/lib/openai/models/chat/chat_completion_message_tool_call.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_message_tool_call.rbi @@ -2,42 +2,34 @@ module OpenAI module Models - ChatCompletionMessageToolCall = T.type_alias { Chat::ChatCompletionMessageToolCall } - module Chat class ChatCompletionMessageToolCall < OpenAI::BaseModel # The ID of the tool call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The function that the model called. sig { returns(OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function) - .returns(OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function # The type of the tool. Currently, only `function` is supported. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig do - params(id: String, function: OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function, type: Symbol) + params( + id: String, + function: T.any(OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(id:, function:, type: :function) @@ -58,21 +50,11 @@ module OpenAI # hallucinate parameters not defined by your function schema. Validate the # arguments in your code before calling your function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The function that the model called. sig { params(arguments: String, name: String).returns(T.attached_class) } @@ -85,5 +67,7 @@ module OpenAI end end end + + ChatCompletionMessageToolCall = Chat::ChatCompletionMessageToolCall end end diff --git a/rbi/lib/openai/models/chat/chat_completion_modality.rbi b/rbi/lib/openai/models/chat/chat_completion_modality.rbi index df9e0044..8c780c0f 100644 --- a/rbi/lib/openai/models/chat/chat_completion_modality.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_modality.rbi @@ -2,17 +2,22 @@ module OpenAI module Models - ChatCompletionModality = T.type_alias { Chat::ChatCompletionModality } - module Chat - class ChatCompletionModality < OpenAI::Enum - abstract! + module ChatCompletionModality + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionModality) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionModality::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Chat::ChatCompletionModality::TaggedSymbol) + AUDIO = T.let(:audio, OpenAI::Models::Chat::ChatCompletionModality::TaggedSymbol) - TEXT = :text - AUDIO = :audio + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionModality::TaggedSymbol]) } + def self.values + end end end + + ChatCompletionModality = Chat::ChatCompletionModality end end diff --git a/rbi/lib/openai/models/chat/chat_completion_named_tool_choice.rbi b/rbi/lib/openai/models/chat/chat_completion_named_tool_choice.rbi index d1d23deb..4c4f4e58 100644 --- a/rbi/lib/openai/models/chat/chat_completion_named_tool_choice.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_named_tool_choice.rbi @@ -2,34 +2,30 @@ module OpenAI module Models - ChatCompletionNamedToolChoice = T.type_alias { Chat::ChatCompletionNamedToolChoice } - module Chat class ChatCompletionNamedToolChoice < OpenAI::BaseModel sig { returns(OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function) } - def function - end + attr_reader :function sig do - params(_: OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function) - .returns(OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function) - end - def function=(_) + params( + function: T.any(OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :function # The type of the tool. Currently, only `function` is supported. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Specifies a tool the model should use. Use to force the model to call a specific # function. sig do - params(function: OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function, type: Symbol) + params( + function: T.any(OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(function:, type: :function) @@ -42,12 +38,7 @@ module OpenAI class Function < OpenAI::BaseModel # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name sig { params(name: String).returns(T.attached_class) } def self.new(name:) @@ -59,5 +50,7 @@ module OpenAI end end end + + ChatCompletionNamedToolChoice = Chat::ChatCompletionNamedToolChoice end end diff --git a/rbi/lib/openai/models/chat/chat_completion_prediction_content.rbi b/rbi/lib/openai/models/chat/chat_completion_prediction_content.rbi index f595e430..5c908db7 100644 --- a/rbi/lib/openai/models/chat/chat_completion_prediction_content.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_prediction_content.rbi @@ -2,39 +2,24 @@ module OpenAI module Models - ChatCompletionPredictionContent = T.type_alias { Chat::ChatCompletionPredictionContent } - module Chat class ChatCompletionPredictionContent < OpenAI::BaseModel # The content that should be matched when generating a model response. If # generated tokens would match this content, the entire model response can be # returned much more quickly. sig { returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) } - def content - end - - sig do - params(_: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - .returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - end - def content=(_) - end + attr_accessor :content # The type of the predicted content you want to provide. This type is currently # always `content`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Static predicted output content, such as the content of a text file that is # being regenerated. sig do params( - content: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]), + content: T.any(String, T::Array[T.any(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Util::AnyHash)]), type: Symbol ) .returns(T.attached_class) @@ -54,14 +39,19 @@ module OpenAI # The content that should be matched when generating a model response. If # generated tokens would match this content, the entire model response can be # returned much more quickly. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])} } + sig { override.returns([String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]]) } + def self.variants + end - ChatCompletionContentPartTextArray = T.type_alias { T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] } + ChatCompletionContentPartTextArray = + T.let(OpenAI::ArrayOf[OpenAI::Models::Chat::ChatCompletionContentPartText], OpenAI::Type::Converter) end end end + + ChatCompletionPredictionContent = Chat::ChatCompletionPredictionContent end end diff --git a/rbi/lib/openai/models/chat/chat_completion_reasoning_effort.rbi b/rbi/lib/openai/models/chat/chat_completion_reasoning_effort.rbi index 204ceb39..479be67b 100644 --- a/rbi/lib/openai/models/chat/chat_completion_reasoning_effort.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_reasoning_effort.rbi @@ -2,10 +2,10 @@ module OpenAI module Models - ChatCompletionReasoningEffort = T.type_alias { Chat::ChatCompletionReasoningEffort } - module Chat - ChatCompletionReasoningEffort = T.type_alias { OpenAI::Models::ReasoningEffort } + ChatCompletionReasoningEffort = OpenAI::Models::ReasoningEffort end + + ChatCompletionReasoningEffort = Chat::ChatCompletionReasoningEffort end end diff --git a/rbi/lib/openai/models/chat/chat_completion_role.rbi b/rbi/lib/openai/models/chat/chat_completion_role.rbi index ae42bac3..0fad6644 100644 --- a/rbi/lib/openai/models/chat/chat_completion_role.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_role.rbi @@ -2,22 +2,27 @@ module OpenAI module Models - ChatCompletionRole = T.type_alias { Chat::ChatCompletionRole } - module Chat # The role of the author of a message - class ChatCompletionRole < OpenAI::Enum - abstract! + module ChatCompletionRole + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionRole) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + DEVELOPER = T.let(:developer, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) + SYSTEM = T.let(:system, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) + USER = T.let(:user, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) + TOOL = T.let(:tool, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) + FUNCTION = T.let(:function, OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol) - DEVELOPER = :developer - SYSTEM = :system - USER = :user - ASSISTANT = :assistant - TOOL = :tool - FUNCTION = :function + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionRole::TaggedSymbol]) } + def self.values + end end end + + ChatCompletionRole = Chat::ChatCompletionRole end end diff --git a/rbi/lib/openai/models/chat/chat_completion_store_message.rbi b/rbi/lib/openai/models/chat/chat_completion_store_message.rbi index a63c1c01..78838f7f 100644 --- a/rbi/lib/openai/models/chat/chat_completion_store_message.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_store_message.rbi @@ -2,18 +2,11 @@ module OpenAI module Models - ChatCompletionStoreMessage = T.type_alias { Chat::ChatCompletionStoreMessage } - module Chat class ChatCompletionStoreMessage < OpenAI::Models::Chat::ChatCompletionMessage # The identifier of the chat message. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # A chat completion message generated by the model. sig { params(id: String).returns(T.attached_class) } @@ -25,5 +18,7 @@ module OpenAI end end end + + ChatCompletionStoreMessage = Chat::ChatCompletionStoreMessage end end diff --git a/rbi/lib/openai/models/chat/chat_completion_stream_options.rbi b/rbi/lib/openai/models/chat/chat_completion_stream_options.rbi index 9fbf5879..bb0ee0d9 100644 --- a/rbi/lib/openai/models/chat/chat_completion_stream_options.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_stream_options.rbi @@ -2,21 +2,20 @@ module OpenAI module Models - ChatCompletionStreamOptions = T.type_alias { Chat::ChatCompletionStreamOptions } - module Chat class ChatCompletionStreamOptions < OpenAI::BaseModel # If set, an additional chunk will be streamed before the `data: [DONE]` message. # The `usage` field on this chunk shows the token usage statistics for the entire - # request, and the `choices` field will always be an empty array. All other chunks - # will also include a `usage` field, but with a null value. + # request, and the `choices` field will always be an empty array. + # + # All other chunks will also include a `usage` field, but with a null value. + # **NOTE:** If the stream is interrupted, you may not receive the final usage + # chunk which contains the total token usage for the request. sig { returns(T.nilable(T::Boolean)) } - def include_usage - end + attr_reader :include_usage - sig { params(_: T::Boolean).returns(T::Boolean) } - def include_usage=(_) - end + sig { params(include_usage: T::Boolean).void } + attr_writer :include_usage # Options for streaming response. Only set this when you set `stream: true`. sig { params(include_usage: T::Boolean).returns(T.attached_class) } @@ -28,5 +27,7 @@ module OpenAI end end end + + ChatCompletionStreamOptions = Chat::ChatCompletionStreamOptions end end diff --git a/rbi/lib/openai/models/chat/chat_completion_system_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_system_message_param.rbi index 1863c0f8..f04bdf4a 100644 --- a/rbi/lib/openai/models/chat/chat_completion_system_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_system_message_param.rbi @@ -2,47 +2,30 @@ module OpenAI module Models - ChatCompletionSystemMessageParam = T.type_alias { Chat::ChatCompletionSystemMessageParam } - module Chat class ChatCompletionSystemMessageParam < OpenAI::BaseModel # The contents of the system message. sig { returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) } - def content - end - - sig do - params(_: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - .returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - end - def content=(_) - end + attr_accessor :content # The role of the messages author, in this case `system`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # An optional name for the participant. Provides the model information to # differentiate between participants of the same role. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # Developer-provided instructions that the model should follow, regardless of # messages sent by the user. With o1 models and newer, use `developer` messages # for this purpose instead. sig do params( - content: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]), + content: T.any(String, T::Array[T.any(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Util::AnyHash)]), name: String, role: Symbol ) @@ -65,14 +48,19 @@ module OpenAI end # The contents of the system message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])} } + sig { override.returns([String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]]) } + def self.variants + end - ChatCompletionContentPartTextArray = T.type_alias { T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] } + ChatCompletionContentPartTextArray = + T.let(OpenAI::ArrayOf[OpenAI::Models::Chat::ChatCompletionContentPartText], OpenAI::Type::Converter) end end end + + ChatCompletionSystemMessageParam = Chat::ChatCompletionSystemMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_token_logprob.rbi b/rbi/lib/openai/models/chat/chat_completion_token_logprob.rbi index 2341c139..33ce4b9e 100644 --- a/rbi/lib/openai/models/chat/chat_completion_token_logprob.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_token_logprob.rbi @@ -2,62 +2,37 @@ module OpenAI module Models - ChatCompletionTokenLogprob = T.type_alias { Chat::ChatCompletionTokenLogprob } - module Chat class ChatCompletionTokenLogprob < OpenAI::BaseModel # The token. sig { returns(String) } - def token - end - - sig { params(_: String).returns(String) } - def token=(_) - end + attr_accessor :token # A list of integers representing the UTF-8 bytes representation of the token. # Useful in instances where characters are represented by multiple tokens and # their byte representations must be combined to generate the correct text # representation. Can be `null` if there is no bytes representation for the token. sig { returns(T.nilable(T::Array[Integer])) } - def bytes - end - - sig { params(_: T.nilable(T::Array[Integer])).returns(T.nilable(T::Array[Integer])) } - def bytes=(_) - end + attr_accessor :bytes # The log probability of this token, if it is within the top 20 most likely # tokens. Otherwise, the value `-9999.0` is used to signify that the token is very # unlikely. sig { returns(Float) } - def logprob - end - - sig { params(_: Float).returns(Float) } - def logprob=(_) - end + attr_accessor :logprob # List of the most likely tokens and their log probability, at this token # position. In rare cases, there may be fewer than the number of requested # `top_logprobs` returned. sig { returns(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob]) } - def top_logprobs - end - - sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob]) - end - def top_logprobs=(_) - end + attr_accessor :top_logprobs sig do params( token: String, bytes: T.nilable(T::Array[Integer]), logprob: Float, - top_logprobs: T::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob] + top_logprobs: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob, OpenAI::Util::AnyHash)] ) .returns(T.attached_class) end @@ -81,35 +56,20 @@ module OpenAI class TopLogprob < OpenAI::BaseModel # The token. sig { returns(String) } - def token - end - - sig { params(_: String).returns(String) } - def token=(_) - end + attr_accessor :token # A list of integers representing the UTF-8 bytes representation of the token. # Useful in instances where characters are represented by multiple tokens and # their byte representations must be combined to generate the correct text # representation. Can be `null` if there is no bytes representation for the token. sig { returns(T.nilable(T::Array[Integer])) } - def bytes - end - - sig { params(_: T.nilable(T::Array[Integer])).returns(T.nilable(T::Array[Integer])) } - def bytes=(_) - end + attr_accessor :bytes # The log probability of this token, if it is within the top 20 most likely # tokens. Otherwise, the value `-9999.0` is used to signify that the token is very # unlikely. sig { returns(Float) } - def logprob - end - - sig { params(_: Float).returns(Float) } - def logprob=(_) - end + attr_accessor :logprob sig do params( @@ -127,5 +87,7 @@ module OpenAI end end end + + ChatCompletionTokenLogprob = Chat::ChatCompletionTokenLogprob end end diff --git a/rbi/lib/openai/models/chat/chat_completion_tool.rbi b/rbi/lib/openai/models/chat/chat_completion_tool.rbi index 5a41a09d..03b8ecd1 100644 --- a/rbi/lib/openai/models/chat/chat_completion_tool.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_tool.rbi @@ -2,28 +2,22 @@ module OpenAI module Models - ChatCompletionTool = T.type_alias { Chat::ChatCompletionTool } - module Chat class ChatCompletionTool < OpenAI::BaseModel sig { returns(OpenAI::Models::FunctionDefinition) } - def function - end + attr_reader :function - sig { params(_: OpenAI::Models::FunctionDefinition).returns(OpenAI::Models::FunctionDefinition) } - def function=(_) - end + sig { params(function: T.any(OpenAI::Models::FunctionDefinition, OpenAI::Util::AnyHash)).void } + attr_writer :function # The type of the tool. Currently, only `function` is supported. sig { returns(Symbol) } - def type - end + attr_accessor :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) + sig do + params(function: T.any(OpenAI::Models::FunctionDefinition, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) end - - sig { params(function: OpenAI::Models::FunctionDefinition, type: Symbol).returns(T.attached_class) } def self.new(function:, type: :function) end @@ -32,5 +26,7 @@ module OpenAI end end end + + ChatCompletionTool = Chat::ChatCompletionTool end end diff --git a/rbi/lib/openai/models/chat/chat_completion_tool_choice_option.rbi b/rbi/lib/openai/models/chat/chat_completion_tool_choice_option.rbi index 0c237bac..ad5c2dd6 100644 --- a/rbi/lib/openai/models/chat/chat_completion_tool_choice_option.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_tool_choice_option.rbi @@ -2,8 +2,6 @@ module OpenAI module Models - ChatCompletionToolChoiceOption = T.type_alias { Chat::ChatCompletionToolChoiceOption } - module Chat # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can @@ -14,24 +12,39 @@ module OpenAI # # `none` is the default when no tools are present. `auto` is the default if tools # are present. - class ChatCompletionToolChoiceOption < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)} } + module ChatCompletionToolChoiceOption + extend OpenAI::Union # `none` means the model will not call any tool and instead generates a message. # `auto` means the model can pick between generating a message or calling one or # more tools. `required` means the model must call one or more tools. - class Auto < OpenAI::Enum - abstract! + module Auto + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::TaggedSymbol) } - NONE = :none - AUTO = :auto - REQUIRED = :required + NONE = T.let(:none, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::TaggedSymbol) + AUTO = T.let(:auto, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::TaggedSymbol) + REQUIRED = T.let(:required, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::TaggedSymbol]) } + def self.values + end + end + + sig do + override + .returns( + [OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] + ) + end + def self.variants end end end + + ChatCompletionToolChoiceOption = Chat::ChatCompletionToolChoiceOption end end diff --git a/rbi/lib/openai/models/chat/chat_completion_tool_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_tool_message_param.rbi index 20936406..4956394b 100644 --- a/rbi/lib/openai/models/chat/chat_completion_tool_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_tool_message_param.rbi @@ -2,43 +2,23 @@ module OpenAI module Models - ChatCompletionToolMessageParam = T.type_alias { Chat::ChatCompletionToolMessageParam } - module Chat class ChatCompletionToolMessageParam < OpenAI::BaseModel # The contents of the tool message. sig { returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) } - def content - end - - sig do - params(_: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - .returns(T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])) - end - def content=(_) - end + attr_accessor :content # The role of the messages author, in this case `tool`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # Tool call that this message is responding to. sig { returns(String) } - def tool_call_id - end - - sig { params(_: String).returns(String) } - def tool_call_id=(_) - end + attr_accessor :tool_call_id sig do params( - content: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]), + content: T.any(String, T::Array[T.any(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Util::AnyHash)]), tool_call_id: String, role: Symbol ) @@ -61,14 +41,19 @@ module OpenAI end # The contents of the tool message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText])} } + sig { override.returns([String, T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]]) } + def self.variants + end - ChatCompletionContentPartTextArray = T.type_alias { T::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] } + ChatCompletionContentPartTextArray = + T.let(OpenAI::ArrayOf[OpenAI::Models::Chat::ChatCompletionContentPartText], OpenAI::Type::Converter) end end end + + ChatCompletionToolMessageParam = Chat::ChatCompletionToolMessageParam end end diff --git a/rbi/lib/openai/models/chat/chat_completion_user_message_param.rbi b/rbi/lib/openai/models/chat/chat_completion_user_message_param.rbi index 7ebaa424..c234e478 100644 --- a/rbi/lib/openai/models/chat/chat_completion_user_message_param.rbi +++ b/rbi/lib/openai/models/chat/chat_completion_user_message_param.rbi @@ -2,8 +2,6 @@ module OpenAI module Models - ChatCompletionUserMessageParam = T.type_alias { Chat::ChatCompletionUserMessageParam } - module Chat class ChatCompletionUserMessageParam < OpenAI::BaseModel # The contents of the user message. @@ -22,58 +20,19 @@ module OpenAI ) ) end - def content - end - - sig do - params( - _: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartImage, - OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, - OpenAI::Models::Chat::ChatCompletionContentPart::File - ) - ] - ) - ) - .returns( - T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartImage, - OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, - OpenAI::Models::Chat::ChatCompletionContentPart::File - ) - ] - ) - ) - end - def content=(_) - end + attr_accessor :content # The role of the messages author, in this case `user`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # An optional name for the participant. Provides the model information to # differentiate between participants of the same role. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name # Messages sent by an end user, containing prompts or additional context # information. @@ -84,6 +43,7 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Chat::ChatCompletionContentPartText, + OpenAI::Util::AnyHash, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File @@ -122,37 +82,34 @@ module OpenAI end # The contents of the user message. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartImage, - OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, - OpenAI::Models::Chat::ChatCompletionContentPart::File - ) + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Chat::ChatCompletionContentPartText, + OpenAI::Models::Chat::ChatCompletionContentPartImage, + OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, + OpenAI::Models::Chat::ChatCompletionContentPart::File + ) + ] ] ) - } end - - ChatCompletionContentPartArray = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionContentPartText, - OpenAI::Models::Chat::ChatCompletionContentPartImage, - OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, - OpenAI::Models::Chat::ChatCompletionContentPart::File - ) - ] + def self.variants end + + ChatCompletionContentPartArray = + T.let(OpenAI::ArrayOf[union: OpenAI::Models::Chat::ChatCompletionContentPart], OpenAI::Type::Converter) end end end + + ChatCompletionUserMessageParam = Chat::ChatCompletionUserMessageParam end end diff --git a/rbi/lib/openai/models/chat/completion_create_params.rbi b/rbi/lib/openai/models/chat/completion_create_params.rbi index 7b69e065..72a30f17 100644 --- a/rbi/lib/openai/models/chat/completion_create_params.rbi +++ b/rbi/lib/openai/models/chat/completion_create_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Chat class CompletionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A list of messages comprising the conversation so far. Depending on the @@ -27,75 +27,30 @@ module OpenAI ] ) end - def messages - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, - OpenAI::Models::Chat::ChatCompletionSystemMessageParam, - OpenAI::Models::Chat::ChatCompletionUserMessageParam, - OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, - OpenAI::Models::Chat::ChatCompletionToolMessageParam, - OpenAI::Models::Chat::ChatCompletionFunctionMessageParam - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, - OpenAI::Models::Chat::ChatCompletionSystemMessageParam, - OpenAI::Models::Chat::ChatCompletionUserMessageParam, - OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, - OpenAI::Models::Chat::ChatCompletionToolMessageParam, - OpenAI::Models::Chat::ChatCompletionFunctionMessageParam - ) - ] - ) - end - def messages=(_) - end + attr_accessor :messages # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a # wide range of models with different capabilities, performance characteristics, # and price points. Refer to the # [model guide](https://platform.openai.com/docs/models) to browse and compare # available models. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::ChatModel::OrSymbol)) } + attr_accessor :model # Parameters for audio output. Required when audio output is requested with # `modalities: ["audio"]`. # [Learn more](https://platform.openai.com/docs/guides/audio). sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam)) } - def audio - end + attr_reader :audio - sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam)) - end - def audio=(_) - end + sig { params(audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudioParam, OpenAI::Util::AnyHash))).void } + attr_writer :audio # Number between -2.0 and 2.0. Positive values penalize new tokens based on their # existing frequency in the text so far, decreasing the model's likelihood to # repeat the same line verbatim. sig { returns(T.nilable(Float)) } - def frequency_penalty - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def frequency_penalty=(_) - end + attr_accessor :frequency_penalty # Deprecated in favor of `tool_choice`. # @@ -111,30 +66,43 @@ module OpenAI # # `none` is the default when no functions are present. `auto` is the default if # functions are present. - sig { returns(T.nilable(T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption))) } - def function_call + sig do + returns( + T.nilable( + T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption + ) + ) + ) end + attr_reader :function_call sig do - params(_: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)) - .returns(T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)) - end - def function_call=(_) + params( + function_call: T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :function_call # Deprecated in favor of `tools`. # # A list of functions the model may generate JSON inputs for. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function])) } - def functions - end + attr_reader :functions sig do - params(_: T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function]) - .returns(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function]) - end - def functions=(_) + params( + functions: T::Array[T.any(OpenAI::Models::Chat::CompletionCreateParams::Function, OpenAI::Util::AnyHash)] + ) + .void end + attr_writer :functions # Modify the likelihood of specified tokens appearing in the completion. # @@ -145,34 +113,19 @@ module OpenAI # increase likelihood of selection; values like -100 or 100 should result in a ban # or exclusive selection of the relevant token. sig { returns(T.nilable(T::Hash[Symbol, Integer])) } - def logit_bias - end - - sig { params(_: T.nilable(T::Hash[Symbol, Integer])).returns(T.nilable(T::Hash[Symbol, Integer])) } - def logit_bias=(_) - end + attr_accessor :logit_bias # Whether to return log probabilities of the output tokens or not. If true, # returns the log probabilities of each output token returned in the `content` of # `message`. sig { returns(T.nilable(T::Boolean)) } - def logprobs - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def logprobs=(_) - end + attr_accessor :logprobs # An upper bound for the number of tokens that can be generated for a completion, # including visible output tokens and # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(Integer)) } - def max_completion_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_completion_tokens=(_) - end + attr_accessor :max_completion_tokens # The maximum number of [tokens](/tokenizer) that can be generated in the chat # completion. This value can be used to control @@ -182,12 +135,7 @@ module OpenAI # compatible with # [o1 series models](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(Integer)) } - def max_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_tokens=(_) - end + attr_accessor :max_tokens # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -195,13 +143,8 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # Output types that you would like the model to generate. Most models are capable # of generating text, which is the default: @@ -213,59 +156,42 @@ module OpenAI # this model generate both text and audio responses, you can use: # # `["text", "audio"]` - sig { returns(T.nilable(T::Array[Symbol])) } - def modalities - end - - sig { params(_: T.nilable(T::Array[Symbol])).returns(T.nilable(T::Array[Symbol])) } - def modalities=(_) - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::OrSymbol])) } + attr_accessor :modalities # How many chat completion choices to generate for each input message. Note that # you will be charged based on the number of generated tokens across all of the # choices. Keep `n` as `1` to minimize costs. sig { returns(T.nilable(Integer)) } - def n - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def n=(_) - end + attr_accessor :n # Whether to enable # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) # during tool use. sig { returns(T.nilable(T::Boolean)) } - def parallel_tool_calls - end + attr_reader :parallel_tool_calls - sig { params(_: T::Boolean).returns(T::Boolean) } - def parallel_tool_calls=(_) - end + sig { params(parallel_tool_calls: T::Boolean).void } + attr_writer :parallel_tool_calls # Static predicted output content, such as the content of a text file that is # being regenerated. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent)) } - def prediction - end + attr_reader :prediction sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent)) - end - def prediction=(_) + params( + prediction: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionPredictionContent, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :prediction # Number between -2.0 and 2.0. Positive values penalize new tokens based on # whether they appear in the text so far, increasing the model's likelihood to # talk about new topics. sig { returns(T.nilable(Float)) } - def presence_penalty - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def presence_penalty=(_) - end + attr_accessor :presence_penalty # **o-series models only** # @@ -273,13 +199,8 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - sig { returns(T.nilable(Symbol)) } - def reasoning_effort - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def reasoning_effort=(_) - end + sig { returns(T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol)) } + attr_accessor :reasoning_effort # An object specifying the format that the model must output. # @@ -302,27 +223,20 @@ module OpenAI ) ) end - def response_format - end + attr_reader :response_format sig do params( - _: T.any( + response_format: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject ) ) - .returns( - T.any( - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONSchema, - OpenAI::Models::ResponseFormatJSONObject - ) - ) - end - def response_format=(_) + .void end + attr_writer :response_format # This feature is in Beta. If specified, our system will make a best effort to # sample deterministically, such that repeated requests with the same `seed` and @@ -330,12 +244,7 @@ module OpenAI # should refer to the `system_fingerprint` response parameter to monitor changes # in the backend. sig { returns(T.nilable(Integer)) } - def seed - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def seed=(_) - end + attr_accessor :seed # Specifies the latency tier to use for processing the request. This parameter is # relevant for customers subscribed to the scale tier service: @@ -351,67 +260,38 @@ module OpenAI # # When this parameter is set, the response body will include the `service_tier` # utilized. - sig { returns(T.nilable(Symbol)) } - def service_tier - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def service_tier=(_) - end + sig { returns(T.nilable(OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::OrSymbol)) } + attr_accessor :service_tier # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. sig { returns(T.nilable(T.any(String, T::Array[String]))) } - def stop - end - - sig do - params( - _: T.nilable( - T.any( - String, - T::Array[String] - ) - ) - ).returns(T.nilable(T.any(String, T::Array[String]))) - end - def stop=(_) - end + attr_accessor :stop # Whether or not to store the output of this chat completion request for use in # our [model distillation](https://platform.openai.com/docs/guides/distillation) # or [evals](https://platform.openai.com/docs/guides/evals) products. sig { returns(T.nilable(T::Boolean)) } - def store - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def store=(_) - end + attr_accessor :store # Options for streaming response. Only set this when you set `stream: true`. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) } - def stream_options - end + attr_reader :stream_options sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) - end - def stream_options=(_) + params( + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :stream_options # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. We generally recommend altering this or `top_p` but # not both. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can @@ -422,41 +302,44 @@ module OpenAI # # `none` is the default when no tools are present. `auto` is the default if tools # are present. - sig { returns(T.nilable(T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice))) } - def tool_choice + sig do + returns( + T.nilable( + T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice + ) + ) + ) end + attr_reader :tool_choice sig do - params(_: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)) - .returns(T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)) - end - def tool_choice=(_) + params( + tool_choice: T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :tool_choice # A list of tools the model may call. Currently, only functions are supported as a # tool. Use this to provide a list of functions the model may generate JSON inputs # for. A max of 128 functions are supported. sig { returns(T.nilable(T::Array[OpenAI::Models::Chat::ChatCompletionTool])) } - def tools - end + attr_reader :tools - sig do - params(_: T::Array[OpenAI::Models::Chat::ChatCompletionTool]) - .returns(T::Array[OpenAI::Models::Chat::ChatCompletionTool]) - end - def tools=(_) - end + sig { params(tools: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTool, OpenAI::Util::AnyHash)]).void } + attr_writer :tools # An integer between 0 and 20 specifying the number of most likely tokens to # return at each token position, each with an associated log probability. # `logprobs` must be set to `true` if this parameter is used. sig { returns(T.nilable(Integer)) } - def top_logprobs - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def top_logprobs=(_) - end + attr_accessor :top_logprobs # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -464,43 +347,37 @@ module OpenAI # # We generally recommend altering this or `temperature` but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user # This tool searches the web for relevant results to use in a response. Learn more # about the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). sig { returns(T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions)) } - def web_search_options - end + attr_reader :web_search_options sig do - params(_: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions) - .returns(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions) - end - def web_search_options=(_) + params( + web_search_options: T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :web_search_options sig do params( messages: T::Array[ T.any( OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, + OpenAI::Util::AnyHash, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, @@ -508,40 +385,49 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionFunctionMessageParam ) ], - model: T.any(String, Symbol), - audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudioParam, OpenAI::Util::AnyHash)), frequency_penalty: T.nilable(Float), - function_call: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption), - functions: T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + function_call: T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption, + OpenAI::Util::AnyHash + ), + functions: T::Array[T.any(OpenAI::Models::Chat::CompletionCreateParams::Function, OpenAI::Util::AnyHash)], logit_bias: T.nilable(T::Hash[Symbol, Integer]), logprobs: T.nilable(T::Boolean), max_completion_tokens: T.nilable(Integer), max_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - modalities: T.nilable(T::Array[Symbol]), + metadata: T.nilable(T::Hash[Symbol, String]), + modalities: T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::OrSymbol]), n: T.nilable(Integer), parallel_tool_calls: T::Boolean, - prediction: T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent), + prediction: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionPredictionContent, OpenAI::Util::AnyHash)), presence_penalty: T.nilable(Float), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject ), seed: T.nilable(Integer), - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::OrSymbol), stop: T.nilable(T.any(String, T::Array[String])), store: T.nilable(T::Boolean), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice), - tools: T::Array[OpenAI::Models::Chat::ChatCompletionTool], + tool_choice: T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice, + OpenAI::Util::AnyHash + ), + tools: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTool, OpenAI::Util::AnyHash)], top_logprobs: T.nilable(Integer), top_p: T.nilable(Float), user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + web_search_options: T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, OpenAI::Util::AnyHash), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -594,34 +480,40 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionFunctionMessageParam ) ], - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam), frequency_penalty: T.nilable(Float), - function_call: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption), + function_call: T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption + ), functions: T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], logit_bias: T.nilable(T::Hash[Symbol, Integer]), logprobs: T.nilable(T::Boolean), max_completion_tokens: T.nilable(Integer), max_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - modalities: T.nilable(T::Array[Symbol]), + metadata: T.nilable(T::Hash[Symbol, String]), + modalities: T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::OrSymbol]), n: T.nilable(Integer), parallel_tool_calls: T::Boolean, prediction: T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent), presence_penalty: T.nilable(Float), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.any( OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject ), seed: T.nilable(Integer), - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::OrSymbol), stop: T.nilable(T.any(String, T::Array[String])), store: T.nilable(T::Boolean), stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice), + tool_choice: T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice + ), tools: T::Array[OpenAI::Models::Chat::ChatCompletionTool], top_logprobs: T.nilable(Integer), top_p: T.nilable(Float), @@ -639,10 +531,12 @@ module OpenAI # and price points. Refer to the # [model guide](https://platform.openai.com/docs/models) to browse and compare # available models. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol]) } + def self.variants + end end # Deprecated in favor of `tool_choice`. @@ -659,21 +553,42 @@ module OpenAI # # `none` is the default when no functions are present. `auto` is the default if # functions are present. - class FunctionCall < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)} } + module FunctionCall + extend OpenAI::Union # `none` means the model will not call a function and instead generates a message. # `auto` means the model can pick between generating a message or calling a # function. - class FunctionCallMode < OpenAI::Enum - abstract! + module FunctionCallMode + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::TaggedSymbol) } + + NONE = + T.let(:none, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::TaggedSymbol) + AUTO = + T.let(:auto, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::TaggedSymbol) + + sig do + override + .returns( + T::Array[OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::TaggedSymbol] + ) + end + def self.values + end + end - NONE = :none - AUTO = :auto + sig do + override + .returns( + [OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] + ) + end + def self.variants end end @@ -681,22 +596,15 @@ module OpenAI # The name of the function to be called. Must be a-z, A-Z, 0-9, or contain # underscores and dashes, with a maximum length of 64. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # A description of what the function does, used by the model to choose when and # how to call the function. sig { returns(T.nilable(String)) } - def description - end + attr_reader :description - sig { params(_: String).returns(String) } - def description=(_) - end + sig { params(description: String).void } + attr_writer :description # The parameters the functions accepts, described as a JSON Schema object. See the # [guide](https://platform.openai.com/docs/guides/function-calling) for examples, @@ -705,33 +613,39 @@ module OpenAI # documentation about the format. # # Omitting `parameters` defines a function with an empty parameter list. - sig { returns(T.nilable(OpenAI::Models::FunctionParameters)) } - def parameters - end + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :parameters - sig { params(_: OpenAI::Models::FunctionParameters).returns(OpenAI::Models::FunctionParameters) } - def parameters=(_) - end + sig { params(parameters: T::Hash[Symbol, T.anything]).void } + attr_writer :parameters sig do - params(name: String, description: String, parameters: OpenAI::Models::FunctionParameters) + params(name: String, description: String, parameters: T::Hash[Symbol, T.anything]) .returns(T.attached_class) end def self.new(name:, description: nil, parameters: nil) end - sig { override.returns({name: String, description: String, parameters: OpenAI::Models::FunctionParameters}) } + sig do + override.returns({name: String, description: String, parameters: T::Hash[Symbol, T.anything]}) + end def to_hash end end - class Modality < OpenAI::Enum - abstract! + module Modality + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality::TaggedSymbol) } - TEXT = :text - AUDIO = :audio + TEXT = T.let(:text, OpenAI::Models::Chat::CompletionCreateParams::Modality::TaggedSymbol) + AUDIO = T.let(:audio, OpenAI::Models::Chat::CompletionCreateParams::Modality::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::TaggedSymbol]) } + def self.values + end end # An object specifying the format that the model must output. @@ -744,17 +658,16 @@ module OpenAI # Setting to `{ "type": "json_object" }` enables the older JSON mode, which # ensures the message the model generates is valid JSON. Using `json_schema` is # preferred for models that support it. - class ResponseFormat < OpenAI::Union - abstract! + module ResponseFormat + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::ResponseFormatText, - OpenAI::Models::ResponseFormatJSONSchema, - OpenAI::Models::ResponseFormatJSONObject + sig do + override + .returns( + [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] ) - } + end + def self.variants end end @@ -772,55 +685,74 @@ module OpenAI # # When this parameter is set, the response body will include the `service_tier` # utilized. - class ServiceTier < OpenAI::Enum - abstract! + module ServiceTier + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol) } - AUTO = :auto - DEFAULT = :default + AUTO = T.let(:auto, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol) + DEFAULT = T.let(:default, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol]) } + def self.values + end end # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. - class Stop < OpenAI::Union - abstract! + module Stop + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.nilable(T.any(String, T::Array[String]))} } + sig { override.returns([String, T::Array[String]]) } + def self.variants + end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) end class WebSearchOptions < OpenAI::BaseModel # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - sig { returns(T.nilable(Symbol)) } - def search_context_size + sig do + returns( + T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::OrSymbol) + ) end + attr_reader :search_context_size - sig { params(_: Symbol).returns(Symbol) } - def search_context_size=(_) + sig do + params( + search_context_size: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::OrSymbol + ) + .void end + attr_writer :search_context_size # Approximate location parameters for the search. sig { returns(T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation)) } - def user_location - end + attr_reader :user_location sig do - params(_: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation)) - .returns(T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation)) - end - def user_location=(_) + params( + user_location: T.nilable( + T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation, OpenAI::Util::AnyHash) + ) + ) + .void end + attr_writer :user_location # This tool searches the web for relevant results to use in a response. Learn more # about the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). sig do params( - search_context_size: Symbol, - user_location: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation) + search_context_size: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::OrSymbol, + user_location: T.nilable( + T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation, OpenAI::Util::AnyHash) + ) ) .returns(T.attached_class) end @@ -831,7 +763,7 @@ module OpenAI override .returns( { - search_context_size: Symbol, + search_context_size: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::OrSymbol, user_location: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation) } ) @@ -841,42 +773,72 @@ module OpenAI # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - class SearchContextSize < OpenAI::Enum - abstract! + module SearchContextSize + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize) } + OrSymbol = + T.type_alias do + T.any( + Symbol, + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::TaggedSymbol + ) + end - LOW = :low - MEDIUM = :medium - HIGH = :high + LOW = + T.let( + :low, + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::TaggedSymbol + ) + MEDIUM = + T.let( + :medium, + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::TaggedSymbol + ) + HIGH = + T.let( + :high, + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::TaggedSymbol + ) + + sig do + override + .returns( + T::Array[OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize::TaggedSymbol] + ) + end + def self.values + end end class UserLocation < OpenAI::BaseModel # Approximate location parameters for the search. sig { returns(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate) } - def approximate - end + attr_reader :approximate sig do - params(_: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate) - .returns(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate) - end - def approximate=(_) + params( + approximate: T.any( + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :approximate # The type of location approximation. Always `approximate`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Approximate location parameters for the search. sig do params( - approximate: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate, + approximate: T.any( + OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate, + OpenAI::Util::AnyHash + ), type: Symbol ) .returns(T.attached_class) @@ -899,41 +861,33 @@ module OpenAI class Approximate < OpenAI::BaseModel # Free text input for the city of the user, e.g. `San Francisco`. sig { returns(T.nilable(String)) } - def city - end + attr_reader :city - sig { params(_: String).returns(String) } - def city=(_) - end + sig { params(city: String).void } + attr_writer :city # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of # the user, e.g. `US`. sig { returns(T.nilable(String)) } - def country - end + attr_reader :country - sig { params(_: String).returns(String) } - def country=(_) - end + sig { params(country: String).void } + attr_writer :country # Free text input for the region of the user, e.g. `California`. sig { returns(T.nilable(String)) } - def region - end + attr_reader :region - sig { params(_: String).returns(String) } - def region=(_) - end + sig { params(region: String).void } + attr_writer :region # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the # user, e.g. `America/Los_Angeles`. sig { returns(T.nilable(String)) } - def timezone - end + attr_reader :timezone - sig { params(_: String).returns(String) } - def timezone=(_) - end + sig { params(timezone: String).void } + attr_writer :timezone # Approximate location parameters for the search. sig do diff --git a/rbi/lib/openai/models/chat/completion_delete_params.rbi b/rbi/lib/openai/models/chat/completion_delete_params.rbi index 6682081d..9bc3d10e 100644 --- a/rbi/lib/openai/models/chat/completion_delete_params.rbi +++ b/rbi/lib/openai/models/chat/completion_delete_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Chat class CompletionDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/chat/completion_list_params.rbi b/rbi/lib/openai/models/chat/completion_list_params.rbi index 45a53c74..e488c018 100644 --- a/rbi/lib/openai/models/chat/completion_list_params.rbi +++ b/rbi/lib/openai/models/chat/completion_list_params.rbi @@ -4,65 +4,52 @@ module OpenAI module Models module Chat class CompletionListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Identifier for the last chat completion from the previous pagination request. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # Number of Chat Completions to retrieve. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # A list of metadata keys to filter the Chat Completions by. Example: # # `metadata[key1]=value1&metadata[key2]=value2` - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The model used to generate the Chat Completions. sig { returns(T.nilable(String)) } - def model - end + attr_reader :model - sig { params(_: String).returns(String) } - def model=(_) - end + sig { params(model: String).void } + attr_writer :model # Sort order for Chat Completions by timestamp. Use `asc` for ascending order or # `desc` for descending order. Defaults to `asc`. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Chat::CompletionListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Chat::CompletionListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, limit: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Chat::CompletionListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -75,9 +62,9 @@ module OpenAI { after: String, limit: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, - order: Symbol, + order: OpenAI::Models::Chat::CompletionListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -87,13 +74,19 @@ module OpenAI # Sort order for Chat Completions by timestamp. Use `asc` for ascending order or # `desc` for descending order. Defaults to `asc`. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Chat::CompletionListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::CompletionListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Chat::CompletionListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Chat::CompletionListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Chat::CompletionListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/chat/completion_retrieve_params.rbi b/rbi/lib/openai/models/chat/completion_retrieve_params.rbi index 1422fe6c..fe74c4a3 100644 --- a/rbi/lib/openai/models/chat/completion_retrieve_params.rbi +++ b/rbi/lib/openai/models/chat/completion_retrieve_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Chat class CompletionRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/chat/completion_update_params.rbi b/rbi/lib/openai/models/chat/completion_update_params.rbi index 0b3aa56f..d9801164 100644 --- a/rbi/lib/openai/models/chat/completion_update_params.rbi +++ b/rbi/lib/openai/models/chat/completion_update_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Chat class CompletionUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Set of 16 key-value pairs that can be attached to an object. This can be useful @@ -13,25 +13,27 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata sig do params( - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end def self.new(metadata:, request_options: {}) end - sig { override.returns({metadata: T.nilable(OpenAI::Models::Metadata), request_options: OpenAI::RequestOptions}) } + sig do + override.returns( + { + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: OpenAI::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/lib/openai/models/chat/completions/message_list_params.rbi b/rbi/lib/openai/models/chat/completions/message_list_params.rbi index 014bdbc9..57006149 100644 --- a/rbi/lib/openai/models/chat/completions/message_list_params.rbi +++ b/rbi/lib/openai/models/chat/completions/message_list_params.rbi @@ -5,43 +5,37 @@ module OpenAI module Chat module Completions class MessageListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Identifier for the last message from the previous pagination request. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # Number of messages to retrieve. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order for messages by timestamp. Use `asc` for ascending order or `desc` # for descending order. Defaults to `asc`. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Chat::Completions::MessageListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Chat::Completions::MessageListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Chat::Completions::MessageListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -49,27 +43,35 @@ module OpenAI end sig do - override.returns( - { - after: String, - limit: Integer, - order: Symbol, - request_options: OpenAI::RequestOptions - } - ) + override + .returns( + { + after: String, + limit: Integer, + order: OpenAI::Models::Chat::Completions::MessageListParams::Order::OrSymbol, + request_options: OpenAI::RequestOptions + } + ) end def to_hash end # Sort order for messages by timestamp. Use `asc` for ascending order or `desc` # for descending order. Defaults to `asc`. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Chat::Completions::MessageListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Chat::Completions::MessageListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Chat::Completions::MessageListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/chat_model.rbi b/rbi/lib/openai/models/chat_model.rbi index acb06a2d..df9c03d2 100644 --- a/rbi/lib/openai/models/chat_model.rbi +++ b/rbi/lib/openai/models/chat_model.rbi @@ -2,55 +2,65 @@ module OpenAI module Models - class ChatModel < OpenAI::Enum - abstract! + module ChatModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ChatModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ChatModel::TaggedSymbol) } - O3_MINI = :"o3-mini" - O3_MINI_2025_01_31 = :"o3-mini-2025-01-31" - O1 = :o1 - O1_2024_12_17 = :"o1-2024-12-17" - O1_PREVIEW = :"o1-preview" - O1_PREVIEW_2024_09_12 = :"o1-preview-2024-09-12" - O1_MINI = :"o1-mini" - O1_MINI_2024_09_12 = :"o1-mini-2024-09-12" - COMPUTER_USE_PREVIEW = :"computer-use-preview" - COMPUTER_USE_PREVIEW_2025_02_04 = :"computer-use-preview-2025-02-04" - COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11" - GPT_4_5_PREVIEW = :"gpt-4.5-preview" - GPT_4_5_PREVIEW_2025_02_27 = :"gpt-4.5-preview-2025-02-27" - GPT_4O = :"gpt-4o" - GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20" - GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06" - GPT_4O_2024_05_13 = :"gpt-4o-2024-05-13" - GPT_4O_AUDIO_PREVIEW = :"gpt-4o-audio-preview" - GPT_4O_AUDIO_PREVIEW_2024_10_01 = :"gpt-4o-audio-preview-2024-10-01" - GPT_4O_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-audio-preview-2024-12-17" - GPT_4O_MINI_AUDIO_PREVIEW = :"gpt-4o-mini-audio-preview" - GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-mini-audio-preview-2024-12-17" - CHATGPT_4O_LATEST = :"chatgpt-4o-latest" - GPT_4O_MINI = :"gpt-4o-mini" - GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18" - GPT_4_TURBO = :"gpt-4-turbo" - GPT_4_TURBO_2024_04_09 = :"gpt-4-turbo-2024-04-09" - GPT_4_0125_PREVIEW = :"gpt-4-0125-preview" - GPT_4_TURBO_PREVIEW = :"gpt-4-turbo-preview" - GPT_4_1106_PREVIEW = :"gpt-4-1106-preview" - GPT_4_VISION_PREVIEW = :"gpt-4-vision-preview" - GPT_4 = :"gpt-4" - GPT_4_0314 = :"gpt-4-0314" - GPT_4_0613 = :"gpt-4-0613" - GPT_4_32K = :"gpt-4-32k" - GPT_4_32K_0314 = :"gpt-4-32k-0314" - GPT_4_32K_0613 = :"gpt-4-32k-0613" - GPT_3_5_TURBO = :"gpt-3.5-turbo" - GPT_3_5_TURBO_16K = :"gpt-3.5-turbo-16k" - GPT_3_5_TURBO_0301 = :"gpt-3.5-turbo-0301" - GPT_3_5_TURBO_0613 = :"gpt-3.5-turbo-0613" - GPT_3_5_TURBO_1106 = :"gpt-3.5-turbo-1106" - GPT_3_5_TURBO_0125 = :"gpt-3.5-turbo-0125" - GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613" + O3_MINI = T.let(:"o3-mini", OpenAI::Models::ChatModel::TaggedSymbol) + O3_MINI_2025_01_31 = T.let(:"o3-mini-2025-01-31", OpenAI::Models::ChatModel::TaggedSymbol) + O1 = T.let(:o1, OpenAI::Models::ChatModel::TaggedSymbol) + O1_2024_12_17 = T.let(:"o1-2024-12-17", OpenAI::Models::ChatModel::TaggedSymbol) + O1_PREVIEW = T.let(:"o1-preview", OpenAI::Models::ChatModel::TaggedSymbol) + O1_PREVIEW_2024_09_12 = T.let(:"o1-preview-2024-09-12", OpenAI::Models::ChatModel::TaggedSymbol) + O1_MINI = T.let(:"o1-mini", OpenAI::Models::ChatModel::TaggedSymbol) + O1_MINI_2024_09_12 = T.let(:"o1-mini-2024-09-12", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O = T.let(:"gpt-4o", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_2024_11_20 = T.let(:"gpt-4o-2024-11-20", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_2024_08_06 = T.let(:"gpt-4o-2024-08-06", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_2024_05_13 = T.let(:"gpt-4o-2024-05-13", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_AUDIO_PREVIEW = T.let(:"gpt-4o-audio-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_AUDIO_PREVIEW_2024_10_01 = + T.let(:"gpt-4o-audio-preview-2024-10-01", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_AUDIO_PREVIEW_2024_12_17 = + T.let(:"gpt-4o-audio-preview-2024-12-17", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI_AUDIO_PREVIEW = T.let(:"gpt-4o-mini-audio-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 = + T.let(:"gpt-4o-mini-audio-preview-2024-12-17", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_SEARCH_PREVIEW = T.let(:"gpt-4o-search-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI_SEARCH_PREVIEW = + T.let(:"gpt-4o-mini-search-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_SEARCH_PREVIEW_2025_03_11 = + T.let(:"gpt-4o-search-preview-2025-03-11", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 = + T.let(:"gpt-4o-mini-search-preview-2025-03-11", OpenAI::Models::ChatModel::TaggedSymbol) + CHATGPT_4O_LATEST = T.let(:"chatgpt-4o-latest", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI = T.let(:"gpt-4o-mini", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4O_MINI_2024_07_18 = T.let(:"gpt-4o-mini-2024-07-18", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_TURBO = T.let(:"gpt-4-turbo", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_TURBO_2024_04_09 = T.let(:"gpt-4-turbo-2024-04-09", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_0125_PREVIEW = T.let(:"gpt-4-0125-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_TURBO_PREVIEW = T.let(:"gpt-4-turbo-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_1106_PREVIEW = T.let(:"gpt-4-1106-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_VISION_PREVIEW = T.let(:"gpt-4-vision-preview", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4 = T.let(:"gpt-4", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_0314 = T.let(:"gpt-4-0314", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_0613 = T.let(:"gpt-4-0613", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_32K = T.let(:"gpt-4-32k", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_32K_0314 = T.let(:"gpt-4-32k-0314", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_4_32K_0613 = T.let(:"gpt-4-32k-0613", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO = T.let(:"gpt-3.5-turbo", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_16K = T.let(:"gpt-3.5-turbo-16k", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_0301 = T.let(:"gpt-3.5-turbo-0301", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_0613 = T.let(:"gpt-3.5-turbo-0613", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_1106 = T.let(:"gpt-3.5-turbo-1106", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_0125 = T.let(:"gpt-3.5-turbo-0125", OpenAI::Models::ChatModel::TaggedSymbol) + GPT_3_5_TURBO_16K_0613 = T.let(:"gpt-3.5-turbo-16k-0613", OpenAI::Models::ChatModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ChatModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/comparison_filter.rbi b/rbi/lib/openai/models/comparison_filter.rbi index bbb84c5d..971045f3 100644 --- a/rbi/lib/openai/models/comparison_filter.rbi +++ b/rbi/lib/openai/models/comparison_filter.rbi @@ -5,12 +5,7 @@ module OpenAI class ComparisonFilter < OpenAI::BaseModel # The key to compare against the value. sig { returns(String) } - def key - end - - sig { params(_: String).returns(String) } - def key=(_) - end + attr_accessor :key # Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`. # @@ -20,33 +15,33 @@ module OpenAI # - `gte`: greater than or equal # - `lt`: less than # - `lte`: less than or equal - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::ComparisonFilter::Type::OrSymbol) } + attr_accessor :type # The value to compare against the attribute key; supports string, number, or # boolean types. sig { returns(T.any(String, Float, T::Boolean)) } - def value - end - - sig { params(_: T.any(String, Float, T::Boolean)).returns(T.any(String, Float, T::Boolean)) } - def value=(_) - end + attr_accessor :value # A filter used to compare a specified attribute key to a given value using a # defined comparison operation. sig do - params(key: String, type: Symbol, value: T.any(String, Float, T::Boolean)).returns(T.attached_class) + params( + key: String, + type: OpenAI::Models::ComparisonFilter::Type::OrSymbol, + value: T.any(String, Float, T::Boolean) + ) + .returns(T.attached_class) end def self.new(key:, type:, value:) end - sig { override.returns({key: String, type: Symbol, value: T.any(String, Float, T::Boolean)}) } + sig do + override + .returns( + {key: String, type: OpenAI::Models::ComparisonFilter::Type::OrSymbol, value: T.any(String, Float, T::Boolean)} + ) + end def to_hash end @@ -58,25 +53,32 @@ module OpenAI # - `gte`: greater than or equal # - `lt`: less than # - `lte`: less than or equal - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ComparisonFilter::Type) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + EQ = T.let(:eq, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) + NE = T.let(:ne, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) + GT = T.let(:gt, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) + GTE = T.let(:gte, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) + LT = T.let(:lt, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) + LTE = T.let(:lte, OpenAI::Models::ComparisonFilter::Type::TaggedSymbol) - EQ = :eq - NE = :ne - GT = :gt - GTE = :gte - LT = :lt - LTE = :lte + sig { override.returns(T::Array[OpenAI::Models::ComparisonFilter::Type::TaggedSymbol]) } + def self.values + end end # The value to compare against the attribute key; supports string, number, or # boolean types. - class Value < OpenAI::Union - abstract! + module Value + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/completion.rbi b/rbi/lib/openai/models/completion.rbi index 5c9f6e01..e877536d 100644 --- a/rbi/lib/openai/models/completion.rbi +++ b/rbi/lib/openai/models/completion.rbi @@ -5,85 +5,64 @@ module OpenAI class Completion < OpenAI::BaseModel # A unique identifier for the completion. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The list of completion choices the model generated for the input prompt. sig { returns(T::Array[OpenAI::Models::CompletionChoice]) } - def choices - end - - sig { params(_: T::Array[OpenAI::Models::CompletionChoice]).returns(T::Array[OpenAI::Models::CompletionChoice]) } - def choices=(_) - end + attr_accessor :choices # The Unix timestamp (in seconds) of when the completion was created. sig { returns(Integer) } - def created - end - - sig { params(_: Integer).returns(Integer) } - def created=(_) - end + attr_accessor :created # The model used for completion. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always "text_completion" sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # This fingerprint represents the backend configuration that the model runs with. # # Can be used in conjunction with the `seed` request parameter to understand when # backend changes have been made that might impact determinism. sig { returns(T.nilable(String)) } - def system_fingerprint - end + attr_reader :system_fingerprint - sig { params(_: String).returns(String) } - def system_fingerprint=(_) - end + sig { params(system_fingerprint: String).void } + attr_writer :system_fingerprint # Usage statistics for the completion request. sig { returns(T.nilable(OpenAI::Models::CompletionUsage)) } - def usage - end + attr_reader :usage - sig { params(_: OpenAI::Models::CompletionUsage).returns(OpenAI::Models::CompletionUsage) } - def usage=(_) - end + sig { params(usage: T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash)).void } + attr_writer :usage # Represents a completion response from the API. Note: both the streamed and # non-streamed response objects share the same shape (unlike the chat endpoint). sig do params( id: String, - choices: T::Array[OpenAI::Models::CompletionChoice], + choices: T::Array[T.any(OpenAI::Models::CompletionChoice, OpenAI::Util::AnyHash)], created: Integer, model: String, system_fingerprint: String, - usage: OpenAI::Models::CompletionUsage, + usage: T.any(OpenAI::Models::CompletionUsage, OpenAI::Util::AnyHash), object: Symbol ) .returns(T.attached_class) end - def self.new(id:, choices:, created:, model:, system_fingerprint: nil, usage: nil, object: :text_completion) + def self.new( + id:, + choices:, + created:, + model:, + system_fingerprint: nil, + usage: nil, + object: :text_completion + ) end sig do diff --git a/rbi/lib/openai/models/completion_choice.rbi b/rbi/lib/openai/models/completion_choice.rbi index 93b41ebf..c37142f2 100644 --- a/rbi/lib/openai/models/completion_choice.rbi +++ b/rbi/lib/openai/models/completion_choice.rbi @@ -7,46 +7,26 @@ module OpenAI # hit a natural stop point or a provided stop sequence, `length` if the maximum # number of tokens specified in the request was reached, or `content_filter` if # content was omitted due to a flag from our content filters. - sig { returns(Symbol) } - def finish_reason - end - - sig { params(_: Symbol).returns(Symbol) } - def finish_reason=(_) - end + sig { returns(OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol) } + attr_accessor :finish_reason sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index sig { returns(T.nilable(OpenAI::Models::CompletionChoice::Logprobs)) } - def logprobs - end + attr_reader :logprobs - sig do - params(_: T.nilable(OpenAI::Models::CompletionChoice::Logprobs)) - .returns(T.nilable(OpenAI::Models::CompletionChoice::Logprobs)) - end - def logprobs=(_) - end + sig { params(logprobs: T.nilable(T.any(OpenAI::Models::CompletionChoice::Logprobs, OpenAI::Util::AnyHash))).void } + attr_writer :logprobs sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text sig do params( - finish_reason: Symbol, + finish_reason: OpenAI::Models::CompletionChoice::FinishReason::OrSymbol, index: Integer, - logprobs: T.nilable(OpenAI::Models::CompletionChoice::Logprobs), + logprobs: T.nilable(T.any(OpenAI::Models::CompletionChoice::Logprobs, OpenAI::Util::AnyHash)), text: String ) .returns(T.attached_class) @@ -58,7 +38,7 @@ module OpenAI override .returns( { - finish_reason: Symbol, + finish_reason: OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol, index: Integer, logprobs: T.nilable(OpenAI::Models::CompletionChoice::Logprobs), text: String @@ -72,48 +52,45 @@ module OpenAI # hit a natural stop point or a provided stop sequence, `length` if the maximum # number of tokens specified in the request was reached, or `content_filter` if # content was omitted due to a flag from our content filters. - class FinishReason < OpenAI::Enum - abstract! + module FinishReason + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::CompletionChoice::FinishReason) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + STOP = T.let(:stop, OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol) + LENGTH = T.let(:length, OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol) + CONTENT_FILTER = T.let(:content_filter, OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol) - STOP = :stop - LENGTH = :length - CONTENT_FILTER = :content_filter + sig { override.returns(T::Array[OpenAI::Models::CompletionChoice::FinishReason::TaggedSymbol]) } + def self.values + end end class Logprobs < OpenAI::BaseModel sig { returns(T.nilable(T::Array[Integer])) } - def text_offset - end + attr_reader :text_offset - sig { params(_: T::Array[Integer]).returns(T::Array[Integer]) } - def text_offset=(_) - end + sig { params(text_offset: T::Array[Integer]).void } + attr_writer :text_offset sig { returns(T.nilable(T::Array[Float])) } - def token_logprobs - end + attr_reader :token_logprobs - sig { params(_: T::Array[Float]).returns(T::Array[Float]) } - def token_logprobs=(_) - end + sig { params(token_logprobs: T::Array[Float]).void } + attr_writer :token_logprobs sig { returns(T.nilable(T::Array[String])) } - def tokens - end + attr_reader :tokens - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def tokens=(_) - end + sig { params(tokens: T::Array[String]).void } + attr_writer :tokens sig { returns(T.nilable(T::Array[T::Hash[Symbol, Float]])) } - def top_logprobs - end + attr_reader :top_logprobs - sig { params(_: T::Array[T::Hash[Symbol, Float]]).returns(T::Array[T::Hash[Symbol, Float]]) } - def top_logprobs=(_) - end + sig { params(top_logprobs: T::Array[T::Hash[Symbol, Float]]).void } + attr_writer :top_logprobs sig do params( diff --git a/rbi/lib/openai/models/completion_create_params.rbi b/rbi/lib/openai/models/completion_create_params.rbi index 2e1185c5..76ecc07b 100644 --- a/rbi/lib/openai/models/completion_create_params.rbi +++ b/rbi/lib/openai/models/completion_create_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class CompletionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # ID of the model to use. You can use the @@ -11,13 +11,8 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol)) } + attr_accessor :model # The prompt(s) to generate completions for, encoded as a string, array of # strings, array of tokens, or array of token arrays. @@ -28,15 +23,7 @@ module OpenAI sig do returns(T.nilable(T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]))) end - def prompt - end - - sig do - params(_: T.nilable(T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]))) - .returns(T.nilable(T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]))) - end - def prompt=(_) - end + attr_accessor :prompt # Generates `best_of` completions server-side and returns the "best" (the one with # the highest log probability per token). Results cannot be streamed. @@ -48,21 +35,11 @@ module OpenAI # consume your token quota. Use carefully and ensure that you have reasonable # settings for `max_tokens` and `stop`. sig { returns(T.nilable(Integer)) } - def best_of - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def best_of=(_) - end + attr_accessor :best_of # Echo back the prompt in addition to the completion sig { returns(T.nilable(T::Boolean)) } - def echo - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def echo=(_) - end + attr_accessor :echo # Number between -2.0 and 2.0. Positive values penalize new tokens based on their # existing frequency in the text so far, decreasing the model's likelihood to @@ -70,12 +47,7 @@ module OpenAI # # [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation) sig { returns(T.nilable(Float)) } - def frequency_penalty - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def frequency_penalty=(_) - end + attr_accessor :frequency_penalty # Modify the likelihood of specified tokens appearing in the completion. # @@ -90,12 +62,7 @@ module OpenAI # As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token # from being generated. sig { returns(T.nilable(T::Hash[Symbol, Integer])) } - def logit_bias - end - - sig { params(_: T.nilable(T::Hash[Symbol, Integer])).returns(T.nilable(T::Hash[Symbol, Integer])) } - def logit_bias=(_) - end + attr_accessor :logit_bias # Include the log probabilities on the `logprobs` most likely output tokens, as # well the chosen tokens. For example, if `logprobs` is 5, the API will return a @@ -104,12 +71,7 @@ module OpenAI # # The maximum value for `logprobs` is 5. sig { returns(T.nilable(Integer)) } - def logprobs - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def logprobs=(_) - end + attr_accessor :logprobs # The maximum number of [tokens](/tokenizer) that can be generated in the # completion. @@ -119,12 +81,7 @@ module OpenAI # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) # for counting tokens. sig { returns(T.nilable(Integer)) } - def max_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_tokens=(_) - end + attr_accessor :max_tokens # How many completions to generate for each prompt. # @@ -132,12 +89,7 @@ module OpenAI # consume your token quota. Use carefully and ensure that you have reasonable # settings for `max_tokens` and `stop`. sig { returns(T.nilable(Integer)) } - def n - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def n=(_) - end + attr_accessor :n # Number between -2.0 and 2.0. Positive values penalize new tokens based on # whether they appear in the text so far, increasing the model's likelihood to @@ -145,12 +97,7 @@ module OpenAI # # [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation) sig { returns(T.nilable(Float)) } - def presence_penalty - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def presence_penalty=(_) - end + attr_accessor :presence_penalty # If specified, our system will make a best effort to sample deterministically, # such that repeated requests with the same `seed` and parameters should return @@ -159,54 +106,30 @@ module OpenAI # Determinism is not guaranteed, and you should refer to the `system_fingerprint` # response parameter to monitor changes in the backend. sig { returns(T.nilable(Integer)) } - def seed - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def seed=(_) - end + attr_accessor :seed # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. sig { returns(T.nilable(T.any(String, T::Array[String]))) } - def stop - end - - sig do - params( - _: T.nilable( - T.any( - String, - T::Array[String] - ) - ) - ).returns(T.nilable(T.any(String, T::Array[String]))) - end - def stop=(_) - end + attr_accessor :stop # Options for streaming response. Only set this when you set `stream: true`. sig { returns(T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) } - def stream_options - end + attr_reader :stream_options sig do - params(_: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) - .returns(T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions)) - end - def stream_options=(_) + params( + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :stream_options # The suffix that comes after a completion of inserted text. # # This parameter is only supported for `gpt-3.5-turbo-instruct`. sig { returns(T.nilable(String)) } - def suffix - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def suffix=(_) - end + attr_accessor :suffix # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more @@ -214,12 +137,7 @@ module OpenAI # # We generally recommend altering this or `top_p` but not both. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -227,27 +145,20 @@ module OpenAI # # We generally recommend altering this or `temperature` but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol), prompt: T.nilable( T.any( String, @@ -266,12 +177,12 @@ module OpenAI presence_penalty: T.nilable(Float), seed: T.nilable(Integer), stop: T.nilable(T.any(String, T::Array[String])), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), suffix: T.nilable(String), temperature: T.nilable(Float), top_p: T.nilable(Float), user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -301,7 +212,7 @@ module OpenAI override .returns( { - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol), prompt: T.nilable( T.any( String, @@ -337,10 +248,20 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::CompletionCreateParams::Model) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::CompletionCreateParams::Model::TaggedSymbol) } + + GPT_3_5_TURBO_INSTRUCT = + T.let(:"gpt-3.5-turbo-instruct", OpenAI::Models::CompletionCreateParams::Model::TaggedSymbol) + DAVINCI_002 = T.let(:"davinci-002", OpenAI::Models::CompletionCreateParams::Model::TaggedSymbol) + BABBAGE_002 = T.let(:"babbage-002", OpenAI::Models::CompletionCreateParams::Model::TaggedSymbol) end # The prompt(s) to generate completions for, encoded as a string, array of @@ -349,28 +270,30 @@ module OpenAI # Note that <|endoftext|> is the document separator that the model sees during # training, so if a prompt is not specified the model will generate as if from the # beginning of a new document. - class Prompt < OpenAI::Union - abstract! + module Prompt + extend OpenAI::Union - Variants = type_template(:out) do - {fixed: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]])} + sig { override.returns([String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]]) } + def self.variants end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) - IntegerArray = T.type_alias { T::Array[Integer] } + IntegerArray = T.let(OpenAI::ArrayOf[Integer], OpenAI::Type::Converter) - ArrayOfToken2DArray = T.type_alias { T::Array[T::Array[Integer]] } + ArrayOfToken2DArray = T.let(OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]], OpenAI::Type::Converter) end # Up to 4 sequences where the API will stop generating further tokens. The # returned text will not contain the stop sequence. - class Stop < OpenAI::Union - abstract! + module Stop + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.nilable(T.any(String, T::Array[String]))} } + sig { override.returns([String, T::Array[String]]) } + def self.variants + end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) end end end diff --git a/rbi/lib/openai/models/completion_usage.rbi b/rbi/lib/openai/models/completion_usage.rbi index de91da0f..8daa195d 100644 --- a/rbi/lib/openai/models/completion_usage.rbi +++ b/rbi/lib/openai/models/completion_usage.rbi @@ -5,54 +5,39 @@ module OpenAI class CompletionUsage < OpenAI::BaseModel # Number of tokens in the generated completion. sig { returns(Integer) } - def completion_tokens - end - - sig { params(_: Integer).returns(Integer) } - def completion_tokens=(_) - end + attr_accessor :completion_tokens # Number of tokens in the prompt. sig { returns(Integer) } - def prompt_tokens - end - - sig { params(_: Integer).returns(Integer) } - def prompt_tokens=(_) - end + attr_accessor :prompt_tokens # Total number of tokens used in the request (prompt + completion). sig { returns(Integer) } - def total_tokens - end - - sig { params(_: Integer).returns(Integer) } - def total_tokens=(_) - end + attr_accessor :total_tokens # Breakdown of tokens used in a completion. sig { returns(T.nilable(OpenAI::Models::CompletionUsage::CompletionTokensDetails)) } - def completion_tokens_details - end + attr_reader :completion_tokens_details sig do - params(_: OpenAI::Models::CompletionUsage::CompletionTokensDetails) - .returns(OpenAI::Models::CompletionUsage::CompletionTokensDetails) - end - def completion_tokens_details=(_) + params( + completion_tokens_details: T.any(OpenAI::Models::CompletionUsage::CompletionTokensDetails, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :completion_tokens_details # Breakdown of tokens used in the prompt. sig { returns(T.nilable(OpenAI::Models::CompletionUsage::PromptTokensDetails)) } - def prompt_tokens_details - end + attr_reader :prompt_tokens_details sig do - params(_: OpenAI::Models::CompletionUsage::PromptTokensDetails) - .returns(OpenAI::Models::CompletionUsage::PromptTokensDetails) - end - def prompt_tokens_details=(_) + params( + prompt_tokens_details: T.any(OpenAI::Models::CompletionUsage::PromptTokensDetails, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :prompt_tokens_details # Usage statistics for the completion request. sig do @@ -60,8 +45,8 @@ module OpenAI completion_tokens: Integer, prompt_tokens: Integer, total_tokens: Integer, - completion_tokens_details: OpenAI::Models::CompletionUsage::CompletionTokensDetails, - prompt_tokens_details: OpenAI::Models::CompletionUsage::PromptTokensDetails + completion_tokens_details: T.any(OpenAI::Models::CompletionUsage::CompletionTokensDetails, OpenAI::Util::AnyHash), + prompt_tokens_details: T.any(OpenAI::Models::CompletionUsage::PromptTokensDetails, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -93,42 +78,34 @@ module OpenAI # When using Predicted Outputs, the number of tokens in the prediction that # appeared in the completion. sig { returns(T.nilable(Integer)) } - def accepted_prediction_tokens - end + attr_reader :accepted_prediction_tokens - sig { params(_: Integer).returns(Integer) } - def accepted_prediction_tokens=(_) - end + sig { params(accepted_prediction_tokens: Integer).void } + attr_writer :accepted_prediction_tokens # Audio input tokens generated by the model. sig { returns(T.nilable(Integer)) } - def audio_tokens - end + attr_reader :audio_tokens - sig { params(_: Integer).returns(Integer) } - def audio_tokens=(_) - end + sig { params(audio_tokens: Integer).void } + attr_writer :audio_tokens # Tokens generated by the model for reasoning. sig { returns(T.nilable(Integer)) } - def reasoning_tokens - end + attr_reader :reasoning_tokens - sig { params(_: Integer).returns(Integer) } - def reasoning_tokens=(_) - end + sig { params(reasoning_tokens: Integer).void } + attr_writer :reasoning_tokens # When using Predicted Outputs, the number of tokens in the prediction that did # not appear in the completion. However, like reasoning tokens, these tokens are # still counted in the total completion tokens for purposes of billing, output, # and context window limits. sig { returns(T.nilable(Integer)) } - def rejected_prediction_tokens - end + attr_reader :rejected_prediction_tokens - sig { params(_: Integer).returns(Integer) } - def rejected_prediction_tokens=(_) - end + sig { params(rejected_prediction_tokens: Integer).void } + attr_writer :rejected_prediction_tokens # Breakdown of tokens used in a completion. sig do @@ -140,7 +117,12 @@ module OpenAI ) .returns(T.attached_class) end - def self.new(accepted_prediction_tokens: nil, audio_tokens: nil, reasoning_tokens: nil, rejected_prediction_tokens: nil) + def self.new( + accepted_prediction_tokens: nil, + audio_tokens: nil, + reasoning_tokens: nil, + rejected_prediction_tokens: nil + ) end sig do @@ -161,21 +143,17 @@ module OpenAI class PromptTokensDetails < OpenAI::BaseModel # Audio input tokens present in the prompt. sig { returns(T.nilable(Integer)) } - def audio_tokens - end + attr_reader :audio_tokens - sig { params(_: Integer).returns(Integer) } - def audio_tokens=(_) - end + sig { params(audio_tokens: Integer).void } + attr_writer :audio_tokens # Cached tokens present in the prompt. sig { returns(T.nilable(Integer)) } - def cached_tokens - end + attr_reader :cached_tokens - sig { params(_: Integer).returns(Integer) } - def cached_tokens=(_) - end + sig { params(cached_tokens: Integer).void } + attr_writer :cached_tokens # Breakdown of tokens used in the prompt. sig { params(audio_tokens: Integer, cached_tokens: Integer).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/compound_filter.rbi b/rbi/lib/openai/models/compound_filter.rbi index 6722f10d..e070a53b 100644 --- a/rbi/lib/openai/models/compound_filter.rbi +++ b/rbi/lib/openai/models/compound_filter.rbi @@ -6,53 +6,58 @@ module OpenAI # Array of filters to combine. Items can be `ComparisonFilter` or # `CompoundFilter`. sig { returns(T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)]) } - def filters - end - - sig do - params(_: T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)]) - .returns(T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)]) - end - def filters=(_) - end + attr_accessor :filters # Type of operation: `and` or `or`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::CompoundFilter::Type::OrSymbol) } + attr_accessor :type # Combine multiple filters using `and` or `or`. sig do - params(filters: T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)], type: Symbol) + params( + filters: T::Array[T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, T.anything)], + type: OpenAI::Models::CompoundFilter::Type::OrSymbol + ) .returns(T.attached_class) end def self.new(filters:, type:) end - sig { override.returns({filters: T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)], type: Symbol}) } + sig do + override + .returns( + { + filters: T::Array[T.any(OpenAI::Models::ComparisonFilter, T.anything)], + type: OpenAI::Models::CompoundFilter::Type::OrSymbol + } + ) + end def to_hash end # A filter used to compare a specified attribute key to a given value using a # defined comparison operation. - class Filter < OpenAI::Union - abstract! + module Filter + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::ComparisonFilter, T.anything)} } + sig { override.returns([OpenAI::Models::ComparisonFilter, T.anything]) } + def self.variants + end end # Type of operation: `and` or `or`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::CompoundFilter::Type) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::CompoundFilter::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AND = T.let(:and, OpenAI::Models::CompoundFilter::Type::TaggedSymbol) + OR = T.let(:or, OpenAI::Models::CompoundFilter::Type::TaggedSymbol) - AND = :and - OR = :or + sig { override.returns(T::Array[OpenAI::Models::CompoundFilter::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/create_embedding_response.rbi b/rbi/lib/openai/models/create_embedding_response.rbi index c095b791..d057718b 100644 --- a/rbi/lib/openai/models/create_embedding_response.rbi +++ b/rbi/lib/openai/models/create_embedding_response.rbi @@ -5,48 +5,28 @@ module OpenAI class CreateEmbeddingResponse < OpenAI::BaseModel # The list of embeddings generated by the model. sig { returns(T::Array[OpenAI::Models::Embedding]) } - def data - end - - sig { params(_: T::Array[OpenAI::Models::Embedding]).returns(T::Array[OpenAI::Models::Embedding]) } - def data=(_) - end + attr_accessor :data # The name of the model used to generate the embedding. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always "list". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The usage information for the request. sig { returns(OpenAI::Models::CreateEmbeddingResponse::Usage) } - def usage - end + attr_reader :usage - sig do - params(_: OpenAI::Models::CreateEmbeddingResponse::Usage) - .returns(OpenAI::Models::CreateEmbeddingResponse::Usage) - end - def usage=(_) - end + sig { params(usage: T.any(OpenAI::Models::CreateEmbeddingResponse::Usage, OpenAI::Util::AnyHash)).void } + attr_writer :usage sig do params( - data: T::Array[OpenAI::Models::Embedding], + data: T::Array[T.any(OpenAI::Models::Embedding, OpenAI::Util::AnyHash)], model: String, - usage: OpenAI::Models::CreateEmbeddingResponse::Usage, + usage: T.any(OpenAI::Models::CreateEmbeddingResponse::Usage, OpenAI::Util::AnyHash), object: Symbol ) .returns(T.attached_class) @@ -71,21 +51,11 @@ module OpenAI class Usage < OpenAI::BaseModel # The number of tokens used by the prompt. sig { returns(Integer) } - def prompt_tokens - end - - sig { params(_: Integer).returns(Integer) } - def prompt_tokens=(_) - end + attr_accessor :prompt_tokens # The total number of tokens used by the request. sig { returns(Integer) } - def total_tokens - end - - sig { params(_: Integer).returns(Integer) } - def total_tokens=(_) - end + attr_accessor :total_tokens # The usage information for the request. sig { params(prompt_tokens: Integer, total_tokens: Integer).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/embedding.rbi b/rbi/lib/openai/models/embedding.rbi index 4218f3b9..90ad0f45 100644 --- a/rbi/lib/openai/models/embedding.rbi +++ b/rbi/lib/openai/models/embedding.rbi @@ -7,30 +7,15 @@ module OpenAI # the model as listed in the # [embedding guide](https://platform.openai.com/docs/guides/embeddings). sig { returns(T::Array[Float]) } - def embedding - end - - sig { params(_: T::Array[Float]).returns(T::Array[Float]) } - def embedding=(_) - end + attr_accessor :embedding # The index of the embedding in the list of embeddings. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The object type, which is always "embedding". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # Represents an embedding vector returned by embedding endpoint. sig { params(embedding: T::Array[Float], index: Integer, object: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/embedding_create_params.rbi b/rbi/lib/openai/models/embedding_create_params.rbi index a9a37c56..9aac2355 100644 --- a/rbi/lib/openai/models/embedding_create_params.rbi +++ b/rbi/lib/openai/models/embedding_create_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class EmbeddingCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Input text to embed, encoded as a string or array of tokens. To embed multiple @@ -15,68 +15,49 @@ module OpenAI # for counting tokens. Some models may also impose a limit on total number of # tokens summed across inputs. sig { returns(T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]])) } - def input - end - - sig do - params(_: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]])) - .returns(T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]])) - end - def input=(_) - end + attr_accessor :input # ID of the model to use. You can use the # [List models](https://platform.openai.com/docs/api-reference/models/list) API to # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::EmbeddingModel::OrSymbol)) } + attr_accessor :model # The number of dimensions the resulting output embeddings should have. Only # supported in `text-embedding-3` and later models. sig { returns(T.nilable(Integer)) } - def dimensions - end + attr_reader :dimensions - sig { params(_: Integer).returns(Integer) } - def dimensions=(_) - end + sig { params(dimensions: Integer).void } + attr_writer :dimensions # The format to return the embeddings in. Can be either `float` or # [`base64`](https://pypi.org/project/pybase64/). - sig { returns(T.nilable(Symbol)) } - def encoding_format - end + sig { returns(T.nilable(OpenAI::Models::EmbeddingCreateParams::EncodingFormat::OrSymbol)) } + attr_reader :encoding_format - sig { params(_: Symbol).returns(Symbol) } - def encoding_format=(_) - end + sig { params(encoding_format: OpenAI::Models::EmbeddingCreateParams::EncodingFormat::OrSymbol).void } + attr_writer :encoding_format # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( input: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::EmbeddingModel::OrSymbol), dimensions: Integer, - encoding_format: Symbol, + encoding_format: OpenAI::Models::EmbeddingCreateParams::EncodingFormat::OrSymbol, user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -88,9 +69,9 @@ module OpenAI .returns( { input: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::EmbeddingModel::OrSymbol), dimensions: Integer, - encoding_format: Symbol, + encoding_format: OpenAI::Models::EmbeddingCreateParams::EncodingFormat::OrSymbol, user: String, request_options: OpenAI::RequestOptions } @@ -107,18 +88,18 @@ module OpenAI # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) # for counting tokens. Some models may also impose a limit on total number of # tokens summed across inputs. - class Input < OpenAI::Union - abstract! + module Input + extend OpenAI::Union - Variants = type_template(:out) do - {fixed: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]])} + sig { override.returns([String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]]) } + def self.variants end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) - IntegerArray = T.type_alias { T::Array[Integer] } + IntegerArray = T.let(OpenAI::ArrayOf[Integer], OpenAI::Type::Converter) - ArrayOfToken2DArray = T.type_alias { T::Array[T::Array[Integer]] } + ArrayOfToken2DArray = T.let(OpenAI::ArrayOf[OpenAI::ArrayOf[Integer]], OpenAI::Type::Converter) end # ID of the model to use. You can use the @@ -126,21 +107,29 @@ module OpenAI # see all of your available models, or see our # [Model overview](https://platform.openai.com/docs/models) for descriptions of # them. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::EmbeddingModel::OrSymbol]) } + def self.variants + end end # The format to return the embeddings in. Can be either `float` or # [`base64`](https://pypi.org/project/pybase64/). - class EncodingFormat < OpenAI::Enum - abstract! + module EncodingFormat + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat::TaggedSymbol) } - FLOAT = :float - BASE64 = :base64 + FLOAT = T.let(:float, OpenAI::Models::EmbeddingCreateParams::EncodingFormat::TaggedSymbol) + BASE64 = T.let(:base64, OpenAI::Models::EmbeddingCreateParams::EncodingFormat::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::EmbeddingCreateParams::EncodingFormat::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/embedding_model.rbi b/rbi/lib/openai/models/embedding_model.rbi index 1bd2eac2..d1fc3704 100644 --- a/rbi/lib/openai/models/embedding_model.rbi +++ b/rbi/lib/openai/models/embedding_model.rbi @@ -2,14 +2,19 @@ module OpenAI module Models - class EmbeddingModel < OpenAI::Enum - abstract! + module EmbeddingModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::EmbeddingModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::EmbeddingModel::TaggedSymbol) } - TEXT_EMBEDDING_ADA_002 = :"text-embedding-ada-002" - TEXT_EMBEDDING_3_SMALL = :"text-embedding-3-small" - TEXT_EMBEDDING_3_LARGE = :"text-embedding-3-large" + TEXT_EMBEDDING_ADA_002 = T.let(:"text-embedding-ada-002", OpenAI::Models::EmbeddingModel::TaggedSymbol) + TEXT_EMBEDDING_3_SMALL = T.let(:"text-embedding-3-small", OpenAI::Models::EmbeddingModel::TaggedSymbol) + TEXT_EMBEDDING_3_LARGE = T.let(:"text-embedding-3-large", OpenAI::Models::EmbeddingModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::EmbeddingModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/error_object.rbi b/rbi/lib/openai/models/error_object.rbi index f7390e71..134b6d66 100644 --- a/rbi/lib/openai/models/error_object.rbi +++ b/rbi/lib/openai/models/error_object.rbi @@ -4,36 +4,16 @@ module OpenAI module Models class ErrorObject < OpenAI::BaseModel sig { returns(T.nilable(String)) } - def code - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def code=(_) - end + attr_accessor :code sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param sig { returns(String) } - def type - end - - sig { params(_: String).returns(String) } - def type=(_) - end + attr_accessor :type sig do params(code: T.nilable(String), message: String, param: T.nilable(String), type: String) diff --git a/rbi/lib/openai/models/file_chunking_strategy.rbi b/rbi/lib/openai/models/file_chunking_strategy.rbi index 93972f9b..4e9e85c9 100644 --- a/rbi/lib/openai/models/file_chunking_strategy.rbi +++ b/rbi/lib/openai/models/file_chunking_strategy.rbi @@ -3,13 +3,16 @@ module OpenAI module Models # The strategy used to chunk the file. - class FileChunkingStrategy < OpenAI::Union - abstract! + module FileChunkingStrategy + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject) - } + sig do + override + .returns( + [OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject] + ) + end + def self.variants end end end diff --git a/rbi/lib/openai/models/file_chunking_strategy_param.rbi b/rbi/lib/openai/models/file_chunking_strategy_param.rbi index aeffdf61..17f0755f 100644 --- a/rbi/lib/openai/models/file_chunking_strategy_param.rbi +++ b/rbi/lib/openai/models/file_chunking_strategy_param.rbi @@ -4,16 +4,16 @@ module OpenAI module Models # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. Only applicable if `file_ids` is non-empty. - class FileChunkingStrategyParam < OpenAI::Union - abstract! + module FileChunkingStrategyParam + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::AutoFileChunkingStrategyParam, - OpenAI::Models::StaticFileChunkingStrategyObjectParam + sig do + override + .returns( + [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/file_content_params.rbi b/rbi/lib/openai/models/file_content_params.rbi index 71e0eaaa..2a195cd2 100644 --- a/rbi/lib/openai/models/file_content_params.rbi +++ b/rbi/lib/openai/models/file_content_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class FileContentParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/file_create_params.rbi b/rbi/lib/openai/models/file_create_params.rbi index 98619f88..8813232a 100644 --- a/rbi/lib/openai/models/file_create_params.rbi +++ b/rbi/lib/openai/models/file_create_params.rbi @@ -3,35 +3,25 @@ module OpenAI module Models class FileCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The File object (not file name) to be uploaded. sig { returns(T.any(IO, StringIO)) } - def file - end - - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def file=(_) - end + attr_accessor :file # The intended purpose of the uploaded file. One of: - `assistants`: Used in the # Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: # Flexible file type for any purpose - `evals`: Used for eval data sets - sig { returns(Symbol) } - def purpose - end - - sig { params(_: Symbol).returns(Symbol) } - def purpose=(_) - end + sig { returns(OpenAI::Models::FilePurpose::OrSymbol) } + attr_accessor :purpose sig do params( file: T.any(IO, StringIO), - purpose: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + purpose: OpenAI::Models::FilePurpose::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -39,13 +29,14 @@ module OpenAI end sig do - override.returns( - { - file: T.any(IO, StringIO), - purpose: Symbol, - request_options: OpenAI::RequestOptions - } - ) + override + .returns( + { + file: T.any(IO, StringIO), + purpose: OpenAI::Models::FilePurpose::OrSymbol, + request_options: OpenAI::RequestOptions + } + ) end def to_hash end diff --git a/rbi/lib/openai/models/file_delete_params.rbi b/rbi/lib/openai/models/file_delete_params.rbi index 5c6407ba..3d675373 100644 --- a/rbi/lib/openai/models/file_delete_params.rbi +++ b/rbi/lib/openai/models/file_delete_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class FileDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/file_deleted.rbi b/rbi/lib/openai/models/file_deleted.rbi index 83029526..fd6fac2b 100644 --- a/rbi/lib/openai/models/file_deleted.rbi +++ b/rbi/lib/openai/models/file_deleted.rbi @@ -4,28 +4,13 @@ module OpenAI module Models class FileDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :file) diff --git a/rbi/lib/openai/models/file_list_params.rbi b/rbi/lib/openai/models/file_list_params.rbi index 48b8106e..027ccc87 100644 --- a/rbi/lib/openai/models/file_list_params.rbi +++ b/rbi/lib/openai/models/file_list_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class FileListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -11,49 +11,41 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A limit on the number of objects to be returned. Limit can range between 1 and # 10,000, and the default is 10,000. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::FileListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::FileListParams::Order::OrSymbol).void } + attr_writer :order # Only return files with the given purpose. sig { returns(T.nilable(String)) } - def purpose - end + attr_reader :purpose - sig { params(_: String).returns(String) } - def purpose=(_) - end + sig { params(purpose: String).void } + attr_writer :purpose sig do params( after: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::FileListParams::Order::OrSymbol, purpose: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -66,7 +58,7 @@ module OpenAI { after: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::FileListParams::Order::OrSymbol, purpose: String, request_options: OpenAI::RequestOptions } @@ -77,13 +69,18 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FileListParams::Order) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::FileListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::FileListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::FileListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::FileListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/file_object.rbi b/rbi/lib/openai/models/file_object.rbi index b31df148..80273345 100644 --- a/rbi/lib/openai/models/file_object.rbi +++ b/rbi/lib/openai/models/file_object.rbi @@ -5,88 +5,49 @@ module OpenAI class FileObject < OpenAI::BaseModel # The file identifier, which can be referenced in the API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The size of the file, in bytes. sig { returns(Integer) } - def bytes - end - - sig { params(_: Integer).returns(Integer) } - def bytes=(_) - end + attr_accessor :bytes # The Unix timestamp (in seconds) for when the file was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The name of the file. sig { returns(String) } - def filename - end - - sig { params(_: String).returns(String) } - def filename=(_) - end + attr_accessor :filename # The object type, which is always `file`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The intended purpose of the file. Supported values are `assistants`, # `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` # and `vision`. - sig { returns(Symbol) } - def purpose - end - - sig { params(_: Symbol).returns(Symbol) } - def purpose=(_) - end + sig { returns(OpenAI::Models::FileObject::Purpose::TaggedSymbol) } + attr_accessor :purpose # Deprecated. The current status of the file, which can be either `uploaded`, # `processed`, or `error`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::FileObject::Status::TaggedSymbol) } + attr_accessor :status # The Unix timestamp (in seconds) for when the file will expire. sig { returns(T.nilable(Integer)) } - def expires_at - end + attr_reader :expires_at - sig { params(_: Integer).returns(Integer) } - def expires_at=(_) - end + sig { params(expires_at: Integer).void } + attr_writer :expires_at # Deprecated. For details on why a fine-tuning training file failed validation, # see the `error` field on `fine_tuning.job`. sig { returns(T.nilable(String)) } - def status_details - end + attr_reader :status_details - sig { params(_: String).returns(String) } - def status_details=(_) - end + sig { params(status_details: String).void } + attr_writer :status_details # The `File` object represents a document that has been uploaded to OpenAI. sig do @@ -95,8 +56,8 @@ module OpenAI bytes: Integer, created_at: Integer, filename: String, - purpose: Symbol, - status: Symbol, + purpose: OpenAI::Models::FileObject::Purpose::OrSymbol, + status: OpenAI::Models::FileObject::Status::OrSymbol, expires_at: Integer, status_details: String, object: Symbol @@ -125,8 +86,8 @@ module OpenAI created_at: Integer, filename: String, object: Symbol, - purpose: Symbol, - status: Symbol, + purpose: OpenAI::Models::FileObject::Purpose::TaggedSymbol, + status: OpenAI::Models::FileObject::Status::TaggedSymbol, expires_at: Integer, status_details: String } @@ -138,30 +99,40 @@ module OpenAI # The intended purpose of the file. Supported values are `assistants`, # `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` # and `vision`. - class Purpose < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - ASSISTANTS = :assistants - ASSISTANTS_OUTPUT = :assistants_output - BATCH = :batch - BATCH_OUTPUT = :batch_output - FINE_TUNE = :"fine-tune" - FINE_TUNE_RESULTS = :"fine-tune-results" - VISION = :vision + module Purpose + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FileObject::Purpose) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::FileObject::Purpose::TaggedSymbol) } + + ASSISTANTS = T.let(:assistants, OpenAI::Models::FileObject::Purpose::TaggedSymbol) + ASSISTANTS_OUTPUT = T.let(:assistants_output, OpenAI::Models::FileObject::Purpose::TaggedSymbol) + BATCH = T.let(:batch, OpenAI::Models::FileObject::Purpose::TaggedSymbol) + BATCH_OUTPUT = T.let(:batch_output, OpenAI::Models::FileObject::Purpose::TaggedSymbol) + FINE_TUNE = T.let(:"fine-tune", OpenAI::Models::FileObject::Purpose::TaggedSymbol) + FINE_TUNE_RESULTS = T.let(:"fine-tune-results", OpenAI::Models::FileObject::Purpose::TaggedSymbol) + VISION = T.let(:vision, OpenAI::Models::FileObject::Purpose::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::FileObject::Purpose::TaggedSymbol]) } + def self.values + end end # Deprecated. The current status of the file, which can be either `uploaded`, # `processed`, or `error`. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FileObject::Status) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::FileObject::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + UPLOADED = T.let(:uploaded, OpenAI::Models::FileObject::Status::TaggedSymbol) + PROCESSED = T.let(:processed, OpenAI::Models::FileObject::Status::TaggedSymbol) + ERROR = T.let(:error, OpenAI::Models::FileObject::Status::TaggedSymbol) - UPLOADED = :uploaded - PROCESSED = :processed - ERROR = :error + sig { override.returns(T::Array[OpenAI::Models::FileObject::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/file_purpose.rbi b/rbi/lib/openai/models/file_purpose.rbi index 07bd11c5..3fa6743d 100644 --- a/rbi/lib/openai/models/file_purpose.rbi +++ b/rbi/lib/openai/models/file_purpose.rbi @@ -6,17 +6,22 @@ module OpenAI # Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: # Flexible file type for any purpose - `evals`: Used for eval data sets - class FilePurpose < OpenAI::Enum - abstract! + module FilePurpose + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FilePurpose) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::FilePurpose::TaggedSymbol) } - ASSISTANTS = :assistants - BATCH = :batch - FINE_TUNE = :"fine-tune" - VISION = :vision - USER_DATA = :user_data - EVALS = :evals + ASSISTANTS = T.let(:assistants, OpenAI::Models::FilePurpose::TaggedSymbol) + BATCH = T.let(:batch, OpenAI::Models::FilePurpose::TaggedSymbol) + FINE_TUNE = T.let(:"fine-tune", OpenAI::Models::FilePurpose::TaggedSymbol) + VISION = T.let(:vision, OpenAI::Models::FilePurpose::TaggedSymbol) + USER_DATA = T.let(:user_data, OpenAI::Models::FilePurpose::TaggedSymbol) + EVALS = T.let(:evals, OpenAI::Models::FilePurpose::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::FilePurpose::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/file_retrieve_params.rbi b/rbi/lib/openai/models/file_retrieve_params.rbi index a1f9e075..579f51ba 100644 --- a/rbi/lib/openai/models/file_retrieve_params.rbi +++ b/rbi/lib/openai/models/file_retrieve_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class FileRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/fine_tuning/fine_tuning_job.rbi b/rbi/lib/openai/models/fine_tuning/fine_tuning_job.rbi index 2de2b251..5aa6d868 100644 --- a/rbi/lib/openai/models/fine_tuning/fine_tuning_job.rbi +++ b/rbi/lib/openai/models/fine_tuning/fine_tuning_job.rbi @@ -2,183 +2,101 @@ module OpenAI module Models - FineTuningJob = T.type_alias { FineTuning::FineTuningJob } - module FineTuning class FineTuningJob < OpenAI::BaseModel # The object identifier, which can be referenced in the API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the fine-tuning job was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # For fine-tuning jobs that have `failed`, this will contain more information on # the cause of the failure. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Error)) } - def error - end + attr_reader :error sig do - params(_: T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Error)) - .returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Error)) - end - def error=(_) + params(error: T.nilable(T.any(OpenAI::Models::FineTuning::FineTuningJob::Error, OpenAI::Util::AnyHash))) + .void end + attr_writer :error # The name of the fine-tuned model that is being created. The value will be null # if the fine-tuning job is still running. sig { returns(T.nilable(String)) } - def fine_tuned_model - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def fine_tuned_model=(_) - end + attr_accessor :fine_tuned_model # The Unix timestamp (in seconds) for when the fine-tuning job was finished. The # value will be null if the fine-tuning job is still running. sig { returns(T.nilable(Integer)) } - def finished_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def finished_at=(_) - end + attr_accessor :finished_at # The hyperparameters used for the fine-tuning job. This value will only be # returned when running `supervised` jobs. sig { returns(OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :hyperparameters # The base model that is being fine-tuned. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # The object type, which is always "fine_tuning.job". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The organization that owns the fine-tuning job. sig { returns(String) } - def organization_id - end - - sig { params(_: String).returns(String) } - def organization_id=(_) - end + attr_accessor :organization_id # The compiled results file ID(s) for the fine-tuning job. You can retrieve the # results with the # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). sig { returns(T::Array[String]) } - def result_files - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def result_files=(_) - end + attr_accessor :result_files # The seed used for the fine-tuning job. sig { returns(Integer) } - def seed - end - - sig { params(_: Integer).returns(Integer) } - def seed=(_) - end + attr_accessor :seed # The current status of the fine-tuning job, which can be either # `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) } + attr_accessor :status # The total number of billable tokens processed by this fine-tuning job. The value # will be null if the fine-tuning job is still running. sig { returns(T.nilable(Integer)) } - def trained_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def trained_tokens=(_) - end + attr_accessor :trained_tokens # The file ID used for training. You can retrieve the training data with the # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). sig { returns(String) } - def training_file - end - - sig { params(_: String).returns(String) } - def training_file=(_) - end + attr_accessor :training_file # The file ID used for validation. You can retrieve the validation results with # the # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). sig { returns(T.nilable(String)) } - def validation_file - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def validation_file=(_) - end + attr_accessor :validation_file # The Unix timestamp (in seconds) for when the fine-tuning job is estimated to # finish. The value will be null if the fine-tuning job is not running. sig { returns(T.nilable(Integer)) } - def estimated_finish - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def estimated_finish=(_) - end + attr_accessor :estimated_finish # A list of integrations to enable for this fine-tuning job. sig { returns(T.nilable(T::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject])) } - def integrations - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject])) - .returns(T.nilable(T::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject])) - end - def integrations=(_) - end + attr_accessor :integrations # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -186,25 +104,15 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The method used for fine-tuning. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method)) } - def method_ - end + attr_reader :method_ - sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Method) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Method) - end - def method_=(_) - end + sig { params(method_: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method, OpenAI::Util::AnyHash)).void } + attr_writer :method_ # The `fine_tuning.job` object represents a fine-tuning job that has been created # through the API. @@ -212,22 +120,24 @@ module OpenAI params( id: String, created_at: Integer, - error: T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Error), + error: T.nilable(T.any(OpenAI::Models::FineTuning::FineTuningJob::Error, OpenAI::Util::AnyHash)), fine_tuned_model: T.nilable(String), finished_at: T.nilable(Integer), - hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters, + hyperparameters: T.any(OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters, OpenAI::Util::AnyHash), model: String, organization_id: String, result_files: T::Array[String], seed: Integer, - status: Symbol, + status: OpenAI::Models::FineTuning::FineTuningJob::Status::OrSymbol, trained_tokens: T.nilable(Integer), training_file: String, validation_file: T.nilable(String), estimated_finish: T.nilable(Integer), - integrations: T.nilable(T::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject]), - metadata: T.nilable(OpenAI::Models::Metadata), - method_: OpenAI::Models::FineTuning::FineTuningJob::Method, + integrations: T.nilable( + T::Array[T.any(OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]), + method_: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method, OpenAI::Util::AnyHash), object: Symbol ) .returns(T.attached_class) @@ -270,13 +180,13 @@ module OpenAI organization_id: String, result_files: T::Array[String], seed: Integer, - status: Symbol, + status: OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol, trained_tokens: T.nilable(Integer), training_file: String, validation_file: T.nilable(String), estimated_finish: T.nilable(Integer), integrations: T.nilable(T::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject]), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), method_: OpenAI::Models::FineTuning::FineTuningJob::Method } ) @@ -287,31 +197,16 @@ module OpenAI class Error < OpenAI::BaseModel # A machine-readable error code. sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end + attr_accessor :code # A human-readable error message. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The parameter that was invalid, usually `training_file` or `validation_file`. # This field will be null if the failure was not parameter-specific. sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param # For fine-tuning jobs that have `failed`, this will contain more information on # the cause of the failure. @@ -328,32 +223,26 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. This value will only be # returned when running `supervised` jobs. @@ -383,84 +272,90 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end # The current status of the fine-tuning job, which can be either # `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::FineTuningJob::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + VALIDATING_FILES = + T.let(:validating_files, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) + QUEUED = T.let(:queued, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) + RUNNING = T.let(:running, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) + SUCCEEDED = T.let(:succeeded, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol) - VALIDATING_FILES = :validating_files - QUEUED = :queued - RUNNING = :running - SUCCEEDED = :succeeded - FAILED = :failed - CANCELLED = :cancelled + sig { override.returns(T::Array[OpenAI::Models::FineTuning::FineTuningJob::Status::TaggedSymbol]) } + def self.values + end end class Method < OpenAI::BaseModel # Configuration for the DPO fine-tuning method. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo)) } - def dpo - end + attr_reader :dpo - sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo) - end - def dpo=(_) - end + sig { params(dpo: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, OpenAI::Util::AnyHash)).void } + attr_writer :dpo # Configuration for the supervised fine-tuning method. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised)) } - def supervised - end + attr_reader :supervised sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised) - end - def supervised=(_) + params( + supervised: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :supervised # The type of method. Is either `supervised` or `dpo`. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::FineTuning::FineTuningJob::Method::Type::OrSymbol).void } + attr_writer :type # The method used for fine-tuning. sig do params( - dpo: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, - supervised: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, - type: Symbol + dpo: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, OpenAI::Util::AnyHash), + supervised: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, OpenAI::Util::AnyHash), + type: OpenAI::Models::FineTuning::FineTuningJob::Method::Type::OrSymbol ) .returns(T.attached_class) end @@ -473,7 +368,7 @@ module OpenAI { dpo: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, supervised: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, - type: Symbol + type: OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol } ) end @@ -483,19 +378,21 @@ module OpenAI class Dpo < OpenAI::BaseModel # The hyperparameters used for the fine-tuning job. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters)) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :hyperparameters # Configuration for the DPO fine-tuning method. sig do - params(hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters, OpenAI::Util::AnyHash) + ) .returns(T.attached_class) end def self.new(hyperparameters: nil) @@ -512,42 +409,34 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. sig { returns(T.nilable(T.any(Symbol, Float))) } - def beta - end + attr_reader :beta - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def beta=(_) - end + sig { params(beta: T.any(Symbol, Float)).void } + attr_writer :beta # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. sig do @@ -578,34 +467,42 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. - class Beta < OpenAI::Union - abstract! + module Beta + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end end @@ -613,19 +510,27 @@ module OpenAI class Supervised < OpenAI::BaseModel # The hyperparameters used for the fine-tuning job. sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters)) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters) - .returns(OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any( + OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :hyperparameters # Configuration for the supervised fine-tuning method. sig do - params(hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters) + params( + hyperparameters: T.any( + OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters, + OpenAI::Util::AnyHash + ) + ) .returns(T.attached_class) end def self.new(hyperparameters: nil) @@ -642,32 +547,26 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. sig do @@ -696,41 +595,55 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end end # The type of method. Is either `supervised` or `dpo`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::FineTuningJob::Method::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol) } - SUPERVISED = :supervised - DPO = :dpo + SUPERVISED = T.let(:supervised, OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol) + DPO = T.let(:dpo, OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::FineTuning::FineTuningJob::Method::Type::TaggedSymbol]) } + def self.values + end end end end end + + FineTuningJob = FineTuning::FineTuningJob end end diff --git a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_event.rbi b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_event.rbi index b1e399d7..73e56f74 100644 --- a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_event.rbi +++ b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_event.rbi @@ -2,87 +2,64 @@ module OpenAI module Models - FineTuningJobEvent = T.type_alias { FineTuning::FineTuningJobEvent } - module FineTuning class FineTuningJobEvent < OpenAI::BaseModel # The object identifier. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the fine-tuning job was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The log level of the event. - sig { returns(Symbol) } - def level - end - - sig { params(_: Symbol).returns(Symbol) } - def level=(_) - end + sig { returns(OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol) } + attr_accessor :level # The message of the event. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The object type, which is always "fine_tuning.job.event". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The data associated with the event. sig { returns(T.nilable(T.anything)) } - def data - end + attr_reader :data - sig { params(_: T.anything).returns(T.anything) } - def data=(_) - end + sig { params(data: T.anything).void } + attr_writer :data # The type of event. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::FineTuning::FineTuningJobEvent::Type::OrSymbol).void } + attr_writer :type # Fine-tuning job event object sig do params( id: String, created_at: Integer, - level: Symbol, + level: OpenAI::Models::FineTuning::FineTuningJobEvent::Level::OrSymbol, message: String, data: T.anything, - type: Symbol, + type: OpenAI::Models::FineTuning::FineTuningJobEvent::Type::OrSymbol, object: Symbol ) .returns(T.attached_class) end - def self.new(id:, created_at:, level:, message:, data: nil, type: nil, object: :"fine_tuning.job.event") + def self.new( + id:, + created_at:, + level:, + message:, + data: nil, + type: nil, + object: :"fine_tuning.job.event" + ) end sig do @@ -91,11 +68,11 @@ module OpenAI { id: String, created_at: Integer, - level: Symbol, + level: OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol, message: String, object: Symbol, data: T.anything, - type: Symbol + type: OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol } ) end @@ -103,26 +80,40 @@ module OpenAI end # The log level of the event. - class Level < OpenAI::Enum - abstract! + module Level + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Level) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol) } - INFO = :info - WARN = :warn - ERROR = :error + INFO = T.let(:info, OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol) + WARN = T.let(:warn, OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol) + ERROR = T.let(:error, OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::Level::TaggedSymbol]) } + def self.values + end end # The type of event. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MESSAGE = T.let(:message, OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol) + METRICS = T.let(:metrics, OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol) - MESSAGE = :message - METRICS = :metrics + sig { override.returns(T::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::Type::TaggedSymbol]) } + def self.values + end end end end + + FineTuningJobEvent = FineTuning::FineTuningJobEvent end end diff --git a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_integration.rbi b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_integration.rbi index d1f932e5..8a6c1da1 100644 --- a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_integration.rbi +++ b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_integration.rbi @@ -2,10 +2,10 @@ module OpenAI module Models - FineTuningJobIntegration = T.type_alias { FineTuning::FineTuningJobIntegration } - module FineTuning - FineTuningJobIntegration = T.type_alias { OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject } + FineTuningJobIntegration = OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject end + + FineTuningJobIntegration = FineTuning::FineTuningJobIntegration end end diff --git a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbi b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbi index f3899e11..315342d0 100644 --- a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbi +++ b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbi @@ -2,50 +2,31 @@ module OpenAI module Models - FineTuningJobWandbIntegration = T.type_alias { FineTuning::FineTuningJobWandbIntegration } - module FineTuning class FineTuningJobWandbIntegration < OpenAI::BaseModel # The name of the project that the new run will be created under. sig { returns(String) } - def project - end - - sig { params(_: String).returns(String) } - def project=(_) - end + attr_accessor :project # The entity to use for the run. This allows you to set the team or username of # the WandB user that you would like associated with the run. If not set, the # default entity for the registered WandB API key is used. sig { returns(T.nilable(String)) } - def entity - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def entity=(_) - end + attr_accessor :entity # A display name to set for the run. If not set, we will use the Job ID as the # name. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name # A list of tags to be attached to the newly created run. These tags are passed # through directly to WandB. Some default tags are generated by OpenAI: # "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". sig { returns(T.nilable(T::Array[String])) } - def tags - end + attr_reader :tags - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def tags=(_) - end + sig { params(tags: T::Array[String]).void } + attr_writer :tags # The settings for your integration with Weights and Biases. This payload # specifies the project that metrics will be sent to. Optionally, you can set an @@ -71,5 +52,7 @@ module OpenAI end end end + + FineTuningJobWandbIntegration = FineTuning::FineTuningJobWandbIntegration end end diff --git a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbi b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbi index f6af3f86..79b69c52 100644 --- a/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbi +++ b/rbi/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbi @@ -2,36 +2,27 @@ module OpenAI module Models - FineTuningJobWandbIntegrationObject = T.type_alias { FineTuning::FineTuningJobWandbIntegrationObject } - module FineTuning class FineTuningJobWandbIntegrationObject < OpenAI::BaseModel # The type of the integration being enabled for the fine-tuning job sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The settings for your integration with Weights and Biases. This payload # specifies the project that metrics will be sent to. Optionally, you can set an # explicit display name for your run, add tags to your run, and set a default # entity (team, username, etc) to be associated with your run. sig { returns(OpenAI::Models::FineTuning::FineTuningJobWandbIntegration) } - def wandb - end + attr_reader :wandb - sig do - params(_: OpenAI::Models::FineTuning::FineTuningJobWandbIntegration) - .returns(OpenAI::Models::FineTuning::FineTuningJobWandbIntegration) - end - def wandb=(_) - end + sig { params(wandb: T.any(OpenAI::Models::FineTuning::FineTuningJobWandbIntegration, OpenAI::Util::AnyHash)).void } + attr_writer :wandb sig do - params(wandb: OpenAI::Models::FineTuning::FineTuningJobWandbIntegration, type: Symbol) + params( + wandb: T.any(OpenAI::Models::FineTuning::FineTuningJobWandbIntegration, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(wandb:, type: :wandb) @@ -42,5 +33,7 @@ module OpenAI end end end + + FineTuningJobWandbIntegrationObject = FineTuning::FineTuningJobWandbIntegrationObject end end diff --git a/rbi/lib/openai/models/fine_tuning/job_cancel_params.rbi b/rbi/lib/openai/models/fine_tuning/job_cancel_params.rbi index bdc32d2b..d9429091 100644 --- a/rbi/lib/openai/models/fine_tuning/job_cancel_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/job_cancel_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module FineTuning class JobCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/fine_tuning/job_create_params.rbi b/rbi/lib/openai/models/fine_tuning/job_create_params.rbi index 224616d6..3844e2ce 100644 --- a/rbi/lib/openai/models/fine_tuning/job_create_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/job_create_params.rbi @@ -4,18 +4,13 @@ module OpenAI module Models module FineTuning class JobCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The name of the model to fine-tune. You can select one of the # [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::FineTuning::JobCreateParams::Model::OrSymbol)) } + attr_accessor :model # The ID of an uploaded file that contains training data. # @@ -35,37 +30,24 @@ module OpenAI # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) # for more details. sig { returns(String) } - def training_file - end - - sig { params(_: String).returns(String) } - def training_file=(_) - end + attr_accessor :training_file # The hyperparameters used for the fine-tuning job. This value is now deprecated # in favor of `method`, and should be passed in under the `method` parameter. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters)) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :hyperparameters # A list of integrations to enable for your fine-tuning job. sig { returns(T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration])) } - def integrations - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration])) - .returns(T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration])) - end - def integrations=(_) - end + attr_accessor :integrations # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -73,36 +55,21 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The method used for fine-tuning. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method)) } - def method_ - end + attr_reader :method_ - sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Method) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Method) - end - def method_=(_) - end + sig { params(method_: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method, OpenAI::Util::AnyHash)).void } + attr_writer :method_ # The seed controls the reproducibility of the job. Passing in the same seed and # job parameters should produce the same results, but may differ in rare cases. If # a seed is not specified, one will be generated for you. sig { returns(T.nilable(Integer)) } - def seed - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def seed=(_) - end + attr_accessor :seed # A string of up to 64 characters that will be added to your fine-tuned model # name. @@ -110,12 +77,7 @@ module OpenAI # For example, a `suffix` of "custom-model-name" would produce a model name like # `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`. sig { returns(T.nilable(String)) } - def suffix - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def suffix=(_) - end + attr_accessor :suffix # The ID of an uploaded file that contains validation data. # @@ -130,25 +92,22 @@ module OpenAI # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) # for more details. sig { returns(T.nilable(String)) } - def validation_file - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def validation_file=(_) - end + attr_accessor :validation_file sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::FineTuning::JobCreateParams::Model::OrSymbol), training_file: String, - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, - integrations: T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]), - metadata: T.nilable(OpenAI::Models::Metadata), - method_: OpenAI::Models::FineTuning::JobCreateParams::Method, + hyperparameters: T.any(OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, OpenAI::Util::AnyHash), + integrations: T.nilable( + T::Array[T.any(OpenAI::Models::FineTuning::JobCreateParams::Integration, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]), + method_: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method, OpenAI::Util::AnyHash), seed: T.nilable(Integer), suffix: T.nilable(String), validation_file: T.nilable(String), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -170,11 +129,11 @@ module OpenAI override .returns( { - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::FineTuning::JobCreateParams::Model::OrSymbol), training_file: String, hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, integrations: T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), method_: OpenAI::Models::FineTuning::JobCreateParams::Method, seed: T.nilable(Integer), suffix: T.nilable(String), @@ -188,42 +147,47 @@ module OpenAI # The name of the model to fine-tune. You can select one of the # [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::FineTuning::JobCreateParams::Model::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model::TaggedSymbol) } - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + BABBAGE_002 = T.let(:"babbage-002", OpenAI::Models::FineTuning::JobCreateParams::Model::TaggedSymbol) + DAVINCI_002 = T.let(:"davinci-002", OpenAI::Models::FineTuning::JobCreateParams::Model::TaggedSymbol) + GPT_3_5_TURBO = T.let(:"gpt-3.5-turbo", OpenAI::Models::FineTuning::JobCreateParams::Model::TaggedSymbol) + GPT_4O_MINI = T.let(:"gpt-4o-mini", OpenAI::Models::FineTuning::JobCreateParams::Model::TaggedSymbol) end class Hyperparameters < OpenAI::BaseModel # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. This value is now deprecated # in favor of `method`, and should be passed in under the `method` parameter. @@ -253,26 +217,32 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end @@ -280,30 +250,28 @@ module OpenAI # The type of integration to enable. Currently, only "wandb" (Weights and Biases) # is supported. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The settings for your integration with Weights and Biases. This payload # specifies the project that metrics will be sent to. Optionally, you can set an # explicit display name for your run, add tags to your run, and set a default # entity (team, username, etc) to be associated with your run. sig { returns(OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb) } - def wandb - end + attr_reader :wandb sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb) - end - def wandb=(_) + params( + wandb: T.any(OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :wandb sig do - params(wandb: OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb, type: Symbol) + params( + wandb: T.any(OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(wandb:, type: :wandb) @@ -316,44 +284,27 @@ module OpenAI class Wandb < OpenAI::BaseModel # The name of the project that the new run will be created under. sig { returns(String) } - def project - end - - sig { params(_: String).returns(String) } - def project=(_) - end + attr_accessor :project # The entity to use for the run. This allows you to set the team or username of # the WandB user that you would like associated with the run. If not set, the # default entity for the registered WandB API key is used. sig { returns(T.nilable(String)) } - def entity - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def entity=(_) - end + attr_accessor :entity # A display name to set for the run. If not set, we will use the Job ID as the # name. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name # A list of tags to be attached to the newly created run. These tags are passed # through directly to WandB. Some default tags are generated by OpenAI: # "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". sig { returns(T.nilable(T::Array[String])) } - def tags - end + attr_reader :tags - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def tags=(_) - end + sig { params(tags: T::Array[String]).void } + attr_writer :tags # The settings for your integration with Weights and Biases. This payload # specifies the project that metrics will be sent to. Optionally, you can set an @@ -388,43 +339,36 @@ module OpenAI class Method < OpenAI::BaseModel # Configuration for the DPO fine-tuning method. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo)) } - def dpo - end + attr_reader :dpo - sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo) - end - def dpo=(_) - end + sig { params(dpo: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, OpenAI::Util::AnyHash)).void } + attr_writer :dpo # Configuration for the supervised fine-tuning method. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised)) } - def supervised - end + attr_reader :supervised sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised) - end - def supervised=(_) + params( + supervised: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :supervised # The type of method. Is either `supervised` or `dpo`. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method::Type::OrSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::FineTuning::JobCreateParams::Method::Type::OrSymbol).void } + attr_writer :type # The method used for fine-tuning. sig do params( - dpo: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, - supervised: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, - type: Symbol + dpo: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, OpenAI::Util::AnyHash), + supervised: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, OpenAI::Util::AnyHash), + type: OpenAI::Models::FineTuning::JobCreateParams::Method::Type::OrSymbol ) .returns(T.attached_class) end @@ -437,7 +381,7 @@ module OpenAI { dpo: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, supervised: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, - type: Symbol + type: OpenAI::Models::FineTuning::JobCreateParams::Method::Type::OrSymbol } ) end @@ -447,19 +391,21 @@ module OpenAI class Dpo < OpenAI::BaseModel # The hyperparameters used for the fine-tuning job. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters)) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :hyperparameters # Configuration for the DPO fine-tuning method. sig do - params(hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters) + params( + hyperparameters: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters, OpenAI::Util::AnyHash) + ) .returns(T.attached_class) end def self.new(hyperparameters: nil) @@ -476,42 +422,34 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. sig { returns(T.nilable(T.any(Symbol, Float))) } - def beta - end + attr_reader :beta - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def beta=(_) - end + sig { params(beta: T.any(Symbol, Float)).void } + attr_writer :beta # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. sig do @@ -542,34 +480,42 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # The beta value for the DPO method. A higher beta value will increase the weight # of the penalty between the policy and reference model. - class Beta < OpenAI::Union - abstract! + module Beta + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end end @@ -577,19 +523,27 @@ module OpenAI class Supervised < OpenAI::BaseModel # The hyperparameters used for the fine-tuning job. sig { returns(T.nilable(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters)) } - def hyperparameters - end + attr_reader :hyperparameters sig do - params(_: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters) - .returns(OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters) - end - def hyperparameters=(_) + params( + hyperparameters: T.any( + OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters, + OpenAI::Util::AnyHash + ) + ) + .void end + attr_writer :hyperparameters # Configuration for the supervised fine-tuning method. sig do - params(hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters) + params( + hyperparameters: T.any( + OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters, + OpenAI::Util::AnyHash + ) + ) .returns(T.attached_class) end def self.new(hyperparameters: nil) @@ -608,32 +562,26 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def batch_size - end + attr_reader :batch_size - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def batch_size=(_) - end + sig { params(batch_size: T.any(Symbol, Integer)).void } + attr_writer :batch_size # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. sig { returns(T.nilable(T.any(Symbol, Float))) } - def learning_rate_multiplier - end + attr_reader :learning_rate_multiplier - sig { params(_: T.any(Symbol, Float)).returns(T.any(Symbol, Float)) } - def learning_rate_multiplier=(_) - end + sig { params(learning_rate_multiplier: T.any(Symbol, Float)).void } + attr_writer :learning_rate_multiplier # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. sig { returns(T.nilable(T.any(Symbol, Integer))) } - def n_epochs - end + attr_reader :n_epochs - sig { params(_: T.any(Symbol, Integer)).returns(T.any(Symbol, Integer)) } - def n_epochs=(_) - end + sig { params(n_epochs: T.any(Symbol, Integer)).void } + attr_writer :n_epochs # The hyperparameters used for the fine-tuning job. sig do @@ -662,38 +610,50 @@ module OpenAI # Number of examples in each batch. A larger batch size means that model # parameters are updated less frequently, but with lower variance. - class BatchSize < OpenAI::Union - abstract! + module BatchSize + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end # Scaling factor for the learning rate. A smaller learning rate may be useful to # avoid overfitting. - class LearningRateMultiplier < OpenAI::Union - abstract! + module LearningRateMultiplier + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Float)} } + sig { override.returns([Symbol, Float]) } + def self.variants + end end # The number of epochs to train the model for. An epoch refers to one full cycle # through the training dataset. - class NEpochs < OpenAI::Union - abstract! + module NEpochs + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(Symbol, Integer)} } + sig { override.returns([Symbol, Integer]) } + def self.variants + end end end end # The type of method. Is either `supervised` or `dpo`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::FineTuning::JobCreateParams::Method::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::FineTuning::JobCreateParams::Method::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + SUPERVISED = T.let(:supervised, OpenAI::Models::FineTuning::JobCreateParams::Method::Type::TaggedSymbol) + DPO = T.let(:dpo, OpenAI::Models::FineTuning::JobCreateParams::Method::Type::TaggedSymbol) - SUPERVISED = :supervised - DPO = :dpo + sig { override.returns(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Method::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/fine_tuning/job_list_events_params.rbi b/rbi/lib/openai/models/fine_tuning/job_list_events_params.rbi index fc4ede17..0bfecb02 100644 --- a/rbi/lib/openai/models/fine_tuning/job_list_events_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/job_list_events_params.rbi @@ -4,32 +4,28 @@ module OpenAI module Models module FineTuning class JobListEventsParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Identifier for the last event from the previous pagination request. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # Number of events to retrieve. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit sig do params( after: String, limit: Integer, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/fine_tuning/job_list_params.rbi b/rbi/lib/openai/models/fine_tuning/job_list_params.rbi index 6e667d46..62697ccd 100644 --- a/rbi/lib/openai/models/fine_tuning/job_list_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/job_list_params.rbi @@ -4,43 +4,34 @@ module OpenAI module Models module FineTuning class JobListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Identifier for the last job from the previous pagination request. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # Number of fine-tuning jobs to retrieve. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Optional metadata filter. To filter, use the syntax `metadata[k]=v`. # Alternatively, set `metadata=null` to indicate no metadata. sig { returns(T.nilable(T::Hash[Symbol, String])) } - def metadata - end - - sig { params(_: T.nilable(T::Hash[Symbol, String])).returns(T.nilable(T::Hash[Symbol, String])) } - def metadata=(_) - end + attr_accessor :metadata sig do params( after: String, limit: Integer, metadata: T.nilable(T::Hash[Symbol, String]), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/fine_tuning/job_retrieve_params.rbi b/rbi/lib/openai/models/fine_tuning/job_retrieve_params.rbi index 238e3029..4fadf667 100644 --- a/rbi/lib/openai/models/fine_tuning/job_retrieve_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/job_retrieve_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module FineTuning class JobRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rbi b/rbi/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rbi index 27b1407f..70dcc5c6 100644 --- a/rbi/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rbi +++ b/rbi/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rbi @@ -5,32 +5,28 @@ module OpenAI module FineTuning module Jobs class CheckpointListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Identifier for the last checkpoint ID from the previous pagination request. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # Number of checkpoints to retrieve. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit sig do params( after: String, limit: Integer, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbi b/rbi/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbi index 54fe9d93..de47d120 100644 --- a/rbi/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbi +++ b/rbi/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbi @@ -7,69 +7,39 @@ module OpenAI class FineTuningJobCheckpoint < OpenAI::BaseModel # The checkpoint identifier, which can be referenced in the API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the checkpoint was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The name of the fine-tuned checkpoint model that is created. sig { returns(String) } - def fine_tuned_model_checkpoint - end - - sig { params(_: String).returns(String) } - def fine_tuned_model_checkpoint=(_) - end + attr_accessor :fine_tuned_model_checkpoint # The name of the fine-tuning job that this checkpoint was created from. sig { returns(String) } - def fine_tuning_job_id - end - - sig { params(_: String).returns(String) } - def fine_tuning_job_id=(_) - end + attr_accessor :fine_tuning_job_id # Metrics at the step number during the fine-tuning job. sig { returns(OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics) } - def metrics - end + attr_reader :metrics sig do - params(_: OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics) - .returns(OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics) - end - def metrics=(_) + params( + metrics: T.any(OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :metrics # The object type, which is always "fine_tuning.job.checkpoint". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The step number that the checkpoint was created at. sig { returns(Integer) } - def step_number - end - - sig { params(_: Integer).returns(Integer) } - def step_number=(_) - end + attr_accessor :step_number # The `fine_tuning.job.checkpoint` object represents a model checkpoint for a # fine-tuning job that is ready to use. @@ -79,7 +49,7 @@ module OpenAI created_at: Integer, fine_tuned_model_checkpoint: String, fine_tuning_job_id: String, - metrics: OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics, + metrics: T.any(OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics, OpenAI::Util::AnyHash), step_number: Integer, object: Symbol ) @@ -115,60 +85,46 @@ module OpenAI class Metrics < OpenAI::BaseModel sig { returns(T.nilable(Float)) } - def full_valid_loss - end + attr_reader :full_valid_loss - sig { params(_: Float).returns(Float) } - def full_valid_loss=(_) - end + sig { params(full_valid_loss: Float).void } + attr_writer :full_valid_loss sig { returns(T.nilable(Float)) } - def full_valid_mean_token_accuracy - end + attr_reader :full_valid_mean_token_accuracy - sig { params(_: Float).returns(Float) } - def full_valid_mean_token_accuracy=(_) - end + sig { params(full_valid_mean_token_accuracy: Float).void } + attr_writer :full_valid_mean_token_accuracy sig { returns(T.nilable(Float)) } - def step - end + attr_reader :step - sig { params(_: Float).returns(Float) } - def step=(_) - end + sig { params(step: Float).void } + attr_writer :step sig { returns(T.nilable(Float)) } - def train_loss - end + attr_reader :train_loss - sig { params(_: Float).returns(Float) } - def train_loss=(_) - end + sig { params(train_loss: Float).void } + attr_writer :train_loss sig { returns(T.nilable(Float)) } - def train_mean_token_accuracy - end + attr_reader :train_mean_token_accuracy - sig { params(_: Float).returns(Float) } - def train_mean_token_accuracy=(_) - end + sig { params(train_mean_token_accuracy: Float).void } + attr_writer :train_mean_token_accuracy sig { returns(T.nilable(Float)) } - def valid_loss - end + attr_reader :valid_loss - sig { params(_: Float).returns(Float) } - def valid_loss=(_) - end + sig { params(valid_loss: Float).void } + attr_writer :valid_loss sig { returns(T.nilable(Float)) } - def valid_mean_token_accuracy - end + attr_reader :valid_mean_token_accuracy - sig { params(_: Float).returns(Float) } - def valid_mean_token_accuracy=(_) - end + sig { params(valid_mean_token_accuracy: Float).void } + attr_writer :valid_mean_token_accuracy # Metrics at the step number during the fine-tuning job. sig do diff --git a/rbi/lib/openai/models/function_definition.rbi b/rbi/lib/openai/models/function_definition.rbi index 75a4000f..f1bad3a8 100644 --- a/rbi/lib/openai/models/function_definition.rbi +++ b/rbi/lib/openai/models/function_definition.rbi @@ -6,22 +6,15 @@ module OpenAI # The name of the function to be called. Must be a-z, A-Z, 0-9, or contain # underscores and dashes, with a maximum length of 64. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # A description of what the function does, used by the model to choose when and # how to call the function. sig { returns(T.nilable(String)) } - def description - end + attr_reader :description - sig { params(_: String).returns(String) } - def description=(_) - end + sig { params(description: String).void } + attr_writer :description # The parameters the functions accepts, described as a JSON Schema object. See the # [guide](https://platform.openai.com/docs/guides/function-calling) for examples, @@ -30,13 +23,11 @@ module OpenAI # documentation about the format. # # Omitting `parameters` defines a function with an empty parameter list. - sig { returns(T.nilable(OpenAI::Models::FunctionParameters)) } - def parameters - end + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :parameters - sig { params(_: OpenAI::Models::FunctionParameters).returns(OpenAI::Models::FunctionParameters) } - def parameters=(_) - end + sig { params(parameters: T::Hash[Symbol, T.anything]).void } + attr_writer :parameters # Whether to enable strict schema adherence when generating the function call. If # set to true, the model will follow the exact schema defined in the `parameters` @@ -44,18 +35,13 @@ module OpenAI # more about Structured Outputs in the # [function calling guide](docs/guides/function-calling). sig { returns(T.nilable(T::Boolean)) } - def strict - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def strict=(_) - end + attr_accessor :strict sig do params( name: String, description: String, - parameters: OpenAI::Models::FunctionParameters, + parameters: T::Hash[Symbol, T.anything], strict: T.nilable(T::Boolean) ) .returns(T.attached_class) @@ -66,7 +52,12 @@ module OpenAI sig do override .returns( - {name: String, description: String, parameters: OpenAI::Models::FunctionParameters, strict: T.nilable(T::Boolean)} + { + name: String, + description: String, + parameters: T::Hash[Symbol, T.anything], + strict: T.nilable(T::Boolean) + } ) end def to_hash diff --git a/rbi/lib/openai/models/function_parameters.rbi b/rbi/lib/openai/models/function_parameters.rbi index 4a46a5a2..8b20436c 100644 --- a/rbi/lib/openai/models/function_parameters.rbi +++ b/rbi/lib/openai/models/function_parameters.rbi @@ -2,6 +2,6 @@ module OpenAI module Models - FunctionParameters = T.type_alias { T::Hash[Symbol, T.anything] } + FunctionParameters = T.let(OpenAI::HashOf[OpenAI::Unknown], OpenAI::Type::Converter) end end diff --git a/rbi/lib/openai/models/image.rbi b/rbi/lib/openai/models/image.rbi index 3c0fc4fa..5af93081 100644 --- a/rbi/lib/openai/models/image.rbi +++ b/rbi/lib/openai/models/image.rbi @@ -6,31 +6,25 @@ module OpenAI # The base64-encoded JSON of the generated image, if `response_format` is # `b64_json`. sig { returns(T.nilable(String)) } - def b64_json - end + attr_reader :b64_json - sig { params(_: String).returns(String) } - def b64_json=(_) - end + sig { params(b64_json: String).void } + attr_writer :b64_json # The prompt that was used to generate the image, if there was any revision to the # prompt. sig { returns(T.nilable(String)) } - def revised_prompt - end + attr_reader :revised_prompt - sig { params(_: String).returns(String) } - def revised_prompt=(_) - end + sig { params(revised_prompt: String).void } + attr_writer :revised_prompt # The URL of the generated image, if `response_format` is `url` (default). sig { returns(T.nilable(String)) } - def url - end + attr_reader :url - sig { params(_: String).returns(String) } - def url=(_) - end + sig { params(url: String).void } + attr_writer :url # Represents the url or the content of an image generated by the OpenAI API. sig { params(b64_json: String, revised_prompt: String, url: String).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/image_create_variation_params.rbi b/rbi/lib/openai/models/image_create_variation_params.rbi index 285e3c70..80245291 100644 --- a/rbi/lib/openai/models/image_create_variation_params.rbi +++ b/rbi/lib/openai/models/image_create_variation_params.rbi @@ -3,84 +3,65 @@ module OpenAI module Models class ImageCreateVariationParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The image to use as the basis for the variation(s). Must be a valid PNG file, # less than 4MB, and square. sig { returns(T.any(IO, StringIO)) } - def image - end - - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def image=(_) - end + attr_accessor :image # The model to use for image generation. Only `dall-e-2` is supported at this # time. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end - - sig { params(_: T.nilable(T.any(String, Symbol))).returns(T.nilable(T.any(String, Symbol))) } - def model=(_) - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol))) } + attr_accessor :model # The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only # `n=1` is supported. sig { returns(T.nilable(Integer)) } - def n - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def n=(_) - end + attr_accessor :n # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - sig { returns(T.nilable(Symbol)) } - def response_format - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def response_format=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageCreateVariationParams::ResponseFormat::OrSymbol)) } + attr_accessor :response_format # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - sig { returns(T.nilable(Symbol)) } - def size - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def size=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageCreateVariationParams::Size::OrSymbol)) } + attr_accessor :size # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( image: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageCreateVariationParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageCreateVariationParams::Size::OrSymbol), user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(image:, model: nil, n: nil, response_format: nil, size: nil, user: nil, request_options: {}) + def self.new( + image:, + model: nil, + n: nil, + response_format: nil, + size: nil, + user: nil, + request_options: {} + ) end sig do @@ -88,10 +69,10 @@ module OpenAI .returns( { image: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageCreateVariationParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageCreateVariationParams::Size::OrSymbol), user: String, request_options: OpenAI::RequestOptions } @@ -102,34 +83,47 @@ module OpenAI # The model to use for image generation. Only `dall-e-2` is supported at this # time. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ImageModel::OrSymbol]) } + def self.variants + end end # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum - abstract! + module ResponseFormat + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageCreateVariationParams::ResponseFormat) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::ImageCreateVariationParams::ResponseFormat::TaggedSymbol) } - URL = :url - B64_JSON = :b64_json + URL = T.let(:url, OpenAI::Models::ImageCreateVariationParams::ResponseFormat::TaggedSymbol) + B64_JSON = T.let(:b64_json, OpenAI::Models::ImageCreateVariationParams::ResponseFormat::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ImageCreateVariationParams::ResponseFormat::TaggedSymbol]) } + def self.values + end end # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - class Size < OpenAI::Enum - abstract! + module Size + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageCreateVariationParams::Size) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageCreateVariationParams::Size::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + NUMBER_256X256 = T.let(:"256x256", OpenAI::Models::ImageCreateVariationParams::Size::TaggedSymbol) + NUMBER_512X512 = T.let(:"512x512", OpenAI::Models::ImageCreateVariationParams::Size::TaggedSymbol) + NUMBER_1024X1024 = T.let(:"1024x1024", OpenAI::Models::ImageCreateVariationParams::Size::TaggedSymbol) - NUMBER_256X256 = :"256x256" - NUMBER_512X512 = :"512x512" - NUMBER_1024X1024 = :"1024x1024" + sig { override.returns(T::Array[OpenAI::Models::ImageCreateVariationParams::Size::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/image_edit_params.rbi b/rbi/lib/openai/models/image_edit_params.rbi index b672e912..130b145b 100644 --- a/rbi/lib/openai/models/image_edit_params.rbi +++ b/rbi/lib/openai/models/image_edit_params.rbi @@ -3,102 +3,68 @@ module OpenAI module Models class ImageEditParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask # is not provided, image must have transparency, which will be used as the mask. sig { returns(T.any(IO, StringIO)) } - def image - end - - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def image=(_) - end + attr_accessor :image # A text description of the desired image(s). The maximum length is 1000 # characters. sig { returns(String) } - def prompt - end - - sig { params(_: String).returns(String) } - def prompt=(_) - end + attr_accessor :prompt # An additional image whose fully transparent areas (e.g. where alpha is zero) # indicate where `image` should be edited. Must be a valid PNG file, less than # 4MB, and have the same dimensions as `image`. sig { returns(T.nilable(T.any(IO, StringIO))) } - def mask - end + attr_reader :mask - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def mask=(_) - end + sig { params(mask: T.any(IO, StringIO)).void } + attr_writer :mask # The model to use for image generation. Only `dall-e-2` is supported at this # time. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end - - sig { params(_: T.nilable(T.any(String, Symbol))).returns(T.nilable(T.any(String, Symbol))) } - def model=(_) - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol))) } + attr_accessor :model # The number of images to generate. Must be between 1 and 10. sig { returns(T.nilable(Integer)) } - def n - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def n=(_) - end + attr_accessor :n # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - sig { returns(T.nilable(Symbol)) } - def response_format - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def response_format=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageEditParams::ResponseFormat::OrSymbol)) } + attr_accessor :response_format # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - sig { returns(T.nilable(Symbol)) } - def size - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def size=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageEditParams::Size::OrSymbol)) } + attr_accessor :size # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( image: T.any(IO, StringIO), prompt: String, mask: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageEditParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageEditParams::Size::OrSymbol), user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -122,10 +88,10 @@ module OpenAI image: T.any(IO, StringIO), prompt: String, mask: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageEditParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageEditParams::Size::OrSymbol), user: String, request_options: OpenAI::RequestOptions } @@ -136,34 +102,46 @@ module OpenAI # The model to use for image generation. Only `dall-e-2` is supported at this # time. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ImageModel::OrSymbol]) } + def self.variants + end end # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum - abstract! + module ResponseFormat + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageEditParams::ResponseFormat) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageEditParams::ResponseFormat::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + URL = T.let(:url, OpenAI::Models::ImageEditParams::ResponseFormat::TaggedSymbol) + B64_JSON = T.let(:b64_json, OpenAI::Models::ImageEditParams::ResponseFormat::TaggedSymbol) - URL = :url - B64_JSON = :b64_json + sig { override.returns(T::Array[OpenAI::Models::ImageEditParams::ResponseFormat::TaggedSymbol]) } + def self.values + end end # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024`. - class Size < OpenAI::Enum - abstract! + module Size + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageEditParams::Size) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageEditParams::Size::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + NUMBER_256X256 = T.let(:"256x256", OpenAI::Models::ImageEditParams::Size::TaggedSymbol) + NUMBER_512X512 = T.let(:"512x512", OpenAI::Models::ImageEditParams::Size::TaggedSymbol) + NUMBER_1024X1024 = T.let(:"1024x1024", OpenAI::Models::ImageEditParams::Size::TaggedSymbol) - NUMBER_256X256 = :"256x256" - NUMBER_512X512 = :"512x512" - NUMBER_1024X1024 = :"1024x1024" + sig { override.returns(T::Array[OpenAI::Models::ImageEditParams::Size::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/image_generate_params.rbi b/rbi/lib/openai/models/image_generate_params.rbi index 7fccc54c..5cdd5c58 100644 --- a/rbi/lib/openai/models/image_generate_params.rbi +++ b/rbi/lib/openai/models/image_generate_params.rbi @@ -3,105 +3,71 @@ module OpenAI module Models class ImageGenerateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A text description of the desired image(s). The maximum length is 1000 # characters for `dall-e-2` and 4000 characters for `dall-e-3`. sig { returns(String) } - def prompt - end - - sig { params(_: String).returns(String) } - def prompt=(_) - end + attr_accessor :prompt # The model to use for image generation. - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end - - sig { params(_: T.nilable(T.any(String, Symbol))).returns(T.nilable(T.any(String, Symbol))) } - def model=(_) - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol))) } + attr_accessor :model # The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only # `n=1` is supported. sig { returns(T.nilable(Integer)) } - def n - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def n=(_) - end + attr_accessor :n # The quality of the image that will be generated. `hd` creates images with finer # details and greater consistency across the image. This param is only supported # for `dall-e-3`. - sig { returns(T.nilable(Symbol)) } - def quality - end + sig { returns(T.nilable(OpenAI::Models::ImageGenerateParams::Quality::OrSymbol)) } + attr_reader :quality - sig { params(_: Symbol).returns(Symbol) } - def quality=(_) - end + sig { params(quality: OpenAI::Models::ImageGenerateParams::Quality::OrSymbol).void } + attr_writer :quality # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - sig { returns(T.nilable(Symbol)) } - def response_format - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def response_format=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageGenerateParams::ResponseFormat::OrSymbol)) } + attr_accessor :response_format # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or # `1024x1792` for `dall-e-3` models. - sig { returns(T.nilable(Symbol)) } - def size - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def size=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageGenerateParams::Size::OrSymbol)) } + attr_accessor :size # The style of the generated images. Must be one of `vivid` or `natural`. Vivid # causes the model to lean towards generating hyper-real and dramatic images. # Natural causes the model to produce more natural, less hyper-real looking # images. This param is only supported for `dall-e-3`. - sig { returns(T.nilable(Symbol)) } - def style - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def style=(_) - end + sig { returns(T.nilable(OpenAI::Models::ImageGenerateParams::Style::OrSymbol)) } + attr_accessor :style # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( prompt: String, - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - quality: Symbol, - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), - style: T.nilable(Symbol), + quality: OpenAI::Models::ImageGenerateParams::Quality::OrSymbol, + response_format: T.nilable(OpenAI::Models::ImageGenerateParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageGenerateParams::Size::OrSymbol), + style: T.nilable(OpenAI::Models::ImageGenerateParams::Style::OrSymbol), user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -123,12 +89,12 @@ module OpenAI .returns( { prompt: String, - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - quality: Symbol, - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), - style: T.nilable(Symbol), + quality: OpenAI::Models::ImageGenerateParams::Quality::OrSymbol, + response_format: T.nilable(OpenAI::Models::ImageGenerateParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageGenerateParams::Size::OrSymbol), + style: T.nilable(OpenAI::Models::ImageGenerateParams::Style::OrSymbol), user: String, request_options: OpenAI::RequestOptions } @@ -138,62 +104,85 @@ module OpenAI end # The model to use for image generation. - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ImageModel::OrSymbol]) } + def self.variants + end end # The quality of the image that will be generated. `hd` creates images with finer # details and greater consistency across the image. This param is only supported # for `dall-e-3`. - class Quality < OpenAI::Enum - abstract! + module Quality + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageGenerateParams::Quality) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageGenerateParams::Quality::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + STANDARD = T.let(:standard, OpenAI::Models::ImageGenerateParams::Quality::TaggedSymbol) + HD = T.let(:hd, OpenAI::Models::ImageGenerateParams::Quality::TaggedSymbol) - STANDARD = :standard - HD = :hd + sig { override.returns(T::Array[OpenAI::Models::ImageGenerateParams::Quality::TaggedSymbol]) } + def self.values + end end # The format in which the generated images are returned. Must be one of `url` or # `b64_json`. URLs are only valid for 60 minutes after the image has been # generated. - class ResponseFormat < OpenAI::Enum - abstract! + module ResponseFormat + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat::TaggedSymbol) } - URL = :url - B64_JSON = :b64_json + URL = T.let(:url, OpenAI::Models::ImageGenerateParams::ResponseFormat::TaggedSymbol) + B64_JSON = T.let(:b64_json, OpenAI::Models::ImageGenerateParams::ResponseFormat::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ImageGenerateParams::ResponseFormat::TaggedSymbol]) } + def self.values + end end # The size of the generated images. Must be one of `256x256`, `512x512`, or # `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or # `1024x1792` for `dall-e-3` models. - class Size < OpenAI::Enum - abstract! + module Size + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageGenerateParams::Size) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + NUMBER_256X256 = T.let(:"256x256", OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) + NUMBER_512X512 = T.let(:"512x512", OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) + NUMBER_1024X1024 = T.let(:"1024x1024", OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) + NUMBER_1792X1024 = T.let(:"1792x1024", OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) + NUMBER_1024X1792 = T.let(:"1024x1792", OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol) - NUMBER_256X256 = :"256x256" - NUMBER_512X512 = :"512x512" - NUMBER_1024X1024 = :"1024x1024" - NUMBER_1792X1024 = :"1792x1024" - NUMBER_1024X1792 = :"1024x1792" + sig { override.returns(T::Array[OpenAI::Models::ImageGenerateParams::Size::TaggedSymbol]) } + def self.values + end end # The style of the generated images. Must be one of `vivid` or `natural`. Vivid # causes the model to lean towards generating hyper-real and dramatic images. # Natural causes the model to produce more natural, less hyper-real looking # images. This param is only supported for `dall-e-3`. - class Style < OpenAI::Enum - abstract! + module Style + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageGenerateParams::Style) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageGenerateParams::Style::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + VIVID = T.let(:vivid, OpenAI::Models::ImageGenerateParams::Style::TaggedSymbol) + NATURAL = T.let(:natural, OpenAI::Models::ImageGenerateParams::Style::TaggedSymbol) - VIVID = :vivid - NATURAL = :natural + sig { override.returns(T::Array[OpenAI::Models::ImageGenerateParams::Style::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/image_model.rbi b/rbi/lib/openai/models/image_model.rbi index 6716a390..6e7b06d9 100644 --- a/rbi/lib/openai/models/image_model.rbi +++ b/rbi/lib/openai/models/image_model.rbi @@ -2,13 +2,18 @@ module OpenAI module Models - class ImageModel < OpenAI::Enum - abstract! + module ImageModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ImageModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ImageModel::TaggedSymbol) } - DALL_E_2 = :"dall-e-2" - DALL_E_3 = :"dall-e-3" + DALL_E_2 = T.let(:"dall-e-2", OpenAI::Models::ImageModel::TaggedSymbol) + DALL_E_3 = T.let(:"dall-e-3", OpenAI::Models::ImageModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ImageModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/images_response.rbi b/rbi/lib/openai/models/images_response.rbi index e9537809..5395968e 100644 --- a/rbi/lib/openai/models/images_response.rbi +++ b/rbi/lib/openai/models/images_response.rbi @@ -4,22 +4,15 @@ module OpenAI module Models class ImagesResponse < OpenAI::BaseModel sig { returns(Integer) } - def created - end - - sig { params(_: Integer).returns(Integer) } - def created=(_) - end + attr_accessor :created sig { returns(T::Array[OpenAI::Models::Image]) } - def data - end + attr_accessor :data - sig { params(_: T::Array[OpenAI::Models::Image]).returns(T::Array[OpenAI::Models::Image]) } - def data=(_) + sig do + params(created: Integer, data: T::Array[T.any(OpenAI::Models::Image, OpenAI::Util::AnyHash)]) + .returns(T.attached_class) end - - sig { params(created: Integer, data: T::Array[OpenAI::Models::Image]).returns(T.attached_class) } def self.new(created:, data:) end diff --git a/rbi/lib/openai/models/metadata.rbi b/rbi/lib/openai/models/metadata.rbi index 634c341b..9b99c6d0 100644 --- a/rbi/lib/openai/models/metadata.rbi +++ b/rbi/lib/openai/models/metadata.rbi @@ -2,6 +2,6 @@ module OpenAI module Models - Metadata = T.type_alias { T.nilable(T::Hash[Symbol, String]) } + Metadata = T.let(OpenAI::HashOf[String], OpenAI::Type::Converter) end end diff --git a/rbi/lib/openai/models/model.rbi b/rbi/lib/openai/models/model.rbi index 07b59908..556bb5fc 100644 --- a/rbi/lib/openai/models/model.rbi +++ b/rbi/lib/openai/models/model.rbi @@ -5,39 +5,19 @@ module OpenAI class Model < OpenAI::BaseModel # The model identifier, which can be referenced in the API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) when the model was created. sig { returns(Integer) } - def created - end - - sig { params(_: Integer).returns(Integer) } - def created=(_) - end + attr_accessor :created # The object type, which is always "model". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The organization that owns the model. sig { returns(String) } - def owned_by - end - - sig { params(_: String).returns(String) } - def owned_by=(_) - end + attr_accessor :owned_by # Describes an OpenAI model offering that can be used with the API. sig { params(id: String, created: Integer, owned_by: String, object: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/model_delete_params.rbi b/rbi/lib/openai/models/model_delete_params.rbi index ad6f9bd8..53253e49 100644 --- a/rbi/lib/openai/models/model_delete_params.rbi +++ b/rbi/lib/openai/models/model_delete_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class ModelDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/model_deleted.rbi b/rbi/lib/openai/models/model_deleted.rbi index 6ed7605b..9888bb84 100644 --- a/rbi/lib/openai/models/model_deleted.rbi +++ b/rbi/lib/openai/models/model_deleted.rbi @@ -4,28 +4,13 @@ module OpenAI module Models class ModelDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(String) } - def object - end - - sig { params(_: String).returns(String) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: String).returns(T.attached_class) } def self.new(id:, deleted:, object:) diff --git a/rbi/lib/openai/models/model_list_params.rbi b/rbi/lib/openai/models/model_list_params.rbi index 90fef299..ccea7e8a 100644 --- a/rbi/lib/openai/models/model_list_params.rbi +++ b/rbi/lib/openai/models/model_list_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class ModelListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/model_retrieve_params.rbi b/rbi/lib/openai/models/model_retrieve_params.rbi index dc7fc8c5..c6b05f8c 100644 --- a/rbi/lib/openai/models/model_retrieve_params.rbi +++ b/rbi/lib/openai/models/model_retrieve_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class ModelRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/moderation.rbi b/rbi/lib/openai/models/moderation.rbi index c430dd8a..bcf566f6 100644 --- a/rbi/lib/openai/models/moderation.rbi +++ b/rbi/lib/openai/models/moderation.rbi @@ -5,48 +5,39 @@ module OpenAI class Moderation < OpenAI::BaseModel # A list of the categories, and whether they are flagged or not. sig { returns(OpenAI::Models::Moderation::Categories) } - def categories - end + attr_reader :categories - sig { params(_: OpenAI::Models::Moderation::Categories).returns(OpenAI::Models::Moderation::Categories) } - def categories=(_) - end + sig { params(categories: T.any(OpenAI::Models::Moderation::Categories, OpenAI::Util::AnyHash)).void } + attr_writer :categories # A list of the categories along with the input type(s) that the score applies to. sig { returns(OpenAI::Models::Moderation::CategoryAppliedInputTypes) } - def category_applied_input_types - end + attr_reader :category_applied_input_types sig do - params(_: OpenAI::Models::Moderation::CategoryAppliedInputTypes) - .returns(OpenAI::Models::Moderation::CategoryAppliedInputTypes) - end - def category_applied_input_types=(_) + params( + category_applied_input_types: T.any(OpenAI::Models::Moderation::CategoryAppliedInputTypes, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :category_applied_input_types # A list of the categories along with their scores as predicted by model. sig { returns(OpenAI::Models::Moderation::CategoryScores) } - def category_scores - end + attr_reader :category_scores - sig { params(_: OpenAI::Models::Moderation::CategoryScores).returns(OpenAI::Models::Moderation::CategoryScores) } - def category_scores=(_) - end + sig { params(category_scores: T.any(OpenAI::Models::Moderation::CategoryScores, OpenAI::Util::AnyHash)).void } + attr_writer :category_scores # Whether any of the below categories are flagged. sig { returns(T::Boolean) } - def flagged - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def flagged=(_) - end + attr_accessor :flagged sig do params( - categories: OpenAI::Models::Moderation::Categories, - category_applied_input_types: OpenAI::Models::Moderation::CategoryAppliedInputTypes, - category_scores: OpenAI::Models::Moderation::CategoryScores, + categories: T.any(OpenAI::Models::Moderation::Categories, OpenAI::Util::AnyHash), + category_applied_input_types: T.any(OpenAI::Models::Moderation::CategoryAppliedInputTypes, OpenAI::Util::AnyHash), + category_scores: T.any(OpenAI::Models::Moderation::CategoryScores, OpenAI::Util::AnyHash), flagged: T::Boolean ) .returns(T.attached_class) @@ -72,136 +63,71 @@ module OpenAI # Content that expresses, incites, or promotes harassing language towards any # target. sig { returns(T::Boolean) } - def harassment - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def harassment=(_) - end + attr_accessor :harassment # Harassment content that also includes violence or serious harm towards any # target. sig { returns(T::Boolean) } - def harassment_threatening - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def harassment_threatening=(_) - end + attr_accessor :harassment_threatening # Content that expresses, incites, or promotes hate based on race, gender, # ethnicity, religion, nationality, sexual orientation, disability status, or # caste. Hateful content aimed at non-protected groups (e.g., chess players) is # harassment. sig { returns(T::Boolean) } - def hate - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def hate=(_) - end + attr_accessor :hate # Hateful content that also includes violence or serious harm towards the targeted # group based on race, gender, ethnicity, religion, nationality, sexual # orientation, disability status, or caste. sig { returns(T::Boolean) } - def hate_threatening - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def hate_threatening=(_) - end + attr_accessor :hate_threatening # Content that includes instructions or advice that facilitate the planning or # execution of wrongdoing, or that gives advice or instruction on how to commit # illicit acts. For example, "how to shoplift" would fit this category. sig { returns(T.nilable(T::Boolean)) } - def illicit - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def illicit=(_) - end + attr_accessor :illicit # Content that includes instructions or advice that facilitate the planning or # execution of wrongdoing that also includes violence, or that gives advice or # instruction on the procurement of any weapon. sig { returns(T.nilable(T::Boolean)) } - def illicit_violent - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def illicit_violent=(_) - end + attr_accessor :illicit_violent # Content that promotes, encourages, or depicts acts of self-harm, such as # suicide, cutting, and eating disorders. sig { returns(T::Boolean) } - def self_harm - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def self_harm=(_) - end + attr_accessor :self_harm # Content that encourages performing acts of self-harm, such as suicide, cutting, # and eating disorders, or that gives instructions or advice on how to commit such # acts. sig { returns(T::Boolean) } - def self_harm_instructions - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def self_harm_instructions=(_) - end + attr_accessor :self_harm_instructions # Content where the speaker expresses that they are engaging or intend to engage # in acts of self-harm, such as suicide, cutting, and eating disorders. sig { returns(T::Boolean) } - def self_harm_intent - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def self_harm_intent=(_) - end + attr_accessor :self_harm_intent # Content meant to arouse sexual excitement, such as the description of sexual # activity, or that promotes sexual services (excluding sex education and # wellness). sig { returns(T::Boolean) } - def sexual - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def sexual=(_) - end + attr_accessor :sexual # Sexual content that includes an individual who is under 18 years old. sig { returns(T::Boolean) } - def sexual_minors - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def sexual_minors=(_) - end + attr_accessor :sexual_minors # Content that depicts death, violence, or physical injury. sig { returns(T::Boolean) } - def violence - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def violence=(_) - end + attr_accessor :violence # Content that depicts death, violence, or physical injury in graphic detail. sig { returns(T::Boolean) } - def violence_graphic - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def violence_graphic=(_) - end + attr_accessor :violence_graphic # A list of the categories, and whether they are flagged or not. sig do @@ -265,138 +191,81 @@ module OpenAI class CategoryAppliedInputTypes < OpenAI::BaseModel # The applied input type(s) for the category 'harassment'. - sig { returns(T::Array[Symbol]) } - def harassment - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def harassment=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::TaggedSymbol]) } + attr_accessor :harassment # The applied input type(s) for the category 'harassment/threatening'. - sig { returns(T::Array[Symbol]) } - def harassment_threatening - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def harassment_threatening=(_) + sig do + returns( + T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::TaggedSymbol] + ) end + attr_accessor :harassment_threatening # The applied input type(s) for the category 'hate'. - sig { returns(T::Array[Symbol]) } - def hate - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def hate=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::TaggedSymbol]) } + attr_accessor :hate # The applied input type(s) for the category 'hate/threatening'. - sig { returns(T::Array[Symbol]) } - def hate_threatening - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def hate_threatening=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::TaggedSymbol]) } + attr_accessor :hate_threatening # The applied input type(s) for the category 'illicit'. - sig { returns(T::Array[Symbol]) } - def illicit - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def illicit=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::TaggedSymbol]) } + attr_accessor :illicit # The applied input type(s) for the category 'illicit/violent'. - sig { returns(T::Array[Symbol]) } - def illicit_violent - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def illicit_violent=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::TaggedSymbol]) } + attr_accessor :illicit_violent # The applied input type(s) for the category 'self-harm'. - sig { returns(T::Array[Symbol]) } - def self_harm - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def self_harm=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol]) } + attr_accessor :self_harm # The applied input type(s) for the category 'self-harm/instructions'. - sig { returns(T::Array[Symbol]) } - def self_harm_instructions - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def self_harm_instructions=(_) + sig do + returns( + T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol] + ) end + attr_accessor :self_harm_instructions # The applied input type(s) for the category 'self-harm/intent'. - sig { returns(T::Array[Symbol]) } - def self_harm_intent - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def self_harm_intent=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol]) } + attr_accessor :self_harm_intent # The applied input type(s) for the category 'sexual'. - sig { returns(T::Array[Symbol]) } - def sexual - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def sexual=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol]) } + attr_accessor :sexual # The applied input type(s) for the category 'sexual/minors'. - sig { returns(T::Array[Symbol]) } - def sexual_minors - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def sexual_minors=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::TaggedSymbol]) } + attr_accessor :sexual_minors # The applied input type(s) for the category 'violence'. - sig { returns(T::Array[Symbol]) } - def violence - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def violence=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol]) } + attr_accessor :violence # The applied input type(s) for the category 'violence/graphic'. - sig { returns(T::Array[Symbol]) } - def violence_graphic - end - - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def violence_graphic=(_) - end + sig { returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol]) } + attr_accessor :violence_graphic # A list of the categories along with the input type(s) that the score applies to. sig do params( - harassment: T::Array[Symbol], - harassment_threatening: T::Array[Symbol], - hate: T::Array[Symbol], - hate_threatening: T::Array[Symbol], - illicit: T::Array[Symbol], - illicit_violent: T::Array[Symbol], - self_harm: T::Array[Symbol], - self_harm_instructions: T::Array[Symbol], - self_harm_intent: T::Array[Symbol], - sexual: T::Array[Symbol], - sexual_minors: T::Array[Symbol], - violence: T::Array[Symbol], - violence_graphic: T::Array[Symbol] + harassment: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::OrSymbol], + harassment_threatening: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::OrSymbol], + hate: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::OrSymbol], + hate_threatening: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::OrSymbol], + illicit: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::OrSymbol], + illicit_violent: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::OrSymbol], + self_harm: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::OrSymbol], + self_harm_instructions: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::OrSymbol], + self_harm_intent: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::OrSymbol], + sexual: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::OrSymbol], + sexual_minors: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::OrSymbol], + violence: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::OrSymbol], + violence_graphic: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::OrSymbol] ) .returns(T.attached_class) end @@ -421,253 +290,311 @@ module OpenAI override .returns( { - harassment: T::Array[Symbol], - harassment_threatening: T::Array[Symbol], - hate: T::Array[Symbol], - hate_threatening: T::Array[Symbol], - illicit: T::Array[Symbol], - illicit_violent: T::Array[Symbol], - self_harm: T::Array[Symbol], - self_harm_instructions: T::Array[Symbol], - self_harm_intent: T::Array[Symbol], - sexual: T::Array[Symbol], - sexual_minors: T::Array[Symbol], - violence: T::Array[Symbol], - violence_graphic: T::Array[Symbol] + harassment: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::TaggedSymbol], + harassment_threatening: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::TaggedSymbol], + hate: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::TaggedSymbol], + hate_threatening: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::TaggedSymbol], + illicit: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::TaggedSymbol], + illicit_violent: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::TaggedSymbol], + self_harm: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol], + self_harm_instructions: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol], + self_harm_intent: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol], + sexual: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol], + sexual_minors: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::TaggedSymbol], + violence: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol], + violence_graphic: T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol] } ) end def to_hash end - class Harassment < OpenAI::Enum - abstract! + module Harassment + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::TaggedSymbol) - TEXT = :text + sig do + override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment::TaggedSymbol]) + end + def self.values + end end - class HarassmentThreatening < OpenAI::Enum - abstract! + module HarassmentThreatening + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = + T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::TaggedSymbol) - TEXT = :text + sig do + override + .returns( + T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening::TaggedSymbol] + ) + end + def self.values + end end - class Hate < OpenAI::Enum - abstract! + module Hate + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::TaggedSymbol) } - TEXT = :text + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate::TaggedSymbol]) } + def self.values + end end - class HateThreatening < OpenAI::Enum - abstract! + module HateThreatening + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::TaggedSymbol) - TEXT = :text + sig do + override + .returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening::TaggedSymbol]) + end + def self.values + end end - class Illicit < OpenAI::Enum - abstract! + module Illicit + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::TaggedSymbol) } - TEXT = :text + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit::TaggedSymbol]) } + def self.values + end end - class IllicitViolent < OpenAI::Enum - abstract! + module IllicitViolent + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::TaggedSymbol) - TEXT = :text + sig do + override + .returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent::TaggedSymbol]) + end + def self.values + end end - class SelfHarm < OpenAI::Enum - abstract! + module SelfHarm + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol) } - TEXT = :text - IMAGE = :image + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol) + IMAGE = T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm::TaggedSymbol]) } + def self.values + end end - class SelfHarmInstruction < OpenAI::Enum - abstract! + module SelfHarmInstruction + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = + T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol) + IMAGE = + T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol) - TEXT = :text - IMAGE = :image + sig do + override + .returns( + T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction::TaggedSymbol] + ) + end + def self.values + end end - class SelfHarmIntent < OpenAI::Enum - abstract! + module SelfHarmIntent + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol) } - TEXT = :text - IMAGE = :image + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol) + IMAGE = + T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent::TaggedSymbol]) + end + def self.values + end end - class Sexual < OpenAI::Enum - abstract! + module Sexual + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol) + IMAGE = T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol) - TEXT = :text - IMAGE = :image + sig { override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual::TaggedSymbol]) } + def self.values + end end - class SexualMinor < OpenAI::Enum - abstract! + module SexualMinor + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::TaggedSymbol) - TEXT = :text + sig do + override + .returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor::TaggedSymbol]) + end + def self.values + end end - class Violence < OpenAI::Enum - abstract! + module Violence + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol) } - TEXT = :text - IMAGE = :image + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol) + IMAGE = T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence::TaggedSymbol]) } + def self.values + end end - class ViolenceGraphic < OpenAI::Enum - abstract! + module ViolenceGraphic + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol) + IMAGE = + T.let(:image, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol) - TEXT = :text - IMAGE = :image + sig do + override + .returns(T::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic::TaggedSymbol]) + end + def self.values + end end end class CategoryScores < OpenAI::BaseModel # The score for the category 'harassment'. sig { returns(Float) } - def harassment - end - - sig { params(_: Float).returns(Float) } - def harassment=(_) - end + attr_accessor :harassment # The score for the category 'harassment/threatening'. sig { returns(Float) } - def harassment_threatening - end - - sig { params(_: Float).returns(Float) } - def harassment_threatening=(_) - end + attr_accessor :harassment_threatening # The score for the category 'hate'. sig { returns(Float) } - def hate - end - - sig { params(_: Float).returns(Float) } - def hate=(_) - end + attr_accessor :hate # The score for the category 'hate/threatening'. sig { returns(Float) } - def hate_threatening - end - - sig { params(_: Float).returns(Float) } - def hate_threatening=(_) - end + attr_accessor :hate_threatening # The score for the category 'illicit'. sig { returns(Float) } - def illicit - end - - sig { params(_: Float).returns(Float) } - def illicit=(_) - end + attr_accessor :illicit # The score for the category 'illicit/violent'. sig { returns(Float) } - def illicit_violent - end - - sig { params(_: Float).returns(Float) } - def illicit_violent=(_) - end + attr_accessor :illicit_violent # The score for the category 'self-harm'. sig { returns(Float) } - def self_harm - end - - sig { params(_: Float).returns(Float) } - def self_harm=(_) - end + attr_accessor :self_harm # The score for the category 'self-harm/instructions'. sig { returns(Float) } - def self_harm_instructions - end - - sig { params(_: Float).returns(Float) } - def self_harm_instructions=(_) - end + attr_accessor :self_harm_instructions # The score for the category 'self-harm/intent'. sig { returns(Float) } - def self_harm_intent - end - - sig { params(_: Float).returns(Float) } - def self_harm_intent=(_) - end + attr_accessor :self_harm_intent # The score for the category 'sexual'. sig { returns(Float) } - def sexual - end - - sig { params(_: Float).returns(Float) } - def sexual=(_) - end + attr_accessor :sexual # The score for the category 'sexual/minors'. sig { returns(Float) } - def sexual_minors - end - - sig { params(_: Float).returns(Float) } - def sexual_minors=(_) - end + attr_accessor :sexual_minors # The score for the category 'violence'. sig { returns(Float) } - def violence - end - - sig { params(_: Float).returns(Float) } - def violence=(_) - end + attr_accessor :violence # The score for the category 'violence/graphic'. sig { returns(Float) } - def violence_graphic - end - - sig { params(_: Float).returns(Float) } - def violence_graphic=(_) - end + attr_accessor :violence_graphic # A list of the categories along with their scores as predicted by model. sig do diff --git a/rbi/lib/openai/models/moderation_create_params.rbi b/rbi/lib/openai/models/moderation_create_params.rbi index e00a5df9..0f79bac9 100644 --- a/rbi/lib/openai/models/moderation_create_params.rbi +++ b/rbi/lib/openai/models/moderation_create_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class ModerationCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Input (or inputs) to classify. Can be a single string, an array of strings, or @@ -17,49 +17,27 @@ module OpenAI ) ) end - def input - end - - sig do - params( - _: T.any( - String, - T::Array[String], - T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] - ) - ) - .returns( - T.any( - String, - T::Array[String], - T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] - ) - ) - end - def input=(_) - end + attr_accessor :input # The content moderation model you would like to use. Learn more in # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and # learn about available models # [here](https://platform.openai.com/docs/models#moderation). - sig { returns(T.nilable(T.any(String, Symbol))) } - def model - end + sig { returns(T.nilable(T.any(String, OpenAI::Models::ModerationModel::OrSymbol))) } + attr_reader :model - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { params(model: T.any(String, OpenAI::Models::ModerationModel::OrSymbol)).void } + attr_writer :model sig do params( input: T.any( String, T::Array[String], - T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] + T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Util::AnyHash, OpenAI::Models::ModerationTextInput)] ), - model: T.any(String, Symbol), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + model: T.any(String, OpenAI::Models::ModerationModel::OrSymbol), + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -75,7 +53,7 @@ module OpenAI T::Array[String], T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] ), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::ModerationModel::OrSymbol), request_options: OpenAI::RequestOptions } ) @@ -85,32 +63,34 @@ module OpenAI # Input (or inputs) to classify. Can be a single string, an array of strings, or # an array of multi-modal input objects similar to other models. - class Input < OpenAI::Union - abstract! + module Input + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - String, - T::Array[String], - T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] + sig do + override + .returns( + [String, T::Array[String], T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)]] ) - } + end + def self.variants end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) - ModerationMultiModalInputArray = T.type_alias { T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] } + ModerationMultiModalInputArray = + T.let(OpenAI::ArrayOf[union: OpenAI::Models::ModerationMultiModalInput], OpenAI::Type::Converter) end # The content moderation model you would like to use. Learn more in # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and # learn about available models # [here](https://platform.openai.com/docs/models#moderation). - class Model < OpenAI::Union - abstract! + module Model + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + sig { override.returns([String, OpenAI::Models::ModerationModel::OrSymbol]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/moderation_create_response.rbi b/rbi/lib/openai/models/moderation_create_response.rbi index bf831d82..0de2d5b0 100644 --- a/rbi/lib/openai/models/moderation_create_response.rbi +++ b/rbi/lib/openai/models/moderation_create_response.rbi @@ -5,33 +5,25 @@ module OpenAI class ModerationCreateResponse < OpenAI::BaseModel # The unique identifier for the moderation request. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The model used to generate the moderation results. sig { returns(String) } - def model - end - - sig { params(_: String).returns(String) } - def model=(_) - end + attr_accessor :model # A list of moderation objects. sig { returns(T::Array[OpenAI::Models::Moderation]) } - def results - end - - sig { params(_: T::Array[OpenAI::Models::Moderation]).returns(T::Array[OpenAI::Models::Moderation]) } - def results=(_) - end + attr_accessor :results # Represents if a given text input is potentially harmful. - sig { params(id: String, model: String, results: T::Array[OpenAI::Models::Moderation]).returns(T.attached_class) } + sig do + params( + id: String, + model: String, + results: T::Array[T.any(OpenAI::Models::Moderation, OpenAI::Util::AnyHash)] + ) + .returns(T.attached_class) + end def self.new(id:, model:, results:) end diff --git a/rbi/lib/openai/models/moderation_image_url_input.rbi b/rbi/lib/openai/models/moderation_image_url_input.rbi index 222a1447..5d3fb30a 100644 --- a/rbi/lib/openai/models/moderation_image_url_input.rbi +++ b/rbi/lib/openai/models/moderation_image_url_input.rbi @@ -5,28 +5,21 @@ module OpenAI class ModerationImageURLInput < OpenAI::BaseModel # Contains either an image URL or a data URL for a base64 encoded image. sig { returns(OpenAI::Models::ModerationImageURLInput::ImageURL) } - def image_url - end + attr_reader :image_url - sig do - params(_: OpenAI::Models::ModerationImageURLInput::ImageURL) - .returns(OpenAI::Models::ModerationImageURLInput::ImageURL) - end - def image_url=(_) - end + sig { params(image_url: T.any(OpenAI::Models::ModerationImageURLInput::ImageURL, OpenAI::Util::AnyHash)).void } + attr_writer :image_url # Always `image_url`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An object describing an image to classify. sig do - params(image_url: OpenAI::Models::ModerationImageURLInput::ImageURL, type: Symbol) + params( + image_url: T.any(OpenAI::Models::ModerationImageURLInput::ImageURL, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(image_url:, type: :image_url) @@ -39,12 +32,7 @@ module OpenAI class ImageURL < OpenAI::BaseModel # Either a URL of the image or the base64 encoded image data. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # Contains either an image URL or a data URL for a base64 encoded image. sig { params(url: String).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/moderation_model.rbi b/rbi/lib/openai/models/moderation_model.rbi index a34a1f36..d3f8dff4 100644 --- a/rbi/lib/openai/models/moderation_model.rbi +++ b/rbi/lib/openai/models/moderation_model.rbi @@ -2,15 +2,21 @@ module OpenAI module Models - class ModerationModel < OpenAI::Enum - abstract! + module ModerationModel + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ModerationModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ModerationModel::TaggedSymbol) } - OMNI_MODERATION_LATEST = :"omni-moderation-latest" - OMNI_MODERATION_2024_09_26 = :"omni-moderation-2024-09-26" - TEXT_MODERATION_LATEST = :"text-moderation-latest" - TEXT_MODERATION_STABLE = :"text-moderation-stable" + OMNI_MODERATION_LATEST = T.let(:"omni-moderation-latest", OpenAI::Models::ModerationModel::TaggedSymbol) + OMNI_MODERATION_2024_09_26 = + T.let(:"omni-moderation-2024-09-26", OpenAI::Models::ModerationModel::TaggedSymbol) + TEXT_MODERATION_LATEST = T.let(:"text-moderation-latest", OpenAI::Models::ModerationModel::TaggedSymbol) + TEXT_MODERATION_STABLE = T.let(:"text-moderation-stable", OpenAI::Models::ModerationModel::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ModerationModel::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/moderation_multi_modal_input.rbi b/rbi/lib/openai/models/moderation_multi_modal_input.rbi index a24328fc..9c96d7b0 100644 --- a/rbi/lib/openai/models/moderation_multi_modal_input.rbi +++ b/rbi/lib/openai/models/moderation_multi_modal_input.rbi @@ -3,10 +3,12 @@ module OpenAI module Models # An object describing an image to classify. - class ModerationMultiModalInput < OpenAI::Union - abstract! + module ModerationMultiModalInput + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)} } + sig { override.returns([OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/moderation_text_input.rbi b/rbi/lib/openai/models/moderation_text_input.rbi index 41888533..dddf6d0b 100644 --- a/rbi/lib/openai/models/moderation_text_input.rbi +++ b/rbi/lib/openai/models/moderation_text_input.rbi @@ -5,21 +5,11 @@ module OpenAI class ModerationTextInput < OpenAI::BaseModel # A string of text to classify. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Always `text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An object describing text to classify. sig { params(text: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/other_file_chunking_strategy_object.rbi b/rbi/lib/openai/models/other_file_chunking_strategy_object.rbi index db3ddb71..14da388e 100644 --- a/rbi/lib/openai/models/other_file_chunking_strategy_object.rbi +++ b/rbi/lib/openai/models/other_file_chunking_strategy_object.rbi @@ -5,12 +5,7 @@ module OpenAI class OtherFileChunkingStrategyObject < OpenAI::BaseModel # Always `other`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # This is returned when the chunking strategy is unknown. Typically, this is # because the file was indexed before the `chunking_strategy` concept was diff --git a/rbi/lib/openai/models/reasoning.rbi b/rbi/lib/openai/models/reasoning.rbi index e6f69e82..aef3d79c 100644 --- a/rbi/lib/openai/models/reasoning.rbi +++ b/rbi/lib/openai/models/reasoning.rbi @@ -9,51 +9,60 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - sig { returns(T.nilable(Symbol)) } - def effort - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def effort=(_) - end + sig { returns(T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol)) } + attr_accessor :effort - # **o-series models only** + # **computer_use_preview only** # # A summary of the reasoning performed by the model. This can be useful for # debugging and understanding the model's reasoning process. One of `concise` or # `detailed`. - sig { returns(T.nilable(Symbol)) } - def generate_summary - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def generate_summary=(_) - end + sig { returns(T.nilable(OpenAI::Models::Reasoning::GenerateSummary::OrSymbol)) } + attr_accessor :generate_summary # **o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). - sig { params(effort: T.nilable(Symbol), generate_summary: T.nilable(Symbol)).returns(T.attached_class) } - def self.new(effort:, generate_summary: nil) + sig do + params( + effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), + generate_summary: T.nilable(OpenAI::Models::Reasoning::GenerateSummary::OrSymbol) + ) + .returns(T.attached_class) + end + def self.new(effort: nil, generate_summary: nil) end - sig { override.returns({effort: T.nilable(Symbol), generate_summary: T.nilable(Symbol)}) } + sig do + override + .returns( + { + effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), + generate_summary: T.nilable(OpenAI::Models::Reasoning::GenerateSummary::OrSymbol) + } + ) + end def to_hash end - # **o-series models only** + # **computer_use_preview only** # # A summary of the reasoning performed by the model. This can be useful for # debugging and understanding the model's reasoning process. One of `concise` or # `detailed`. - class GenerateSummary < OpenAI::Enum - abstract! + module GenerateSummary + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Reasoning::GenerateSummary) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Reasoning::GenerateSummary::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + CONCISE = T.let(:concise, OpenAI::Models::Reasoning::GenerateSummary::TaggedSymbol) + DETAILED = T.let(:detailed, OpenAI::Models::Reasoning::GenerateSummary::TaggedSymbol) - CONCISE = :concise - DETAILED = :detailed + sig { override.returns(T::Array[OpenAI::Models::Reasoning::GenerateSummary::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/reasoning_effort.rbi b/rbi/lib/openai/models/reasoning_effort.rbi index dcca18c9..0563845c 100644 --- a/rbi/lib/openai/models/reasoning_effort.rbi +++ b/rbi/lib/openai/models/reasoning_effort.rbi @@ -8,14 +8,19 @@ module OpenAI # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can # result in faster responses and fewer tokens used on reasoning in a response. - class ReasoningEffort < OpenAI::Enum - abstract! + module ReasoningEffort + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ReasoningEffort) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ReasoningEffort::TaggedSymbol) } - LOW = :low - MEDIUM = :medium - HIGH = :high + LOW = T.let(:low, OpenAI::Models::ReasoningEffort::TaggedSymbol) + MEDIUM = T.let(:medium, OpenAI::Models::ReasoningEffort::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::ReasoningEffort::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::ReasoningEffort::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/response_format_json_object.rbi b/rbi/lib/openai/models/response_format_json_object.rbi index 044c6ff6..331cb19e 100644 --- a/rbi/lib/openai/models/response_format_json_object.rbi +++ b/rbi/lib/openai/models/response_format_json_object.rbi @@ -5,12 +5,7 @@ module OpenAI class ResponseFormatJSONObject < OpenAI::BaseModel # The type of response format being defined. Always `json_object`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # JSON object response format. An older method of generating JSON responses. Using # `json_schema` is recommended for models that support it. Note that the model diff --git a/rbi/lib/openai/models/response_format_json_schema.rbi b/rbi/lib/openai/models/response_format_json_schema.rbi index de32d2a7..ea87d33f 100644 --- a/rbi/lib/openai/models/response_format_json_schema.rbi +++ b/rbi/lib/openai/models/response_format_json_schema.rbi @@ -5,30 +5,26 @@ module OpenAI class ResponseFormatJSONSchema < OpenAI::BaseModel # Structured Outputs configuration options, including a JSON Schema. sig { returns(OpenAI::Models::ResponseFormatJSONSchema::JSONSchema) } - def json_schema - end + attr_reader :json_schema sig do - params(_: OpenAI::Models::ResponseFormatJSONSchema::JSONSchema) - .returns(OpenAI::Models::ResponseFormatJSONSchema::JSONSchema) - end - def json_schema=(_) + params(json_schema: T.any(OpenAI::Models::ResponseFormatJSONSchema::JSONSchema, OpenAI::Util::AnyHash)) + .void end + attr_writer :json_schema # The type of response format being defined. Always `json_schema`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # JSON Schema response format. Used to generate structured JSON responses. Learn # more about # [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). sig do - params(json_schema: OpenAI::Models::ResponseFormatJSONSchema::JSONSchema, type: Symbol) + params( + json_schema: T.any(OpenAI::Models::ResponseFormatJSONSchema::JSONSchema, OpenAI::Util::AnyHash), + type: Symbol + ) .returns(T.attached_class) end def self.new(json_schema:, type: :json_schema) @@ -42,32 +38,23 @@ module OpenAI # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores # and dashes, with a maximum length of 64. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # A description of what the response format is for, used by the model to determine # how to respond in the format. sig { returns(T.nilable(String)) } - def description - end + attr_reader :description - sig { params(_: String).returns(String) } - def description=(_) - end + sig { params(description: String).void } + attr_writer :description # The schema for the response format, described as a JSON Schema object. Learn how # to build JSON schemas [here](https://json-schema.org/). sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } - def schema - end + attr_reader :schema - sig { params(_: T::Hash[Symbol, T.anything]).returns(T::Hash[Symbol, T.anything]) } - def schema=(_) - end + sig { params(schema: T::Hash[Symbol, T.anything]).void } + attr_writer :schema # Whether to enable strict schema adherence when generating the output. If set to # true, the model will always follow the exact schema defined in the `schema` @@ -75,12 +62,7 @@ module OpenAI # learn more, read the # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). sig { returns(T.nilable(T::Boolean)) } - def strict - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def strict=(_) - end + attr_accessor :strict # Structured Outputs configuration options, including a JSON Schema. sig do diff --git a/rbi/lib/openai/models/response_format_text.rbi b/rbi/lib/openai/models/response_format_text.rbi index 2894efdf..a4b2db5e 100644 --- a/rbi/lib/openai/models/response_format_text.rbi +++ b/rbi/lib/openai/models/response_format_text.rbi @@ -5,12 +5,7 @@ module OpenAI class ResponseFormatText < OpenAI::BaseModel # The type of response format being defined. Always `text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Default response format. Used to generate text responses. sig { params(type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/computer_tool.rbi b/rbi/lib/openai/models/responses/computer_tool.rbi index 40b9918f..10f57a60 100644 --- a/rbi/lib/openai/models/responses/computer_tool.rbi +++ b/rbi/lib/openai/models/responses/computer_tool.rbi @@ -6,65 +6,64 @@ module OpenAI class ComputerTool < OpenAI::BaseModel # The height of the computer display. sig { returns(Float) } - def display_height - end - - sig { params(_: Float).returns(Float) } - def display_height=(_) - end + attr_accessor :display_height # The width of the computer display. sig { returns(Float) } - def display_width - end - - sig { params(_: Float).returns(Float) } - def display_width=(_) - end + attr_accessor :display_width # The type of computer environment to control. - sig { returns(Symbol) } - def environment - end - - sig { params(_: Symbol).returns(Symbol) } - def environment=(_) - end + sig { returns(OpenAI::Models::Responses::ComputerTool::Environment::OrSymbol) } + attr_accessor :environment # The type of the computer use tool. Always `computer_use_preview`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A tool that controls a virtual computer. Learn more about the # [computer tool](https://platform.openai.com/docs/guides/tools-computer-use). sig do - params(display_height: Float, display_width: Float, environment: Symbol, type: Symbol) + params( + display_height: Float, + display_width: Float, + environment: OpenAI::Models::Responses::ComputerTool::Environment::OrSymbol, + type: Symbol + ) .returns(T.attached_class) end def self.new(display_height:, display_width:, environment:, type: :computer_use_preview) end sig do - override.returns({display_height: Float, display_width: Float, environment: Symbol, type: Symbol}) + override + .returns( + { + display_height: Float, + display_width: Float, + environment: OpenAI::Models::Responses::ComputerTool::Environment::OrSymbol, + type: Symbol + } + ) end def to_hash end # The type of computer environment to control. - class Environment < OpenAI::Enum - abstract! + module Environment + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ComputerTool::Environment) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MAC = T.let(:mac, OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol) + WINDOWS = T.let(:windows, OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol) + UBUNTU = T.let(:ubuntu, OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol) + BROWSER = T.let(:browser, OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol) - MAC = :mac - WINDOWS = :windows - UBUNTU = :ubuntu - BROWSER = :browser + sig { override.returns(T::Array[OpenAI::Models::Responses::ComputerTool::Environment::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/easy_input_message.rbi b/rbi/lib/openai/models/responses/easy_input_message.rbi index 990b3527..d8597a18 100644 --- a/rbi/lib/openai/models/responses/easy_input_message.rbi +++ b/rbi/lib/openai/models/responses/easy_input_message.rbi @@ -6,35 +6,33 @@ module OpenAI class EasyInputMessage < OpenAI::BaseModel # Text, image, or audio input to the model, used to generate a response. Can also # contain previous assistant responses. - sig { returns(T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList)) } - def content - end - sig do - params(_: T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList)) - .returns(T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList)) - end - def content=(_) + returns( + T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ) + ) end + attr_accessor :content # The role of the message input. One of `user`, `assistant`, `system`, or # `developer`. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Responses::EasyInputMessage::Role::OrSymbol) } + attr_accessor :role # The type of the message input. Always `message`. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::Responses::EasyInputMessage::Type::OrSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::Responses::EasyInputMessage::Type::OrSymbol).void } + attr_writer :type # A message input to the model with a role indicating instruction following # hierarchy. Instructions given with the `developer` or `system` role take @@ -43,9 +41,19 @@ module OpenAI # interactions. sig do params( - content: T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList), - role: Symbol, - type: Symbol + content: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ), + role: OpenAI::Models::Responses::EasyInputMessage::Role::OrSymbol, + type: OpenAI::Models::Responses::EasyInputMessage::Type::OrSymbol ) .returns(T.attached_class) end @@ -55,7 +63,20 @@ module OpenAI sig do override .returns( - {content: T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList), role: Symbol, type: Symbol} + { + content: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ), + role: OpenAI::Models::Responses::EasyInputMessage::Role::OrSymbol, + type: OpenAI::Models::Responses::EasyInputMessage::Type::OrSymbol + } ) end def to_hash @@ -63,32 +84,60 @@ module OpenAI # Text, image, or audio input to the model, used to generate a response. Can also # contain previous assistant responses. - class Content < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(String, OpenAI::Models::Responses::ResponseInputMessageContentList)} } + module Content + extend OpenAI::Union + + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ] + ) + end + def self.variants + end end # The role of the message input. One of `user`, `assistant`, `system`, or # `developer`. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::EasyInputMessage::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = T.let(:user, OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol) + ASSISTANT = T.let(:assistant, OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol) + SYSTEM = T.let(:system, OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol) + DEVELOPER = T.let(:developer, OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol) - USER = :user - ASSISTANT = :assistant - SYSTEM = :system - DEVELOPER = :developer + sig { override.returns(T::Array[OpenAI::Models::Responses::EasyInputMessage::Role::TaggedSymbol]) } + def self.values + end end # The type of the message input. Always `message`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::EasyInputMessage::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::EasyInputMessage::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MESSAGE = T.let(:message, OpenAI::Models::Responses::EasyInputMessage::Type::TaggedSymbol) - MESSAGE = :message + sig { override.returns(T::Array[OpenAI::Models::Responses::EasyInputMessage::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/file_search_tool.rbi b/rbi/lib/openai/models/responses/file_search_tool.rbi index 3a6bd9db..62517b8d 100644 --- a/rbi/lib/openai/models/responses/file_search_tool.rbi +++ b/rbi/lib/openai/models/responses/file_search_tool.rbi @@ -6,55 +6,43 @@ module OpenAI class FileSearchTool < OpenAI::BaseModel # The type of the file search tool. Always `file_search`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The IDs of the vector stores to search. sig { returns(T::Array[String]) } - def vector_store_ids - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def vector_store_ids=(_) - end + attr_accessor :vector_store_ids # A filter to apply based on file attributes. sig { returns(T.nilable(T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter))) } - def filters - end + attr_reader :filters sig do - params(_: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)) - .returns(T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)) - end - def filters=(_) + params( + filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, OpenAI::Models::CompoundFilter) + ) + .void end + attr_writer :filters # The maximum number of results to return. This number should be between 1 and 50 # inclusive. sig { returns(T.nilable(Integer)) } - def max_num_results - end + attr_reader :max_num_results - sig { params(_: Integer).returns(Integer) } - def max_num_results=(_) - end + sig { params(max_num_results: Integer).void } + attr_writer :max_num_results # Ranking options for search. sig { returns(T.nilable(OpenAI::Models::Responses::FileSearchTool::RankingOptions)) } - def ranking_options - end + attr_reader :ranking_options sig do - params(_: OpenAI::Models::Responses::FileSearchTool::RankingOptions) - .returns(OpenAI::Models::Responses::FileSearchTool::RankingOptions) - end - def ranking_options=(_) + params( + ranking_options: T.any(OpenAI::Models::Responses::FileSearchTool::RankingOptions, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :ranking_options # A tool that searches for relevant content from uploaded files. Learn more about # the @@ -62,14 +50,20 @@ module OpenAI sig do params( vector_store_ids: T::Array[String], - filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter), + filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, OpenAI::Models::CompoundFilter), max_num_results: Integer, - ranking_options: OpenAI::Models::Responses::FileSearchTool::RankingOptions, + ranking_options: T.any(OpenAI::Models::Responses::FileSearchTool::RankingOptions, OpenAI::Util::AnyHash), type: Symbol ) .returns(T.attached_class) end - def self.new(vector_store_ids:, filters: nil, max_num_results: nil, ranking_options: nil, type: :file_search) + def self.new( + vector_store_ids:, + filters: nil, + max_num_results: nil, + ranking_options: nil, + type: :file_search + ) end sig do @@ -88,50 +82,72 @@ module OpenAI end # A filter to apply based on file attributes. - class Filters < OpenAI::Union - abstract! + module Filters + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)} } + sig { override.returns([OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter]) } + def self.variants + end end class RankingOptions < OpenAI::BaseModel # The ranker to use for the file search. - sig { returns(T.nilable(Symbol)) } - def ranker - end + sig { returns(T.nilable(OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::OrSymbol)) } + attr_reader :ranker - sig { params(_: Symbol).returns(Symbol) } - def ranker=(_) - end + sig { params(ranker: OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::OrSymbol).void } + attr_writer :ranker # The score threshold for the file search, a number between 0 and 1. Numbers # closer to 1 will attempt to return only the most relevant results, but may # return fewer results. sig { returns(T.nilable(Float)) } - def score_threshold - end + attr_reader :score_threshold - sig { params(_: Float).returns(Float) } - def score_threshold=(_) - end + sig { params(score_threshold: Float).void } + attr_writer :score_threshold # Ranking options for search. - sig { params(ranker: Symbol, score_threshold: Float).returns(T.attached_class) } + sig do + params( + ranker: OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::OrSymbol, + score_threshold: Float + ) + .returns(T.attached_class) + end def self.new(ranker: nil, score_threshold: nil) end - sig { override.returns({ranker: Symbol, score_threshold: Float}) } + sig do + override + .returns( + {ranker: OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::OrSymbol, score_threshold: Float} + ) + end def to_hash end # The ranker to use for the file search. - class Ranker < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - AUTO = :auto - DEFAULT_2024_11_15 = :"default-2024-11-15" + module Ranker + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::TaggedSymbol) } + + AUTO = T.let(:auto, OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::TaggedSymbol) + DEFAULT_2024_11_15 = + T.let( + :"default-2024-11-15", + OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::TaggedSymbol + ) + + sig do + override.returns(T::Array[OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/function_tool.rbi b/rbi/lib/openai/models/responses/function_tool.rbi index 8513be94..7462dada 100644 --- a/rbi/lib/openai/models/responses/function_tool.rbi +++ b/rbi/lib/openai/models/responses/function_tool.rbi @@ -6,49 +6,24 @@ module OpenAI class FunctionTool < OpenAI::BaseModel # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # A JSON schema object describing the parameters of the function. sig { returns(T::Hash[Symbol, T.anything]) } - def parameters - end - - sig { params(_: T::Hash[Symbol, T.anything]).returns(T::Hash[Symbol, T.anything]) } - def parameters=(_) - end + attr_accessor :parameters # Whether to enforce strict parameter validation. Default `true`. sig { returns(T::Boolean) } - def strict - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def strict=(_) - end + attr_accessor :strict # The type of the function tool. Always `function`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A description of the function. Used by the model to determine whether or not to # call the function. sig { returns(T.nilable(String)) } - def description - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def description=(_) - end + attr_accessor :description # Defines a function in your own code the model can choose to call. Learn more # about diff --git a/rbi/lib/openai/models/responses/input_item_list_params.rbi b/rbi/lib/openai/models/responses/input_item_list_params.rbi index 1162dc6a..bbd299bd 100644 --- a/rbi/lib/openai/models/responses/input_item_list_params.rbi +++ b/rbi/lib/openai/models/responses/input_item_list_params.rbi @@ -4,60 +4,61 @@ module OpenAI module Models module Responses class InputItemListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # An item ID to list items after, used in pagination. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # An item ID to list items before, used in pagination. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before + + # Additional fields to include in the response. See the `include` parameter for + # Response creation above for more information. + sig { returns(T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol])) } + attr_reader :include + + sig { params(include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]).void } + attr_writer :include # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # The order to return the input items in. Default is `asc`. # # - `asc`: Return the input items in ascending order. # - `desc`: Return the input items in descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::Responses::InputItemListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::Responses::InputItemListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, before: String, + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::Responses::InputItemListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(after: nil, before: nil, limit: nil, order: nil, request_options: {}) + def self.new(after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {}) end sig do @@ -66,8 +67,9 @@ module OpenAI { after: String, before: String, + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], limit: Integer, - order: Symbol, + order: OpenAI::Models::Responses::InputItemListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -79,13 +81,19 @@ module OpenAI # # - `asc`: Return the input items in ascending order. # - `desc`: Return the input items in descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::InputItemListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::InputItemListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::Responses::InputItemListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::Responses::InputItemListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::Responses::InputItemListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response.rbi b/rbi/lib/openai/models/responses/response.rbi index b7062e57..db73d16a 100644 --- a/rbi/lib/openai/models/responses/response.rbi +++ b/rbi/lib/openai/models/responses/response.rbi @@ -6,59 +6,39 @@ module OpenAI class Response < OpenAI::BaseModel # Unique identifier for this Response. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # Unix timestamp (in seconds) of when this Response was created. sig { returns(Float) } - def created_at - end - - sig { params(_: Float).returns(Float) } - def created_at=(_) - end + attr_accessor :created_at # An error object returned when the model fails to generate a Response. sig { returns(T.nilable(OpenAI::Models::Responses::ResponseError)) } - def error - end + attr_reader :error - sig do - params(_: T.nilable(OpenAI::Models::Responses::ResponseError)) - .returns(T.nilable(OpenAI::Models::Responses::ResponseError)) - end - def error=(_) - end + sig { params(error: T.nilable(T.any(OpenAI::Models::Responses::ResponseError, OpenAI::Util::AnyHash))).void } + attr_writer :error # Details about why the response is incomplete. sig { returns(T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails)) } - def incomplete_details - end + attr_reader :incomplete_details sig do - params(_: T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails)) - .returns(T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails)) - end - def incomplete_details=(_) + params( + incomplete_details: T.nilable(T.any(OpenAI::Models::Responses::Response::IncompleteDetails, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :incomplete_details # Inserts a system (or developer) message as the first item in the model's # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -66,35 +46,24 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a # wide range of models with different capabilities, performance characteristics, # and price points. Refer to the # [model guide](https://platform.openai.com/docs/models) to browse and compare # available models. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) + sig do + returns( + T.any(String, OpenAI::Models::ChatModel::TaggedSymbol, OpenAI::Models::ResponsesModel::TaggedSymbol) + ) end + attr_accessor :model # The object type of this resource - always set to `response`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # An array of content items generated by the model. # @@ -117,80 +86,32 @@ module OpenAI ] ) end - def output - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ] - ) - end - def output=(_) - end + attr_accessor :output # Whether to allow the model to run tool calls in parallel. sig { returns(T::Boolean) } - def parallel_tool_calls - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def parallel_tool_calls=(_) - end + attr_accessor :parallel_tool_calls # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. We generally recommend altering this or `top_p` but # not both. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. sig do returns( - T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) - ) - end - def tool_choice - end - - sig do - params( - _: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) - ) - .returns( - T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) + T.any( + OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Models::Responses::ToolChoiceFunction ) + ) end - def tool_choice=(_) - end + attr_accessor :tool_choice # An array of tools the model may call while generating a response. You can # specify which tool to use by setting the `tool_choice` parameter. @@ -218,33 +139,7 @@ module OpenAI ] ) end - def tools - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Responses::FileSearchTool, - OpenAI::Models::Responses::FunctionTool, - OpenAI::Models::Responses::ComputerTool, - OpenAI::Models::Responses::WebSearchTool - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::FileSearchTool, - OpenAI::Models::Responses::FunctionTool, - OpenAI::Models::Responses::ComputerTool, - OpenAI::Models::Responses::WebSearchTool - ) - ] - ) - end - def tools=(_) - end + attr_accessor :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -252,56 +147,37 @@ module OpenAI # # We generally recommend altering this or `temperature` but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(Integer)) } - def max_output_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_output_tokens=(_) - end + attr_accessor :max_output_tokens # The unique ID of the previous response to the model. Use this to create # multi-turn conversations. Learn more about # [conversation state](https://platform.openai.com/docs/guides/conversation-state). sig { returns(T.nilable(String)) } - def previous_response_id - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def previous_response_id=(_) - end + attr_accessor :previous_response_id # **o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(OpenAI::Models::Reasoning)) } - def reasoning - end + attr_reader :reasoning - sig { params(_: T.nilable(OpenAI::Models::Reasoning)).returns(T.nilable(OpenAI::Models::Reasoning)) } - def reasoning=(_) - end + sig { params(reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash))).void } + attr_writer :reasoning # The status of the response generation. One of `completed`, `failed`, # `in_progress`, or `incomplete`. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseStatus::TaggedSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseStatus::OrSymbol).void } + attr_writer :status # Configuration options for a text response from the model. Can be plain text or # structured JSON data. Learn more: @@ -309,15 +185,10 @@ module OpenAI # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) sig { returns(T.nilable(OpenAI::Models::Responses::ResponseTextConfig)) } - def text - end + attr_reader :text - sig do - params(_: OpenAI::Models::Responses::ResponseTextConfig) - .returns(OpenAI::Models::Responses::ResponseTextConfig) - end - def text=(_) - end + sig { params(text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash)).void } + attr_writer :text # The truncation strategy to use for the model response. # @@ -326,47 +197,39 @@ module OpenAI # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - sig { returns(T.nilable(Symbol)) } - def truncation - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def truncation=(_) - end + sig { returns(T.nilable(OpenAI::Models::Responses::Response::Truncation::TaggedSymbol)) } + attr_accessor :truncation # Represents token usage details including input tokens, output tokens, a # breakdown of output tokens, and the total tokens used. sig { returns(T.nilable(OpenAI::Models::Responses::ResponseUsage)) } - def usage - end + attr_reader :usage - sig { params(_: OpenAI::Models::Responses::ResponseUsage).returns(OpenAI::Models::Responses::ResponseUsage) } - def usage=(_) - end + sig { params(usage: T.any(OpenAI::Models::Responses::ResponseUsage, OpenAI::Util::AnyHash)).void } + attr_writer :usage # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( id: String, created_at: Float, - error: T.nilable(OpenAI::Models::Responses::ResponseError), - incomplete_details: T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails), + error: T.nilable(T.any(OpenAI::Models::Responses::ResponseError, OpenAI::Util::AnyHash)), + incomplete_details: T.nilable(T.any(OpenAI::Models::Responses::Response::IncompleteDetails, OpenAI::Util::AnyHash)), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.any(String, Symbol), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol), output: T::Array[ T.any( OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, @@ -376,10 +239,16 @@ module OpenAI ], parallel_tool_calls: T::Boolean, temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool @@ -388,11 +257,11 @@ module OpenAI top_p: T.nilable(Float), max_output_tokens: T.nilable(Integer), previous_response_id: T.nilable(String), - reasoning: T.nilable(OpenAI::Models::Reasoning), - status: Symbol, - text: OpenAI::Models::Responses::ResponseTextConfig, - truncation: T.nilable(Symbol), - usage: OpenAI::Models::Responses::ResponseUsage, + reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash)), + status: OpenAI::Models::Responses::ResponseStatus::OrSymbol, + text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash), + truncation: T.nilable(OpenAI::Models::Responses::Response::Truncation::OrSymbol), + usage: T.any(OpenAI::Models::Responses::ResponseUsage, OpenAI::Util::AnyHash), user: String, object: Symbol ) @@ -433,8 +302,8 @@ module OpenAI error: T.nilable(OpenAI::Models::Responses::ResponseError), incomplete_details: T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.any(String, Symbol), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.any(String, OpenAI::Models::ChatModel::TaggedSymbol, OpenAI::Models::ResponsesModel::TaggedSymbol), object: Symbol, output: T::Array[ T.any( @@ -448,7 +317,11 @@ module OpenAI ], parallel_tool_calls: T::Boolean, temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, @@ -461,9 +334,9 @@ module OpenAI max_output_tokens: T.nilable(Integer), previous_response_id: T.nilable(String), reasoning: T.nilable(OpenAI::Models::Reasoning), - status: Symbol, + status: OpenAI::Models::Responses::ResponseStatus::TaggedSymbol, text: OpenAI::Models::Responses::ResponseTextConfig, - truncation: T.nilable(Symbol), + truncation: T.nilable(OpenAI::Models::Responses::Response::Truncation::TaggedSymbol), usage: OpenAI::Models::Responses::ResponseUsage, user: String } @@ -474,55 +347,57 @@ module OpenAI class IncompleteDetails < OpenAI::BaseModel # The reason why the response is incomplete. - sig { returns(T.nilable(Symbol)) } - def reason - end + sig { returns(T.nilable(OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol)) } + attr_reader :reason - sig { params(_: Symbol).returns(Symbol) } - def reason=(_) - end + sig { params(reason: OpenAI::Models::Responses::Response::IncompleteDetails::Reason::OrSymbol).void } + attr_writer :reason # Details about why the response is incomplete. - sig { params(reason: Symbol).returns(T.attached_class) } + sig do + params(reason: OpenAI::Models::Responses::Response::IncompleteDetails::Reason::OrSymbol) + .returns(T.attached_class) + end def self.new(reason: nil) end - sig { override.returns({reason: Symbol}) } + sig { override.returns({reason: OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol}) } def to_hash end # The reason why the response is incomplete. - class Reason < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - MAX_OUTPUT_TOKENS = :max_output_tokens - CONTENT_FILTER = :content_filter + module Reason + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::Response::IncompleteDetails::Reason) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol) } + + MAX_OUTPUT_TOKENS = + T.let(:max_output_tokens, OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol) + CONTENT_FILTER = + T.let(:content_filter, OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::Response::IncompleteDetails::Reason::TaggedSymbol]) } + def self.values + end end end - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a - # wide range of models with different capabilities, performance characteristics, - # and price points. Refer to the - # [model guide](https://platform.openai.com/docs/models) to browse and compare - # available models. - class Model < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } - end - # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. - class ToolChoice < OpenAI::Union - abstract! + module ToolChoice + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) - } + sig do + override + .returns( + [OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] + ) + end + def self.variants end end @@ -533,13 +408,18 @@ module OpenAI # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - class Truncation < OpenAI::Enum - abstract! + module Truncation + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::Response::Truncation) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::Response::Truncation::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::Responses::Response::Truncation::TaggedSymbol) + DISABLED = T.let(:disabled, OpenAI::Models::Responses::Response::Truncation::TaggedSymbol) - AUTO = :auto - DISABLED = :disabled + sig { override.returns(T::Array[OpenAI::Models::Responses::Response::Truncation::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_audio_delta_event.rbi b/rbi/lib/openai/models/responses/response_audio_delta_event.rbi index 54ec9c86..af937de8 100644 --- a/rbi/lib/openai/models/responses/response_audio_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_audio_delta_event.rbi @@ -6,21 +6,11 @@ module OpenAI class ResponseAudioDeltaEvent < OpenAI::BaseModel # A chunk of Base64 encoded response audio bytes. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The type of the event. Always `response.audio.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when there is a partial audio response. sig { params(delta: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_audio_done_event.rbi b/rbi/lib/openai/models/responses/response_audio_done_event.rbi index d60d8ffe..2f302c28 100644 --- a/rbi/lib/openai/models/responses/response_audio_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_audio_done_event.rbi @@ -6,12 +6,7 @@ module OpenAI class ResponseAudioDoneEvent < OpenAI::BaseModel # The type of the event. Always `response.audio.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the audio response is complete. sig { params(type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_audio_transcript_delta_event.rbi b/rbi/lib/openai/models/responses/response_audio_transcript_delta_event.rbi index 072b6541..f2206761 100644 --- a/rbi/lib/openai/models/responses/response_audio_transcript_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_audio_transcript_delta_event.rbi @@ -6,21 +6,11 @@ module OpenAI class ResponseAudioTranscriptDeltaEvent < OpenAI::BaseModel # The partial transcript of the audio response. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The type of the event. Always `response.audio.transcript.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when there is a partial transcript of audio. sig { params(delta: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_audio_transcript_done_event.rbi b/rbi/lib/openai/models/responses/response_audio_transcript_done_event.rbi index 940f3497..cb69a888 100644 --- a/rbi/lib/openai/models/responses/response_audio_transcript_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_audio_transcript_done_event.rbi @@ -6,12 +6,7 @@ module OpenAI class ResponseAudioTranscriptDoneEvent < OpenAI::BaseModel # The type of the event. Always `response.audio.transcript.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the full audio transcript is completed. sig { params(type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi index 21d55044..26d256d8 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseCodeInterpreterCallCodeDeltaEvent < OpenAI::BaseModel # The partial code snippet added by the code interpreter. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The index of the output item that the code interpreter call is in progress. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.code_interpreter_call.code.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a partial code snippet is added by the code interpreter. sig { params(delta: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rbi index 294664ab..c1512e6a 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseCodeInterpreterCallCodeDoneEvent < OpenAI::BaseModel # The final code snippet output by the code interpreter. sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end + attr_accessor :code # The index of the output item that the code interpreter call is in progress. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.code_interpreter_call.code.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when code snippet output is finalized by the code interpreter. sig { params(code: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_call_completed_event.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_call_completed_event.rbi index 389d9f49..ea6117b4 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_call_completed_event.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_call_completed_event.rbi @@ -6,38 +6,28 @@ module OpenAI class ResponseCodeInterpreterCallCompletedEvent < OpenAI::BaseModel # A tool call to run code. sig { returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) } - def code_interpreter_call - end + attr_reader :code_interpreter_call sig do - params(_: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - .returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - end - def code_interpreter_call=(_) + params( + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter_call # The index of the output item that the code interpreter call is in progress. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.code_interpreter_call.completed`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the code interpreter call is completed. sig do params( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash), output_index: Integer, type: Symbol ) diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi index 9d0d0524..e49fec75 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi @@ -6,44 +6,38 @@ module OpenAI class ResponseCodeInterpreterCallInProgressEvent < OpenAI::BaseModel # A tool call to run code. sig { returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) } - def code_interpreter_call - end + attr_reader :code_interpreter_call sig do - params(_: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - .returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - end - def code_interpreter_call=(_) + params( + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter_call # The index of the output item that the code interpreter call is in progress. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.code_interpreter_call.in_progress`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a code interpreter call is in progress. sig do params( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash), output_index: Integer, type: Symbol ) .returns(T.attached_class) end - def self.new(code_interpreter_call:, output_index:, type: :"response.code_interpreter_call.in_progress") + def self.new( + code_interpreter_call:, + output_index:, + type: :"response.code_interpreter_call.in_progress" + ) end sig do diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi index 4757018f..a19cad6d 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi @@ -6,44 +6,38 @@ module OpenAI class ResponseCodeInterpreterCallInterpretingEvent < OpenAI::BaseModel # A tool call to run code. sig { returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) } - def code_interpreter_call - end + attr_reader :code_interpreter_call sig do - params(_: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - .returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall) - end - def code_interpreter_call=(_) + params( + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :code_interpreter_call # The index of the output item that the code interpreter call is in progress. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.code_interpreter_call.interpreting`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the code interpreter is actively interpreting the code snippet. sig do params( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + code_interpreter_call: T.any(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Util::AnyHash), output_index: Integer, type: Symbol ) .returns(T.attached_class) end - def self.new(code_interpreter_call:, output_index:, type: :"response.code_interpreter_call.interpreting") + def self.new( + code_interpreter_call:, + output_index:, + type: :"response.code_interpreter_call.interpreting" + ) end sig do diff --git a/rbi/lib/openai/models/responses/response_code_interpreter_tool_call.rbi b/rbi/lib/openai/models/responses/response_code_interpreter_tool_call.rbi index b68befef..91dbb3cd 100644 --- a/rbi/lib/openai/models/responses/response_code_interpreter_tool_call.rbi +++ b/rbi/lib/openai/models/responses/response_code_interpreter_tool_call.rbi @@ -6,21 +6,11 @@ module OpenAI class ResponseCodeInterpreterToolCall < OpenAI::BaseModel # The unique ID of the code interpreter tool call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The code to run. sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end + attr_accessor :code # The results of the code interpreter tool call. sig do @@ -33,47 +23,15 @@ module OpenAI ] ) end - def results - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files - ) - ] - ) - end - def results=(_) - end + attr_accessor :results # The status of the code interpreter tool call. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol) } + attr_accessor :status # The type of the code interpreter tool call. Always `code_interpreter_call`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A tool call to run code. sig do @@ -83,10 +41,11 @@ module OpenAI results: T::Array[ T.any( OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files ) ], - status: Symbol, + status: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::OrSymbol, type: Symbol ) .returns(T.attached_class) @@ -106,7 +65,7 @@ module OpenAI OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files ) ], - status: Symbol, + status: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol, type: Symbol } ) @@ -115,36 +74,17 @@ module OpenAI end # The output of a code interpreter tool call that is text. - class Result < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, - OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files - ) - } - end + module Result + extend OpenAI::Union class Logs < OpenAI::BaseModel # The logs of the code interpreter tool call. sig { returns(String) } - def logs - end - - sig { params(_: String).returns(String) } - def logs=(_) - end + attr_accessor :logs # The type of the code interpreter text output. Always `logs`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The output of a code interpreter tool call that is text. sig { params(logs: String, type: Symbol).returns(T.attached_class) } @@ -158,29 +98,21 @@ module OpenAI class Files < OpenAI::BaseModel sig { returns(T::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File]) } - def files - end - - sig do - params(_: T::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File]) - .returns(T::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File]) - end - def files=(_) - end + attr_accessor :files # The type of the code interpreter file output. Always `files`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The output of a code interpreter tool call that is a file. sig do params( - files: T::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File], + files: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File, + OpenAI::Util::AnyHash + ) + ], type: Symbol ) .returns(T.attached_class) @@ -203,21 +135,11 @@ module OpenAI class File < OpenAI::BaseModel # The ID of the file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The MIME type of the file. sig { returns(String) } - def mime_type - end - - sig { params(_: String).returns(String) } - def mime_type=(_) - end + attr_accessor :mime_type sig { params(file_id: String, mime_type: String).returns(T.attached_class) } def self.new(file_id:, mime_type:) @@ -228,17 +150,39 @@ module OpenAI end end end + + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files] + ) + end + def self.variants + end end # The status of the code interpreter tool call. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - INTERPRETING = :interpreting - COMPLETED = :completed + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol) + INTERPRETING = + T.let(:interpreting, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status::TaggedSymbol]) + end + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_completed_event.rbi b/rbi/lib/openai/models/responses/response_completed_event.rbi index 7db04649..4b78bb8f 100644 --- a/rbi/lib/openai/models/responses/response_completed_event.rbi +++ b/rbi/lib/openai/models/responses/response_completed_event.rbi @@ -6,24 +6,20 @@ module OpenAI class ResponseCompletedEvent < OpenAI::BaseModel # Properties of the completed response. sig { returns(OpenAI::Models::Responses::Response) } - def response - end + attr_reader :response - sig { params(_: OpenAI::Models::Responses::Response).returns(OpenAI::Models::Responses::Response) } - def response=(_) - end + sig { params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash)).void } + attr_writer :response # The type of the event. Always `response.completed`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the model response is complete. - sig { params(response: OpenAI::Models::Responses::Response, type: Symbol).returns(T.attached_class) } + sig do + params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(response:, type: :"response.completed") end diff --git a/rbi/lib/openai/models/responses/response_computer_tool_call.rbi b/rbi/lib/openai/models/responses/response_computer_tool_call.rbi index bc8782dc..298263bd 100644 --- a/rbi/lib/openai/models/responses/response_computer_tool_call.rbi +++ b/rbi/lib/openai/models/responses/response_computer_tool_call.rbi @@ -6,12 +6,7 @@ module OpenAI class ResponseComputerToolCall < OpenAI::BaseModel # The unique ID of the computer call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # A click action. sig do @@ -29,79 +24,24 @@ module OpenAI ) ) end - def action - end - - sig do - params( - _: T.any( - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait - ) - ) - .returns( - T.any( - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait - ) - ) - end - def action=(_) - end + attr_accessor :action # An identifier used when responding to the tool call with output. sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end + attr_accessor :call_id # The pending safety checks for the computer call. sig { returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck]) } - def pending_safety_checks - end - - sig do - params(_: T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck]) - .returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck]) - end - def pending_safety_checks=(_) - end + attr_accessor :pending_safety_checks # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseComputerToolCall::Status::OrSymbol) } + attr_accessor :status # The type of the computer call. Always `computer_call`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseComputerToolCall::Type::OrSymbol) } + attr_accessor :type # A tool call to a computer use tool. See the # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) @@ -111,6 +51,7 @@ module OpenAI id: String, action: T.any( OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, @@ -121,9 +62,9 @@ module OpenAI OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait ), call_id: String, - pending_safety_checks: T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck], - status: Symbol, - type: Symbol + pending_safety_checks: T::Array[T.any(OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck, OpenAI::Util::AnyHash)], + status: OpenAI::Models::Responses::ResponseComputerToolCall::Status::OrSymbol, + type: OpenAI::Models::Responses::ResponseComputerToolCall::Type::OrSymbol ) .returns(T.attached_class) end @@ -148,8 +89,8 @@ module OpenAI ), call_id: String, pending_safety_checks: T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck], - status: Symbol, - type: Symbol + status: OpenAI::Models::Responses::ResponseComputerToolCall::Status::OrSymbol, + type: OpenAI::Models::Responses::ResponseComputerToolCall::Type::OrSymbol } ) end @@ -157,85 +98,84 @@ module OpenAI end # A click action. - class Action < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, - OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait - ) - } - end + module Action + extend OpenAI::Union class Click < OpenAI::BaseModel # Indicates which mouse button was pressed during the click. One of `left`, # `right`, `wheel`, `back`, or `forward`. - sig { returns(Symbol) } - def button - end - - sig { params(_: Symbol).returns(Symbol) } - def button=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::OrSymbol) } + attr_accessor :button # Specifies the event type. For a click action, this property is always set to # `click`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The x-coordinate where the click occurred. sig { returns(Integer) } - def x - end - - sig { params(_: Integer).returns(Integer) } - def x=(_) - end + attr_accessor :x # The y-coordinate where the click occurred. sig { returns(Integer) } - def y_ - end - - sig { params(_: Integer).returns(Integer) } - def y_=(_) - end + attr_accessor :y_ # A click action. - sig { params(button: Symbol, x: Integer, y_: Integer, type: Symbol).returns(T.attached_class) } + sig do + params( + button: OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::OrSymbol, + x: Integer, + y_: Integer, + type: Symbol + ) + .returns(T.attached_class) + end def self.new(button:, x:, y_:, type: :click) end - sig { override.returns({button: Symbol, type: Symbol, x: Integer, y_: Integer}) } + sig do + override + .returns( + { + button: OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::OrSymbol, + type: Symbol, + x: Integer, + y_: Integer + } + ) + end def to_hash end # Indicates which mouse button was pressed during the click. One of `left`, # `right`, `wheel`, `back`, or `forward`. - class Button < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - LEFT = :left - RIGHT = :right - WHEEL = :wheel - BACK = :back - FORWARD = :forward + module Button + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) } + + LEFT = + T.let(:left, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) + RIGHT = + T.let(:right, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) + WHEEL = + T.let(:wheel, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) + BACK = + T.let(:back, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) + FORWARD = + T.let(:forward, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol) + + sig do + override + .returns( + T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button::TaggedSymbol] + ) + end + def self.values + end end end @@ -243,30 +183,15 @@ module OpenAI # Specifies the event type. For a double click action, this property is always set # to `double_click`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The x-coordinate where the double click occurred. sig { returns(Integer) } - def x - end - - sig { params(_: Integer).returns(Integer) } - def x=(_) - end + attr_accessor :x # The y-coordinate where the double click occurred. sig { returns(Integer) } - def y_ - end - - sig { params(_: Integer).returns(Integer) } - def y_=(_) - end + attr_accessor :y_ # A double click action. sig { params(x: Integer, y_: Integer, type: Symbol).returns(T.attached_class) } @@ -289,30 +214,17 @@ module OpenAI # ] # ``` sig { returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path]) } - def path - end - - sig do - params(_: T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path]) - .returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path]) - end - def path=(_) - end + attr_accessor :path # Specifies the event type. For a drag action, this property is always set to # `drag`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A drag action. sig do params( - path: T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path], + path: T::Array[T.any(OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path, OpenAI::Util::AnyHash)], type: Symbol ) .returns(T.attached_class) @@ -332,21 +244,11 @@ module OpenAI class Path < OpenAI::BaseModel # The x-coordinate. sig { returns(Integer) } - def x - end - - sig { params(_: Integer).returns(Integer) } - def x=(_) - end + attr_accessor :x # The y-coordinate. sig { returns(Integer) } - def y_ - end - - sig { params(_: Integer).returns(Integer) } - def y_=(_) - end + attr_accessor :y_ # A series of x/y coordinate pairs in the drag path. sig { params(x: Integer, y_: Integer).returns(T.attached_class) } @@ -363,22 +265,12 @@ module OpenAI # The combination of keys the model is requesting to be pressed. This is an array # of strings, each representing a key. sig { returns(T::Array[String]) } - def keys - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def keys=(_) - end + attr_accessor :keys # Specifies the event type. For a keypress action, this property is always set to # `keypress`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A collection of keypresses the model would like to perform. sig { params(keys: T::Array[String], type: Symbol).returns(T.attached_class) } @@ -394,30 +286,15 @@ module OpenAI # Specifies the event type. For a move action, this property is always set to # `move`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The x-coordinate to move to. sig { returns(Integer) } - def x - end - - sig { params(_: Integer).returns(Integer) } - def x=(_) - end + attr_accessor :x # The y-coordinate to move to. sig { returns(Integer) } - def y_ - end - - sig { params(_: Integer).returns(Integer) } - def y_=(_) - end + attr_accessor :y_ # A mouse move action. sig { params(x: Integer, y_: Integer, type: Symbol).returns(T.attached_class) } @@ -433,12 +310,7 @@ module OpenAI # Specifies the event type. For a screenshot action, this property is always set # to `screenshot`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A screenshot action. sig { params(type: Symbol).returns(T.attached_class) } @@ -453,49 +325,24 @@ module OpenAI class Scroll < OpenAI::BaseModel # The horizontal scroll distance. sig { returns(Integer) } - def scroll_x - end - - sig { params(_: Integer).returns(Integer) } - def scroll_x=(_) - end + attr_accessor :scroll_x # The vertical scroll distance. sig { returns(Integer) } - def scroll_y - end - - sig { params(_: Integer).returns(Integer) } - def scroll_y=(_) - end + attr_accessor :scroll_y # Specifies the event type. For a scroll action, this property is always set to # `scroll`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The x-coordinate where the scroll occurred. sig { returns(Integer) } - def x - end - - sig { params(_: Integer).returns(Integer) } - def x=(_) - end + attr_accessor :x # The y-coordinate where the scroll occurred. sig { returns(Integer) } - def y_ - end - - sig { params(_: Integer).returns(Integer) } - def y_=(_) - end + attr_accessor :y_ # A scroll action. sig do @@ -515,22 +362,12 @@ module OpenAI class Type < OpenAI::BaseModel # The text to type. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # Specifies the event type. For a type action, this property is always set to # `type`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An action to type in text. sig { params(text: String, type: Symbol).returns(T.attached_class) } @@ -546,12 +383,7 @@ module OpenAI # Specifies the event type. For a wait action, this property is always set to # `wait`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A wait action. sig { params(type: Symbol).returns(T.attached_class) } @@ -562,35 +394,29 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait] + ) + end + def self.variants + end end class PendingSafetyCheck < OpenAI::BaseModel # The ID of the pending safety check. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The type of the pending safety check. sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end + attr_accessor :code # Details about the pending safety check. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # A pending safety check for the computer call. sig { params(id: String, code: String, message: String).returns(T.attached_class) } @@ -604,23 +430,39 @@ module OpenAI # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseComputerToolCall::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseComputerToolCall::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseComputerToolCall::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Status::TaggedSymbol]) } + def self.values + end end # The type of the computer call. Always `computer_call`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Type::TaggedSymbol) } - COMPUTER_CALL = :computer_call + COMPUTER_CALL = + T.let(:computer_call, OpenAI::Models::Responses::ResponseComputerToolCall::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_computer_tool_call_output_item.rbi b/rbi/lib/openai/models/responses/response_computer_tool_call_output_item.rbi new file mode 100644 index 00000000..a1ef5e14 --- /dev/null +++ b/rbi/lib/openai/models/responses/response_computer_tool_call_output_item.rbi @@ -0,0 +1,155 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseComputerToolCallOutputItem < OpenAI::BaseModel + # The unique ID of the computer call tool output. + sig { returns(String) } + attr_accessor :id + + # The ID of the computer tool call that produced the output. + sig { returns(String) } + attr_accessor :call_id + + # A computer screenshot image used with the computer use tool. + sig { returns(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot) } + attr_reader :output + + sig do + params( + output: T.any(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, OpenAI::Util::AnyHash) + ) + .void + end + attr_writer :output + + # The type of the computer tool call output. Always `computer_call_output`. + sig { returns(Symbol) } + attr_accessor :type + + # The safety checks reported by the API that have been acknowledged by the + # developer. + sig do + returns( + T.nilable( + T::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck] + ) + ) + end + attr_reader :acknowledged_safety_checks + + sig do + params( + acknowledged_safety_checks: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck, + OpenAI::Util::AnyHash + ) + ] + ) + .void + end + attr_writer :acknowledged_safety_checks + + # The status of the message input. One of `in_progress`, `completed`, or + # `incomplete`. Populated when input items are returned via API. + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol)) } + attr_reader :status + + sig { params(status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::OrSymbol).void } + attr_writer :status + + sig do + params( + id: String, + call_id: String, + output: T.any(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, OpenAI::Util::AnyHash), + acknowledged_safety_checks: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck, + OpenAI::Util::AnyHash + ) + ], + status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::OrSymbol, + type: Symbol + ) + .returns(T.attached_class) + end + def self.new( + id:, + call_id:, + output:, + acknowledged_safety_checks: nil, + status: nil, + type: :computer_call_output + ) + end + + sig do + override + .returns( + { + id: String, + call_id: String, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, + type: Symbol, + acknowledged_safety_checks: T::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck], + status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol + } + ) + end + def to_hash + end + + class AcknowledgedSafetyCheck < OpenAI::BaseModel + # The ID of the pending safety check. + sig { returns(String) } + attr_accessor :id + + # The type of the pending safety check. + sig { returns(String) } + attr_accessor :code + + # Details about the pending safety check. + sig { returns(String) } + attr_accessor :message + + # A pending safety check for the computer call. + sig { params(id: String, code: String, message: String).returns(T.attached_class) } + def self.new(id:, code:, message:) + end + + sig { override.returns({id: String, code: String, message: String}) } + def to_hash + end + end + + # The status of the message input. One of `in_progress`, `completed`, or + # `incomplete`. Populated when input items are returned via API. + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status::TaggedSymbol]) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rbi b/rbi/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rbi new file mode 100644 index 00000000..1246a3c0 --- /dev/null +++ b/rbi/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseComputerToolCallOutputScreenshot < OpenAI::BaseModel + # Specifies the event type. For a computer screenshot, this property is always set + # to `computer_screenshot`. + sig { returns(Symbol) } + attr_accessor :type + + # The identifier of an uploaded file that contains the screenshot. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The URL of the screenshot image. + sig { returns(T.nilable(String)) } + attr_reader :image_url + + sig { params(image_url: String).void } + attr_writer :image_url + + # A computer screenshot image used with the computer use tool. + sig { params(file_id: String, image_url: String, type: Symbol).returns(T.attached_class) } + def self.new(file_id: nil, image_url: nil, type: :computer_screenshot) + end + + sig { override.returns({type: Symbol, file_id: String, image_url: String}) } + def to_hash + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_content.rbi b/rbi/lib/openai/models/responses/response_content.rbi index 58f3f635..ef91ffdf 100644 --- a/rbi/lib/openai/models/responses/response_content.rbi +++ b/rbi/lib/openai/models/responses/response_content.rbi @@ -4,19 +4,16 @@ module OpenAI module Models module Responses # Multi-modal input and output contents. - class ResponseContent < OpenAI::Union - abstract! + module ResponseContent + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseInputText, - OpenAI::Models::Responses::ResponseInputImage, - OpenAI::Models::Responses::ResponseInputFile, - OpenAI::Models::Responses::ResponseOutputText, - OpenAI::Models::Responses::ResponseOutputRefusal + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_content_part_added_event.rbi b/rbi/lib/openai/models/responses/response_content_part_added_event.rbi index ca3acd5c..2c961d2d 100644 --- a/rbi/lib/openai/models/responses/response_content_part_added_event.rbi +++ b/rbi/lib/openai/models/responses/response_content_part_added_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseContentPartAddedEvent < OpenAI::BaseModel # The index of the content part that was added. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The ID of the output item that the content part was added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the content part was added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The content part that was added. sig do @@ -37,28 +22,11 @@ module OpenAI T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) ) end - def part - end - - sig do - params( - _: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - ) - .returns( - T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - ) - end - def part=(_) - end + attr_accessor :part # The type of the event. Always `response.content_part.added`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a new content part is added. sig do @@ -66,7 +34,11 @@ module OpenAI content_index: Integer, item_id: String, output_index: Integer, - part: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal), + part: T.any( + OpenAI::Models::Responses::ResponseOutputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseOutputRefusal + ), type: Symbol ) .returns(T.attached_class) @@ -90,13 +62,14 @@ module OpenAI end # The content part that was added. - class Part < OpenAI::Union - abstract! + module Part + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - } + sig do + override + .returns([OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal]) + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_content_part_done_event.rbi b/rbi/lib/openai/models/responses/response_content_part_done_event.rbi index 65977cbe..b5948c6d 100644 --- a/rbi/lib/openai/models/responses/response_content_part_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_content_part_done_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseContentPartDoneEvent < OpenAI::BaseModel # The index of the content part that is done. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The ID of the output item that the content part was added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the content part was added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The content part that is done. sig do @@ -37,28 +22,11 @@ module OpenAI T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) ) end - def part - end - - sig do - params( - _: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - ) - .returns( - T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - ) - end - def part=(_) - end + attr_accessor :part # The type of the event. Always `response.content_part.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a content part is done. sig do @@ -66,7 +34,11 @@ module OpenAI content_index: Integer, item_id: String, output_index: Integer, - part: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal), + part: T.any( + OpenAI::Models::Responses::ResponseOutputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseOutputRefusal + ), type: Symbol ) .returns(T.attached_class) @@ -90,13 +62,14 @@ module OpenAI end # The content part that is done. - class Part < OpenAI::Union - abstract! + module Part + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - } + sig do + override + .returns([OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal]) + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_create_params.rbi b/rbi/lib/openai/models/responses/response_create_params.rbi index f7396668..305eb10e 100644 --- a/rbi/lib/openai/models/responses/response_create_params.rbi +++ b/rbi/lib/openai/models/responses/response_create_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module Responses class ResponseCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Text, image, or file inputs to the model, used to generate a response. @@ -16,29 +16,37 @@ module OpenAI # - [File inputs](https://platform.openai.com/docs/guides/pdf-files) # - [Conversation state](https://platform.openai.com/docs/guides/conversation-state) # - [Function calling](https://platform.openai.com/docs/guides/function-calling) - sig { returns(T.any(String, OpenAI::Models::Responses::ResponseInput)) } - def input - end - sig do - params(_: T.any(String, OpenAI::Models::Responses::ResponseInput)) - .returns(T.any(String, OpenAI::Models::Responses::ResponseInput)) - end - def input=(_) + returns( + T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ) + ) end + attr_accessor :input # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a # wide range of models with different capabilities, performance characteristics, # and price points. Refer to the # [model guide](https://platform.openai.com/docs/models) to browse and compare # available models. - sig { returns(T.any(String, Symbol)) } - def model - end - - sig { params(_: T.any(String, Symbol)).returns(T.any(String, Symbol)) } - def model=(_) - end + sig { returns(T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol)) } + attr_accessor :model # Specify additional output data to include in the model response. Currently # supported values are: @@ -48,38 +56,23 @@ module OpenAI # - `message.input_image.image_url`: Include image urls from the input message. # - `computer_call_output.output.image_url`: Include image urls from the computer # call output. - sig { returns(T.nilable(T::Array[Symbol])) } - def include - end - - sig { params(_: T.nilable(T::Array[Symbol])).returns(T.nilable(T::Array[Symbol])) } - def include=(_) - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol])) } + attr_accessor :include # Inserts a system (or developer) message as the first item in the model's # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. sig { returns(T.nilable(String)) } - def instructions - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def instructions=(_) - end + attr_accessor :instructions # An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(Integer)) } - def max_output_tokens - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_output_tokens=(_) - end + attr_accessor :max_output_tokens # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -87,66 +80,39 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # Whether to allow the model to run tool calls in parallel. sig { returns(T.nilable(T::Boolean)) } - def parallel_tool_calls - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def parallel_tool_calls=(_) - end + attr_accessor :parallel_tool_calls # The unique ID of the previous response to the model. Use this to create # multi-turn conversations. Learn more about # [conversation state](https://platform.openai.com/docs/guides/conversation-state). sig { returns(T.nilable(String)) } - def previous_response_id - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def previous_response_id=(_) - end + attr_accessor :previous_response_id # **o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). sig { returns(T.nilable(OpenAI::Models::Reasoning)) } - def reasoning - end + attr_reader :reasoning - sig { params(_: T.nilable(OpenAI::Models::Reasoning)).returns(T.nilable(OpenAI::Models::Reasoning)) } - def reasoning=(_) - end + sig { params(reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash))).void } + attr_writer :reasoning # Whether to store the generated model response for later retrieval via API. sig { returns(T.nilable(T::Boolean)) } - def store - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def store=(_) - end + attr_accessor :store # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will # make the output more random, while lower values like 0.2 will make it more # focused and deterministic. We generally recommend altering this or `top_p` but # not both. sig { returns(T.nilable(Float)) } - def temperature - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def temperature=(_) - end + attr_accessor :temperature # Configuration options for a text response from the model. Can be plain text or # structured JSON data. Learn more: @@ -154,15 +120,10 @@ module OpenAI # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) sig { returns(T.nilable(OpenAI::Models::Responses::ResponseTextConfig)) } - def text - end + attr_reader :text - sig do - params(_: OpenAI::Models::Responses::ResponseTextConfig) - .returns(OpenAI::Models::Responses::ResponseTextConfig) - end - def text=(_) - end + sig { params(text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash)).void } + attr_writer :text # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model @@ -170,23 +131,28 @@ module OpenAI sig do returns( T.nilable( - T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) + T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Models::Responses::ToolChoiceFunction + ) ) ) end - def tool_choice - end + attr_reader :tool_choice sig do params( - _: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) - ) - .returns( - T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ToolChoiceFunction ) + ) + .void end - def tool_choice=(_) - end + attr_writer :tool_choice # An array of tools the model may call while generating a response. You can # specify which tool to use by setting the `tool_choice` parameter. @@ -216,33 +182,23 @@ module OpenAI ) ) end - def tools - end + attr_reader :tools sig do params( - _: T::Array[ + tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool ) ] ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::FileSearchTool, - OpenAI::Models::Responses::FunctionTool, - OpenAI::Models::Responses::ComputerTool, - OpenAI::Models::Responses::WebSearchTool - ) - ] - ) - end - def tools=(_) + .void end + attr_writer :tools # An alternative to sampling with temperature, called nucleus sampling, where the # model considers the results of the tokens with top_p probability mass. So 0.1 @@ -250,12 +206,7 @@ module OpenAI # # We generally recommend altering this or `temperature` but not both. sig { returns(T.nilable(Float)) } - def top_p - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def top_p=(_) - end + attr_accessor :top_p # The truncation strategy to use for the model response. # @@ -264,52 +215,69 @@ module OpenAI # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - sig { returns(T.nilable(Symbol)) } - def truncation - end - - sig { params(_: T.nilable(Symbol)).returns(T.nilable(Symbol)) } - def truncation=(_) - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseCreateParams::Truncation::OrSymbol)) } + attr_accessor :truncation # A unique identifier representing your end-user, which can help OpenAI to monitor # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). sig { returns(T.nilable(String)) } - def user - end + attr_reader :user - sig { params(_: String).returns(String) } - def user=(_) - end + sig { params(user: String).void } + attr_writer :user sig do params( - input: T.any(String, OpenAI::Models::Responses::ResponseInput), - model: T.any(String, Symbol), - include: T.nilable(T::Array[Symbol]), + input: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol), + include: T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]), instructions: T.nilable(String), max_output_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), parallel_tool_calls: T.nilable(T::Boolean), previous_response_id: T.nilable(String), - reasoning: T.nilable(OpenAI::Models::Reasoning), + reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash)), store: T.nilable(T::Boolean), temperature: T.nilable(Float), - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool ) ], top_p: T.nilable(Float), - truncation: T.nilable(Symbol), + truncation: T.nilable(OpenAI::Models::Responses::ResponseCreateParams::Truncation::OrSymbol), user: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -339,19 +307,40 @@ module OpenAI override .returns( { - input: T.any(String, OpenAI::Models::Responses::ResponseInput), - model: T.any(String, Symbol), - include: T.nilable(T::Array[Symbol]), + input: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol), + include: T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]), instructions: T.nilable(String), max_output_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), parallel_tool_calls: T.nilable(T::Boolean), previous_response_id: T.nilable(String), reasoning: T.nilable(OpenAI::Models::Reasoning), store: T.nilable(T::Boolean), temperature: T.nilable(Float), text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, @@ -361,7 +350,7 @@ module OpenAI ) ], top_p: T.nilable(Float), - truncation: T.nilable(Symbol), + truncation: T.nilable(OpenAI::Models::Responses::ResponseCreateParams::Truncation::OrSymbol), user: String, request_options: OpenAI::RequestOptions } @@ -379,33 +368,49 @@ module OpenAI # - [File inputs](https://platform.openai.com/docs/guides/pdf-files) # - [Conversation state](https://platform.openai.com/docs/guides/conversation-state) # - [Function calling](https://platform.openai.com/docs/guides/function-calling) - class Input < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(String, OpenAI::Models::Responses::ResponseInput)} } - end - - # Model ID used to generate the response, like `gpt-4o` or `o1`. OpenAI offers a - # wide range of models with different capabilities, performance characteristics, - # and price points. Refer to the - # [model guide](https://platform.openai.com/docs/models) to browse and compare - # available models. - class Model < OpenAI::Union - abstract! - - Variants = type_template(:out) { {fixed: T.any(String, Symbol)} } + module Input + extend OpenAI::Union + + sig do + override + .returns( + [ + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ] + ) + end + def self.variants + end end # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. - class ToolChoice < OpenAI::Union - abstract! + module ToolChoice + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction) - } + sig do + override + .returns( + [OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] + ) + end + def self.variants end end @@ -416,13 +421,20 @@ module OpenAI # window by dropping input items in the middle of the conversation. # - `disabled` (default): If a model response will exceed the context window size # for a model, the request will fail with a 400 error. - class Truncation < OpenAI::Enum - abstract! + module Truncation + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation::TaggedSymbol) } - AUTO = :auto - DISABLED = :disabled + AUTO = T.let(:auto, OpenAI::Models::Responses::ResponseCreateParams::Truncation::TaggedSymbol) + DISABLED = T.let(:disabled, OpenAI::Models::Responses::ResponseCreateParams::Truncation::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseCreateParams::Truncation::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_created_event.rbi b/rbi/lib/openai/models/responses/response_created_event.rbi index c68b3697..0ff42037 100644 --- a/rbi/lib/openai/models/responses/response_created_event.rbi +++ b/rbi/lib/openai/models/responses/response_created_event.rbi @@ -6,24 +6,20 @@ module OpenAI class ResponseCreatedEvent < OpenAI::BaseModel # The response that was created. sig { returns(OpenAI::Models::Responses::Response) } - def response - end + attr_reader :response - sig { params(_: OpenAI::Models::Responses::Response).returns(OpenAI::Models::Responses::Response) } - def response=(_) - end + sig { params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash)).void } + attr_writer :response # The type of the event. Always `response.created`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An event that is emitted when a response is created. - sig { params(response: OpenAI::Models::Responses::Response, type: Symbol).returns(T.attached_class) } + sig do + params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(response:, type: :"response.created") end diff --git a/rbi/lib/openai/models/responses/response_delete_params.rbi b/rbi/lib/openai/models/responses/response_delete_params.rbi index b268b24b..92e2ddb7 100644 --- a/rbi/lib/openai/models/responses/response_delete_params.rbi +++ b/rbi/lib/openai/models/responses/response_delete_params.rbi @@ -4,12 +4,16 @@ module OpenAI module Models module Responses class ResponseDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/responses/response_error.rbi b/rbi/lib/openai/models/responses/response_error.rbi index 7f9b2db2..a000c309 100644 --- a/rbi/lib/openai/models/responses/response_error.rbi +++ b/rbi/lib/openai/models/responses/response_error.rbi @@ -5,56 +5,66 @@ module OpenAI module Responses class ResponseError < OpenAI::BaseModel # The error code for the response. - sig { returns(Symbol) } - def code - end - - sig { params(_: Symbol).returns(Symbol) } - def code=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) } + attr_accessor :code # A human-readable description of the error. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # An error object returned when the model fails to generate a Response. - sig { params(code: Symbol, message: String).returns(T.attached_class) } + sig do + params(code: OpenAI::Models::Responses::ResponseError::Code::OrSymbol, message: String) + .returns(T.attached_class) + end def self.new(code:, message:) end - sig { override.returns({code: Symbol, message: String}) } + sig { override.returns({code: OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol, message: String}) } def to_hash end # The error code for the response. - class Code < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - SERVER_ERROR = :server_error - RATE_LIMIT_EXCEEDED = :rate_limit_exceeded - INVALID_PROMPT = :invalid_prompt - VECTOR_STORE_TIMEOUT = :vector_store_timeout - INVALID_IMAGE = :invalid_image - INVALID_IMAGE_FORMAT = :invalid_image_format - INVALID_BASE64_IMAGE = :invalid_base64_image - INVALID_IMAGE_URL = :invalid_image_url - IMAGE_TOO_LARGE = :image_too_large - IMAGE_TOO_SMALL = :image_too_small - IMAGE_PARSE_ERROR = :image_parse_error - IMAGE_CONTENT_POLICY_VIOLATION = :image_content_policy_violation - INVALID_IMAGE_MODE = :invalid_image_mode - IMAGE_FILE_TOO_LARGE = :image_file_too_large - UNSUPPORTED_IMAGE_MEDIA_TYPE = :unsupported_image_media_type - EMPTY_IMAGE_FILE = :empty_image_file - FAILED_TO_DOWNLOAD_IMAGE = :failed_to_download_image - IMAGE_FILE_NOT_FOUND = :image_file_not_found + module Code + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseError::Code) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) } + + SERVER_ERROR = T.let(:server_error, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + RATE_LIMIT_EXCEEDED = + T.let(:rate_limit_exceeded, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_PROMPT = T.let(:invalid_prompt, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + VECTOR_STORE_TIMEOUT = + T.let(:vector_store_timeout, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_IMAGE = T.let(:invalid_image, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_IMAGE_FORMAT = + T.let(:invalid_image_format, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_BASE64_IMAGE = + T.let(:invalid_base64_image, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_IMAGE_URL = + T.let(:invalid_image_url, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_TOO_LARGE = T.let(:image_too_large, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_TOO_SMALL = T.let(:image_too_small, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_PARSE_ERROR = + T.let(:image_parse_error, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_CONTENT_POLICY_VIOLATION = + T.let(:image_content_policy_violation, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + INVALID_IMAGE_MODE = + T.let(:invalid_image_mode, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_FILE_TOO_LARGE = + T.let(:image_file_too_large, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + UNSUPPORTED_IMAGE_MEDIA_TYPE = + T.let(:unsupported_image_media_type, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + EMPTY_IMAGE_FILE = T.let(:empty_image_file, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + FAILED_TO_DOWNLOAD_IMAGE = + T.let(:failed_to_download_image, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + IMAGE_FILE_NOT_FOUND = + T.let(:image_file_not_found, OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseError::Code::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_error_event.rbi b/rbi/lib/openai/models/responses/response_error_event.rbi index f4c0e9f0..303a0210 100644 --- a/rbi/lib/openai/models/responses/response_error_event.rbi +++ b/rbi/lib/openai/models/responses/response_error_event.rbi @@ -6,39 +6,19 @@ module OpenAI class ResponseErrorEvent < OpenAI::BaseModel # The error code. sig { returns(T.nilable(String)) } - def code - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def code=(_) - end + attr_accessor :code # The error message. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The error parameter. sig { returns(T.nilable(String)) } - def param - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def param=(_) - end + attr_accessor :param # The type of the event. Always `error`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when an error occurs. sig do diff --git a/rbi/lib/openai/models/responses/response_failed_event.rbi b/rbi/lib/openai/models/responses/response_failed_event.rbi index c6d9fd32..8a3b97e1 100644 --- a/rbi/lib/openai/models/responses/response_failed_event.rbi +++ b/rbi/lib/openai/models/responses/response_failed_event.rbi @@ -6,24 +6,20 @@ module OpenAI class ResponseFailedEvent < OpenAI::BaseModel # The response that failed. sig { returns(OpenAI::Models::Responses::Response) } - def response - end + attr_reader :response - sig { params(_: OpenAI::Models::Responses::Response).returns(OpenAI::Models::Responses::Response) } - def response=(_) - end + sig { params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash)).void } + attr_writer :response # The type of the event. Always `response.failed`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An event that is emitted when a response fails. - sig { params(response: OpenAI::Models::Responses::Response, type: Symbol).returns(T.attached_class) } + sig do + params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(response:, type: :"response.failed") end diff --git a/rbi/lib/openai/models/responses/response_file_search_call_completed_event.rbi b/rbi/lib/openai/models/responses/response_file_search_call_completed_event.rbi index ffb5cae7..fd8d4c62 100644 --- a/rbi/lib/openai/models/responses/response_file_search_call_completed_event.rbi +++ b/rbi/lib/openai/models/responses/response_file_search_call_completed_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseFileSearchCallCompletedEvent < OpenAI::BaseModel # The ID of the output item that the file search call is initiated. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the file search call is initiated. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.file_search_call.completed`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a file search call is completed (results found). sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_file_search_call_in_progress_event.rbi b/rbi/lib/openai/models/responses/response_file_search_call_in_progress_event.rbi index 2feeebed..621c0706 100644 --- a/rbi/lib/openai/models/responses/response_file_search_call_in_progress_event.rbi +++ b/rbi/lib/openai/models/responses/response_file_search_call_in_progress_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseFileSearchCallInProgressEvent < OpenAI::BaseModel # The ID of the output item that the file search call is initiated. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the file search call is initiated. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.file_search_call.in_progress`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a file search call is initiated. sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_file_search_call_searching_event.rbi b/rbi/lib/openai/models/responses/response_file_search_call_searching_event.rbi index b340e2ff..849e6603 100644 --- a/rbi/lib/openai/models/responses/response_file_search_call_searching_event.rbi +++ b/rbi/lib/openai/models/responses/response_file_search_call_searching_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseFileSearchCallSearchingEvent < OpenAI::BaseModel # The ID of the output item that the file search call is initiated. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the file search call is searching. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.file_search_call.searching`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a file search is currently searching. sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_file_search_tool_call.rbi b/rbi/lib/openai/models/responses/response_file_search_tool_call.rbi index 17a4bdb2..55b6067b 100644 --- a/rbi/lib/openai/models/responses/response_file_search_tool_call.rbi +++ b/rbi/lib/openai/models/responses/response_file_search_tool_call.rbi @@ -6,52 +6,24 @@ module OpenAI class ResponseFileSearchToolCall < OpenAI::BaseModel # The unique ID of the file search tool call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The queries used to search for files. sig { returns(T::Array[String]) } - def queries - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def queries=(_) - end + attr_accessor :queries # The status of the file search tool call. One of `in_progress`, `searching`, # `incomplete` or `failed`, - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::OrSymbol) } + attr_accessor :status # The type of the file search tool call. Always `file_search_call`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The results of the file search tool call. sig { returns(T.nilable(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result])) } - def results - end - - sig do - params(_: T.nilable(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result])) - .returns(T.nilable(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result])) - end - def results=(_) - end + attr_accessor :results # The results of a file search tool call. See the # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) @@ -60,8 +32,10 @@ module OpenAI params( id: String, queries: T::Array[String], - status: Symbol, - results: T.nilable(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result]), + status: OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::OrSymbol, + results: T.nilable( + T::Array[T.any(OpenAI::Models::Responses::ResponseFileSearchToolCall::Result, OpenAI::Util::AnyHash)] + ), type: Symbol ) .returns(T.attached_class) @@ -75,7 +49,7 @@ module OpenAI { id: String, queries: T::Array[String], - status: Symbol, + status: OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::OrSymbol, type: Symbol, results: T.nilable(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result]) } @@ -86,16 +60,27 @@ module OpenAI # The status of the file search tool call. One of `in_progress`, `searching`, # `incomplete` or `failed`, - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) + SEARCHING = + T.let(:searching, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - SEARCHING = :searching - COMPLETED = :completed - INCOMPLETE = :incomplete - FAILED = :failed + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Status::TaggedSymbol]) } + def self.values + end end class Result < OpenAI::BaseModel @@ -105,51 +90,35 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes # The unique ID of the file. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The name of the file. sig { returns(T.nilable(String)) } - def filename - end + attr_reader :filename - sig { params(_: String).returns(String) } - def filename=(_) - end + sig { params(filename: String).void } + attr_writer :filename # The relevance score of the file - a value between 0 and 1. sig { returns(T.nilable(Float)) } - def score - end + attr_reader :score - sig { params(_: Float).returns(Float) } - def score=(_) - end + sig { params(score: Float).void } + attr_writer :score # The text that was retrieved from the file. sig { returns(T.nilable(String)) } - def text - end + attr_reader :text - sig { params(_: String).returns(String) } - def text=(_) - end + sig { params(text: String).void } + attr_writer :text sig do params( @@ -179,10 +148,12 @@ module OpenAI def to_hash end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/responses/response_format_text_config.rbi b/rbi/lib/openai/models/responses/response_format_text_config.rbi index f3595c51..24160f1c 100644 --- a/rbi/lib/openai/models/responses/response_format_text_config.rbi +++ b/rbi/lib/openai/models/responses/response_format_text_config.rbi @@ -16,17 +16,16 @@ module OpenAI # Setting to `{ "type": "json_object" }` enables the older JSON mode, which # ensures the message the model generates is valid JSON. Using `json_schema` is # preferred for models that support it. - class ResponseFormatTextConfig < OpenAI::Union - abstract! + module ResponseFormatTextConfig + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::ResponseFormatText, - OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, - OpenAI::Models::ResponseFormatJSONObject + sig do + override + .returns( + [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_format_text_json_schema_config.rbi b/rbi/lib/openai/models/responses/response_format_text_json_schema_config.rbi index aab69ea5..8d657f44 100644 --- a/rbi/lib/openai/models/responses/response_format_text_json_schema_config.rbi +++ b/rbi/lib/openai/models/responses/response_format_text_json_schema_config.rbi @@ -4,44 +4,27 @@ module OpenAI module Models module Responses class ResponseFormatTextJSONSchemaConfig < OpenAI::BaseModel + # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores + # and dashes, with a maximum length of 64. + sig { returns(String) } + attr_accessor :name + # The schema for the response format, described as a JSON Schema object. Learn how # to build JSON schemas [here](https://json-schema.org/). sig { returns(T::Hash[Symbol, T.anything]) } - def schema - end - - sig { params(_: T::Hash[Symbol, T.anything]).returns(T::Hash[Symbol, T.anything]) } - def schema=(_) - end + attr_accessor :schema # The type of response format being defined. Always `json_schema`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A description of what the response format is for, used by the model to determine # how to respond in the format. sig { returns(T.nilable(String)) } - def description - end + attr_reader :description - sig { params(_: String).returns(String) } - def description=(_) - end - - # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores - # and dashes, with a maximum length of 64. - sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(description: String).void } + attr_writer :description # Whether to enable strict schema adherence when generating the output. If set to # true, the model will always follow the exact schema defined in the `schema` @@ -49,37 +32,32 @@ module OpenAI # learn more, read the # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). sig { returns(T.nilable(T::Boolean)) } - def strict - end - - sig { params(_: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } - def strict=(_) - end + attr_accessor :strict # JSON Schema response format. Used to generate structured JSON responses. Learn # more about # [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). sig do params( + name: String, schema: T::Hash[Symbol, T.anything], description: String, - name: String, strict: T.nilable(T::Boolean), type: Symbol ) .returns(T.attached_class) end - def self.new(schema:, description: nil, name: nil, strict: nil, type: :json_schema) + def self.new(name:, schema:, description: nil, strict: nil, type: :json_schema) end sig do override .returns( { + name: String, schema: T::Hash[Symbol, T.anything], type: Symbol, description: String, - name: String, strict: T.nilable(T::Boolean) } ) diff --git a/rbi/lib/openai/models/responses/response_function_call_arguments_delta_event.rbi b/rbi/lib/openai/models/responses/response_function_call_arguments_delta_event.rbi index bd790e94..5aada226 100644 --- a/rbi/lib/openai/models/responses/response_function_call_arguments_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_function_call_arguments_delta_event.rbi @@ -6,39 +6,19 @@ module OpenAI class ResponseFunctionCallArgumentsDeltaEvent < OpenAI::BaseModel # The function-call arguments delta that is added. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The ID of the output item that the function-call arguments delta is added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the function-call arguments delta is added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.function_call_arguments.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when there is a partial function-call arguments delta. sig do diff --git a/rbi/lib/openai/models/responses/response_function_call_arguments_done_event.rbi b/rbi/lib/openai/models/responses/response_function_call_arguments_done_event.rbi index 48684e3e..ba8b13d1 100644 --- a/rbi/lib/openai/models/responses/response_function_call_arguments_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_function_call_arguments_done_event.rbi @@ -6,38 +6,18 @@ module OpenAI class ResponseFunctionCallArgumentsDoneEvent < OpenAI::BaseModel # The function-call arguments. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The ID of the item. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when function-call arguments are finalized. sig do diff --git a/rbi/lib/openai/models/responses/response_function_tool_call.rbi b/rbi/lib/openai/models/responses/response_function_tool_call.rbi index a92d38ed..0135732e 100644 --- a/rbi/lib/openai/models/responses/response_function_tool_call.rbi +++ b/rbi/lib/openai/models/responses/response_function_tool_call.rbi @@ -4,95 +4,89 @@ module OpenAI module Models module Responses class ResponseFunctionToolCall < OpenAI::BaseModel - # The unique ID of the function tool call. - sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end - # A JSON string of the arguments to pass to the function. sig { returns(String) } - def arguments - end - - sig { params(_: String).returns(String) } - def arguments=(_) - end + attr_accessor :arguments # The unique ID of the function tool call generated by the model. sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end + attr_accessor :call_id # The name of the function to run. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The type of the function tool call. Always `function_call`. sig { returns(Symbol) } - def type - end + attr_accessor :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + # The unique ID of the function tool call. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseFunctionToolCall::Status::OrSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseFunctionToolCall::Status::OrSymbol).void } + attr_writer :status # A tool call to run a function. See the # [function calling guide](https://platform.openai.com/docs/guides/function-calling) # for more information. sig do - params(id: String, arguments: String, call_id: String, name: String, status: Symbol, type: Symbol) + params( + arguments: String, + call_id: String, + name: String, + id: String, + status: OpenAI::Models::Responses::ResponseFunctionToolCall::Status::OrSymbol, + type: Symbol + ) .returns(T.attached_class) end - def self.new(id:, arguments:, call_id:, name:, status: nil, type: :function_call) + def self.new(arguments:, call_id:, name:, id: nil, status: nil, type: :function_call) end sig do override - .returns({ - id: String, - arguments: String, - call_id: String, - name: String, - type: Symbol, - status: Symbol - }) + .returns( + { + arguments: String, + call_id: String, + name: String, + type: Symbol, + id: String, + status: OpenAI::Models::Responses::ResponseFunctionToolCall::Status::OrSymbol + } + ) end def to_hash end # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseFunctionToolCall::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseFunctionToolCall::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseFunctionToolCall::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseFunctionToolCall::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseFunctionToolCall::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseFunctionToolCall::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_function_tool_call_item.rbi b/rbi/lib/openai/models/responses/response_function_tool_call_item.rbi new file mode 100644 index 00000000..8a6699fb --- /dev/null +++ b/rbi/lib/openai/models/responses/response_function_tool_call_item.rbi @@ -0,0 +1,24 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseFunctionToolCallItem < OpenAI::Models::Responses::ResponseFunctionToolCall + # The unique ID of the function tool call. + sig { returns(String) } + attr_accessor :id + + # A tool call to run a function. See the + # [function calling guide](https://platform.openai.com/docs/guides/function-calling) + # for more information. + sig { params(id: String).returns(T.attached_class) } + def self.new(id:) + end + + sig { override.returns({id: String}) } + def to_hash + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_function_tool_call_output_item.rbi b/rbi/lib/openai/models/responses/response_function_tool_call_output_item.rbi new file mode 100644 index 00000000..a3ae3675 --- /dev/null +++ b/rbi/lib/openai/models/responses/response_function_tool_call_output_item.rbi @@ -0,0 +1,86 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseFunctionToolCallOutputItem < OpenAI::BaseModel + # The unique ID of the function call tool output. + sig { returns(String) } + attr_accessor :id + + # The unique ID of the function tool call generated by the model. + sig { returns(String) } + attr_accessor :call_id + + # A JSON string of the output of the function tool call. + sig { returns(String) } + attr_accessor :output + + # The type of the function tool call output. Always `function_call_output`. + sig { returns(Symbol) } + attr_accessor :type + + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol)) } + attr_reader :status + + sig { params(status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::OrSymbol).void } + attr_writer :status + + sig do + params( + id: String, + call_id: String, + output: String, + status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::OrSymbol, + type: Symbol + ) + .returns(T.attached_class) + end + def self.new(id:, call_id:, output:, status: nil, type: :function_call_output) + end + + sig do + override + .returns( + { + id: String, + call_id: String, + output: String, + type: Symbol, + status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol + } + ) + end + def to_hash + end + + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol]) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_function_web_search.rbi b/rbi/lib/openai/models/responses/response_function_web_search.rbi index fa36c718..0dfe2413 100644 --- a/rbi/lib/openai/models/responses/response_function_web_search.rbi +++ b/rbi/lib/openai/models/responses/response_function_web_search.rbi @@ -6,52 +6,57 @@ module OpenAI class ResponseFunctionWebSearch < OpenAI::BaseModel # The unique ID of the web search tool call. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The status of the web search tool call. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::OrSymbol) } + attr_accessor :status # The type of the web search tool call. Always `web_search_call`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The results of a web search tool call. See the # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for # more information. - sig { params(id: String, status: Symbol, type: Symbol).returns(T.attached_class) } + sig do + params( + id: String, + status: OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::OrSymbol, + type: Symbol + ) + .returns(T.attached_class) + end def self.new(id:, status:, type: :web_search_call) end - sig { override.returns({id: String, status: Symbol, type: Symbol}) } + sig do + override + .returns( + {id: String, status: OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::OrSymbol, type: Symbol} + ) + end def to_hash end # The status of the web search tool call. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol) + SEARCHING = T.let(:searching, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - SEARCHING = :searching - COMPLETED = :completed - FAILED = :failed + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseFunctionWebSearch::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_in_progress_event.rbi b/rbi/lib/openai/models/responses/response_in_progress_event.rbi index 57a31950..7895e6a8 100644 --- a/rbi/lib/openai/models/responses/response_in_progress_event.rbi +++ b/rbi/lib/openai/models/responses/response_in_progress_event.rbi @@ -6,24 +6,20 @@ module OpenAI class ResponseInProgressEvent < OpenAI::BaseModel # The response that is in progress. sig { returns(OpenAI::Models::Responses::Response) } - def response - end + attr_reader :response - sig { params(_: OpenAI::Models::Responses::Response).returns(OpenAI::Models::Responses::Response) } - def response=(_) - end + sig { params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash)).void } + attr_writer :response # The type of the event. Always `response.in_progress`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when the response is in progress. - sig { params(response: OpenAI::Models::Responses::Response, type: Symbol).returns(T.attached_class) } + sig do + params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(response:, type: :"response.in_progress") end diff --git a/rbi/lib/openai/models/responses/response_includable.rbi b/rbi/lib/openai/models/responses/response_includable.rbi index 363cdad4..9b325a79 100644 --- a/rbi/lib/openai/models/responses/response_includable.rbi +++ b/rbi/lib/openai/models/responses/response_includable.rbi @@ -11,14 +11,25 @@ module OpenAI # - `message.input_image.image_url`: Include image urls from the input message. # - `computer_call_output.output.image_url`: Include image urls from the computer # call output. - class ResponseIncludable < OpenAI::Enum - abstract! + module ResponseIncludable + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseIncludable) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseIncludable::TaggedSymbol) } - FILE_SEARCH_CALL_RESULTS = :"file_search_call.results" - MESSAGE_INPUT_IMAGE_IMAGE_URL = :"message.input_image.image_url" - COMPUTER_CALL_OUTPUT_OUTPUT_IMAGE_URL = :"computer_call_output.output.image_url" + FILE_SEARCH_CALL_RESULTS = + T.let(:"file_search_call.results", OpenAI::Models::Responses::ResponseIncludable::TaggedSymbol) + MESSAGE_INPUT_IMAGE_IMAGE_URL = + T.let(:"message.input_image.image_url", OpenAI::Models::Responses::ResponseIncludable::TaggedSymbol) + COMPUTER_CALL_OUTPUT_OUTPUT_IMAGE_URL = + T.let( + :"computer_call_output.output.image_url", + OpenAI::Models::Responses::ResponseIncludable::TaggedSymbol + ) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseIncludable::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_incomplete_event.rbi b/rbi/lib/openai/models/responses/response_incomplete_event.rbi index 9ca0c85e..ea974ede 100644 --- a/rbi/lib/openai/models/responses/response_incomplete_event.rbi +++ b/rbi/lib/openai/models/responses/response_incomplete_event.rbi @@ -6,24 +6,20 @@ module OpenAI class ResponseIncompleteEvent < OpenAI::BaseModel # The response that was incomplete. sig { returns(OpenAI::Models::Responses::Response) } - def response - end + attr_reader :response - sig { params(_: OpenAI::Models::Responses::Response).returns(OpenAI::Models::Responses::Response) } - def response=(_) - end + sig { params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash)).void } + attr_writer :response # The type of the event. Always `response.incomplete`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An event that is emitted when a response finishes as incomplete. - sig { params(response: OpenAI::Models::Responses::Response, type: Symbol).returns(T.attached_class) } + sig do + params(response: T.any(OpenAI::Models::Responses::Response, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(response:, type: :"response.incomplete") end diff --git a/rbi/lib/openai/models/responses/response_input.rbi b/rbi/lib/openai/models/responses/response_input.rbi index 622e3348..d903e04f 100644 --- a/rbi/lib/openai/models/responses/response_input.rbi +++ b/rbi/lib/openai/models/responses/response_input.rbi @@ -3,23 +3,8 @@ module OpenAI module Models module Responses - ResponseInput = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Responses::EasyInputMessage, - OpenAI::Models::Responses::ResponseInputItem::Message, - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, - OpenAI::Models::Responses::ResponseReasoningItem, - OpenAI::Models::Responses::ResponseInputItem::ItemReference - ) - ] - end + ResponseInput = + T.let(OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseInputItem], OpenAI::Type::Converter) end end end diff --git a/rbi/lib/openai/models/responses/response_input_audio.rbi b/rbi/lib/openai/models/responses/response_input_audio.rbi index f49d5163..98923bc5 100644 --- a/rbi/lib/openai/models/responses/response_input_audio.rbi +++ b/rbi/lib/openai/models/responses/response_input_audio.rbi @@ -6,48 +6,51 @@ module OpenAI class ResponseInputAudio < OpenAI::BaseModel # Base64-encoded audio data. sig { returns(String) } - def data - end - - sig { params(_: String).returns(String) } - def data=(_) - end + attr_accessor :data # The format of the audio data. Currently supported formats are `mp3` and `wav`. - sig { returns(Symbol) } - def format_ - end - - sig { params(_: Symbol).returns(Symbol) } - def format_=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseInputAudio::Format::OrSymbol) } + attr_accessor :format_ # The type of the input item. Always `input_audio`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An audio input to the model. - sig { params(data: String, format_: Symbol, type: Symbol).returns(T.attached_class) } + sig do + params( + data: String, + format_: OpenAI::Models::Responses::ResponseInputAudio::Format::OrSymbol, + type: Symbol + ) + .returns(T.attached_class) + end def self.new(data:, format_:, type: :input_audio) end - sig { override.returns({data: String, format_: Symbol, type: Symbol}) } + sig do + override + .returns( + {data: String, format_: OpenAI::Models::Responses::ResponseInputAudio::Format::OrSymbol, type: Symbol} + ) + end def to_hash end # The format of the audio data. Currently supported formats are `mp3` and `wav`. - class Format < OpenAI::Enum - abstract! + module Format + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputAudio::Format) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputAudio::Format::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + MP3 = T.let(:mp3, OpenAI::Models::Responses::ResponseInputAudio::Format::TaggedSymbol) + WAV = T.let(:wav, OpenAI::Models::Responses::ResponseInputAudio::Format::TaggedSymbol) - MP3 = :mp3 - WAV = :wav + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputAudio::Format::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_input_content.rbi b/rbi/lib/openai/models/responses/response_input_content.rbi index 957c8020..d63620b1 100644 --- a/rbi/lib/openai/models/responses/response_input_content.rbi +++ b/rbi/lib/openai/models/responses/response_input_content.rbi @@ -4,17 +4,16 @@ module OpenAI module Models module Responses # A text input to the model. - class ResponseInputContent < OpenAI::Union - abstract! + module ResponseInputContent + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseInputText, - OpenAI::Models::Responses::ResponseInputImage, - OpenAI::Models::Responses::ResponseInputFile + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_input_file.rbi b/rbi/lib/openai/models/responses/response_input_file.rbi index cedf90ec..05c60269 100644 --- a/rbi/lib/openai/models/responses/response_input_file.rbi +++ b/rbi/lib/openai/models/responses/response_input_file.rbi @@ -6,39 +6,28 @@ module OpenAI class ResponseInputFile < OpenAI::BaseModel # The type of the input item. Always `input_file`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The content of the file to be sent to the model. sig { returns(T.nilable(String)) } - def file_data - end + attr_reader :file_data - sig { params(_: String).returns(String) } - def file_data=(_) - end + sig { params(file_data: String).void } + attr_writer :file_data # The ID of the file to be sent to the model. sig { returns(T.nilable(String)) } - def file_id - end + attr_reader :file_id - sig { params(_: String).returns(String) } - def file_id=(_) - end + sig { params(file_id: String).void } + attr_writer :file_id # The name of the file to be sent to the model. sig { returns(T.nilable(String)) } - def filename - end + attr_reader :filename - sig { params(_: String).returns(String) } - def filename=(_) - end + sig { params(filename: String).void } + attr_writer :filename # A file input to the model. sig do diff --git a/rbi/lib/openai/models/responses/response_input_image.rbi b/rbi/lib/openai/models/responses/response_input_image.rbi index f4e450ae..4d92987a 100644 --- a/rbi/lib/openai/models/responses/response_input_image.rbi +++ b/rbi/lib/openai/models/responses/response_input_image.rbi @@ -6,74 +6,66 @@ module OpenAI class ResponseInputImage < OpenAI::BaseModel # The detail level of the image to be sent to the model. One of `high`, `low`, or # `auto`. Defaults to `auto`. - sig { returns(Symbol) } - def detail - end - - sig { params(_: Symbol).returns(Symbol) } - def detail=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseInputImage::Detail::OrSymbol) } + attr_accessor :detail # The type of the input item. Always `input_image`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The ID of the file to be sent to the model. sig { returns(T.nilable(String)) } - def file_id - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def file_id=(_) - end + attr_accessor :file_id # The URL of the image to be sent to the model. A fully qualified URL or base64 # encoded image in a data URL. sig { returns(T.nilable(String)) } - def image_url - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def image_url=(_) - end + attr_accessor :image_url # An image input to the model. Learn about # [image inputs](https://platform.openai.com/docs/guides/vision). sig do - params(detail: Symbol, file_id: T.nilable(String), image_url: T.nilable(String), type: Symbol) + params( + detail: OpenAI::Models::Responses::ResponseInputImage::Detail::OrSymbol, + file_id: T.nilable(String), + image_url: T.nilable(String), + type: Symbol + ) .returns(T.attached_class) end def self.new(detail:, file_id: nil, image_url: nil, type: :input_image) end sig do - override.returns( - { - detail: Symbol, - type: Symbol, - file_id: T.nilable(String), - image_url: T.nilable(String) - } - ) + override + .returns( + { + detail: OpenAI::Models::Responses::ResponseInputImage::Detail::OrSymbol, + type: Symbol, + file_id: T.nilable(String), + image_url: T.nilable(String) + } + ) end def to_hash end # The detail level of the image to be sent to the model. One of `high`, `low`, or # `auto`. Defaults to `auto`. - class Detail < OpenAI::Enum - abstract! + module Detail + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputImage::Detail) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputImage::Detail::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + HIGH = T.let(:high, OpenAI::Models::Responses::ResponseInputImage::Detail::TaggedSymbol) + LOW = T.let(:low, OpenAI::Models::Responses::ResponseInputImage::Detail::TaggedSymbol) + AUTO = T.let(:auto, OpenAI::Models::Responses::ResponseInputImage::Detail::TaggedSymbol) - HIGH = :high - LOW = :low - AUTO = :auto + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputImage::Detail::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_input_item.rbi b/rbi/lib/openai/models/responses/response_input_item.rbi index fc0ede1f..7f12e53f 100644 --- a/rbi/lib/openai/models/responses/response_input_item.rbi +++ b/rbi/lib/openai/models/responses/response_input_item.rbi @@ -8,78 +8,60 @@ module OpenAI # precedence over instructions given with the `user` role. Messages with the # `assistant` role are presumed to have been generated by the model in previous # interactions. - class ResponseInputItem < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::EasyInputMessage, - OpenAI::Models::Responses::ResponseInputItem::Message, - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, - OpenAI::Models::Responses::ResponseReasoningItem, - OpenAI::Models::Responses::ResponseInputItem::ItemReference - ) - } - end + module ResponseInputItem + extend OpenAI::Union class Message < OpenAI::BaseModel # A list of one or many input items to the model, containing different content # types. - sig { returns(OpenAI::Models::Responses::ResponseInputMessageContentList) } - def content - end - sig do - params(_: OpenAI::Models::Responses::ResponseInputMessageContentList) - .returns(OpenAI::Models::Responses::ResponseInputMessageContentList) - end - def content=(_) + returns( + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ) end + attr_accessor :content # The role of the message input. One of `user`, `system`, or `developer`. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseInputItem::Message::Role::OrSymbol) } + attr_accessor :role # The status of item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputItem::Message::Status::OrSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseInputItem::Message::Status::OrSymbol).void } + attr_writer :status # The type of the message input. Always set to `message`. - sig { returns(T.nilable(Symbol)) } - def type - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputItem::Message::Type::OrSymbol)) } + attr_reader :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { params(type: OpenAI::Models::Responses::ResponseInputItem::Message::Type::OrSymbol).void } + attr_writer :type # A message input to the model with a role indicating instruction following # hierarchy. Instructions given with the `developer` or `system` role take # precedence over instructions given with the `user` role. sig do params( - content: OpenAI::Models::Responses::ResponseInputMessageContentList, - role: Symbol, - status: Symbol, - type: Symbol + content: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ], + role: OpenAI::Models::Responses::ResponseInputItem::Message::Role::OrSymbol, + status: OpenAI::Models::Responses::ResponseInputItem::Message::Status::OrSymbol, + type: OpenAI::Models::Responses::ResponseInputItem::Message::Type::OrSymbol ) .returns(T.attached_class) end @@ -89,84 +71,107 @@ module OpenAI sig do override .returns( - {content: OpenAI::Models::Responses::ResponseInputMessageContentList, role: Symbol, status: Symbol, type: Symbol} + { + content: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ], + role: OpenAI::Models::Responses::ResponseInputItem::Message::Role::OrSymbol, + status: OpenAI::Models::Responses::ResponseInputItem::Message::Status::OrSymbol, + type: OpenAI::Models::Responses::ResponseInputItem::Message::Type::OrSymbol + } ) end def to_hash end # The role of the message input. One of `user`, `system`, or `developer`. - class Role < OpenAI::Enum - abstract! + module Role + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Role::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + USER = T.let(:user, OpenAI::Models::Responses::ResponseInputItem::Message::Role::TaggedSymbol) + SYSTEM = T.let(:system, OpenAI::Models::Responses::ResponseInputItem::Message::Role::TaggedSymbol) + DEVELOPER = T.let(:developer, OpenAI::Models::Responses::ResponseInputItem::Message::Role::TaggedSymbol) - USER = :user - SYSTEM = :system - DEVELOPER = :developer + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputItem::Message::Role::TaggedSymbol]) } + def self.values + end end # The status of item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseInputItem::Message::Status::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseInputItem::Message::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseInputItem::Message::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputItem::Message::Status::TaggedSymbol]) } + def self.values + end end # The type of the message input. Always set to `message`. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Type::TaggedSymbol) } - MESSAGE = :message + MESSAGE = T.let(:message, OpenAI::Models::Responses::ResponseInputItem::Message::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputItem::Message::Type::TaggedSymbol]) } + def self.values + end end end class ComputerCallOutput < OpenAI::BaseModel # The ID of the computer tool call that produced the output. sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end + attr_accessor :call_id # A computer screenshot image used with the computer use tool. - sig { returns(OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output) } - def output - end + sig { returns(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot) } + attr_reader :output sig do - params(_: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output) - .returns(OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output) - end - def output=(_) + params( + output: T.any(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :output # The type of the computer tool call output. Always `computer_call_output`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The ID of the computer tool call output. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id # The safety checks reported by the API that have been acknowledged by the # developer. @@ -177,43 +182,54 @@ module OpenAI ) ) end - def acknowledged_safety_checks - end + attr_reader :acknowledged_safety_checks sig do params( - _: T::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck] - ) - .returns( - T::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck] + acknowledged_safety_checks: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck, + OpenAI::Util::AnyHash ) + ] + ) + .void end - def acknowledged_safety_checks=(_) - end + attr_writer :acknowledged_safety_checks # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::OrSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::OrSymbol).void } + attr_writer :status # The output of a computer tool call. sig do params( call_id: String, - output: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output, + output: T.any(OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, OpenAI::Util::AnyHash), id: String, - acknowledged_safety_checks: T::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck], - status: Symbol, + acknowledged_safety_checks: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck, + OpenAI::Util::AnyHash + ) + ], + status: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::OrSymbol, type: Symbol ) .returns(T.attached_class) end - def self.new(call_id:, output:, id: nil, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output) + def self.new( + call_id:, + output:, + id: nil, + acknowledged_safety_checks: nil, + status: nil, + type: :computer_call_output + ) end sig do @@ -221,83 +237,29 @@ module OpenAI .returns( { call_id: String, - output: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, type: Symbol, id: String, acknowledged_safety_checks: T::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck], - status: Symbol + status: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::OrSymbol } ) end def to_hash end - class Output < OpenAI::BaseModel - # Specifies the event type. For a computer screenshot, this property is always set - # to `computer_screenshot`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end - - # The identifier of an uploaded file that contains the screenshot. - sig { returns(T.nilable(String)) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end - - # The URL of the screenshot image. - sig { returns(T.nilable(String)) } - def image_url - end - - sig { params(_: String).returns(String) } - def image_url=(_) - end - - # A computer screenshot image used with the computer use tool. - sig { params(file_id: String, image_url: String, type: Symbol).returns(T.attached_class) } - def self.new(file_id: nil, image_url: nil, type: :computer_screenshot) - end - - sig { override.returns({type: Symbol, file_id: String, image_url: String}) } - def to_hash - end - end - class AcknowledgedSafetyCheck < OpenAI::BaseModel # The ID of the pending safety check. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The type of the pending safety check. sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end + attr_accessor :code # Details about the pending safety check. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # A pending safety check for the computer call. sig { params(id: String, code: String, message: String).returns(T.attached_class) } @@ -311,64 +273,61 @@ module OpenAI # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let( + :in_progress, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::TaggedSymbol + ) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status::TaggedSymbol]) + end + def self.values + end end end class FunctionCallOutput < OpenAI::BaseModel # The unique ID of the function tool call generated by the model. sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end + attr_accessor :call_id # A JSON string of the output of the function tool call. sig { returns(String) } - def output - end - - sig { params(_: String).returns(String) } - def output=(_) - end + attr_accessor :output # The type of the function tool call output. Always `function_call_output`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The unique ID of the function tool call output. Populated when this item is # returned via API. sig { returns(T.nilable(String)) } - def id - end + attr_reader :id - sig { params(_: String).returns(String) } - def id=(_) - end + sig { params(id: String).void } + attr_writer :id # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::OrSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::OrSymbol).void } + attr_writer :status # The output of a function tool call. sig do @@ -376,50 +335,66 @@ module OpenAI call_id: String, output: String, id: String, - status: Symbol, + status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::OrSymbol, type: Symbol - ).returns(T.attached_class) + ) + .returns(T.attached_class) end def self.new(call_id:, output:, id: nil, status: nil, type: :function_call_output) end sig do - override.returns({call_id: String, output: String, type: Symbol, id: String, status: Symbol}) + override + .returns( + { + call_id: String, + output: String, + type: Symbol, + id: String, + status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::OrSymbol + } + ) end def to_hash end # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let( + :in_progress, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::TaggedSymbol + ) + COMPLETED = + T.let(:completed, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::TaggedSymbol) + + sig do + override + .returns(T::Array[OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status::TaggedSymbol]) + end + def self.values + end end end class ItemReference < OpenAI::BaseModel # The ID of the item to reference. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The type of item to reference. Always `item_reference`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An internal identifier for an item to reference. sig { params(id: String, type: Symbol).returns(T.attached_class) } @@ -430,6 +405,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ItemReference] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/responses/response_input_message_content_list.rbi b/rbi/lib/openai/models/responses/response_input_message_content_list.rbi index d4c36f8d..174cada3 100644 --- a/rbi/lib/openai/models/responses/response_input_message_content_list.rbi +++ b/rbi/lib/openai/models/responses/response_input_message_content_list.rbi @@ -3,15 +3,8 @@ module OpenAI module Models module Responses - ResponseInputMessageContentList = T.type_alias do - T::Array[ - T.any( - OpenAI::Models::Responses::ResponseInputText, - OpenAI::Models::Responses::ResponseInputImage, - OpenAI::Models::Responses::ResponseInputFile - ) - ] - end + ResponseInputMessageContentList = + T.let(OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseInputContent], OpenAI::Type::Converter) end end end diff --git a/rbi/lib/openai/models/responses/response_input_message_item.rbi b/rbi/lib/openai/models/responses/response_input_message_item.rbi new file mode 100644 index 00000000..345adad7 --- /dev/null +++ b/rbi/lib/openai/models/responses/response_input_message_item.rbi @@ -0,0 +1,141 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseInputMessageItem < OpenAI::BaseModel + # The unique ID of the message input. + sig { returns(String) } + attr_accessor :id + + # A list of one or many input items to the model, containing different content + # types. + sig do + returns( + T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ] + ) + end + attr_accessor :content + + # The role of the message input. One of `user`, `system`, or `developer`. + sig { returns(OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol) } + attr_accessor :role + + # The status of item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol)) } + attr_reader :status + + sig { params(status: OpenAI::Models::Responses::ResponseInputMessageItem::Status::OrSymbol).void } + attr_writer :status + + # The type of the message input. Always set to `message`. + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseInputMessageItem::Type::TaggedSymbol)) } + attr_reader :type + + sig { params(type: OpenAI::Models::Responses::ResponseInputMessageItem::Type::OrSymbol).void } + attr_writer :type + + sig do + params( + id: String, + content: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ], + role: OpenAI::Models::Responses::ResponseInputMessageItem::Role::OrSymbol, + status: OpenAI::Models::Responses::ResponseInputMessageItem::Status::OrSymbol, + type: OpenAI::Models::Responses::ResponseInputMessageItem::Type::OrSymbol + ) + .returns(T.attached_class) + end + def self.new(id:, content:, role:, status: nil, type: nil) + end + + sig do + override + .returns( + { + id: String, + content: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseInputText, + OpenAI::Models::Responses::ResponseInputImage, + OpenAI::Models::Responses::ResponseInputFile + ) + ], + role: OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol, + status: OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol, + type: OpenAI::Models::Responses::ResponseInputMessageItem::Type::TaggedSymbol + } + ) + end + def to_hash + end + + # The role of the message input. One of `user`, `system`, or `developer`. + module Role + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol) } + + USER = T.let(:user, OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol) + SYSTEM = T.let(:system, OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol) + DEVELOPER = T.let(:developer, OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputMessageItem::Role::TaggedSymbol]) } + def self.values + end + end + + # The status of item. One of `in_progress`, `completed`, or `incomplete`. + # Populated when items are returned via API. + module Status + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol) } + + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol) + INCOMPLETE = + T.let(:incomplete, OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputMessageItem::Status::TaggedSymbol]) } + def self.values + end + end + + # The type of the message input. Always set to `message`. + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type::TaggedSymbol) } + + MESSAGE = T.let(:message, OpenAI::Models::Responses::ResponseInputMessageItem::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseInputMessageItem::Type::TaggedSymbol]) } + def self.values + end + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_input_text.rbi b/rbi/lib/openai/models/responses/response_input_text.rbi index 16fc4040..5c0838ec 100644 --- a/rbi/lib/openai/models/responses/response_input_text.rbi +++ b/rbi/lib/openai/models/responses/response_input_text.rbi @@ -6,21 +6,11 @@ module OpenAI class ResponseInputText < OpenAI::BaseModel # The text input to the model. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of the input item. Always `input_text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A text input to the model. sig { params(text: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_item.rbi b/rbi/lib/openai/models/responses/response_item.rbi new file mode 100644 index 00000000..b57094c5 --- /dev/null +++ b/rbi/lib/openai/models/responses/response_item.rbi @@ -0,0 +1,21 @@ +# typed: strong + +module OpenAI + module Models + module Responses + # Content item used to generate a response. + module ResponseItem + extend OpenAI::Union + + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/lib/openai/models/responses/response_item_list.rbi b/rbi/lib/openai/models/responses/response_item_list.rbi index f6e9982c..a7e4d918 100644 --- a/rbi/lib/openai/models/responses/response_item_list.rbi +++ b/rbi/lib/openai/models/responses/response_item_list.rbi @@ -2,8 +2,6 @@ module OpenAI module Models - ResponseItemList = T.type_alias { Responses::ResponseItemList } - module Responses class ResponseItemList < OpenAI::BaseModel # A list of items used to generate this response. @@ -11,103 +9,50 @@ module OpenAI returns( T::Array[ T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, + OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput + OpenAI::Models::Responses::ResponseFunctionToolCallItem, + OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem ) ] ) end - def data - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput - ) - ] - ) - end - def data=(_) - end + attr_accessor :data # The ID of the first item in the list. sig { returns(String) } - def first_id - end - - sig { params(_: String).returns(String) } - def first_id=(_) - end + attr_accessor :first_id # Whether there are more items available. sig { returns(T::Boolean) } - def has_more - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def has_more=(_) - end + attr_accessor :has_more # The ID of the last item in the list. sig { returns(String) } - def last_id - end - - sig { params(_: String).returns(String) } - def last_id=(_) - end + attr_accessor :last_id # The type of object returned, must be `list`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # A list of Response items. sig do params( data: T::Array[ T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, + OpenAI::Models::Responses::ResponseInputMessageItem, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput + OpenAI::Models::Responses::ResponseFunctionToolCallItem, + OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem ) ], first_id: String, @@ -126,14 +71,14 @@ module OpenAI { data: T::Array[ T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, + OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput + OpenAI::Models::Responses::ResponseFunctionToolCallItem, + OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem ) ], first_id: String, @@ -145,410 +90,9 @@ module OpenAI end def to_hash end - - # Content item used to generate a response. - class Data < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput - ) - } - end - - class Message < OpenAI::BaseModel - # The unique ID of the message input. - sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end - - # A list of one or many input items to the model, containing different content - # types. - sig { returns(OpenAI::Models::Responses::ResponseInputMessageContentList) } - def content - end - - sig do - params(_: OpenAI::Models::Responses::ResponseInputMessageContentList) - .returns(OpenAI::Models::Responses::ResponseInputMessageContentList) - end - def content=(_) - end - - # The role of the message input. One of `user`, `system`, or `developer`. - sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end - - # The status of item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end - - # The type of the message input. Always set to `message`. - sig { returns(T.nilable(Symbol)) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end - - sig do - params( - id: String, - content: OpenAI::Models::Responses::ResponseInputMessageContentList, - role: Symbol, - status: Symbol, - type: Symbol - ) - .returns(T.attached_class) - end - def self.new(id:, content:, role:, status: nil, type: nil) - end - - sig do - override - .returns( - { - id: String, - content: OpenAI::Models::Responses::ResponseInputMessageContentList, - role: Symbol, - status: Symbol, - type: Symbol - } - ) - end - def to_hash - end - - # The role of the message input. One of `user`, `system`, or `developer`. - class Role < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - USER = :user - SYSTEM = :system - DEVELOPER = :developer - end - - # The status of item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - end - - # The type of the message input. Always set to `message`. - class Type < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - MESSAGE = :message - end - end - - class ComputerCallOutput < OpenAI::BaseModel - # The unique ID of the computer call tool output. - sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end - - # The ID of the computer tool call that produced the output. - sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end - - # A computer screenshot image used with the computer use tool. - sig { returns(OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output) } - def output - end - - sig do - params(_: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output) - .returns(OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output) - end - def output=(_) - end - - # The type of the computer tool call output. Always `computer_call_output`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end - - # The safety checks reported by the API that have been acknowledged by the - # developer. - sig do - returns( - T.nilable( - T::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] - ) - ) - end - def acknowledged_safety_checks - end - - sig do - params( - _: T::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] - ) - .returns( - T::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] - ) - end - def acknowledged_safety_checks=(_) - end - - # The status of the message input. One of `in_progress`, `completed`, or - # `incomplete`. Populated when input items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end - - sig do - params( - id: String, - call_id: String, - output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output, - acknowledged_safety_checks: T::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck], - status: Symbol, - type: Symbol - ) - .returns(T.attached_class) - end - def self.new(id:, call_id:, output:, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output) - end - - sig do - override - .returns( - { - id: String, - call_id: String, - output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output, - type: Symbol, - acknowledged_safety_checks: T::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck], - status: Symbol - } - ) - end - def to_hash - end - - class Output < OpenAI::BaseModel - # Specifies the event type. For a computer screenshot, this property is always set - # to `computer_screenshot`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end - - # The identifier of an uploaded file that contains the screenshot. - sig { returns(T.nilable(String)) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end - - # The URL of the screenshot image. - sig { returns(T.nilable(String)) } - def image_url - end - - sig { params(_: String).returns(String) } - def image_url=(_) - end - - # A computer screenshot image used with the computer use tool. - sig { params(file_id: String, image_url: String, type: Symbol).returns(T.attached_class) } - def self.new(file_id: nil, image_url: nil, type: :computer_screenshot) - end - - sig { override.returns({type: Symbol, file_id: String, image_url: String}) } - def to_hash - end - end - - class AcknowledgedSafetyCheck < OpenAI::BaseModel - # The ID of the pending safety check. - sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end - - # The type of the pending safety check. - sig { returns(String) } - def code - end - - sig { params(_: String).returns(String) } - def code=(_) - end - - # Details about the pending safety check. - sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end - - # A pending safety check for the computer call. - sig { params(id: String, code: String, message: String).returns(T.attached_class) } - def self.new(id:, code:, message:) - end - - sig { override.returns({id: String, code: String, message: String}) } - def to_hash - end - end - - # The status of the message input. One of `in_progress`, `completed`, or - # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - end - end - - class FunctionCallOutput < OpenAI::BaseModel - # The unique ID of the function call tool output. - sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end - - # The unique ID of the function tool call generated by the model. - sig { returns(String) } - def call_id - end - - sig { params(_: String).returns(String) } - def call_id=(_) - end - - # A JSON string of the output of the function tool call. - sig { returns(String) } - def output - end - - sig { params(_: String).returns(String) } - def output=(_) - end - - # The type of the function tool call output. Always `function_call_output`. - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end - - # The status of the item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end - - sig do - params( - id: String, - call_id: String, - output: String, - status: Symbol, - type: Symbol - ).returns(T.attached_class) - end - def self.new(id:, call_id:, output:, status: nil, type: :function_call_output) - end - - sig do - override.returns({id: String, call_id: String, output: String, type: Symbol, status: Symbol}) - end - def to_hash - end - - # The status of the item. One of `in_progress`, `completed`, or `incomplete`. - # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete - end - end - end end end + + ResponseItemList = Responses::ResponseItemList end end diff --git a/rbi/lib/openai/models/responses/response_output_audio.rbi b/rbi/lib/openai/models/responses/response_output_audio.rbi index 162e5138..c5a26f54 100644 --- a/rbi/lib/openai/models/responses/response_output_audio.rbi +++ b/rbi/lib/openai/models/responses/response_output_audio.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseOutputAudio < OpenAI::BaseModel # Base64-encoded audio data from the model. sig { returns(String) } - def data - end - - sig { params(_: String).returns(String) } - def data=(_) - end + attr_accessor :data # The transcript of the audio data from the model. sig { returns(String) } - def transcript - end - - sig { params(_: String).returns(String) } - def transcript=(_) - end + attr_accessor :transcript # The type of the output audio. Always `output_audio`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An audio output from the model. sig { params(data: String, transcript: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_output_item.rbi b/rbi/lib/openai/models/responses/response_output_item.rbi index 75949da7..9d893172 100644 --- a/rbi/lib/openai/models/responses/response_output_item.rbi +++ b/rbi/lib/openai/models/responses/response_output_item.rbi @@ -4,20 +4,16 @@ module OpenAI module Models module Responses # An output message from the model. - class ResponseOutputItem < OpenAI::Union - abstract! + module ResponseOutputItem + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_output_item_added_event.rbi b/rbi/lib/openai/models/responses/response_output_item_added_event.rbi index 0e49a206..648d48d9 100644 --- a/rbi/lib/openai/models/responses/response_output_item_added_event.rbi +++ b/rbi/lib/openai/models/responses/response_output_item_added_event.rbi @@ -17,57 +17,22 @@ module OpenAI ) ) end - def item - end - - sig do - params( - _: T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ) - .returns( - T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ) - end - def item=(_) - end + attr_accessor :item # The index of the output item that was added. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.output_item.added`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a new output item is added. sig do params( item: T.any( OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, diff --git a/rbi/lib/openai/models/responses/response_output_item_done_event.rbi b/rbi/lib/openai/models/responses/response_output_item_done_event.rbi index e53adef5..1d8ebd83 100644 --- a/rbi/lib/openai/models/responses/response_output_item_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_output_item_done_event.rbi @@ -17,57 +17,22 @@ module OpenAI ) ) end - def item - end - - sig do - params( - _: T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ) - .returns( - T.any( - OpenAI::Models::Responses::ResponseOutputMessage, - OpenAI::Models::Responses::ResponseFileSearchToolCall, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseReasoningItem - ) - ) - end - def item=(_) - end + attr_accessor :item # The index of the output item that was marked done. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.output_item.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when an output item is marked done. sig do params( item: T.any( OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, diff --git a/rbi/lib/openai/models/responses/response_output_message.rbi b/rbi/lib/openai/models/responses/response_output_message.rbi index 7fb7026c..d91e17f1 100644 --- a/rbi/lib/openai/models/responses/response_output_message.rbi +++ b/rbi/lib/openai/models/responses/response_output_message.rbi @@ -6,12 +6,7 @@ module OpenAI class ResponseOutputMessage < OpenAI::BaseModel # The unique ID of the output message. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The content of the output message. sig do @@ -19,54 +14,33 @@ module OpenAI T::Array[T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] ) end - def content - end - - sig do - params( - _: T::Array[T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - ) - .returns( - T::Array[T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)] - ) - end - def content=(_) - end + attr_accessor :content # The role of the output message. Always `assistant`. sig { returns(Symbol) } - def role - end - - sig { params(_: Symbol).returns(Symbol) } - def role=(_) - end + attr_accessor :role # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Responses::ResponseOutputMessage::Status::OrSymbol) } + attr_accessor :status # The type of the output message. Always `message`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # An output message from the model. sig do params( id: String, - content: T::Array[T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)], - status: Symbol, + content: T::Array[ + T.any( + OpenAI::Models::Responses::ResponseOutputText, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseOutputRefusal + ) + ], + status: OpenAI::Models::Responses::ResponseOutputMessage::Status::OrSymbol, role: Symbol, type: Symbol ) @@ -82,7 +56,7 @@ module OpenAI id: String, content: T::Array[T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)], role: Symbol, - status: Symbol, + status: OpenAI::Models::Responses::ResponseOutputMessage::Status::OrSymbol, type: Symbol } ) @@ -91,26 +65,33 @@ module OpenAI end # A text output from the model. - class Content < OpenAI::Union - abstract! + module Content + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal) - } + sig do + override + .returns([OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal]) + end + def self.variants end end # The status of the message input. One of `in_progress`, `completed`, or # `incomplete`. Populated when input items are returned via API. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseOutputMessage::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseOutputMessage::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Responses::ResponseOutputMessage::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseOutputMessage::Status::TaggedSymbol) + INCOMPLETE = T.let(:incomplete, OpenAI::Models::Responses::ResponseOutputMessage::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseOutputMessage::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_output_refusal.rbi b/rbi/lib/openai/models/responses/response_output_refusal.rbi index 1db3c101..5e416cf9 100644 --- a/rbi/lib/openai/models/responses/response_output_refusal.rbi +++ b/rbi/lib/openai/models/responses/response_output_refusal.rbi @@ -6,21 +6,11 @@ module OpenAI class ResponseOutputRefusal < OpenAI::BaseModel # The refusal explanationfrom the model. sig { returns(String) } - def refusal - end - - sig { params(_: String).returns(String) } - def refusal=(_) - end + attr_accessor :refusal # The type of the refusal. Always `refusal`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A refusal from the model. sig { params(refusal: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_output_text.rbi b/rbi/lib/openai/models/responses/response_output_text.rbi index e04d3988..561c4b12 100644 --- a/rbi/lib/openai/models/responses/response_output_text.rbi +++ b/rbi/lib/openai/models/responses/response_output_text.rbi @@ -16,49 +16,15 @@ module OpenAI ] ) end - def annotations - end - - sig do - params( - _: T::Array[ - T.any( - OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath - ) - ] - ) - .returns( - T::Array[ - T.any( - OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath - ) - ] - ) - end - def annotations=(_) - end + attr_accessor :annotations # The text output from the model. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of the output text. Always `output_text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A text output from the model. sig do @@ -66,6 +32,7 @@ module OpenAI annotations: T::Array[ T.any( OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath ) @@ -98,46 +65,21 @@ module OpenAI end # A citation to a file. - class Annotation < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath - ) - } - end + module Annotation + extend OpenAI::Union class FileCitation < OpenAI::BaseModel # The ID of the file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The index of the file in the list of files. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of the file citation. Always `file_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A citation to a file. sig { params(file_id: String, index: Integer, type: Symbol).returns(T.attached_class) } @@ -152,48 +94,23 @@ module OpenAI class URLCitation < OpenAI::BaseModel # The index of the last character of the URL citation in the message. sig { returns(Integer) } - def end_index - end - - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + attr_accessor :end_index # The index of the first character of the URL citation in the message. sig { returns(Integer) } - def start_index - end - - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + attr_accessor :start_index # The title of the web resource. sig { returns(String) } - def title - end - - sig { params(_: String).returns(String) } - def title=(_) - end + attr_accessor :title # The type of the URL citation. Always `url_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The URL of the web resource. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # A citation for a web resource used to generate a model response. sig do @@ -221,30 +138,15 @@ module OpenAI class FilePath < OpenAI::BaseModel # The ID of the file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The index of the file in the list of files. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of the file path. Always `file_path`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A path to a file. sig { params(file_id: String, index: Integer, type: Symbol).returns(T.attached_class) } @@ -255,6 +157,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/responses/response_reasoning_item.rbi b/rbi/lib/openai/models/responses/response_reasoning_item.rbi index 66b69b58..ba09b049 100644 --- a/rbi/lib/openai/models/responses/response_reasoning_item.rbi +++ b/rbi/lib/openai/models/responses/response_reasoning_item.rbi @@ -6,51 +6,31 @@ module OpenAI class ResponseReasoningItem < OpenAI::BaseModel # The unique identifier of the reasoning content. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # Reasoning text contents. sig { returns(T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary]) } - def summary - end - - sig do - params(_: T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary]) - .returns(T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary]) - end - def summary=(_) - end + attr_accessor :summary # The type of the object. Always `reasoning`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - sig { returns(T.nilable(Symbol)) } - def status - end + sig { returns(T.nilable(OpenAI::Models::Responses::ResponseReasoningItem::Status::OrSymbol)) } + attr_reader :status - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { params(status: OpenAI::Models::Responses::ResponseReasoningItem::Status::OrSymbol).void } + attr_writer :status # A description of the chain of thought used by a reasoning model while generating # a response. sig do params( id: String, - summary: T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary], - status: Symbol, + summary: T::Array[T.any(OpenAI::Models::Responses::ResponseReasoningItem::Summary, OpenAI::Util::AnyHash)], + status: OpenAI::Models::Responses::ResponseReasoningItem::Status::OrSymbol, type: Symbol ) .returns(T.attached_class) @@ -65,7 +45,7 @@ module OpenAI id: String, summary: T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary], type: Symbol, - status: Symbol + status: OpenAI::Models::Responses::ResponseReasoningItem::Status::OrSymbol } ) end @@ -75,21 +55,11 @@ module OpenAI class Summary < OpenAI::BaseModel # A short summary of the reasoning used by the model when generating the response. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of the object. Always `summary_text`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type sig { params(text: String, type: Symbol).returns(T.attached_class) } def self.new(text:, type: :summary_text) @@ -102,14 +72,20 @@ module OpenAI # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseReasoningItem::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseReasoningItem::Status::TaggedSymbol) } - IN_PROGRESS = :in_progress - COMPLETED = :completed - INCOMPLETE = :incomplete + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Responses::ResponseReasoningItem::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseReasoningItem::Status::TaggedSymbol) + INCOMPLETE = T.let(:incomplete, OpenAI::Models::Responses::ResponseReasoningItem::Status::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseReasoningItem::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_refusal_delta_event.rbi b/rbi/lib/openai/models/responses/response_refusal_delta_event.rbi index f4a53f02..cbbd66ed 100644 --- a/rbi/lib/openai/models/responses/response_refusal_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_refusal_delta_event.rbi @@ -6,48 +6,23 @@ module OpenAI class ResponseRefusalDeltaEvent < OpenAI::BaseModel # The index of the content part that the refusal text is added to. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The refusal text that is added. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The ID of the output item that the refusal text is added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the refusal text is added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.refusal.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when there is a partial refusal text. sig do diff --git a/rbi/lib/openai/models/responses/response_refusal_done_event.rbi b/rbi/lib/openai/models/responses/response_refusal_done_event.rbi index 1e4bf80b..1f24f6df 100644 --- a/rbi/lib/openai/models/responses/response_refusal_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_refusal_done_event.rbi @@ -6,48 +6,23 @@ module OpenAI class ResponseRefusalDoneEvent < OpenAI::BaseModel # The index of the content part that the refusal text is finalized. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The ID of the output item that the refusal text is finalized. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the refusal text is finalized. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The refusal text that is finalized. sig { returns(String) } - def refusal - end - - sig { params(_: String).returns(String) } - def refusal=(_) - end + attr_accessor :refusal # The type of the event. Always `response.refusal.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when refusal text is finalized. sig do diff --git a/rbi/lib/openai/models/responses/response_retrieve_params.rbi b/rbi/lib/openai/models/responses/response_retrieve_params.rbi index 8e817f0d..df3a5dc9 100644 --- a/rbi/lib/openai/models/responses/response_retrieve_params.rbi +++ b/rbi/lib/openai/models/responses/response_retrieve_params.rbi @@ -4,30 +4,36 @@ module OpenAI module Models module Responses class ResponseRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # Additional fields to include in the response. See the `include` parameter for # Response creation above for more information. - sig { returns(T.nilable(T::Array[Symbol])) } - def include - end + sig { returns(T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol])) } + attr_reader :include - sig { params(_: T::Array[Symbol]).returns(T::Array[Symbol]) } - def include=(_) - end + sig { params(include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]).void } + attr_writer :include sig do params( - include: T::Array[Symbol], - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end def self.new(include: nil, request_options: {}) end - sig { override.returns({include: T::Array[Symbol], request_options: OpenAI::RequestOptions}) } + sig do + override + .returns( + { + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], + request_options: OpenAI::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/lib/openai/models/responses/response_status.rbi b/rbi/lib/openai/models/responses/response_status.rbi index f6a3f6ce..a46776c9 100644 --- a/rbi/lib/openai/models/responses/response_status.rbi +++ b/rbi/lib/openai/models/responses/response_status.rbi @@ -5,15 +5,20 @@ module OpenAI module Responses # The status of the response generation. One of `completed`, `failed`, # `in_progress`, or `incomplete`. - class ResponseStatus < OpenAI::Enum - abstract! + module ResponseStatus + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ResponseStatus) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ResponseStatus::TaggedSymbol) } - COMPLETED = :completed - FAILED = :failed - IN_PROGRESS = :in_progress - INCOMPLETE = :incomplete + COMPLETED = T.let(:completed, OpenAI::Models::Responses::ResponseStatus::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::Responses::ResponseStatus::TaggedSymbol) + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::Responses::ResponseStatus::TaggedSymbol) + INCOMPLETE = T.let(:incomplete, OpenAI::Models::Responses::ResponseStatus::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ResponseStatus::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/response_stream_event.rbi b/rbi/lib/openai/models/responses/response_stream_event.rbi index 0b1bb12f..e04029c8 100644 --- a/rbi/lib/openai/models/responses/response_stream_event.rbi +++ b/rbi/lib/openai/models/responses/response_stream_event.rbi @@ -4,46 +4,16 @@ module OpenAI module Models module Responses # Emitted when there is a partial audio response. - class ResponseStreamEvent < OpenAI::Union - abstract! + module ResponseStreamEvent + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseAudioDeltaEvent, - OpenAI::Models::Responses::ResponseAudioDoneEvent, - OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, - OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, - OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, - OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, - OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, - OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, - OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, - OpenAI::Models::Responses::ResponseCompletedEvent, - OpenAI::Models::Responses::ResponseContentPartAddedEvent, - OpenAI::Models::Responses::ResponseContentPartDoneEvent, - OpenAI::Models::Responses::ResponseCreatedEvent, - OpenAI::Models::Responses::ResponseErrorEvent, - OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, - OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, - OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, - OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, - OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, - OpenAI::Models::Responses::ResponseInProgressEvent, - OpenAI::Models::Responses::ResponseFailedEvent, - OpenAI::Models::Responses::ResponseIncompleteEvent, - OpenAI::Models::Responses::ResponseOutputItemAddedEvent, - OpenAI::Models::Responses::ResponseOutputItemDoneEvent, - OpenAI::Models::Responses::ResponseRefusalDeltaEvent, - OpenAI::Models::Responses::ResponseRefusalDoneEvent, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, - OpenAI::Models::Responses::ResponseTextDeltaEvent, - OpenAI::Models::Responses::ResponseTextDoneEvent, - OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, - OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, - OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/response_text_annotation_delta_event.rbi b/rbi/lib/openai/models/responses/response_text_annotation_delta_event.rbi index 00dfd4c2..4ad5009e 100644 --- a/rbi/lib/openai/models/responses/response_text_annotation_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_text_annotation_delta_event.rbi @@ -14,78 +14,34 @@ module OpenAI ) ) end - def annotation - end - - sig do - params( - _: T.any( - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath - ) - ) - .returns( - T.any( - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath - ) - ) - end - def annotation=(_) - end + attr_accessor :annotation # The index of the annotation that was added. sig { returns(Integer) } - def annotation_index - end - - sig { params(_: Integer).returns(Integer) } - def annotation_index=(_) - end + attr_accessor :annotation_index # The index of the content part that the text annotation was added to. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The ID of the output item that the text annotation was added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the text annotation was added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.output_text.annotation.added`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a text annotation is added. sig do params( annotation: T.any( OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath ), @@ -128,46 +84,21 @@ module OpenAI end # A citation to a file. - class Annotation < OpenAI::Union - abstract! - - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, - OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath - ) - } - end + module Annotation + extend OpenAI::Union class FileCitation < OpenAI::BaseModel # The ID of the file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The index of the file in the list of files. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of the file citation. Always `file_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A citation to a file. sig { params(file_id: String, index: Integer, type: Symbol).returns(T.attached_class) } @@ -182,48 +113,23 @@ module OpenAI class URLCitation < OpenAI::BaseModel # The index of the last character of the URL citation in the message. sig { returns(Integer) } - def end_index - end - - sig { params(_: Integer).returns(Integer) } - def end_index=(_) - end + attr_accessor :end_index # The index of the first character of the URL citation in the message. sig { returns(Integer) } - def start_index - end - - sig { params(_: Integer).returns(Integer) } - def start_index=(_) - end + attr_accessor :start_index # The title of the web resource. sig { returns(String) } - def title - end - - sig { params(_: String).returns(String) } - def title=(_) - end + attr_accessor :title # The type of the URL citation. Always `url_citation`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # The URL of the web resource. sig { returns(String) } - def url - end - - sig { params(_: String).returns(String) } - def url=(_) - end + attr_accessor :url # A citation for a web resource used to generate a model response. sig do @@ -251,30 +157,15 @@ module OpenAI class FilePath < OpenAI::BaseModel # The ID of the file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The index of the file in the list of files. sig { returns(Integer) } - def index - end - - sig { params(_: Integer).returns(Integer) } - def index=(_) - end + attr_accessor :index # The type of the file path. Always `file_path`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # A path to a file. sig { params(file_id: String, index: Integer, type: Symbol).returns(T.attached_class) } @@ -285,6 +176,15 @@ module OpenAI def to_hash end end + + sig do + override + .returns( + [OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath] + ) + end + def self.variants + end end end end diff --git a/rbi/lib/openai/models/responses/response_text_config.rbi b/rbi/lib/openai/models/responses/response_text_config.rbi index 2287e496..240a7e92 100644 --- a/rbi/lib/openai/models/responses/response_text_config.rbi +++ b/rbi/lib/openai/models/responses/response_text_config.rbi @@ -28,27 +28,20 @@ module OpenAI ) ) end - def format_ - end + attr_reader :format_ sig do params( - _: T.any( + format_: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject ) ) - .returns( - T.any( - OpenAI::Models::ResponseFormatText, - OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, - OpenAI::Models::ResponseFormatJSONObject - ) - ) - end - def format_=(_) + .void end + attr_writer :format_ # Configuration options for a text response from the model. Can be plain text or # structured JSON data. Learn more: @@ -59,6 +52,7 @@ module OpenAI params( format_: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject ) diff --git a/rbi/lib/openai/models/responses/response_text_delta_event.rbi b/rbi/lib/openai/models/responses/response_text_delta_event.rbi index 50307018..efb4c979 100644 --- a/rbi/lib/openai/models/responses/response_text_delta_event.rbi +++ b/rbi/lib/openai/models/responses/response_text_delta_event.rbi @@ -6,48 +6,23 @@ module OpenAI class ResponseTextDeltaEvent < OpenAI::BaseModel # The index of the content part that the text delta was added to. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The text delta that was added. sig { returns(String) } - def delta - end - - sig { params(_: String).returns(String) } - def delta=(_) - end + attr_accessor :delta # The ID of the output item that the text delta was added to. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the text delta was added to. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.output_text.delta`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when there is an additional text delta. sig do diff --git a/rbi/lib/openai/models/responses/response_text_done_event.rbi b/rbi/lib/openai/models/responses/response_text_done_event.rbi index 56e6ddd7..b8e7bf9a 100644 --- a/rbi/lib/openai/models/responses/response_text_done_event.rbi +++ b/rbi/lib/openai/models/responses/response_text_done_event.rbi @@ -6,48 +6,23 @@ module OpenAI class ResponseTextDoneEvent < OpenAI::BaseModel # The index of the content part that the text content is finalized. sig { returns(Integer) } - def content_index - end - - sig { params(_: Integer).returns(Integer) } - def content_index=(_) - end + attr_accessor :content_index # The ID of the output item that the text content is finalized. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the text content is finalized. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The text content that is finalized. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of the event. Always `response.output_text.done`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when text content is finalized. sig do diff --git a/rbi/lib/openai/models/responses/response_usage.rbi b/rbi/lib/openai/models/responses/response_usage.rbi index b46f45aa..1ec163da 100644 --- a/rbi/lib/openai/models/responses/response_usage.rbi +++ b/rbi/lib/openai/models/responses/response_usage.rbi @@ -6,55 +6,59 @@ module OpenAI class ResponseUsage < OpenAI::BaseModel # The number of input tokens. sig { returns(Integer) } - def input_tokens - end + attr_accessor :input_tokens + + # A detailed breakdown of the input tokens. + sig { returns(OpenAI::Models::Responses::ResponseUsage::InputTokensDetails) } + attr_reader :input_tokens_details - sig { params(_: Integer).returns(Integer) } - def input_tokens=(_) + sig do + params( + input_tokens_details: T.any(OpenAI::Models::Responses::ResponseUsage::InputTokensDetails, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :input_tokens_details # The number of output tokens. sig { returns(Integer) } - def output_tokens - end - - sig { params(_: Integer).returns(Integer) } - def output_tokens=(_) - end + attr_accessor :output_tokens # A detailed breakdown of the output tokens. sig { returns(OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails) } - def output_tokens_details - end + attr_reader :output_tokens_details sig do - params(_: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails) - .returns(OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails) - end - def output_tokens_details=(_) + params( + output_tokens_details: T.any(OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :output_tokens_details # The total number of tokens used. sig { returns(Integer) } - def total_tokens - end - - sig { params(_: Integer).returns(Integer) } - def total_tokens=(_) - end + attr_accessor :total_tokens # Represents token usage details including input tokens, output tokens, a # breakdown of output tokens, and the total tokens used. sig do params( input_tokens: Integer, + input_tokens_details: T.any(OpenAI::Models::Responses::ResponseUsage::InputTokensDetails, OpenAI::Util::AnyHash), output_tokens: Integer, - output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, + output_tokens_details: T.any(OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, OpenAI::Util::AnyHash), total_tokens: Integer ) .returns(T.attached_class) end - def self.new(input_tokens:, output_tokens:, output_tokens_details:, total_tokens:) + def self.new( + input_tokens:, + input_tokens_details:, + output_tokens:, + output_tokens_details:, + total_tokens: + ) end sig do @@ -62,6 +66,7 @@ module OpenAI .returns( { input_tokens: Integer, + input_tokens_details: OpenAI::Models::Responses::ResponseUsage::InputTokensDetails, output_tokens: Integer, output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, total_tokens: Integer @@ -71,15 +76,26 @@ module OpenAI def to_hash end - class OutputTokensDetails < OpenAI::BaseModel - # The number of reasoning tokens. + class InputTokensDetails < OpenAI::BaseModel + # The number of tokens that were retrieved from the cache. + # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). sig { returns(Integer) } - def reasoning_tokens + attr_accessor :cached_tokens + + # A detailed breakdown of the input tokens. + sig { params(cached_tokens: Integer).returns(T.attached_class) } + def self.new(cached_tokens:) end - sig { params(_: Integer).returns(Integer) } - def reasoning_tokens=(_) + sig { override.returns({cached_tokens: Integer}) } + def to_hash end + end + + class OutputTokensDetails < OpenAI::BaseModel + # The number of reasoning tokens. + sig { returns(Integer) } + attr_accessor :reasoning_tokens # A detailed breakdown of the output tokens. sig { params(reasoning_tokens: Integer).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_web_search_call_completed_event.rbi b/rbi/lib/openai/models/responses/response_web_search_call_completed_event.rbi index 1348fded..b02a5b1f 100644 --- a/rbi/lib/openai/models/responses/response_web_search_call_completed_event.rbi +++ b/rbi/lib/openai/models/responses/response_web_search_call_completed_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseWebSearchCallCompletedEvent < OpenAI::BaseModel # Unique ID for the output item associated with the web search call. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the web search call is associated with. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.web_search_call.completed`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a web search call is completed. sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_web_search_call_in_progress_event.rbi b/rbi/lib/openai/models/responses/response_web_search_call_in_progress_event.rbi index 891725d6..11aa3340 100644 --- a/rbi/lib/openai/models/responses/response_web_search_call_in_progress_event.rbi +++ b/rbi/lib/openai/models/responses/response_web_search_call_in_progress_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseWebSearchCallInProgressEvent < OpenAI::BaseModel # Unique ID for the output item associated with the web search call. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the web search call is associated with. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.web_search_call.in_progress`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a web search call is initiated. sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/response_web_search_call_searching_event.rbi b/rbi/lib/openai/models/responses/response_web_search_call_searching_event.rbi index a2f0a421..c97724d2 100644 --- a/rbi/lib/openai/models/responses/response_web_search_call_searching_event.rbi +++ b/rbi/lib/openai/models/responses/response_web_search_call_searching_event.rbi @@ -6,30 +6,15 @@ module OpenAI class ResponseWebSearchCallSearchingEvent < OpenAI::BaseModel # Unique ID for the output item associated with the web search call. sig { returns(String) } - def item_id - end - - sig { params(_: String).returns(String) } - def item_id=(_) - end + attr_accessor :item_id # The index of the output item that the web search call is associated with. sig { returns(Integer) } - def output_index - end - - sig { params(_: Integer).returns(Integer) } - def output_index=(_) - end + attr_accessor :output_index # The type of the event. Always `response.web_search_call.searching`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Emitted when a web search call is executing. sig { params(item_id: String, output_index: Integer, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/tool.rbi b/rbi/lib/openai/models/responses/tool.rbi index e1477b05..0f080b1b 100644 --- a/rbi/lib/openai/models/responses/tool.rbi +++ b/rbi/lib/openai/models/responses/tool.rbi @@ -6,18 +6,16 @@ module OpenAI # A tool that searches for relevant content from uploaded files. Learn more about # the # [file search tool](https://platform.openai.com/docs/guides/tools-file-search). - class Tool < OpenAI::Union - abstract! + module Tool + extend OpenAI::Union - Variants = type_template(:out) do - { - fixed: T.any( - OpenAI::Models::Responses::FileSearchTool, - OpenAI::Models::Responses::FunctionTool, - OpenAI::Models::Responses::ComputerTool, - OpenAI::Models::Responses::WebSearchTool + sig do + override + .returns( + [OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool] ) - } + end + def self.variants end end end diff --git a/rbi/lib/openai/models/responses/tool_choice_function.rbi b/rbi/lib/openai/models/responses/tool_choice_function.rbi index a8afd2d4..29aa1b6c 100644 --- a/rbi/lib/openai/models/responses/tool_choice_function.rbi +++ b/rbi/lib/openai/models/responses/tool_choice_function.rbi @@ -6,21 +6,11 @@ module OpenAI class ToolChoiceFunction < OpenAI::BaseModel # The name of the function to call. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # For function calling, the type is always `function`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Use this option to force the model to call a specific function. sig { params(name: String, type: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/responses/tool_choice_options.rbi b/rbi/lib/openai/models/responses/tool_choice_options.rbi index c047abb7..27f51058 100644 --- a/rbi/lib/openai/models/responses/tool_choice_options.rbi +++ b/rbi/lib/openai/models/responses/tool_choice_options.rbi @@ -11,14 +11,19 @@ module OpenAI # more tools. # # `required` means the model must call one or more tools. - class ToolChoiceOptions < OpenAI::Enum - abstract! + module ToolChoiceOptions + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ToolChoiceOptions) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol) } - NONE = :none - AUTO = :auto - REQUIRED = :required + NONE = T.let(:none, OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol) + AUTO = T.let(:auto, OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol) + REQUIRED = T.let(:required, OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::ToolChoiceOptions::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/tool_choice_types.rbi b/rbi/lib/openai/models/responses/tool_choice_types.rbi index 8459293b..6119c6e4 100644 --- a/rbi/lib/openai/models/responses/tool_choice_types.rbi +++ b/rbi/lib/openai/models/responses/tool_choice_types.rbi @@ -12,21 +12,16 @@ module OpenAI # - `file_search` # - `web_search_preview` # - `computer_use_preview` - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Responses::ToolChoiceTypes::Type::OrSymbol) } + attr_accessor :type # Indicates that the model should use a built-in tool to generate a response. # [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools). - sig { params(type: Symbol).returns(T.attached_class) } + sig { params(type: OpenAI::Models::Responses::ToolChoiceTypes::Type::OrSymbol).returns(T.attached_class) } def self.new(type:) end - sig { override.returns({type: Symbol}) } + sig { override.returns({type: OpenAI::Models::Responses::ToolChoiceTypes::Type::OrSymbol}) } def to_hash end @@ -38,15 +33,23 @@ module OpenAI # - `file_search` # - `web_search_preview` # - `computer_use_preview` - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::ToolChoiceTypes::Type) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + FILE_SEARCH = T.let(:file_search, OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol) + WEB_SEARCH_PREVIEW = + T.let(:web_search_preview, OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol) + COMPUTER_USE_PREVIEW = + T.let(:computer_use_preview, OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol) + WEB_SEARCH_PREVIEW_2025_03_11 = + T.let(:web_search_preview_2025_03_11, OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol) - FILE_SEARCH = :file_search - WEB_SEARCH_PREVIEW = :web_search_preview - COMPUTER_USE_PREVIEW = :computer_use_preview - WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11 + sig { override.returns(T::Array[OpenAI::Models::Responses::ToolChoiceTypes::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/responses/web_search_tool.rbi b/rbi/lib/openai/models/responses/web_search_tool.rbi index cf2fb2f6..86e24a9b 100644 --- a/rbi/lib/openai/models/responses/web_search_tool.rbi +++ b/rbi/lib/openai/models/responses/web_search_tool.rbi @@ -8,43 +8,36 @@ module OpenAI # # - `web_search_preview` # - `web_search_preview_2025_03_11` - sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + sig { returns(OpenAI::Models::Responses::WebSearchTool::Type::OrSymbol) } + attr_accessor :type # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - sig { returns(T.nilable(Symbol)) } - def search_context_size - end + sig { returns(T.nilable(OpenAI::Models::Responses::WebSearchTool::SearchContextSize::OrSymbol)) } + attr_reader :search_context_size - sig { params(_: Symbol).returns(Symbol) } - def search_context_size=(_) - end + sig { params(search_context_size: OpenAI::Models::Responses::WebSearchTool::SearchContextSize::OrSymbol).void } + attr_writer :search_context_size sig { returns(T.nilable(OpenAI::Models::Responses::WebSearchTool::UserLocation)) } - def user_location - end + attr_reader :user_location sig do - params(_: T.nilable(OpenAI::Models::Responses::WebSearchTool::UserLocation)) - .returns(T.nilable(OpenAI::Models::Responses::WebSearchTool::UserLocation)) - end - def user_location=(_) + params( + user_location: T.nilable(T.any(OpenAI::Models::Responses::WebSearchTool::UserLocation, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :user_location # This tool searches the web for relevant results to use in a response. Learn more # about the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search). sig do params( - type: Symbol, - search_context_size: Symbol, - user_location: T.nilable(OpenAI::Models::Responses::WebSearchTool::UserLocation) + type: OpenAI::Models::Responses::WebSearchTool::Type::OrSymbol, + search_context_size: OpenAI::Models::Responses::WebSearchTool::SearchContextSize::OrSymbol, + user_location: T.nilable(T.any(OpenAI::Models::Responses::WebSearchTool::UserLocation, OpenAI::Util::AnyHash)) ) .returns(T.attached_class) end @@ -55,8 +48,8 @@ module OpenAI override .returns( { - type: Symbol, - search_context_size: Symbol, + type: OpenAI::Models::Responses::WebSearchTool::Type::OrSymbol, + search_context_size: OpenAI::Models::Responses::WebSearchTool::SearchContextSize::OrSymbol, user_location: T.nilable(OpenAI::Models::Responses::WebSearchTool::UserLocation) } ) @@ -68,74 +61,75 @@ module OpenAI # # - `web_search_preview` # - `web_search_preview_2025_03_11` - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum - Value = type_template(:out) { {fixed: Symbol} } + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Responses::WebSearchTool::Type) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Responses::WebSearchTool::Type::TaggedSymbol) } - WEB_SEARCH_PREVIEW = :web_search_preview - WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11 + WEB_SEARCH_PREVIEW = + T.let(:web_search_preview, OpenAI::Models::Responses::WebSearchTool::Type::TaggedSymbol) + WEB_SEARCH_PREVIEW_2025_03_11 = + T.let(:web_search_preview_2025_03_11, OpenAI::Models::Responses::WebSearchTool::Type::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::Responses::WebSearchTool::Type::TaggedSymbol]) } + def self.values + end end # High level guidance for the amount of context window space to use for the # search. One of `low`, `medium`, or `high`. `medium` is the default. - class SearchContextSize < OpenAI::Enum - abstract! + module SearchContextSize + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::Responses::WebSearchTool::SearchContextSize) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::Responses::WebSearchTool::SearchContextSize::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + LOW = T.let(:low, OpenAI::Models::Responses::WebSearchTool::SearchContextSize::TaggedSymbol) + MEDIUM = T.let(:medium, OpenAI::Models::Responses::WebSearchTool::SearchContextSize::TaggedSymbol) + HIGH = T.let(:high, OpenAI::Models::Responses::WebSearchTool::SearchContextSize::TaggedSymbol) - LOW = :low - MEDIUM = :medium - HIGH = :high + sig { override.returns(T::Array[OpenAI::Models::Responses::WebSearchTool::SearchContextSize::TaggedSymbol]) } + def self.values + end end class UserLocation < OpenAI::BaseModel # The type of location approximation. Always `approximate`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Free text input for the city of the user, e.g. `San Francisco`. sig { returns(T.nilable(String)) } - def city - end + attr_reader :city - sig { params(_: String).returns(String) } - def city=(_) - end + sig { params(city: String).void } + attr_writer :city # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of # the user, e.g. `US`. sig { returns(T.nilable(String)) } - def country - end + attr_reader :country - sig { params(_: String).returns(String) } - def country=(_) - end + sig { params(country: String).void } + attr_writer :country # Free text input for the region of the user, e.g. `California`. sig { returns(T.nilable(String)) } - def region - end + attr_reader :region - sig { params(_: String).returns(String) } - def region=(_) - end + sig { params(region: String).void } + attr_writer :region # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the # user, e.g. `America/Los_Angeles`. sig { returns(T.nilable(String)) } - def timezone - end + attr_reader :timezone - sig { params(_: String).returns(String) } - def timezone=(_) - end + sig { params(timezone: String).void } + attr_writer :timezone sig do params(city: String, country: String, region: String, timezone: String, type: Symbol) diff --git a/rbi/lib/openai/models/responses_model.rbi b/rbi/lib/openai/models/responses_model.rbi new file mode 100644 index 00000000..4e2b1c2b --- /dev/null +++ b/rbi/lib/openai/models/responses_model.rbi @@ -0,0 +1,22 @@ +# typed: strong + +module OpenAI + module Models + module ResponsesModel + extend OpenAI::Union + + sig { override.returns([String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol]) } + def self.variants + end + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::ResponsesModel) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::ResponsesModel::TaggedSymbol) } + + O1_PRO = T.let(:"o1-pro", OpenAI::Models::ResponsesModel::TaggedSymbol) + O1_PRO_2025_03_19 = T.let(:"o1-pro-2025-03-19", OpenAI::Models::ResponsesModel::TaggedSymbol) + COMPUTER_USE_PREVIEW = T.let(:"computer-use-preview", OpenAI::Models::ResponsesModel::TaggedSymbol) + COMPUTER_USE_PREVIEW_2025_03_11 = + T.let(:"computer-use-preview-2025-03-11", OpenAI::Models::ResponsesModel::TaggedSymbol) + end + end +end diff --git a/rbi/lib/openai/models/static_file_chunking_strategy.rbi b/rbi/lib/openai/models/static_file_chunking_strategy.rbi index 1d8d219c..bb5abe4d 100644 --- a/rbi/lib/openai/models/static_file_chunking_strategy.rbi +++ b/rbi/lib/openai/models/static_file_chunking_strategy.rbi @@ -7,22 +7,12 @@ module OpenAI # # Note that the overlap must not exceed half of `max_chunk_size_tokens`. sig { returns(Integer) } - def chunk_overlap_tokens - end - - sig { params(_: Integer).returns(Integer) } - def chunk_overlap_tokens=(_) - end + attr_accessor :chunk_overlap_tokens # The maximum number of tokens in each chunk. The default value is `800`. The # minimum value is `100` and the maximum value is `4096`. sig { returns(Integer) } - def max_chunk_size_tokens - end - - sig { params(_: Integer).returns(Integer) } - def max_chunk_size_tokens=(_) - end + attr_accessor :max_chunk_size_tokens sig { params(chunk_overlap_tokens: Integer, max_chunk_size_tokens: Integer).returns(T.attached_class) } def self.new(chunk_overlap_tokens:, max_chunk_size_tokens:) diff --git a/rbi/lib/openai/models/static_file_chunking_strategy_object.rbi b/rbi/lib/openai/models/static_file_chunking_strategy_object.rbi index 99645473..eac14e48 100644 --- a/rbi/lib/openai/models/static_file_chunking_strategy_object.rbi +++ b/rbi/lib/openai/models/static_file_chunking_strategy_object.rbi @@ -4,23 +4,19 @@ module OpenAI module Models class StaticFileChunkingStrategyObject < OpenAI::BaseModel sig { returns(OpenAI::Models::StaticFileChunkingStrategy) } - def static - end + attr_reader :static - sig { params(_: OpenAI::Models::StaticFileChunkingStrategy).returns(OpenAI::Models::StaticFileChunkingStrategy) } - def static=(_) - end + sig { params(static: T.any(OpenAI::Models::StaticFileChunkingStrategy, OpenAI::Util::AnyHash)).void } + attr_writer :static # Always `static`. sig { returns(Symbol) } - def type - end + attr_accessor :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) + sig do + params(static: T.any(OpenAI::Models::StaticFileChunkingStrategy, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) end - - sig { params(static: OpenAI::Models::StaticFileChunkingStrategy, type: Symbol).returns(T.attached_class) } def self.new(static:, type: :static) end diff --git a/rbi/lib/openai/models/static_file_chunking_strategy_object_param.rbi b/rbi/lib/openai/models/static_file_chunking_strategy_object_param.rbi index a7ed94e1..5387db39 100644 --- a/rbi/lib/openai/models/static_file_chunking_strategy_object_param.rbi +++ b/rbi/lib/openai/models/static_file_chunking_strategy_object_param.rbi @@ -4,24 +4,20 @@ module OpenAI module Models class StaticFileChunkingStrategyObjectParam < OpenAI::BaseModel sig { returns(OpenAI::Models::StaticFileChunkingStrategy) } - def static - end + attr_reader :static - sig { params(_: OpenAI::Models::StaticFileChunkingStrategy).returns(OpenAI::Models::StaticFileChunkingStrategy) } - def static=(_) - end + sig { params(static: T.any(OpenAI::Models::StaticFileChunkingStrategy, OpenAI::Util::AnyHash)).void } + attr_writer :static # Always `static`. sig { returns(Symbol) } - def type - end - - sig { params(_: Symbol).returns(Symbol) } - def type=(_) - end + attr_accessor :type # Customize your own chunking strategy by setting chunk size and chunk overlap. - sig { params(static: OpenAI::Models::StaticFileChunkingStrategy, type: Symbol).returns(T.attached_class) } + sig do + params(static: T.any(OpenAI::Models::StaticFileChunkingStrategy, OpenAI::Util::AnyHash), type: Symbol) + .returns(T.attached_class) + end def self.new(static:, type: :static) end diff --git a/rbi/lib/openai/models/upload.rbi b/rbi/lib/openai/models/upload.rbi index 1da23f04..129170d8 100644 --- a/rbi/lib/openai/models/upload.rbi +++ b/rbi/lib/openai/models/upload.rbi @@ -5,86 +5,44 @@ module OpenAI class Upload < OpenAI::BaseModel # The Upload unique identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The intended number of bytes to be uploaded. sig { returns(Integer) } - def bytes - end - - sig { params(_: Integer).returns(Integer) } - def bytes=(_) - end + attr_accessor :bytes # The Unix timestamp (in seconds) for when the Upload was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The Unix timestamp (in seconds) for when the Upload will expire. sig { returns(Integer) } - def expires_at - end - - sig { params(_: Integer).returns(Integer) } - def expires_at=(_) - end + attr_accessor :expires_at # The name of the file to be uploaded. sig { returns(String) } - def filename - end - - sig { params(_: String).returns(String) } - def filename=(_) - end + attr_accessor :filename # The object type, which is always "upload". sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The intended purpose of the file. # [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose) # for acceptable values. sig { returns(String) } - def purpose - end - - sig { params(_: String).returns(String) } - def purpose=(_) - end + attr_accessor :purpose # The status of the Upload. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::Upload::Status::TaggedSymbol) } + attr_accessor :status # The `File` object represents a document that has been uploaded to OpenAI. sig { returns(T.nilable(OpenAI::Models::FileObject)) } - def file - end + attr_reader :file - sig { params(_: T.nilable(OpenAI::Models::FileObject)).returns(T.nilable(OpenAI::Models::FileObject)) } - def file=(_) - end + sig { params(file: T.nilable(T.any(OpenAI::Models::FileObject, OpenAI::Util::AnyHash))).void } + attr_writer :file # The Upload object can accept byte chunks in the form of Parts. sig do @@ -95,13 +53,23 @@ module OpenAI expires_at: Integer, filename: String, purpose: String, - status: Symbol, - file: T.nilable(OpenAI::Models::FileObject), + status: OpenAI::Models::Upload::Status::OrSymbol, + file: T.nilable(T.any(OpenAI::Models::FileObject, OpenAI::Util::AnyHash)), object: Symbol ) .returns(T.attached_class) end - def self.new(id:, bytes:, created_at:, expires_at:, filename:, purpose:, status:, file: nil, object: :upload) + def self.new( + id:, + bytes:, + created_at:, + expires_at:, + filename:, + purpose:, + status:, + file: nil, + object: :upload + ) end sig do @@ -115,7 +83,7 @@ module OpenAI filename: String, object: Symbol, purpose: String, - status: Symbol, + status: OpenAI::Models::Upload::Status::TaggedSymbol, file: T.nilable(OpenAI::Models::FileObject) } ) @@ -124,15 +92,20 @@ module OpenAI end # The status of the Upload. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::Upload::Status) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::Upload::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + PENDING = T.let(:pending, OpenAI::Models::Upload::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::Upload::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::Upload::Status::TaggedSymbol) + EXPIRED = T.let(:expired, OpenAI::Models::Upload::Status::TaggedSymbol) - PENDING = :pending - COMPLETED = :completed - CANCELLED = :cancelled - EXPIRED = :expired + sig { override.returns(T::Array[OpenAI::Models::Upload::Status::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/upload_cancel_params.rbi b/rbi/lib/openai/models/upload_cancel_params.rbi index 6db61397..7fb18dd3 100644 --- a/rbi/lib/openai/models/upload_cancel_params.rbi +++ b/rbi/lib/openai/models/upload_cancel_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class UploadCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/upload_complete_params.rbi b/rbi/lib/openai/models/upload_complete_params.rbi index f8550617..24f09fa4 100644 --- a/rbi/lib/openai/models/upload_complete_params.rbi +++ b/rbi/lib/openai/models/upload_complete_params.rbi @@ -3,33 +3,26 @@ module OpenAI module Models class UploadCompleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The ordered list of Part IDs. sig { returns(T::Array[String]) } - def part_ids - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def part_ids=(_) - end + attr_accessor :part_ids # The optional md5 checksum for the file contents to verify if the bytes uploaded # matches what you expect. sig { returns(T.nilable(String)) } - def md5 - end + attr_reader :md5 - sig { params(_: String).returns(String) } - def md5=(_) - end + sig { params(md5: String).void } + attr_writer :md5 sig do params( part_ids: T::Array[String], md5: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/upload_create_params.rbi b/rbi/lib/openai/models/upload_create_params.rbi index 22555f0e..1e0390bf 100644 --- a/rbi/lib/openai/models/upload_create_params.rbi +++ b/rbi/lib/openai/models/upload_create_params.rbi @@ -3,58 +3,38 @@ module OpenAI module Models class UploadCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The number of bytes in the file you are uploading. sig { returns(Integer) } - def bytes - end - - sig { params(_: Integer).returns(Integer) } - def bytes=(_) - end + attr_accessor :bytes # The name of the file to upload. sig { returns(String) } - def filename - end - - sig { params(_: String).returns(String) } - def filename=(_) - end + attr_accessor :filename # The MIME type of the file. # # This must fall within the supported MIME types for your file purpose. See the # supported MIME types for assistants and vision. sig { returns(String) } - def mime_type - end - - sig { params(_: String).returns(String) } - def mime_type=(_) - end + attr_accessor :mime_type # The intended purpose of the uploaded file. # # See the # [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose). - sig { returns(Symbol) } - def purpose - end - - sig { params(_: Symbol).returns(Symbol) } - def purpose=(_) - end + sig { returns(OpenAI::Models::FilePurpose::OrSymbol) } + attr_accessor :purpose sig do params( bytes: Integer, filename: String, mime_type: String, - purpose: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + purpose: OpenAI::Models::FilePurpose::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -68,7 +48,7 @@ module OpenAI bytes: Integer, filename: String, mime_type: String, - purpose: Symbol, + purpose: OpenAI::Models::FilePurpose::OrSymbol, request_options: OpenAI::RequestOptions } ) diff --git a/rbi/lib/openai/models/uploads/part_create_params.rbi b/rbi/lib/openai/models/uploads/part_create_params.rbi index 7ef6052a..c6f213d5 100644 --- a/rbi/lib/openai/models/uploads/part_create_params.rbi +++ b/rbi/lib/openai/models/uploads/part_create_params.rbi @@ -4,22 +4,17 @@ module OpenAI module Models module Uploads class PartCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The chunk of bytes for this Part. sig { returns(T.any(IO, StringIO)) } - def data - end - - sig { params(_: T.any(IO, StringIO)).returns(T.any(IO, StringIO)) } - def data=(_) - end + attr_accessor :data sig do params( data: T.any(IO, StringIO), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/uploads/upload_part.rbi b/rbi/lib/openai/models/uploads/upload_part.rbi index ae805178..43223349 100644 --- a/rbi/lib/openai/models/uploads/upload_part.rbi +++ b/rbi/lib/openai/models/uploads/upload_part.rbi @@ -2,45 +2,23 @@ module OpenAI module Models - UploadPart = T.type_alias { Uploads::UploadPart } - module Uploads class UploadPart < OpenAI::BaseModel # The upload Part unique identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the Part was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The object type, which is always `upload.part`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The ID of the Upload object that this Part was added to. sig { returns(String) } - def upload_id - end - - sig { params(_: String).returns(String) } - def upload_id=(_) - end + attr_accessor :upload_id # The upload Part represents a chunk of bytes we can add to an Upload object. sig do @@ -54,5 +32,7 @@ module OpenAI end end end + + UploadPart = Uploads::UploadPart end end diff --git a/rbi/lib/openai/models/vector_store.rbi b/rbi/lib/openai/models/vector_store.rbi index 642c27bf..fae6b032 100644 --- a/rbi/lib/openai/models/vector_store.rbi +++ b/rbi/lib/openai/models/vector_store.rbi @@ -5,38 +5,21 @@ module OpenAI class VectorStore < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the vector store was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at sig { returns(OpenAI::Models::VectorStore::FileCounts) } - def file_counts - end + attr_reader :file_counts - sig { params(_: OpenAI::Models::VectorStore::FileCounts).returns(OpenAI::Models::VectorStore::FileCounts) } - def file_counts=(_) - end + sig { params(file_counts: T.any(OpenAI::Models::VectorStore::FileCounts, OpenAI::Util::AnyHash)).void } + attr_writer :file_counts # The Unix timestamp (in seconds) for when the vector store was last active. sig { returns(T.nilable(Integer)) } - def last_active_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def last_active_at=(_) - end + attr_accessor :last_active_at # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -44,69 +27,37 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The name of the vector store. sig { returns(String) } - def name - end - - sig { params(_: String).returns(String) } - def name=(_) - end + attr_accessor :name # The object type, which is always `vector_store`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The status of the vector store, which can be either `expired`, `in_progress`, or # `completed`. A status of `completed` indicates that the vector store is ready # for use. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::VectorStore::Status::TaggedSymbol) } + attr_accessor :status # The total number of bytes used by the files in the vector store. sig { returns(Integer) } - def usage_bytes - end - - sig { params(_: Integer).returns(Integer) } - def usage_bytes=(_) - end + attr_accessor :usage_bytes # The expiration policy for a vector store. sig { returns(T.nilable(OpenAI::Models::VectorStore::ExpiresAfter)) } - def expires_after - end + attr_reader :expires_after - sig { params(_: OpenAI::Models::VectorStore::ExpiresAfter).returns(OpenAI::Models::VectorStore::ExpiresAfter) } - def expires_after=(_) - end + sig { params(expires_after: T.any(OpenAI::Models::VectorStore::ExpiresAfter, OpenAI::Util::AnyHash)).void } + attr_writer :expires_after # The Unix timestamp (in seconds) for when the vector store will expire. sig { returns(T.nilable(Integer)) } - def expires_at - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def expires_at=(_) - end + attr_accessor :expires_at # A vector store is a collection of processed files can be used by the # `file_search` tool. @@ -114,13 +65,13 @@ module OpenAI params( id: String, created_at: Integer, - file_counts: OpenAI::Models::VectorStore::FileCounts, + file_counts: T.any(OpenAI::Models::VectorStore::FileCounts, OpenAI::Util::AnyHash), last_active_at: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: String, - status: Symbol, + status: OpenAI::Models::VectorStore::Status::OrSymbol, usage_bytes: Integer, - expires_after: OpenAI::Models::VectorStore::ExpiresAfter, + expires_after: T.any(OpenAI::Models::VectorStore::ExpiresAfter, OpenAI::Util::AnyHash), expires_at: T.nilable(Integer), object: Symbol ) @@ -149,10 +100,10 @@ module OpenAI created_at: Integer, file_counts: OpenAI::Models::VectorStore::FileCounts, last_active_at: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: String, object: Symbol, - status: Symbol, + status: OpenAI::Models::VectorStore::Status::TaggedSymbol, usage_bytes: Integer, expires_after: OpenAI::Models::VectorStore::ExpiresAfter, expires_at: T.nilable(Integer) @@ -165,48 +116,23 @@ module OpenAI class FileCounts < OpenAI::BaseModel # The number of files that were cancelled. sig { returns(Integer) } - def cancelled - end - - sig { params(_: Integer).returns(Integer) } - def cancelled=(_) - end + attr_accessor :cancelled # The number of files that have been successfully processed. sig { returns(Integer) } - def completed - end - - sig { params(_: Integer).returns(Integer) } - def completed=(_) - end + attr_accessor :completed # The number of files that have failed to process. sig { returns(Integer) } - def failed - end - - sig { params(_: Integer).returns(Integer) } - def failed=(_) - end + attr_accessor :failed # The number of files that are currently being processed. sig { returns(Integer) } - def in_progress - end - - sig { params(_: Integer).returns(Integer) } - def in_progress=(_) - end + attr_accessor :in_progress # The total number of files. sig { returns(Integer) } - def total - end - - sig { params(_: Integer).returns(Integer) } - def total=(_) - end + attr_accessor :total sig do params( @@ -238,35 +164,30 @@ module OpenAI # The status of the vector store, which can be either `expired`, `in_progress`, or # `completed`. A status of `completed` indicates that the vector store is ready # for use. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStore::Status) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::VectorStore::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + EXPIRED = T.let(:expired, OpenAI::Models::VectorStore::Status::TaggedSymbol) + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::VectorStore::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::VectorStore::Status::TaggedSymbol) - EXPIRED = :expired - IN_PROGRESS = :in_progress - COMPLETED = :completed + sig { override.returns(T::Array[OpenAI::Models::VectorStore::Status::TaggedSymbol]) } + def self.values + end end class ExpiresAfter < OpenAI::BaseModel # Anchor timestamp after which the expiration policy applies. Supported anchors: # `last_active_at`. sig { returns(Symbol) } - def anchor - end - - sig { params(_: Symbol).returns(Symbol) } - def anchor=(_) - end + attr_accessor :anchor # The number of days after the anchor time that the vector store will expire. sig { returns(Integer) } - def days - end - - sig { params(_: Integer).returns(Integer) } - def days=(_) - end + attr_accessor :days # The expiration policy for a vector store. sig { params(days: Integer, anchor: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/vector_store_create_params.rbi b/rbi/lib/openai/models/vector_store_create_params.rbi index 02ffb8d9..4c0acebf 100644 --- a/rbi/lib/openai/models/vector_store_create_params.rbi +++ b/rbi/lib/openai/models/vector_store_create_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class VectorStoreCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The chunking strategy used to chunk the file(s). If not set, will use the `auto` @@ -18,48 +18,38 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ) ) - .returns( - T.any( - OpenAI::Models::AutoFileChunkingStrategyParam, - OpenAI::Models::StaticFileChunkingStrategyObjectParam - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy # The expiration policy for a vector store. sig { returns(T.nilable(OpenAI::Models::VectorStoreCreateParams::ExpiresAfter)) } - def expires_after - end + attr_reader :expires_after sig do - params(_: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter) - .returns(OpenAI::Models::VectorStoreCreateParams::ExpiresAfter) - end - def expires_after=(_) + params(expires_after: T.any(OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, OpenAI::Util::AnyHash)) + .void end + attr_writer :expires_after # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that # the vector store should use. Useful for tools like `file_search` that can access # files. sig { returns(T.nilable(T::Array[String])) } - def file_ids - end + attr_reader :file_ids - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + sig { params(file_ids: T::Array[String]).void } + attr_writer :file_ids # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -67,38 +57,39 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The name of the vector store. sig { returns(T.nilable(String)) } - def name - end + attr_reader :name - sig { params(_: String).returns(String) } - def name=(_) - end + sig { params(name: String).void } + attr_writer :name sig do params( chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, + expires_after: T.any(OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, OpenAI::Util::AnyHash), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(chunking_strategy: nil, expires_after: nil, file_ids: nil, metadata: nil, name: nil, request_options: {}) + def self.new( + chunking_strategy: nil, + expires_after: nil, + file_ids: nil, + metadata: nil, + name: nil, + request_options: {} + ) end sig do @@ -111,7 +102,7 @@ module OpenAI ), expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: String, request_options: OpenAI::RequestOptions } @@ -124,21 +115,11 @@ module OpenAI # Anchor timestamp after which the expiration policy applies. Supported anchors: # `last_active_at`. sig { returns(Symbol) } - def anchor - end - - sig { params(_: Symbol).returns(Symbol) } - def anchor=(_) - end + attr_accessor :anchor # The number of days after the anchor time that the vector store will expire. sig { returns(Integer) } - def days - end - - sig { params(_: Integer).returns(Integer) } - def days=(_) - end + attr_accessor :days # The expiration policy for a vector store. sig { params(days: Integer, anchor: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/vector_store_delete_params.rbi b/rbi/lib/openai/models/vector_store_delete_params.rbi index 3fa908fe..d01c30e0 100644 --- a/rbi/lib/openai/models/vector_store_delete_params.rbi +++ b/rbi/lib/openai/models/vector_store_delete_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class VectorStoreDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/vector_store_deleted.rbi b/rbi/lib/openai/models/vector_store_deleted.rbi index ede60489..bd0e83c0 100644 --- a/rbi/lib/openai/models/vector_store_deleted.rbi +++ b/rbi/lib/openai/models/vector_store_deleted.rbi @@ -4,28 +4,13 @@ module OpenAI module Models class VectorStoreDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"vector_store.deleted") diff --git a/rbi/lib/openai/models/vector_store_list_params.rbi b/rbi/lib/openai/models/vector_store_list_params.rbi index 5749ce8a..a46b89ef 100644 --- a/rbi/lib/openai/models/vector_store_list_params.rbi +++ b/rbi/lib/openai/models/vector_store_list_params.rbi @@ -3,7 +3,7 @@ module OpenAI module Models class VectorStoreListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -11,52 +11,44 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::VectorStoreListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::VectorStoreListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::VectorStoreListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -70,7 +62,7 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::VectorStoreListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -80,13 +72,18 @@ module OpenAI # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStoreListParams::Order) } + OrSymbol = T.type_alias { T.any(Symbol, OpenAI::Models::VectorStoreListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::VectorStoreListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::VectorStoreListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::VectorStoreListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/vector_store_retrieve_params.rbi b/rbi/lib/openai/models/vector_store_retrieve_params.rbi index 88a00415..7e591036 100644 --- a/rbi/lib/openai/models/vector_store_retrieve_params.rbi +++ b/rbi/lib/openai/models/vector_store_retrieve_params.rbi @@ -3,12 +3,16 @@ module OpenAI module Models class VectorStoreRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig do - params(request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.attached_class) + params( + request_options: T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ).returns(T.attached_class) end def self.new(request_options: {}) end diff --git a/rbi/lib/openai/models/vector_store_search_params.rbi b/rbi/lib/openai/models/vector_store_search_params.rbi index 91a2ec22..c6d6cc94 100644 --- a/rbi/lib/openai/models/vector_store_search_params.rbi +++ b/rbi/lib/openai/models/vector_store_search_params.rbi @@ -3,73 +3,71 @@ module OpenAI module Models class VectorStoreSearchParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A query string for a search sig { returns(T.any(String, T::Array[String])) } - def query - end - - sig { params(_: T.any(String, T::Array[String])).returns(T.any(String, T::Array[String])) } - def query=(_) - end + attr_accessor :query # A filter to apply based on file attributes. sig { returns(T.nilable(T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter))) } - def filters - end + attr_reader :filters sig do - params(_: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)) - .returns(T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)) - end - def filters=(_) + params( + filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, OpenAI::Models::CompoundFilter) + ) + .void end + attr_writer :filters # The maximum number of results to return. This number should be between 1 and 50 # inclusive. sig { returns(T.nilable(Integer)) } - def max_num_results - end + attr_reader :max_num_results - sig { params(_: Integer).returns(Integer) } - def max_num_results=(_) - end + sig { params(max_num_results: Integer).void } + attr_writer :max_num_results # Ranking options for search. sig { returns(T.nilable(OpenAI::Models::VectorStoreSearchParams::RankingOptions)) } - def ranking_options - end + attr_reader :ranking_options sig do - params(_: OpenAI::Models::VectorStoreSearchParams::RankingOptions) - .returns(OpenAI::Models::VectorStoreSearchParams::RankingOptions) - end - def ranking_options=(_) + params( + ranking_options: T.any(OpenAI::Models::VectorStoreSearchParams::RankingOptions, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :ranking_options # Whether to rewrite the natural language query for vector search. sig { returns(T.nilable(T::Boolean)) } - def rewrite_query - end + attr_reader :rewrite_query - sig { params(_: T::Boolean).returns(T::Boolean) } - def rewrite_query=(_) - end + sig { params(rewrite_query: T::Boolean).void } + attr_writer :rewrite_query sig do params( query: T.any(String, T::Array[String]), - filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter), + filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, OpenAI::Models::CompoundFilter), max_num_results: Integer, - ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, + ranking_options: T.any(OpenAI::Models::VectorStoreSearchParams::RankingOptions, OpenAI::Util::AnyHash), rewrite_query: T::Boolean, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(query:, filters: nil, max_num_results: nil, ranking_options: nil, rewrite_query: nil, request_options: {}) + def self.new( + query:, + filters: nil, + max_num_results: nil, + ranking_options: nil, + rewrite_query: nil, + request_options: {} + ) end sig do @@ -89,54 +87,76 @@ module OpenAI end # A query string for a search - class Query < OpenAI::Union - abstract! + module Query + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, T::Array[String])} } + sig { override.returns([String, T::Array[String]]) } + def self.variants + end - StringArray = T.type_alias { T::Array[String] } + StringArray = T.let(OpenAI::ArrayOf[String], OpenAI::Type::Converter) end # A filter to apply based on file attributes. - class Filters < OpenAI::Union - abstract! + module Filters + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)} } + sig { override.returns([OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter]) } + def self.variants + end end class RankingOptions < OpenAI::BaseModel - sig { returns(T.nilable(Symbol)) } - def ranker - end + sig { returns(T.nilable(OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::OrSymbol)) } + attr_reader :ranker - sig { params(_: Symbol).returns(Symbol) } - def ranker=(_) - end + sig { params(ranker: OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::OrSymbol).void } + attr_writer :ranker sig { returns(T.nilable(Float)) } - def score_threshold - end + attr_reader :score_threshold - sig { params(_: Float).returns(Float) } - def score_threshold=(_) - end + sig { params(score_threshold: Float).void } + attr_writer :score_threshold # Ranking options for search. - sig { params(ranker: Symbol, score_threshold: Float).returns(T.attached_class) } + sig do + params( + ranker: OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::OrSymbol, + score_threshold: Float + ) + .returns(T.attached_class) + end def self.new(ranker: nil, score_threshold: nil) end - sig { override.returns({ranker: Symbol, score_threshold: Float}) } + sig do + override + .returns( + {ranker: OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::OrSymbol, score_threshold: Float} + ) + end def to_hash end - class Ranker < OpenAI::Enum - abstract! + module Ranker + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + AUTO = T.let(:auto, OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::TaggedSymbol) + DEFAULT_2024_11_15 = + T.let( + :"default-2024-11-15", + OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::TaggedSymbol + ) - AUTO = :auto - DEFAULT_2024_11_15 = :"default-2024-11-15" + sig { override.returns(T::Array[OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/vector_store_search_response.rbi b/rbi/lib/openai/models/vector_store_search_response.rbi index a2443437..4baabfad 100644 --- a/rbi/lib/openai/models/vector_store_search_response.rbi +++ b/rbi/lib/openai/models/vector_store_search_response.rbi @@ -9,59 +9,28 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes # Content chunks from the file. sig { returns(T::Array[OpenAI::Models::VectorStoreSearchResponse::Content]) } - def content - end - - sig do - params(_: T::Array[OpenAI::Models::VectorStoreSearchResponse::Content]) - .returns(T::Array[OpenAI::Models::VectorStoreSearchResponse::Content]) - end - def content=(_) - end + attr_accessor :content # The ID of the vector store file. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # The name of the vector store file. sig { returns(String) } - def filename - end - - sig { params(_: String).returns(String) } - def filename=(_) - end + attr_accessor :filename # The similarity score for the result. sig { returns(Float) } - def score - end - - sig { params(_: Float).returns(Float) } - def score=(_) - end + attr_accessor :score sig do params( attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), - content: T::Array[OpenAI::Models::VectorStoreSearchResponse::Content], + content: T::Array[T.any(OpenAI::Models::VectorStoreSearchResponse::Content, OpenAI::Util::AnyHash)], file_id: String, filename: String, score: Float @@ -86,46 +55,50 @@ module OpenAI def to_hash end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end class Content < OpenAI::BaseModel # The text content returned from search. sig { returns(String) } - def text - end - - sig { params(_: String).returns(String) } - def text=(_) - end + attr_accessor :text # The type of content. - sig { returns(Symbol) } - def type - end + sig { returns(OpenAI::Models::VectorStoreSearchResponse::Content::Type::TaggedSymbol) } + attr_accessor :type - sig { params(_: Symbol).returns(Symbol) } - def type=(_) + sig do + params(text: String, type: OpenAI::Models::VectorStoreSearchResponse::Content::Type::OrSymbol) + .returns(T.attached_class) end - - sig { params(text: String, type: Symbol).returns(T.attached_class) } def self.new(text:, type:) end - sig { override.returns({text: String, type: Symbol}) } + sig do + override + .returns({text: String, type: OpenAI::Models::VectorStoreSearchResponse::Content::Type::TaggedSymbol}) + end def to_hash end # The type of content. - class Type < OpenAI::Enum - abstract! + module Type + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStoreSearchResponse::Content::Type) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStoreSearchResponse::Content::Type::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + TEXT = T.let(:text, OpenAI::Models::VectorStoreSearchResponse::Content::Type::TaggedSymbol) - TEXT = :text + sig { override.returns(T::Array[OpenAI::Models::VectorStoreSearchResponse::Content::Type::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/vector_store_update_params.rbi b/rbi/lib/openai/models/vector_store_update_params.rbi index 88614cee..04887f7e 100644 --- a/rbi/lib/openai/models/vector_store_update_params.rbi +++ b/rbi/lib/openai/models/vector_store_update_params.rbi @@ -3,20 +3,20 @@ module OpenAI module Models class VectorStoreUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # The expiration policy for a vector store. sig { returns(T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter)) } - def expires_after - end + attr_reader :expires_after sig do - params(_: T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter)) - .returns(T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter)) - end - def expires_after=(_) + params( + expires_after: T.nilable(T.any(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :expires_after # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -24,29 +24,19 @@ module OpenAI # # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. - sig { returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata - end - - sig { params(_: T.nilable(OpenAI::Models::Metadata)).returns(T.nilable(OpenAI::Models::Metadata)) } - def metadata=(_) - end + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_accessor :metadata # The name of the vector store. sig { returns(T.nilable(String)) } - def name - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def name=(_) - end + attr_accessor :name sig do params( - expires_after: T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter), - metadata: T.nilable(OpenAI::Models::Metadata), + expires_after: T.nilable(T.any(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, OpenAI::Util::AnyHash)), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -58,7 +48,7 @@ module OpenAI .returns( { expires_after: T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), request_options: OpenAI::RequestOptions } @@ -71,21 +61,11 @@ module OpenAI # Anchor timestamp after which the expiration policy applies. Supported anchors: # `last_active_at`. sig { returns(Symbol) } - def anchor - end - - sig { params(_: Symbol).returns(Symbol) } - def anchor=(_) - end + attr_accessor :anchor # The number of days after the anchor time that the vector store will expire. sig { returns(Integer) } - def days - end - - sig { params(_: Integer).returns(Integer) } - def days=(_) - end + attr_accessor :days # The expiration policy for a vector store. sig { params(days: Integer, anchor: Symbol).returns(T.attached_class) } diff --git a/rbi/lib/openai/models/vector_stores/file_batch_cancel_params.rbi b/rbi/lib/openai/models/vector_stores/file_batch_cancel_params.rbi index cc6cad3f..0a18aa15 100644 --- a/rbi/lib/openai/models/vector_stores/file_batch_cancel_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_batch_cancel_params.rbi @@ -4,21 +4,16 @@ module OpenAI module Models module VectorStores class FileBatchCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id sig do params( vector_store_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/vector_stores/file_batch_create_params.rbi b/rbi/lib/openai/models/vector_stores/file_batch_create_params.rbi index 4be0dcb6..2f1c7b95 100644 --- a/rbi/lib/openai/models/vector_stores/file_batch_create_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_batch_create_params.rbi @@ -4,19 +4,14 @@ module OpenAI module Models module VectorStores class FileBatchCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that # the vector store should use. Useful for tools like `file_search` that can access # files. sig { returns(T::Array[String]) } - def file_ids - end - - sig { params(_: T::Array[String]).returns(T::Array[String]) } - def file_ids=(_) - end + attr_accessor :file_ids # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -24,15 +19,7 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. Only applicable if `file_ids` is non-empty. @@ -46,25 +33,19 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ) ) - .returns( - T.any( - OpenAI::Models::AutoFileChunkingStrategyParam, - OpenAI::Models::StaticFileChunkingStrategyObjectParam - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy sig do params( @@ -72,9 +53,10 @@ module OpenAI attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -98,10 +80,12 @@ module OpenAI def to_hash end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/vector_stores/file_batch_list_files_params.rbi b/rbi/lib/openai/models/vector_stores/file_batch_list_files_params.rbi index c7da2f41..4cba5c1a 100644 --- a/rbi/lib/openai/models/vector_stores/file_batch_list_files_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_batch_list_files_params.rbi @@ -4,83 +4,76 @@ module OpenAI module Models module VectorStores class FileBatchListFilesParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id # A cursor for use in pagination. `after` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - sig { returns(T.nilable(Symbol)) } - def filter - end + sig { returns(T.nilable(OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::OrSymbol)) } + attr_reader :filter - sig { params(_: Symbol).returns(Symbol) } - def filter=(_) - end + sig { params(filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::OrSymbol).void } + attr_writer :filter # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::OrSymbol).void } + attr_writer :order sig do params( vector_store_id: String, after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::OrSymbol, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end - def self.new(vector_store_id:, after: nil, before: nil, filter: nil, limit: nil, order: nil, request_options: {}) + def self.new( + vector_store_id:, + after: nil, + before: nil, + filter: nil, + limit: nil, + order: nil, + request_options: {} + ) end sig do @@ -90,9 +83,9 @@ module OpenAI vector_store_id: String, after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::OrSymbol, limit: Integer, - order: Symbol, + order: OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -101,26 +94,43 @@ module OpenAI end # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - class Filter < OpenAI::Enum - abstract! + module Filter + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol) + COMPLETED = + T.let(:completed, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol) + CANCELLED = + T.let(:cancelled, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol) - IN_PROGRESS = :in_progress - COMPLETED = :completed - FAILED = :failed - CANCELLED = :cancelled + sig { override.returns(T::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::TaggedSymbol]) } + def self.values + end end # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/vector_stores/file_batch_retrieve_params.rbi b/rbi/lib/openai/models/vector_stores/file_batch_retrieve_params.rbi index 20edec10..16e593c7 100644 --- a/rbi/lib/openai/models/vector_stores/file_batch_retrieve_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_batch_retrieve_params.rbi @@ -4,21 +4,16 @@ module OpenAI module Models module VectorStores class FileBatchRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id sig do params( vector_store_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/vector_stores/file_content_params.rbi b/rbi/lib/openai/models/vector_stores/file_content_params.rbi index e9c610a6..9558d156 100644 --- a/rbi/lib/openai/models/vector_stores/file_content_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_content_params.rbi @@ -4,21 +4,16 @@ module OpenAI module Models module VectorStores class FileContentParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id sig do params( vector_store_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/vector_stores/file_content_response.rbi b/rbi/lib/openai/models/vector_stores/file_content_response.rbi index 7986b030..1fad3ed9 100644 --- a/rbi/lib/openai/models/vector_stores/file_content_response.rbi +++ b/rbi/lib/openai/models/vector_stores/file_content_response.rbi @@ -6,21 +6,17 @@ module OpenAI class FileContentResponse < OpenAI::BaseModel # The text content sig { returns(T.nilable(String)) } - def text - end + attr_reader :text - sig { params(_: String).returns(String) } - def text=(_) - end + sig { params(text: String).void } + attr_writer :text # The content type (currently only `"text"`) sig { returns(T.nilable(String)) } - def type - end + attr_reader :type - sig { params(_: String).returns(String) } - def type=(_) - end + sig { params(type: String).void } + attr_writer :type sig { params(text: String, type: String).returns(T.attached_class) } def self.new(text: nil, type: nil) diff --git a/rbi/lib/openai/models/vector_stores/file_create_params.rbi b/rbi/lib/openai/models/vector_stores/file_create_params.rbi index 57e35c52..1acbeb21 100644 --- a/rbi/lib/openai/models/vector_stores/file_create_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_create_params.rbi @@ -4,19 +4,14 @@ module OpenAI module Models module VectorStores class FileCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A [File](https://platform.openai.com/docs/api-reference/files) ID that the # vector store should use. Useful for tools like `file_search` that can access # files. sig { returns(String) } - def file_id - end - - sig { params(_: String).returns(String) } - def file_id=(_) - end + attr_accessor :file_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -24,15 +19,7 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes # The chunking strategy used to chunk the file(s). If not set, will use the `auto` # strategy. Only applicable if `file_ids` is non-empty. @@ -46,25 +33,19 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any( + chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ) ) - .returns( - T.any( - OpenAI::Models::AutoFileChunkingStrategyParam, - OpenAI::Models::StaticFileChunkingStrategyObjectParam - ) - ) - end - def chunking_strategy=(_) + .void end + attr_writer :chunking_strategy sig do params( @@ -72,9 +53,10 @@ module OpenAI attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -98,10 +80,12 @@ module OpenAI def to_hash end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/vector_stores/file_delete_params.rbi b/rbi/lib/openai/models/vector_stores/file_delete_params.rbi index f7fe2e55..9ffd9fb3 100644 --- a/rbi/lib/openai/models/vector_stores/file_delete_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_delete_params.rbi @@ -4,21 +4,16 @@ module OpenAI module Models module VectorStores class FileDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id sig do params( vector_store_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/vector_stores/file_list_params.rbi b/rbi/lib/openai/models/vector_stores/file_list_params.rbi index 0f62a65d..0043569a 100644 --- a/rbi/lib/openai/models/vector_stores/file_list_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_list_params.rbi @@ -4,7 +4,7 @@ module OpenAI module Models module VectorStores class FileListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters # A cursor for use in pagination. `after` is an object ID that defines your place @@ -12,62 +12,52 @@ module OpenAI # ending with obj_foo, your subsequent call can include after=obj_foo in order to # fetch the next page of the list. sig { returns(T.nilable(String)) } - def after - end + attr_reader :after - sig { params(_: String).returns(String) } - def after=(_) - end + sig { params(after: String).void } + attr_writer :after # A cursor for use in pagination. `before` is an object ID that defines your place # in the list. For instance, if you make a list request and receive 100 objects, # starting with obj_foo, your subsequent call can include before=obj_foo in order # to fetch the previous page of the list. sig { returns(T.nilable(String)) } - def before - end + attr_reader :before - sig { params(_: String).returns(String) } - def before=(_) - end + sig { params(before: String).void } + attr_writer :before # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - sig { returns(T.nilable(Symbol)) } - def filter - end + sig { returns(T.nilable(OpenAI::Models::VectorStores::FileListParams::Filter::OrSymbol)) } + attr_reader :filter - sig { params(_: Symbol).returns(Symbol) } - def filter=(_) - end + sig { params(filter: OpenAI::Models::VectorStores::FileListParams::Filter::OrSymbol).void } + attr_writer :filter # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. sig { returns(T.nilable(Integer)) } - def limit - end + attr_reader :limit - sig { params(_: Integer).returns(Integer) } - def limit=(_) - end + sig { params(limit: Integer).void } + attr_writer :limit # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - sig { returns(T.nilable(Symbol)) } - def order - end + sig { returns(T.nilable(OpenAI::Models::VectorStores::FileListParams::Order::OrSymbol)) } + attr_reader :order - sig { params(_: Symbol).returns(Symbol) } - def order=(_) - end + sig { params(order: OpenAI::Models::VectorStores::FileListParams::Order::OrSymbol).void } + attr_writer :order sig do params( after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileListParams::Filter::OrSymbol, limit: Integer, - order: Symbol, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + order: OpenAI::Models::VectorStores::FileListParams::Order::OrSymbol, + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -80,9 +70,9 @@ module OpenAI { after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileListParams::Filter::OrSymbol, limit: Integer, - order: Symbol, + order: OpenAI::Models::VectorStores::FileListParams::Order::OrSymbol, request_options: OpenAI::RequestOptions } ) @@ -91,26 +81,38 @@ module OpenAI end # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - class Filter < OpenAI::Enum - abstract! + module Filter + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::FileListParams::Filter) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol) - IN_PROGRESS = :in_progress - COMPLETED = :completed - FAILED = :failed - CANCELLED = :cancelled + sig { override.returns(T::Array[OpenAI::Models::VectorStores::FileListParams::Filter::TaggedSymbol]) } + def self.values + end end # Sort order by the `created_at` timestamp of the objects. `asc` for ascending # order and `desc` for descending order. - class Order < OpenAI::Enum - abstract! + module Order + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::FileListParams::Order) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::FileListParams::Order::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + ASC = T.let(:asc, OpenAI::Models::VectorStores::FileListParams::Order::TaggedSymbol) + DESC = T.let(:desc, OpenAI::Models::VectorStores::FileListParams::Order::TaggedSymbol) - ASC = :asc - DESC = :desc + sig { override.returns(T::Array[OpenAI::Models::VectorStores::FileListParams::Order::TaggedSymbol]) } + def self.values + end end end end diff --git a/rbi/lib/openai/models/vector_stores/file_retrieve_params.rbi b/rbi/lib/openai/models/vector_stores/file_retrieve_params.rbi index 4f1f1768..8ac6b042 100644 --- a/rbi/lib/openai/models/vector_stores/file_retrieve_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_retrieve_params.rbi @@ -4,21 +4,16 @@ module OpenAI module Models module VectorStores class FileRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id sig do params( vector_store_id: String, - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end diff --git a/rbi/lib/openai/models/vector_stores/file_update_params.rbi b/rbi/lib/openai/models/vector_stores/file_update_params.rbi index e3693815..a8c04b54 100644 --- a/rbi/lib/openai/models/vector_stores/file_update_params.rbi +++ b/rbi/lib/openai/models/vector_stores/file_update_params.rbi @@ -4,16 +4,11 @@ module OpenAI module Models module VectorStores class FileUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -21,21 +16,13 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes sig do params( vector_store_id: String, attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), - request_options: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]) + request_options: T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash) ) .returns(T.attached_class) end @@ -55,10 +42,12 @@ module OpenAI def to_hash end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end diff --git a/rbi/lib/openai/models/vector_stores/vector_store_file.rbi b/rbi/lib/openai/models/vector_stores/vector_store_file.rbi index 0d906238..ad610fcb 100644 --- a/rbi/lib/openai/models/vector_stores/vector_store_file.rbi +++ b/rbi/lib/openai/models/vector_stores/vector_store_file.rbi @@ -2,82 +2,50 @@ module OpenAI module Models - VectorStoreFile = T.type_alias { VectorStores::VectorStoreFile } - module VectorStores class VectorStoreFile < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the vector store file was created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at # The last error associated with this vector store file. Will be `null` if there # are no errors. sig { returns(T.nilable(OpenAI::Models::VectorStores::VectorStoreFile::LastError)) } - def last_error - end + attr_reader :last_error sig do - params(_: T.nilable(OpenAI::Models::VectorStores::VectorStoreFile::LastError)) - .returns(T.nilable(OpenAI::Models::VectorStores::VectorStoreFile::LastError)) - end - def last_error=(_) + params( + last_error: T.nilable(T.any(OpenAI::Models::VectorStores::VectorStoreFile::LastError, OpenAI::Util::AnyHash)) + ) + .void end + attr_writer :last_error # The object type, which is always `vector_store.file`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The status of the vector store file, which can be either `in_progress`, # `completed`, `cancelled`, or `failed`. The status `completed` indicates that the # vector store file is ready for use. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) } + attr_accessor :status # The total vector store usage in bytes. Note that this may be different from the # original file size. sig { returns(Integer) } - def usage_bytes - end - - sig { params(_: Integer).returns(Integer) } - def usage_bytes=(_) - end + attr_accessor :usage_bytes # The ID of the # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) # that the [File](https://platform.openai.com/docs/api-reference/files) is # attached to. sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id # Set of 16 key-value pairs that can be attached to an object. This can be useful # for storing additional information about the object in a structured format, and @@ -85,15 +53,7 @@ module OpenAI # length of 64 characters. Values are strings with a maximum length of 512 # characters, booleans, or numbers. sig { returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) } - def attributes - end - - sig do - params(_: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - .returns(T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)])) - end - def attributes=(_) - end + attr_accessor :attributes # The strategy used to chunk the file. sig do @@ -103,31 +63,35 @@ module OpenAI ) ) end - def chunking_strategy - end + attr_reader :chunking_strategy sig do params( - _: T.any(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject) - ) - .returns( - T.any(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject) + chunking_strategy: T.any( + OpenAI::Models::StaticFileChunkingStrategyObject, + OpenAI::Util::AnyHash, + OpenAI::Models::OtherFileChunkingStrategyObject ) + ) + .void end - def chunking_strategy=(_) - end + attr_writer :chunking_strategy # A list of files attached to a vector store. sig do params( id: String, created_at: Integer, - last_error: T.nilable(OpenAI::Models::VectorStores::VectorStoreFile::LastError), - status: Symbol, + last_error: T.nilable(T.any(OpenAI::Models::VectorStores::VectorStoreFile::LastError, OpenAI::Util::AnyHash)), + status: OpenAI::Models::VectorStores::VectorStoreFile::Status::OrSymbol, usage_bytes: Integer, vector_store_id: String, attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), - chunking_strategy: T.any(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject), + chunking_strategy: T.any( + OpenAI::Models::StaticFileChunkingStrategyObject, + OpenAI::Util::AnyHash, + OpenAI::Models::OtherFileChunkingStrategyObject + ), object: Symbol ) .returns(T.attached_class) @@ -153,7 +117,7 @@ module OpenAI created_at: Integer, last_error: T.nilable(OpenAI::Models::VectorStores::VectorStoreFile::LastError), object: Symbol, - status: Symbol, + status: OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol, usage_bytes: Integer, vector_store_id: String, attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), @@ -166,65 +130,83 @@ module OpenAI class LastError < OpenAI::BaseModel # One of `server_error` or `rate_limit_exceeded`. - sig { returns(Symbol) } - def code - end - - sig { params(_: Symbol).returns(Symbol) } - def code=(_) - end + sig { returns(OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol) } + attr_accessor :code # A human-readable description of the error. sig { returns(String) } - def message - end - - sig { params(_: String).returns(String) } - def message=(_) - end + attr_accessor :message # The last error associated with this vector store file. Will be `null` if there # are no errors. - sig { params(code: Symbol, message: String).returns(T.attached_class) } + sig do + params(code: OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::OrSymbol, message: String) + .returns(T.attached_class) + end def self.new(code:, message:) end - sig { override.returns({code: Symbol, message: String}) } + sig do + override + .returns( + {code: OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol, message: String} + ) + end def to_hash end # One of `server_error` or `rate_limit_exceeded`. - class Code < OpenAI::Enum - abstract! - - Value = type_template(:out) { {fixed: Symbol} } - - SERVER_ERROR = :server_error - UNSUPPORTED_FILE = :unsupported_file - INVALID_FILE = :invalid_file + module Code + extend OpenAI::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol) } + + SERVER_ERROR = + T.let(:server_error, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol) + UNSUPPORTED_FILE = + T.let(:unsupported_file, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol) + INVALID_FILE = + T.let(:invalid_file, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol) + + sig { override.returns(T::Array[OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code::TaggedSymbol]) } + def self.values + end end end # The status of the vector store file, which can be either `in_progress`, # `completed`, `cancelled`, or `failed`. The status `completed` indicates that the # vector store file is ready for use. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::VectorStoreFile::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = T.let(:in_progress, OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - COMPLETED = :completed - CANCELLED = :cancelled - FAILED = :failed + sig { override.returns(T::Array[OpenAI::Models::VectorStores::VectorStoreFile::Status::TaggedSymbol]) } + def self.values + end end - class Attribute < OpenAI::Union - abstract! + module Attribute + extend OpenAI::Union - Variants = type_template(:out) { {fixed: T.any(String, Float, T::Boolean)} } + sig { override.returns([String, Float, T::Boolean]) } + def self.variants + end end end end + + VectorStoreFile = VectorStores::VectorStoreFile end end diff --git a/rbi/lib/openai/models/vector_stores/vector_store_file_batch.rbi b/rbi/lib/openai/models/vector_stores/vector_store_file_batch.rbi index 3ee9a72d..09d4693b 100644 --- a/rbi/lib/openai/models/vector_stores/vector_store_file_batch.rbi +++ b/rbi/lib/openai/models/vector_stores/vector_store_file_batch.rbi @@ -2,84 +2,64 @@ module OpenAI module Models - VectorStoreFileBatch = T.type_alias { VectorStores::VectorStoreFileBatch } - module VectorStores class VectorStoreFileBatch < OpenAI::BaseModel # The identifier, which can be referenced in API endpoints. sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id # The Unix timestamp (in seconds) for when the vector store files batch was # created. sig { returns(Integer) } - def created_at - end - - sig { params(_: Integer).returns(Integer) } - def created_at=(_) - end + attr_accessor :created_at sig { returns(OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts) } - def file_counts - end + attr_reader :file_counts sig do - params(_: OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts) - .returns(OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts) - end - def file_counts=(_) + params( + file_counts: T.any(OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, OpenAI::Util::AnyHash) + ) + .void end + attr_writer :file_counts # The object type, which is always `vector_store.file_batch`. sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object # The status of the vector store files batch, which can be either `in_progress`, # `completed`, `cancelled` or `failed`. - sig { returns(Symbol) } - def status - end - - sig { params(_: Symbol).returns(Symbol) } - def status=(_) - end + sig { returns(OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) } + attr_accessor :status # The ID of the # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) # that the [File](https://platform.openai.com/docs/api-reference/files) is # attached to. sig { returns(String) } - def vector_store_id - end - - sig { params(_: String).returns(String) } - def vector_store_id=(_) - end + attr_accessor :vector_store_id # A batch of files attached to a vector store. sig do params( id: String, created_at: Integer, - file_counts: OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, - status: Symbol, + file_counts: T.any(OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, OpenAI::Util::AnyHash), + status: OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::OrSymbol, vector_store_id: String, object: Symbol ) .returns(T.attached_class) end - def self.new(id:, created_at:, file_counts:, status:, vector_store_id:, object: :"vector_store.files_batch") + def self.new( + id:, + created_at:, + file_counts:, + status:, + vector_store_id:, + object: :"vector_store.files_batch" + ) end sig do @@ -90,7 +70,7 @@ module OpenAI created_at: Integer, file_counts: OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, object: Symbol, - status: Symbol, + status: OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol, vector_store_id: String } ) @@ -101,48 +81,23 @@ module OpenAI class FileCounts < OpenAI::BaseModel # The number of files that where cancelled. sig { returns(Integer) } - def cancelled - end - - sig { params(_: Integer).returns(Integer) } - def cancelled=(_) - end + attr_accessor :cancelled # The number of files that have been processed. sig { returns(Integer) } - def completed - end - - sig { params(_: Integer).returns(Integer) } - def completed=(_) - end + attr_accessor :completed # The number of files that have failed to process. sig { returns(Integer) } - def failed - end - - sig { params(_: Integer).returns(Integer) } - def failed=(_) - end + attr_accessor :failed # The number of files that are currently being processed. sig { returns(Integer) } - def in_progress - end - - sig { params(_: Integer).returns(Integer) } - def in_progress=(_) - end + attr_accessor :in_progress # The total number of files. sig { returns(Integer) } - def total - end - - sig { params(_: Integer).returns(Integer) } - def total=(_) - end + attr_accessor :total sig do params( @@ -173,17 +128,26 @@ module OpenAI # The status of the vector store files batch, which can be either `in_progress`, # `completed`, `cancelled` or `failed`. - class Status < OpenAI::Enum - abstract! + module Status + extend OpenAI::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status) } + OrSymbol = + T.type_alias { T.any(Symbol, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) } - Value = type_template(:out) { {fixed: Symbol} } + IN_PROGRESS = + T.let(:in_progress, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) + COMPLETED = T.let(:completed, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) + CANCELLED = T.let(:cancelled, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) + FAILED = T.let(:failed, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol) - IN_PROGRESS = :in_progress - COMPLETED = :completed - CANCELLED = :cancelled - FAILED = :failed + sig { override.returns(T::Array[OpenAI::Models::VectorStores::VectorStoreFileBatch::Status::TaggedSymbol]) } + def self.values + end end end end + + VectorStoreFileBatch = VectorStores::VectorStoreFileBatch end end diff --git a/rbi/lib/openai/models/vector_stores/vector_store_file_deleted.rbi b/rbi/lib/openai/models/vector_stores/vector_store_file_deleted.rbi index 932ec0f8..6c4d25fa 100644 --- a/rbi/lib/openai/models/vector_stores/vector_store_file_deleted.rbi +++ b/rbi/lib/openai/models/vector_stores/vector_store_file_deleted.rbi @@ -2,33 +2,16 @@ module OpenAI module Models - VectorStoreFileDeleted = T.type_alias { VectorStores::VectorStoreFileDeleted } - module VectorStores class VectorStoreFileDeleted < OpenAI::BaseModel sig { returns(String) } - def id - end - - sig { params(_: String).returns(String) } - def id=(_) - end + attr_accessor :id sig { returns(T::Boolean) } - def deleted - end - - sig { params(_: T::Boolean).returns(T::Boolean) } - def deleted=(_) - end + attr_accessor :deleted sig { returns(Symbol) } - def object - end - - sig { params(_: Symbol).returns(Symbol) } - def object=(_) - end + attr_accessor :object sig { params(id: String, deleted: T::Boolean, object: Symbol).returns(T.attached_class) } def self.new(id:, deleted:, object: :"vector_store.file.deleted") @@ -39,5 +22,7 @@ module OpenAI end end end + + VectorStoreFileDeleted = VectorStores::VectorStoreFileDeleted end end diff --git a/rbi/lib/openai/page.rbi b/rbi/lib/openai/page.rbi index a738bab8..8a668d1c 100644 --- a/rbi/lib/openai/page.rbi +++ b/rbi/lib/openai/page.rbi @@ -2,24 +2,18 @@ module OpenAI class Page - include OpenAI::BasePage + include OpenAI::Type::BasePage Elem = type_member sig { returns(T.nilable(T::Array[Elem])) } - def data - end - - sig { params(_: T.nilable(T::Array[Elem])).returns(T.nilable(T::Array[Elem])) } - def data=(_) - end + attr_accessor :data sig { returns(String) } - def object - end + attr_accessor :object - sig { params(_: String).returns(String) } - def object=(_) + sig { returns(String) } + def inspect end end end diff --git a/rbi/lib/openai/pooled_net_requester.rbi b/rbi/lib/openai/pooled_net_requester.rbi deleted file mode 100644 index 2cdf7b6b..00000000 --- a/rbi/lib/openai/pooled_net_requester.rbi +++ /dev/null @@ -1,48 +0,0 @@ -# typed: strong - -module OpenAI - # @api private - class PooledNetRequester - RequestShape = T.type_alias do - {method: Symbol, url: URI::Generic, headers: T::Hash[String, String], body: T.anything, deadline: Float} - end - - class << self - # @api private - sig { params(url: URI::Generic).returns(Net::HTTP) } - def connect(url) - end - - # @api private - sig { params(conn: Net::HTTP, deadline: Float).void } - def calibrate_socket_timeout(conn, deadline) - end - - # @api private - sig do - params(request: OpenAI::PooledNetRequester::RequestShape, blk: T.proc.params(arg0: String).void) - .returns(Net::HTTPGenericRequest) - end - def build_request(request, &blk) - end - end - - # @api private - sig { params(url: URI::Generic, deadline: Float, blk: T.proc.params(arg0: Net::HTTP).void).void } - private def with_pool(url, deadline:, &blk) - end - - # @api private - sig do - params(request: OpenAI::PooledNetRequester::RequestShape) - .returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) - end - def execute(request) - end - - # @api private - sig { params(size: Integer).returns(T.attached_class) } - def self.new(size: Etc.nprocessors) - end - end -end diff --git a/rbi/lib/openai/request_options.rbi b/rbi/lib/openai/request_options.rbi index ded742c2..4e963f12 100644 --- a/rbi/lib/openai/request_options.rbi +++ b/rbi/lib/openai/request_options.rbi @@ -1,29 +1,6 @@ # typed: strong module OpenAI - # @api private - module RequestParameters - # Options to specify HTTP behaviour for this request. - sig { returns(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) } - def request_options - end - - sig do - params(_: T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - .returns(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) - end - def request_options=(_) - end - - # @api private - module Converter - # @api private - sig { params(params: T.anything).returns([T.anything, T::Hash[Symbol, T.anything]]) } - def dump_request(params) - end - end - end - # Specify HTTP behaviour to use for a specific request. These options supplement # or override those provided at the client level. # @@ -38,69 +15,33 @@ module OpenAI # Idempotency key to send with request and all associated retries. Will only be # sent for write requests. sig { returns(T.nilable(String)) } - def idempotency_key - end - - sig { params(_: T.nilable(String)).returns(T.nilable(String)) } - def idempotency_key=(_) - end + attr_accessor :idempotency_key # Extra query params to send with the request. These are `.merge`’d into any # `query` given at the client level. sig { returns(T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])) } - def extra_query - end - - sig do - params(_: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])) - .returns(T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])) - end - def extra_query=(_) - end + attr_accessor :extra_query # Extra headers to send with the request. These are `.merged`’d into any # `extra_headers` given at the client level. sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) } - def extra_headers - end - - sig do - params(_: T.nilable(T::Hash[String, T.nilable(String)])) - .returns(T.nilable(T::Hash[String, T.nilable(String)])) - end - def extra_headers=(_) - end + attr_accessor :extra_headers # Extra data to send with the request. These are deep merged into any data # generated as part of the normal request. - sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } - def extra_body - end - - sig { params(_: T.nilable(T::Hash[Symbol, T.anything])).returns(T.nilable(T::Hash[Symbol, T.anything])) } - def extra_body=(_) - end + sig { returns(T.nilable(T.anything)) } + attr_accessor :extra_body # Maximum number of retries to attempt after a failed initial request. sig { returns(T.nilable(Integer)) } - def max_retries - end - - sig { params(_: T.nilable(Integer)).returns(T.nilable(Integer)) } - def max_retries=(_) - end + attr_accessor :max_retries # Request timeout in seconds. sig { returns(T.nilable(Float)) } - def timeout - end - - sig { params(_: T.nilable(Float)).returns(T.nilable(Float)) } - def timeout=(_) - end + attr_accessor :timeout # Returns a new instance of RequestOptions. - sig { params(values: T::Hash[Symbol, T.anything]).returns(T.attached_class) } + sig { params(values: OpenAI::Util::AnyHash).returns(T.attached_class) } def self.new(values = {}) end end diff --git a/rbi/lib/openai/resources/audio.rbi b/rbi/lib/openai/resources/audio.rbi index c3381f2e..353012c6 100644 --- a/rbi/lib/openai/resources/audio.rbi +++ b/rbi/lib/openai/resources/audio.rbi @@ -4,16 +4,13 @@ module OpenAI module Resources class Audio sig { returns(OpenAI::Resources::Audio::Transcriptions) } - def transcriptions - end + attr_reader :transcriptions sig { returns(OpenAI::Resources::Audio::Translations) } - def translations - end + attr_reader :translations sig { returns(OpenAI::Resources::Audio::Speech) } - def speech - end + attr_reader :speech sig { params(client: OpenAI::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/lib/openai/resources/audio/speech.rbi b/rbi/lib/openai/resources/audio/speech.rbi index ae6f4be5..d17427d8 100644 --- a/rbi/lib/openai/resources/audio/speech.rbi +++ b/rbi/lib/openai/resources/audio/speech.rbi @@ -8,25 +8,29 @@ module OpenAI sig do params( input: String, - model: T.any(String, Symbol), - voice: Symbol, - response_format: Symbol, + model: T.any(String, OpenAI::Models::Audio::SpeechModel::OrSymbol), + voice: T.any(String, OpenAI::Models::Audio::SpeechCreateParams::Voice::OrSymbol), + instructions: String, + response_format: OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat::OrSymbol, speed: Float, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) - .returns(T.anything) + .returns(StringIO) end def create( # The text to generate audio for. The maximum length is 4096 characters. input:, # One of the available [TTS models](https://platform.openai.com/docs/models#tts): - # `tts-1` or `tts-1-hd` + # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`. model:, # The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - # `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the - # voices are available in the + # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and + # `verse`. Previews of the voices are available in the # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). voice:, + # Control the voice of your generated audio with additional instructions. Does not + # work with `tts-1` or `tts-1-hd`. + instructions: nil, # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, # `wav`, and `pcm`. response_format: nil, diff --git a/rbi/lib/openai/resources/audio/transcriptions.rbi b/rbi/lib/openai/resources/audio/transcriptions.rbi index 50e5c416..0a0205db 100644 --- a/rbi/lib/openai/resources/audio/transcriptions.rbi +++ b/rbi/lib/openai/resources/audio/transcriptions.rbi @@ -8,13 +8,15 @@ module OpenAI sig do params( file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), + include: T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol], language: String, prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::AudioResponseFormat::OrSymbol, temperature: Float, - timestamp_granularities: T::Array[Symbol], - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + timestamp_granularities: T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol], + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(T.any(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)) end @@ -22,9 +24,16 @@ module OpenAI # The audio file object (not file name) to transcribe, in one of these formats: # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. file:, - # ID of the model to use. Only `whisper-1` (which is powered by our open source - # Whisper V2 model) is currently available. + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). model:, + # Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. + include: nil, # The language of the input audio. Supplying the input language in # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) # format will improve accuracy and latency. @@ -35,7 +44,8 @@ module OpenAI # should match the audio language. prompt: nil, # The format of the output, in one of these options: `json`, `text`, `srt`, - # `verbose_json`, or `vtt`. + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. response_format: nil, # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the # output more random, while lower values like 0.2 will make it more focused and @@ -49,6 +59,78 @@ module OpenAI # is no additional latency for segment timestamps, but generating word timestamps # incurs additional latency. timestamp_granularities: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: false, + request_options: {} + ) + end + + # Transcribes audio into the input language. + sig do + params( + file: T.any(IO, StringIO), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), + include: T::Array[OpenAI::Models::Audio::TranscriptionInclude::OrSymbol], + language: String, + prompt: String, + response_format: OpenAI::Models::AudioResponseFormat::OrSymbol, + temperature: Float, + timestamp_granularities: T::Array[OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity::OrSymbol], + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) + ) + .returns( + OpenAI::Stream[ + T.any( + OpenAI::Models::Audio::TranscriptionTextDeltaEvent, + OpenAI::Models::Audio::TranscriptionTextDoneEvent + ) + ] + ) + end + def create_streaming( + # The audio file object (not file name) to transcribe, in one of these formats: + # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. + file:, + # ID of the model to use. The options are `gpt-4o-transcribe`, + # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source + # Whisper V2 model). + model:, + # Additional information to include in the transcription response. `logprobs` will + # return the log probabilities of the tokens in the response to understand the + # model's confidence in the transcription. `logprobs` only works with + # response_format set to `json` and only with the models `gpt-4o-transcribe` and + # `gpt-4o-mini-transcribe`. + include: nil, + # The language of the input audio. Supplying the input language in + # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) + # format will improve accuracy and latency. + language: nil, + # An optional text to guide the model's style or continue a previous audio + # segment. The + # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) + # should match the audio language. + prompt: nil, + # The format of the output, in one of these options: `json`, `text`, `srt`, + # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, + # the only supported format is `json`. + response_format: nil, + # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the + # output more random, while lower values like 0.2 will make it more focused and + # deterministic. If set to 0, the model will use + # [log probability](https://en.wikipedia.org/wiki/Log_probability) to + # automatically increase the temperature until certain thresholds are hit. + temperature: nil, + # The timestamp granularities to populate for this transcription. + # `response_format` must be set `verbose_json` to use timestamp granularities. + # Either or both of these options are supported: `word`, or `segment`. Note: There + # is no additional latency for segment timestamps, but generating word timestamps + # incurs additional latency. + timestamp_granularities: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end diff --git a/rbi/lib/openai/resources/audio/translations.rbi b/rbi/lib/openai/resources/audio/translations.rbi index 278e3855..c99220ed 100644 --- a/rbi/lib/openai/resources/audio/translations.rbi +++ b/rbi/lib/openai/resources/audio/translations.rbi @@ -8,11 +8,11 @@ module OpenAI sig do params( file: T.any(IO, StringIO), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::AudioModel::OrSymbol), prompt: String, - response_format: Symbol, + response_format: OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat::OrSymbol, temperature: Float, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(T.any(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)) end diff --git a/rbi/lib/openai/resources/batches.rbi b/rbi/lib/openai/resources/batches.rbi index a3f56e28..0e76d86b 100644 --- a/rbi/lib/openai/resources/batches.rbi +++ b/rbi/lib/openai/resources/batches.rbi @@ -6,11 +6,11 @@ module OpenAI # Creates and executes a batch from an uploaded file of requests sig do params( - completion_window: Symbol, - endpoint: Symbol, + completion_window: OpenAI::Models::BatchCreateParams::CompletionWindow::OrSymbol, + endpoint: OpenAI::Models::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Batch) end @@ -19,9 +19,9 @@ module OpenAI # is supported. completion_window:, # The endpoint to be used for all requests in the batch. Currently - # `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - # Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 - # embedding inputs across all requests in the batch. + # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` + # are supported. Note that `/v1/embeddings` batches are also restricted to a + # maximum of 50,000 embedding inputs across all requests in the batch. endpoint:, # The ID of an uploaded file that contains requests for the new batch. # @@ -48,7 +48,12 @@ module OpenAI sig do params( batch_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::Batch) end @@ -64,7 +69,7 @@ module OpenAI params( after: String, limit: Integer, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Batch]) end @@ -87,7 +92,12 @@ module OpenAI sig do params( batch_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::Batch) end diff --git a/rbi/lib/openai/resources/beta.rbi b/rbi/lib/openai/resources/beta.rbi index 3e97021d..eebedd02 100644 --- a/rbi/lib/openai/resources/beta.rbi +++ b/rbi/lib/openai/resources/beta.rbi @@ -4,12 +4,10 @@ module OpenAI module Resources class Beta sig { returns(OpenAI::Resources::Beta::Assistants) } - def assistants - end + attr_reader :assistants sig { returns(OpenAI::Resources::Beta::Threads) } - def threads - end + attr_reader :threads sig { params(client: OpenAI::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/lib/openai/resources/beta/assistants.rbi b/rbi/lib/openai/resources/beta/assistants.rbi index c9d62665..5b415b26 100644 --- a/rbi/lib/openai/resources/beta/assistants.rbi +++ b/rbi/lib/openai/resources/beta/assistants.rbi @@ -7,31 +7,33 @@ module OpenAI # Create an assistant with a model and instructions. sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_resources: T.nilable(OpenAI::Models::Beta::AssistantCreateParams::ToolResources), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantCreateParams::ToolResources, OpenAI::Util::AnyHash)), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ], top_p: T.nilable(Float), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Assistant) end @@ -111,7 +113,7 @@ module OpenAI sig do params( assistant_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Assistant) end @@ -128,29 +130,31 @@ module OpenAI assistant_id: String, description: T.nilable(String), instructions: T.nilable(String), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.any(String, Symbol), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.any(String, OpenAI::Models::Beta::AssistantUpdateParams::Model::OrSymbol), name: T.nilable(String), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_resources: T.nilable(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, OpenAI::Util::AnyHash)), tools: T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ], top_p: T.nilable(Float), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Assistant) end @@ -234,8 +238,8 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Beta::AssistantListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Beta::Assistant]) end @@ -264,7 +268,7 @@ module OpenAI sig do params( assistant_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::AssistantDeleted) end diff --git a/rbi/lib/openai/resources/beta/threads.rbi b/rbi/lib/openai/resources/beta/threads.rbi index 2170549d..2c2ac7ef 100644 --- a/rbi/lib/openai/resources/beta/threads.rbi +++ b/rbi/lib/openai/resources/beta/threads.rbi @@ -5,20 +5,18 @@ module OpenAI class Beta class Threads sig { returns(OpenAI::Resources::Beta::Threads::Runs) } - def runs - end + attr_reader :runs sig { returns(OpenAI::Resources::Beta::Threads::Messages) } - def messages - end + attr_reader :messages # Create a thread. sig do params( - messages: T::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateParams::ToolResources), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + messages: T::Array[T.any(OpenAI::Models::Beta::ThreadCreateParams::Message, OpenAI::Util::AnyHash)], + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateParams::ToolResources, OpenAI::Util::AnyHash)), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Thread) end @@ -46,7 +44,7 @@ module OpenAI sig do params( thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Thread) end @@ -61,9 +59,9 @@ module OpenAI sig do params( thread_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + metadata: T.nilable(T::Hash[Symbol, String]), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, OpenAI::Util::AnyHash)), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Thread) end @@ -90,7 +88,7 @@ module OpenAI sig do params( thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::ThreadDeleted) end @@ -108,33 +106,44 @@ module OpenAI instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources), + thread: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, OpenAI::Util::AnyHash), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, OpenAI::Util::AnyHash)), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -227,6 +236,9 @@ module OpenAI # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. truncation_strategy: nil, + # There is no need to provide `stream:`. Instead, use `#create_and_run_streaming` + # or `#create_and_run` for streaming and non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -238,33 +250,44 @@ module OpenAI instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), - tool_resources: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources), + thread: T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, OpenAI::Util::AnyHash), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), + tool_resources: T.nilable(T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, OpenAI::Util::AnyHash)), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns( OpenAI::Stream[ @@ -386,6 +409,9 @@ module OpenAI # Controls for how a thread will be truncated prior to the run. Use this to # control the intial context window of the run. truncation_strategy: nil, + # There is no need to provide `stream:`. Instead, use `#create_and_run_streaming` + # or `#create_and_run` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end diff --git a/rbi/lib/openai/resources/beta/threads/messages.rbi b/rbi/lib/openai/resources/beta/threads/messages.rbi index d417b9d0..24507cc6 100644 --- a/rbi/lib/openai/resources/beta/threads/messages.rbi +++ b/rbi/lib/openai/resources/beta/threads/messages.rbi @@ -14,15 +14,18 @@ module OpenAI T::Array[ T.any( OpenAI::Models::Beta::Threads::ImageFileContentBlock, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam ) ] ), - role: Symbol, - attachments: T.nilable(T::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]), - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + role: OpenAI::Models::Beta::Threads::MessageCreateParams::Role::OrSymbol, + attachments: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Message) end @@ -57,7 +60,7 @@ module OpenAI params( message_id: String, thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Message) end @@ -76,8 +79,8 @@ module OpenAI params( message_id: String, thread_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Message) end @@ -104,9 +107,9 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::Beta::Threads::MessageListParams::Order::OrSymbol, run_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Message]) end @@ -141,7 +144,7 @@ module OpenAI params( message_id: String, thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::MessageDeleted) end diff --git a/rbi/lib/openai/resources/beta/threads/runs.rbi b/rbi/lib/openai/resources/beta/threads/runs.rbi index c2a318dd..71cf02b1 100644 --- a/rbi/lib/openai/resources/beta/threads/runs.rbi +++ b/rbi/lib/openai/resources/beta/threads/runs.rbi @@ -6,46 +6,58 @@ module OpenAI class Threads class Runs sig { returns(OpenAI::Resources::Beta::Threads::Runs::Steps) } - def steps - end + attr_reader :steps # Create a run. sig do params( thread_id: String, assistant_id: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], additional_instructions: T.nilable(String), - additional_messages: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]), + additional_messages: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage, OpenAI::Util::AnyHash)] + ), instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -158,6 +170,9 @@ module OpenAI # Body param: Controls for how a thread will be truncated prior to the run. Use # this to control the intial context window of the run. truncation_strategy: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -167,38 +182,51 @@ module OpenAI params( thread_id: String, assistant_id: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], additional_instructions: T.nilable(String), - additional_messages: T.nilable(T::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]), + additional_messages: T.nilable( + T::Array[T.any(OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage, OpenAI::Util::AnyHash)] + ), instructions: T.nilable(String), max_completion_tokens: T.nilable(Integer), max_prompt_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - model: T.nilable(T.any(String, Symbol)), + metadata: T.nilable(T::Hash[Symbol, String]), + model: T.nilable(T.any(String, OpenAI::Models::ChatModel::OrSymbol)), parallel_tool_calls: T::Boolean, - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.nilable( T.any( Symbol, OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema ) ), temperature: T.nilable(Float), - tool_choice: T.nilable(T.any(Symbol, OpenAI::Models::Beta::AssistantToolChoice)), + tool_choice: T.nilable( + T.any( + OpenAI::Models::Beta::AssistantToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Beta::AssistantToolChoice, + OpenAI::Util::AnyHash + ) + ), tools: T.nilable( T::Array[ T.any( OpenAI::Models::Beta::CodeInterpreterTool, + OpenAI::Util::AnyHash, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool ) ] ), top_p: T.nilable(Float), - truncation_strategy: T.nilable(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + truncation_strategy: T.nilable( + T.any(OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, OpenAI::Util::AnyHash) + ), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns( OpenAI::Stream[ @@ -340,6 +368,9 @@ module OpenAI # Body param: Controls for how a thread will be truncated prior to the run. Use # this to control the intial context window of the run. truncation_strategy: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end @@ -349,7 +380,7 @@ module OpenAI params( run_id: String, thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -368,8 +399,8 @@ module OpenAI params( run_id: String, thread_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -397,8 +428,8 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Beta::Threads::RunListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Run]) end @@ -430,7 +461,7 @@ module OpenAI params( run_id: String, thread_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -451,8 +482,9 @@ module OpenAI params( run_id: String, thread_id: String, - tool_outputs: T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + tool_outputs: T::Array[T.any(OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput, OpenAI::Util::AnyHash)], + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Run) end @@ -465,6 +497,10 @@ module OpenAI thread_id:, # Body param: A list of tools for which the outputs are being submitted. tool_outputs:, + # There is no need to provide `stream:`. Instead, use + # `#submit_tool_outputs_streaming` or `#submit_tool_outputs` for streaming and + # non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -477,8 +513,9 @@ module OpenAI params( run_id: String, thread_id: String, - tool_outputs: T::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + tool_outputs: T::Array[T.any(OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput, OpenAI::Util::AnyHash)], + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns( OpenAI::Stream[ @@ -520,6 +557,10 @@ module OpenAI thread_id:, # Body param: A list of tools for which the outputs are being submitted. tool_outputs:, + # There is no need to provide `stream:`. Instead, use + # `#submit_tool_outputs_streaming` or `#submit_tool_outputs` for streaming and + # non-streaming use cases, respectively. + stream: true, request_options: {} ) end diff --git a/rbi/lib/openai/resources/beta/threads/runs/steps.rbi b/rbi/lib/openai/resources/beta/threads/runs/steps.rbi index 4833b5fb..36fc8b92 100644 --- a/rbi/lib/openai/resources/beta/threads/runs/steps.rbi +++ b/rbi/lib/openai/resources/beta/threads/runs/steps.rbi @@ -12,8 +12,8 @@ module OpenAI step_id: String, thread_id: String, run_id: String, - include: T::Array[Symbol], - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Beta::Threads::Runs::RunStep) end @@ -44,10 +44,10 @@ module OpenAI thread_id: String, after: String, before: String, - include: T::Array[Symbol], + include: T::Array[OpenAI::Models::Beta::Threads::Runs::RunStepInclude::OrSymbol], limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Beta::Threads::Runs::StepListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Runs::RunStep]) end diff --git a/rbi/lib/openai/resources/chat.rbi b/rbi/lib/openai/resources/chat.rbi index 4d090d3f..98440959 100644 --- a/rbi/lib/openai/resources/chat.rbi +++ b/rbi/lib/openai/resources/chat.rbi @@ -4,8 +4,7 @@ module OpenAI module Resources class Chat sig { returns(OpenAI::Resources::Chat::Completions) } - def completions - end + attr_reader :completions sig { params(client: OpenAI::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/lib/openai/resources/chat/completions.rbi b/rbi/lib/openai/resources/chat/completions.rbi index 7f6a851c..58bc7161 100644 --- a/rbi/lib/openai/resources/chat/completions.rbi +++ b/rbi/lib/openai/resources/chat/completions.rbi @@ -5,8 +5,7 @@ module OpenAI class Chat class Completions sig { returns(OpenAI::Resources::Chat::Completions::Messages) } - def messages - end + attr_reader :messages # **Starting a new project?** We recommend trying # [Responses](https://platform.openai.com/docs/api-reference/responses) to take @@ -30,6 +29,7 @@ module OpenAI messages: T::Array[ T.any( OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, + OpenAI::Util::AnyHash, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, @@ -37,40 +37,50 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionFunctionMessageParam ) ], - model: T.any(String, Symbol), - audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudioParam, OpenAI::Util::AnyHash)), frequency_penalty: T.nilable(Float), - function_call: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption), - functions: T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + function_call: T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption, + OpenAI::Util::AnyHash + ), + functions: T::Array[T.any(OpenAI::Models::Chat::CompletionCreateParams::Function, OpenAI::Util::AnyHash)], logit_bias: T.nilable(T::Hash[Symbol, Integer]), logprobs: T.nilable(T::Boolean), max_completion_tokens: T.nilable(Integer), max_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - modalities: T.nilable(T::Array[Symbol]), + metadata: T.nilable(T::Hash[Symbol, String]), + modalities: T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::OrSymbol]), n: T.nilable(Integer), parallel_tool_calls: T::Boolean, - prediction: T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent), + prediction: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionPredictionContent, OpenAI::Util::AnyHash)), presence_penalty: T.nilable(Float), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject ), seed: T.nilable(Integer), - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::OrSymbol), stop: T.nilable(T.any(String, T::Array[String])), store: T.nilable(T::Boolean), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice), - tools: T::Array[OpenAI::Models::Chat::ChatCompletionTool], + tool_choice: T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice, + OpenAI::Util::AnyHash + ), + tools: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTool, OpenAI::Util::AnyHash)], top_logprobs: T.nilable(Integer), top_p: T.nilable(Float), user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + web_search_options: T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, OpenAI::Util::AnyHash), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Chat::ChatCompletion) end @@ -258,6 +268,9 @@ module OpenAI # about the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). web_search_options: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -284,6 +297,7 @@ module OpenAI messages: T::Array[ T.any( OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, + OpenAI::Util::AnyHash, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, @@ -291,40 +305,50 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionFunctionMessageParam ) ], - model: T.any(String, Symbol), - audio: T.nilable(OpenAI::Models::Chat::ChatCompletionAudioParam), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol), + audio: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionAudioParam, OpenAI::Util::AnyHash)), frequency_penalty: T.nilable(Float), - function_call: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionFunctionCallOption), - functions: T::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + function_call: T.any( + OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode::OrSymbol, + OpenAI::Models::Chat::ChatCompletionFunctionCallOption, + OpenAI::Util::AnyHash + ), + functions: T::Array[T.any(OpenAI::Models::Chat::CompletionCreateParams::Function, OpenAI::Util::AnyHash)], logit_bias: T.nilable(T::Hash[Symbol, Integer]), logprobs: T.nilable(T::Boolean), max_completion_tokens: T.nilable(Integer), max_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), - modalities: T.nilable(T::Array[Symbol]), + metadata: T.nilable(T::Hash[Symbol, String]), + modalities: T.nilable(T::Array[OpenAI::Models::Chat::CompletionCreateParams::Modality::OrSymbol]), n: T.nilable(Integer), parallel_tool_calls: T::Boolean, - prediction: T.nilable(OpenAI::Models::Chat::ChatCompletionPredictionContent), + prediction: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionPredictionContent, OpenAI::Util::AnyHash)), presence_penalty: T.nilable(Float), - reasoning_effort: T.nilable(Symbol), + reasoning_effort: T.nilable(OpenAI::Models::ReasoningEffort::OrSymbol), response_format: T.any( OpenAI::Models::ResponseFormatText, + OpenAI::Util::AnyHash, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject ), seed: T.nilable(Integer), - service_tier: T.nilable(Symbol), + service_tier: T.nilable(OpenAI::Models::Chat::CompletionCreateParams::ServiceTier::OrSymbol), stop: T.nilable(T.any(String, T::Array[String])), store: T.nilable(T::Boolean), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), temperature: T.nilable(Float), - tool_choice: T.any(Symbol, OpenAI::Models::Chat::ChatCompletionNamedToolChoice), - tools: T::Array[OpenAI::Models::Chat::ChatCompletionTool], + tool_choice: T.any( + OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, + OpenAI::Models::Chat::ChatCompletionNamedToolChoice, + OpenAI::Util::AnyHash + ), + tools: T::Array[T.any(OpenAI::Models::Chat::ChatCompletionTool, OpenAI::Util::AnyHash)], top_logprobs: T.nilable(Integer), top_p: T.nilable(Float), user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + web_search_options: T.any(OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, OpenAI::Util::AnyHash), + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Stream[OpenAI::Models::Chat::ChatCompletionChunk]) end @@ -512,6 +536,9 @@ module OpenAI # about the # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). web_search_options: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end @@ -521,7 +548,7 @@ module OpenAI sig do params( completion_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Chat::ChatCompletion) end @@ -538,8 +565,8 @@ module OpenAI sig do params( completion_id: String, - metadata: T.nilable(OpenAI::Models::Metadata), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + metadata: T.nilable(T::Hash[Symbol, String]), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Chat::ChatCompletion) end @@ -563,10 +590,10 @@ module OpenAI params( after: String, limit: Integer, - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), model: String, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Chat::CompletionListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletion]) end @@ -593,7 +620,7 @@ module OpenAI sig do params( completion_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Chat::ChatCompletionDeleted) end diff --git a/rbi/lib/openai/resources/chat/completions/messages.rbi b/rbi/lib/openai/resources/chat/completions/messages.rbi index 3e7c16e2..f86371f9 100644 --- a/rbi/lib/openai/resources/chat/completions/messages.rbi +++ b/rbi/lib/openai/resources/chat/completions/messages.rbi @@ -12,8 +12,8 @@ module OpenAI completion_id: String, after: String, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Chat::Completions::MessageListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletionStoreMessage]) end diff --git a/rbi/lib/openai/resources/completions.rbi b/rbi/lib/openai/resources/completions.rbi index 949f94ed..64b4c2ef 100644 --- a/rbi/lib/openai/resources/completions.rbi +++ b/rbi/lib/openai/resources/completions.rbi @@ -6,7 +6,7 @@ module OpenAI # Creates a completion for the provided prompt and parameters. sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol), prompt: T.nilable( T.any( String, @@ -25,12 +25,13 @@ module OpenAI presence_penalty: T.nilable(Float), seed: T.nilable(Integer), stop: T.nilable(T.any(String, T::Array[String])), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), suffix: T.nilable(String), temperature: T.nilable(Float), top_p: T.nilable(Float), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Completion) end @@ -138,6 +139,9 @@ module OpenAI # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). user: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -145,7 +149,7 @@ module OpenAI # Creates a completion for the provided prompt and parameters. sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::CompletionCreateParams::Model::OrSymbol), prompt: T.nilable( T.any( String, @@ -164,12 +168,13 @@ module OpenAI presence_penalty: T.nilable(Float), seed: T.nilable(Integer), stop: T.nilable(T.any(String, T::Array[String])), - stream_options: T.nilable(OpenAI::Models::Chat::ChatCompletionStreamOptions), + stream_options: T.nilable(T.any(OpenAI::Models::Chat::ChatCompletionStreamOptions, OpenAI::Util::AnyHash)), suffix: T.nilable(String), temperature: T.nilable(Float), top_p: T.nilable(Float), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Stream[OpenAI::Models::Completion]) end @@ -277,6 +282,9 @@ module OpenAI # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). user: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end diff --git a/rbi/lib/openai/resources/embeddings.rbi b/rbi/lib/openai/resources/embeddings.rbi index 025c37a7..9c05cf33 100644 --- a/rbi/lib/openai/resources/embeddings.rbi +++ b/rbi/lib/openai/resources/embeddings.rbi @@ -7,11 +7,11 @@ module OpenAI sig do params( input: T.any(String, T::Array[String], T::Array[Integer], T::Array[T::Array[Integer]]), - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::EmbeddingModel::OrSymbol), dimensions: Integer, - encoding_format: Symbol, + encoding_format: OpenAI::Models::EmbeddingCreateParams::EncodingFormat::OrSymbol, user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::CreateEmbeddingResponse) end diff --git a/rbi/lib/openai/resources/files.rbi b/rbi/lib/openai/resources/files.rbi index 441f93e0..9ddc3a8e 100644 --- a/rbi/lib/openai/resources/files.rbi +++ b/rbi/lib/openai/resources/files.rbi @@ -27,8 +27,8 @@ module OpenAI sig do params( file: T.any(IO, StringIO), - purpose: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + purpose: OpenAI::Models::FilePurpose::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::FileObject) end @@ -48,7 +48,12 @@ module OpenAI sig do params( file_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::FileObject) end @@ -64,9 +69,9 @@ module OpenAI params( after: String, limit: Integer, - order: Symbol, + order: OpenAI::Models::FileListParams::Order::OrSymbol, purpose: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::FileObject]) end @@ -92,7 +97,12 @@ module OpenAI sig do params( file_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::FileDeleted) end @@ -107,9 +117,14 @@ module OpenAI sig do params( file_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) - .returns(T.anything) + .returns(StringIO) end def content( # The ID of the file to use for this request. diff --git a/rbi/lib/openai/resources/fine_tuning.rbi b/rbi/lib/openai/resources/fine_tuning.rbi index 0699b0ee..f2743caa 100644 --- a/rbi/lib/openai/resources/fine_tuning.rbi +++ b/rbi/lib/openai/resources/fine_tuning.rbi @@ -4,8 +4,7 @@ module OpenAI module Resources class FineTuning sig { returns(OpenAI::Resources::FineTuning::Jobs) } - def jobs - end + attr_reader :jobs sig { params(client: OpenAI::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/lib/openai/resources/fine_tuning/jobs.rbi b/rbi/lib/openai/resources/fine_tuning/jobs.rbi index e1709e2c..7d8544da 100644 --- a/rbi/lib/openai/resources/fine_tuning/jobs.rbi +++ b/rbi/lib/openai/resources/fine_tuning/jobs.rbi @@ -5,8 +5,7 @@ module OpenAI class FineTuning class Jobs sig { returns(OpenAI::Resources::FineTuning::Jobs::Checkpoints) } - def checkpoints - end + attr_reader :checkpoints # Creates a fine-tuning job which begins the process of creating a new model from # a given dataset. @@ -17,16 +16,18 @@ module OpenAI # [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning) sig do params( - model: T.any(String, Symbol), + model: T.any(String, OpenAI::Models::FineTuning::JobCreateParams::Model::OrSymbol), training_file: String, - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, - integrations: T.nilable(T::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]), - metadata: T.nilable(OpenAI::Models::Metadata), - method_: OpenAI::Models::FineTuning::JobCreateParams::Method, + hyperparameters: T.any(OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, OpenAI::Util::AnyHash), + integrations: T.nilable( + T::Array[T.any(OpenAI::Models::FineTuning::JobCreateParams::Integration, OpenAI::Util::AnyHash)] + ), + metadata: T.nilable(T::Hash[Symbol, String]), + method_: T.any(OpenAI::Models::FineTuning::JobCreateParams::Method, OpenAI::Util::AnyHash), seed: T.nilable(Integer), suffix: T.nilable(String), validation_file: T.nilable(String), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::FineTuning::FineTuningJob) end @@ -99,7 +100,7 @@ module OpenAI sig do params( fine_tuning_job_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::FineTuning::FineTuningJob) end @@ -116,7 +117,7 @@ module OpenAI after: String, limit: Integer, metadata: T.nilable(T::Hash[Symbol, String]), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJob]) end @@ -136,7 +137,7 @@ module OpenAI sig do params( fine_tuning_job_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::FineTuning::FineTuningJob) end @@ -153,7 +154,7 @@ module OpenAI fine_tuning_job_id: String, after: String, limit: Integer, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJobEvent]) end diff --git a/rbi/lib/openai/resources/fine_tuning/jobs/checkpoints.rbi b/rbi/lib/openai/resources/fine_tuning/jobs/checkpoints.rbi index 24509186..5986546b 100644 --- a/rbi/lib/openai/resources/fine_tuning/jobs/checkpoints.rbi +++ b/rbi/lib/openai/resources/fine_tuning/jobs/checkpoints.rbi @@ -11,7 +11,7 @@ module OpenAI fine_tuning_job_id: String, after: String, limit: Integer, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint]) end diff --git a/rbi/lib/openai/resources/images.rbi b/rbi/lib/openai/resources/images.rbi index 396f2edd..d36dd357 100644 --- a/rbi/lib/openai/resources/images.rbi +++ b/rbi/lib/openai/resources/images.rbi @@ -7,12 +7,12 @@ module OpenAI sig do params( image: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageCreateVariationParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageCreateVariationParams::Size::OrSymbol), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::ImagesResponse) end @@ -47,12 +47,12 @@ module OpenAI image: T.any(IO, StringIO), prompt: String, mask: T.any(IO, StringIO), - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), + response_format: T.nilable(OpenAI::Models::ImageEditParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageEditParams::Size::OrSymbol), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::ImagesResponse) end @@ -91,14 +91,14 @@ module OpenAI sig do params( prompt: String, - model: T.nilable(T.any(String, Symbol)), + model: T.nilable(T.any(String, OpenAI::Models::ImageModel::OrSymbol)), n: T.nilable(Integer), - quality: Symbol, - response_format: T.nilable(Symbol), - size: T.nilable(Symbol), - style: T.nilable(Symbol), + quality: OpenAI::Models::ImageGenerateParams::Quality::OrSymbol, + response_format: T.nilable(OpenAI::Models::ImageGenerateParams::ResponseFormat::OrSymbol), + size: T.nilable(OpenAI::Models::ImageGenerateParams::Size::OrSymbol), + style: T.nilable(OpenAI::Models::ImageGenerateParams::Style::OrSymbol), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::ImagesResponse) end diff --git a/rbi/lib/openai/resources/models.rbi b/rbi/lib/openai/resources/models.rbi index 52e65f29..505640bc 100644 --- a/rbi/lib/openai/resources/models.rbi +++ b/rbi/lib/openai/resources/models.rbi @@ -8,7 +8,12 @@ module OpenAI sig do params( model: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::Model) end @@ -22,7 +27,7 @@ module OpenAI # Lists the currently available models, and provides basic information about each # one such as the owner and availability. sig do - params(request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything]))) + params(request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash))) .returns(OpenAI::Page[OpenAI::Models::Model]) end def list(request_options: {}) @@ -33,7 +38,12 @@ module OpenAI sig do params( model: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable( + T.any( + OpenAI::RequestOptions, + OpenAI::Util::AnyHash + ) + ) ) .returns(OpenAI::Models::ModelDeleted) end diff --git a/rbi/lib/openai/resources/moderations.rbi b/rbi/lib/openai/resources/moderations.rbi index 3b9b2bd0..0fd74373 100644 --- a/rbi/lib/openai/resources/moderations.rbi +++ b/rbi/lib/openai/resources/moderations.rbi @@ -10,10 +10,10 @@ module OpenAI input: T.any( String, T::Array[String], - T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)] + T::Array[T.any(OpenAI::Models::ModerationImageURLInput, OpenAI::Util::AnyHash, OpenAI::Models::ModerationTextInput)] ), - model: T.any(String, Symbol), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + model: T.any(String, OpenAI::Models::ModerationModel::OrSymbol), + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::ModerationCreateResponse) end diff --git a/rbi/lib/openai/resources/responses.rbi b/rbi/lib/openai/resources/responses.rbi index 823cc8a1..1c7a99ac 100644 --- a/rbi/lib/openai/resources/responses.rbi +++ b/rbi/lib/openai/resources/responses.rbi @@ -4,8 +4,7 @@ module OpenAI module Resources class Responses sig { returns(OpenAI::Resources::Responses::InputItems) } - def input_items - end + attr_reader :input_items # Creates a model response. Provide # [text](https://platform.openai.com/docs/guides/text) or @@ -20,31 +19,56 @@ module OpenAI # your own data as input for the model's response. sig do params( - input: T.any(String, OpenAI::Models::Responses::ResponseInput), - model: T.any(String, Symbol), - include: T.nilable(T::Array[Symbol]), + input: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol), + include: T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]), instructions: T.nilable(String), max_output_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), parallel_tool_calls: T.nilable(T::Boolean), previous_response_id: T.nilable(String), - reasoning: T.nilable(OpenAI::Models::Reasoning), + reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash)), store: T.nilable(T::Boolean), temperature: T.nilable(Float), - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool ) ], top_p: T.nilable(Float), - truncation: T.nilable(Symbol), + truncation: T.nilable(OpenAI::Models::Responses::ResponseCreateParams::Truncation::OrSymbol), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Responses::Response) end @@ -78,8 +102,8 @@ module OpenAI # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. instructions: nil, # An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and @@ -153,6 +177,9 @@ module OpenAI # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). user: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: false, request_options: {} ) end @@ -170,31 +197,56 @@ module OpenAI # your own data as input for the model's response. sig do params( - input: T.any(String, OpenAI::Models::Responses::ResponseInput), - model: T.any(String, Symbol), - include: T.nilable(T::Array[Symbol]), + input: T.any( + String, + T::Array[ + T.any( + OpenAI::Models::Responses::EasyInputMessage, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ResponseInputItem::Message, + OpenAI::Models::Responses::ResponseOutputMessage, + OpenAI::Models::Responses::ResponseFileSearchToolCall, + OpenAI::Models::Responses::ResponseComputerToolCall, + OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, + OpenAI::Models::Responses::ResponseFunctionWebSearch, + OpenAI::Models::Responses::ResponseFunctionToolCall, + OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, + OpenAI::Models::Responses::ResponseReasoningItem, + OpenAI::Models::Responses::ResponseInputItem::ItemReference + ) + ] + ), + model: T.any(String, OpenAI::Models::ChatModel::OrSymbol, OpenAI::Models::ResponsesModel::OrSymbol), + include: T.nilable(T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol]), instructions: T.nilable(String), max_output_tokens: T.nilable(Integer), - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), parallel_tool_calls: T.nilable(T::Boolean), previous_response_id: T.nilable(String), - reasoning: T.nilable(OpenAI::Models::Reasoning), + reasoning: T.nilable(T.any(OpenAI::Models::Reasoning, OpenAI::Util::AnyHash)), store: T.nilable(T::Boolean), temperature: T.nilable(Float), - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: T.any(Symbol, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction), + text: T.any(OpenAI::Models::Responses::ResponseTextConfig, OpenAI::Util::AnyHash), + tool_choice: T.any( + OpenAI::Models::Responses::ToolChoiceOptions::OrSymbol, + OpenAI::Models::Responses::ToolChoiceTypes, + OpenAI::Util::AnyHash, + OpenAI::Models::Responses::ToolChoiceFunction + ), tools: T::Array[ T.any( OpenAI::Models::Responses::FileSearchTool, + OpenAI::Util::AnyHash, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool ) ], top_p: T.nilable(Float), - truncation: T.nilable(Symbol), + truncation: T.nilable(OpenAI::Models::Responses::ResponseCreateParams::Truncation::OrSymbol), user: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + stream: T.noreturn, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns( OpenAI::Stream[ @@ -265,8 +317,8 @@ module OpenAI # context. # # When using along with `previous_response_id`, the instructions from a previous - # response will be not be carried over to the next response. This makes it simple - # to swap out system (or developer) messages in new responses. + # response will not be carried over to the next response. This makes it simple to + # swap out system (or developer) messages in new responses. instructions: nil, # An upper bound for the number of tokens that can be generated for a response, # including visible output tokens and @@ -340,6 +392,9 @@ module OpenAI # and detect abuse. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). user: nil, + # There is no need to provide `stream:`. Instead, use `#create_streaming` or + # `#create` for streaming and non-streaming use cases, respectively. + stream: true, request_options: {} ) end @@ -348,8 +403,8 @@ module OpenAI sig do params( response_id: String, - include: T::Array[Symbol], - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Responses::Response) end @@ -367,7 +422,7 @@ module OpenAI sig do params( response_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .void end diff --git a/rbi/lib/openai/resources/responses/input_items.rbi b/rbi/lib/openai/resources/responses/input_items.rbi index f6d2e651..35fb21c7 100644 --- a/rbi/lib/openai/resources/responses/input_items.rbi +++ b/rbi/lib/openai/resources/responses/input_items.rbi @@ -10,21 +10,22 @@ module OpenAI response_id: String, after: String, before: String, + include: T::Array[OpenAI::Models::Responses::ResponseIncludable::OrSymbol], limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::Responses::InputItemListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns( OpenAI::CursorPage[ T.any( - OpenAI::Models::Responses::ResponseItemList::Data::Message, + OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, - OpenAI::Models::Responses::ResponseFunctionToolCall, - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput + OpenAI::Models::Responses::ResponseFunctionToolCallItem, + OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem ) ] ) @@ -36,6 +37,9 @@ module OpenAI after: nil, # An item ID to list items before, used in pagination. before: nil, + # Additional fields to include in the response. See the `include` parameter for + # Response creation above for more information. + include: nil, # A limit on the number of objects to be returned. Limit can range between 1 and # 100, and the default is 20. limit: nil, diff --git a/rbi/lib/openai/resources/uploads.rbi b/rbi/lib/openai/resources/uploads.rbi index 98a58dc5..55b2b24e 100644 --- a/rbi/lib/openai/resources/uploads.rbi +++ b/rbi/lib/openai/resources/uploads.rbi @@ -4,8 +4,7 @@ module OpenAI module Resources class Uploads sig { returns(OpenAI::Resources::Uploads::Parts) } - def parts - end + attr_reader :parts # Creates an intermediate # [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object @@ -31,8 +30,8 @@ module OpenAI bytes: Integer, filename: String, mime_type: String, - purpose: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + purpose: OpenAI::Models::FilePurpose::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Upload) end @@ -59,7 +58,7 @@ module OpenAI sig do params( upload_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Upload) end @@ -88,7 +87,7 @@ module OpenAI upload_id: String, part_ids: T::Array[String], md5: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Upload) end diff --git a/rbi/lib/openai/resources/uploads/parts.rbi b/rbi/lib/openai/resources/uploads/parts.rbi index 6e52432f..b90746ff 100644 --- a/rbi/lib/openai/resources/uploads/parts.rbi +++ b/rbi/lib/openai/resources/uploads/parts.rbi @@ -19,7 +19,7 @@ module OpenAI params( upload_id: String, data: T.any(IO, StringIO), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::Uploads::UploadPart) end diff --git a/rbi/lib/openai/resources/vector_stores.rbi b/rbi/lib/openai/resources/vector_stores.rbi index 32aecdbf..0c24ebc9 100644 --- a/rbi/lib/openai/resources/vector_stores.rbi +++ b/rbi/lib/openai/resources/vector_stores.rbi @@ -4,25 +4,24 @@ module OpenAI module Resources class VectorStores sig { returns(OpenAI::Resources::VectorStores::Files) } - def files - end + attr_reader :files sig { returns(OpenAI::Resources::VectorStores::FileBatches) } - def file_batches - end + attr_reader :file_batches # Create a vector store. sig do params( chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, + expires_after: T.any(OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, OpenAI::Util::AnyHash), file_ids: T::Array[String], - metadata: T.nilable(OpenAI::Models::Metadata), + metadata: T.nilable(T::Hash[Symbol, String]), name: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStore) end @@ -53,7 +52,7 @@ module OpenAI sig do params( vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStore) end @@ -68,10 +67,10 @@ module OpenAI sig do params( vector_store_id: String, - expires_after: T.nilable(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter), - metadata: T.nilable(OpenAI::Models::Metadata), + expires_after: T.nilable(T.any(OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, OpenAI::Util::AnyHash)), + metadata: T.nilable(T::Hash[Symbol, String]), name: T.nilable(String), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStore) end @@ -99,8 +98,8 @@ module OpenAI after: String, before: String, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::VectorStoreListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::VectorStore]) end @@ -129,7 +128,7 @@ module OpenAI sig do params( vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStoreDeleted) end @@ -146,11 +145,11 @@ module OpenAI params( vector_store_id: String, query: T.any(String, T::Array[String]), - filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter), + filters: T.any(OpenAI::Models::ComparisonFilter, OpenAI::Util::AnyHash, OpenAI::Models::CompoundFilter), max_num_results: Integer, - ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, + ranking_options: T.any(OpenAI::Models::VectorStoreSearchParams::RankingOptions, OpenAI::Util::AnyHash), rewrite_query: T::Boolean, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Page[OpenAI::Models::VectorStoreSearchResponse]) end diff --git a/rbi/lib/openai/resources/vector_stores/file_batches.rbi b/rbi/lib/openai/resources/vector_stores/file_batches.rbi index ec4e8e7a..62bd27b1 100644 --- a/rbi/lib/openai/resources/vector_stores/file_batches.rbi +++ b/rbi/lib/openai/resources/vector_stores/file_batches.rbi @@ -12,9 +12,10 @@ module OpenAI attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFileBatch) end @@ -43,7 +44,7 @@ module OpenAI params( batch_id: String, vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFileBatch) end @@ -62,7 +63,7 @@ module OpenAI params( batch_id: String, vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFileBatch) end @@ -82,10 +83,10 @@ module OpenAI vector_store_id: String, after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter::OrSymbol, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::VectorStores::FileBatchListFilesParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile]) end diff --git a/rbi/lib/openai/resources/vector_stores/files.rbi b/rbi/lib/openai/resources/vector_stores/files.rbi index 2fc3ae57..37afdaf7 100644 --- a/rbi/lib/openai/resources/vector_stores/files.rbi +++ b/rbi/lib/openai/resources/vector_stores/files.rbi @@ -14,9 +14,10 @@ module OpenAI attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), chunking_strategy: T.any( OpenAI::Models::AutoFileChunkingStrategyParam, + OpenAI::Util::AnyHash, OpenAI::Models::StaticFileChunkingStrategyObjectParam ), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFile) end @@ -45,7 +46,7 @@ module OpenAI params( file_id: String, vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFile) end @@ -64,7 +65,7 @@ module OpenAI file_id: String, vector_store_id: String, attributes: T.nilable(T::Hash[Symbol, T.any(String, Float, T::Boolean)]), - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFile) end @@ -89,10 +90,10 @@ module OpenAI vector_store_id: String, after: String, before: String, - filter: Symbol, + filter: OpenAI::Models::VectorStores::FileListParams::Filter::OrSymbol, limit: Integer, - order: Symbol, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + order: OpenAI::Models::VectorStores::FileListParams::Order::OrSymbol, + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile]) end @@ -129,7 +130,7 @@ module OpenAI params( file_id: String, vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Models::VectorStores::VectorStoreFileDeleted) end @@ -147,7 +148,7 @@ module OpenAI params( file_id: String, vector_store_id: String, - request_options: T.nilable(T.any(OpenAI::RequestOptions, T::Hash[Symbol, T.anything])) + request_options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) ) .returns(OpenAI::Page[OpenAI::Models::VectorStores::FileContentResponse]) end diff --git a/rbi/lib/openai/stream.rbi b/rbi/lib/openai/stream.rbi index 75e469ce..ba0c2f8a 100644 --- a/rbi/lib/openai/stream.rbi +++ b/rbi/lib/openai/stream.rbi @@ -2,7 +2,7 @@ module OpenAI class Stream - include OpenAI::BaseStream + include OpenAI::Type::BaseStream Message = type_member(:in) { {fixed: OpenAI::Util::ServerSentEvent} } Elem = type_member(:out) diff --git a/rbi/lib/openai/transport/base_client.rbi b/rbi/lib/openai/transport/base_client.rbi new file mode 100644 index 00000000..7deae432 --- /dev/null +++ b/rbi/lib/openai/transport/base_client.rbi @@ -0,0 +1,204 @@ +# typed: strong + +module OpenAI + module Transport + # @api private + class BaseClient + abstract! + + RequestComponentsShape = + T.type_alias do + { + method: Symbol, + path: T.any(String, T::Array[String]), + query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), + headers: T.nilable( + T::Hash[String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + )] + ), + body: T.nilable(T.anything), + unwrap: T.nilable(Symbol), + page: T.nilable(T::Class[OpenAI::Type::BasePage[OpenAI::BaseModel]]), + stream: T.nilable(T::Class[OpenAI::Type::BaseStream[T.anything, OpenAI::BaseModel]]), + model: T.nilable(OpenAI::Type::Converter::Input), + options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) + } + end + + RequestInputShape = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + max_retries: Integer, + timeout: Float + } + end + + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + PLATFORM_HEADERS = T::Hash[String, String] + + class << self + # @api private + sig { params(req: OpenAI::Transport::BaseClient::RequestComponentsShape).void } + def validate!(req) + end + + # @api private + sig do + params( + status: Integer, + headers: T.any( + T::Hash[String, String], + Net::HTTPHeader + ) + ).returns(T::Boolean) + end + def should_retry?(status, headers:) + end + + # @api private + sig do + params( + request: OpenAI::Transport::BaseClient::RequestInputShape, + status: Integer, + response_headers: T.any(T::Hash[String, String], Net::HTTPHeader) + ) + .returns(OpenAI::Transport::BaseClient::RequestInputShape) + end + def follow_redirect(request, status:, response_headers:) + end + + # @api private + sig do + params( + status: T.any(Integer, OpenAI::APIConnectionError), + stream: T.nilable(T::Enumerable[String]) + ).void + end + def reap_connection!(status, stream:) + end + end + + # @api private + sig { returns(OpenAI::Transport::PooledNetRequester) } + attr_accessor :requester + + # @api private + sig do + params( + base_url: String, + timeout: Float, + max_retries: Integer, + initial_retry_delay: Float, + max_retry_delay: Float, + headers: T::Hash[String, + T.nilable(T.any(String, Integer, T::Array[T.nilable(T.any(String, Integer))]))], + idempotency_header: T.nilable(String) + ) + .returns(T.attached_class) + end + def self.new( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + end + + # @api private + sig { overridable.returns(T::Hash[String, String]) } + private def auth_headers + end + + # @api private + sig { returns(String) } + private def generate_idempotency_key + end + + # @api private + sig do + overridable + .params(req: OpenAI::Transport::BaseClient::RequestComponentsShape, opts: OpenAI::Util::AnyHash) + .returns(OpenAI::Transport::BaseClient::RequestInputShape) + end + private def build_request(req, opts) + end + + # @api private + sig { params(headers: T::Hash[String, String], retry_count: Integer).returns(Float) } + private def retry_delay(headers, retry_count:) + end + + # @api private + sig do + params( + request: OpenAI::Transport::BaseClient::RequestInputShape, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: T::Boolean + ) + .returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + private def send_request(request, redirect_count:, retry_count:, send_retry_header:) + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + sig do + params( + method: Symbol, + path: T.any(String, T::Array[String]), + query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), + headers: T.nilable( + T::Hash[String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + )] + ), + body: T.nilable(T.anything), + unwrap: T.nilable(Symbol), + page: T.nilable(T::Class[OpenAI::Type::BasePage[OpenAI::BaseModel]]), + stream: T.nilable(T::Class[OpenAI::Type::BaseStream[T.anything, OpenAI::BaseModel]]), + model: T.nilable(OpenAI::Type::Converter::Input), + options: T.nilable(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) + ) + .returns(T.anything) + end + def request( + method, + path, + query: {}, + headers: {}, + body: nil, + unwrap: nil, + page: nil, + stream: nil, + model: OpenAI::Unknown, + options: {} + ) + end + + sig { returns(String) } + def inspect + end + end + end +end diff --git a/rbi/lib/openai/transport/pooled_net_requester.rbi b/rbi/lib/openai/transport/pooled_net_requester.rbi new file mode 100644 index 00000000..d90c1881 --- /dev/null +++ b/rbi/lib/openai/transport/pooled_net_requester.rbi @@ -0,0 +1,64 @@ +# typed: strong + +module OpenAI + module Transport + # @api private + class PooledNetRequester + RequestShape = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + deadline: Float + } + end + + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + class << self + # @api private + sig { params(url: URI::Generic).returns(Net::HTTP) } + def connect(url) + end + + # @api private + sig { params(conn: Net::HTTP, deadline: Float).void } + def calibrate_socket_timeout(conn, deadline) + end + + # @api private + sig do + params( + request: OpenAI::Transport::PooledNetRequester::RequestShape, + blk: T.proc.params(arg0: String).void + ) + .returns(Net::HTTPGenericRequest) + end + def build_request(request, &blk) + end + end + + # @api private + sig { params(url: URI::Generic, deadline: Float, blk: T.proc.params(arg0: Net::HTTP).void).void } + private def with_pool(url, deadline:, &blk) + end + + # @api private + sig do + params(request: OpenAI::Transport::PooledNetRequester::RequestShape) + .returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + def execute(request) + end + + # @api private + sig { params(size: Integer).returns(T.attached_class) } + def self.new(size: Etc.nprocessors) + end + end + end +end diff --git a/rbi/lib/openai/type.rbi b/rbi/lib/openai/type.rbi new file mode 100644 index 00000000..a52a8d3b --- /dev/null +++ b/rbi/lib/openai/type.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module OpenAI + Unknown = OpenAI::Type::Unknown + + BooleanModel = OpenAI::Type::BooleanModel + + Enum = OpenAI::Type::Enum + + Union = OpenAI::Type::Union + + ArrayOf = OpenAI::Type::ArrayOf + + HashOf = OpenAI::Type::HashOf + + BaseModel = OpenAI::Type::BaseModel + + RequestParameters = OpenAI::Type::RequestParameters + + # This module contains various type declarations. + module Type + end +end diff --git a/rbi/lib/openai/type/array_of.rbi b/rbi/lib/openai/type/array_of.rbi new file mode 100644 index 00000000..2f6ace65 --- /dev/null +++ b/rbi/lib/openai/type/array_of.rbi @@ -0,0 +1,82 @@ +# typed: strong + +module OpenAI + module Type + # @api private + # + # Array of items of a given type. + class ArrayOf + include OpenAI::Type::Converter + + abstract! + final! + + Elem = type_member(:out) + + sig(:final) do + params( + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + # @api private + sig(:final) do + override + .params(value: T.any(T::Enumerable[Elem], T.anything), state: OpenAI::Type::Converter::State) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig(:final) do + override + .params(value: T.any(T::Enumerable[Elem], T.anything)) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def dump(value) + end + + # @api private + sig(:final) { returns(Elem) } + protected def item_type + end + + # @api private + sig(:final) { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig(:final) do + params( + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .void + end + def initialize(type_info, spec = {}) + end + end + end +end diff --git a/rbi/lib/openai/type/base_model.rbi b/rbi/lib/openai/type/base_model.rbi new file mode 100644 index 00000000..e379903e --- /dev/null +++ b/rbi/lib/openai/type/base_model.rbi @@ -0,0 +1,189 @@ +# typed: strong + +module OpenAI + module Type + class BaseModel + extend OpenAI::Type::Converter + + abstract! + + KnownFieldShape = T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean, nilable: T::Boolean} } + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + sig do + returns( + T::Hash[Symbol, + T.all( + OpenAI::BaseModel::KnownFieldShape, + {type_fn: T.proc.returns(OpenAI::Type::Converter::Input)} + )] + ) + end + def known_fields + end + + # @api private + sig do + returns( + T::Hash[Symbol, + T.all(OpenAI::BaseModel::KnownFieldShape, {type: OpenAI::Type::Converter::Input})] + ) + end + def fields + end + + # @api private + sig do + params( + name_sym: Symbol, + required: T::Boolean, + type_info: T.any( + { + const: T.nilable(T.any(NilClass, T::Boolean, Integer, Float, Symbol)), + enum: T.nilable(T.proc.returns(OpenAI::Type::Converter::Input)), + union: T.nilable(T.proc.returns(OpenAI::Type::Converter::Input)), + api_name: Symbol, + nil?: T::Boolean + }, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .void + end + private def add_field(name_sym, required:, type_info:, spec:) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .void + end + def required(name_sym, type_info, spec = {}) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .void + end + def optional(name_sym, type_info, spec = {}) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + sig { params(blk: T.proc.void).void } + private def request_only(&blk) + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + sig { params(blk: T.proc.void).void } + private def response_only(&blk) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + class << self + # @api private + sig do + override + .params( + value: T.any(OpenAI::BaseModel, T::Hash[T.anything, T.anything], T.anything), + state: OpenAI::Type::Converter::State + ) + .returns(T.any(T.attached_class, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params(value: T.any(T.attached_class, T.anything)) + .returns(T.any(T::Hash[T.anything, T.anything], T.anything)) + end + def dump(value) + end + end + + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + sig { params(key: Symbol).returns(T.nilable(T.anything)) } + def [](key) + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(OpenAI::Util::AnyHash) } + def to_h + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(OpenAI::Util::AnyHash) } + def to_hash + end + + sig { params(keys: T.nilable(T::Array[Symbol])).returns(OpenAI::Util::AnyHash) } + def deconstruct_keys(keys) + end + + # Create a new instance of a model. + sig { params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns(T.attached_class) } + def self.new(data = {}) + end + + sig { returns(String) } + def inspect + end + end + end +end diff --git a/rbi/lib/openai/type/base_page.rbi b/rbi/lib/openai/type/base_page.rbi new file mode 100644 index 00000000..03abe2c1 --- /dev/null +++ b/rbi/lib/openai/type/base_page.rbi @@ -0,0 +1,38 @@ +# typed: strong + +module OpenAI + module Type + module BasePage + Elem = type_member(:out) + + sig { overridable.returns(T::Boolean) } + def next_page? + end + + sig { overridable.returns(T.self_type) } + def next_page + end + + sig { overridable.params(blk: T.proc.params(arg0: Elem).void).void } + def auto_paging_each(&blk) + end + + sig { returns(T::Enumerable[Elem]) } + def to_enum + end + + # @api private + sig do + params( + client: OpenAI::Transport::BaseClient, + req: OpenAI::Transport::BaseClient::RequestComponentsShape, + headers: T.any(T::Hash[String, String], Net::HTTPHeader), + page_data: T.anything + ) + .void + end + def initialize(client:, req:, headers:, page_data:) + end + end + end +end diff --git a/rbi/lib/openai/type/base_stream.rbi b/rbi/lib/openai/type/base_stream.rbi new file mode 100644 index 00000000..8fa7098c --- /dev/null +++ b/rbi/lib/openai/type/base_stream.rbi @@ -0,0 +1,43 @@ +# typed: strong + +module OpenAI + module Type + module BaseStream + include Enumerable + + Message = type_member(:in) + Elem = type_member(:out) + + sig { void } + def close + end + + # @api private + sig { overridable.returns(T::Enumerable[Elem]) } + private def iterator + end + + sig { params(blk: T.proc.params(arg0: Elem).void).void } + def each(&blk) + end + + sig { returns(T::Enumerator[Elem]) } + def to_enum + end + + # @api private + sig do + params( + model: T.any(T::Class[T.anything], OpenAI::Type::Converter), + url: URI::Generic, + status: Integer, + response: Net::HTTPResponse, + stream: T::Enumerable[Message] + ) + .void + end + def initialize(model:, url:, status:, response:, stream:) + end + end + end +end diff --git a/rbi/lib/openai/type/boolean_model.rbi b/rbi/lib/openai/type/boolean_model.rbi new file mode 100644 index 00000000..96efcadd --- /dev/null +++ b/rbi/lib/openai/type/boolean_model.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module OpenAI + module Type + # @api private + # + # Ruby has no Boolean class; this is something for models to refer to. + class BooleanModel + extend OpenAI::Type::Converter + + abstract! + final! + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + sig(:final) do + override + .params(value: T.any(T::Boolean, T.anything), state: OpenAI::Type::Converter::State) + .returns(T.any(T::Boolean, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig(:final) do + override.params(value: T.any(T::Boolean, T.anything)).returns(T.any(T::Boolean, T.anything)) + end + def dump(value) + end + end + end + end +end diff --git a/rbi/lib/openai/type/converter.rbi b/rbi/lib/openai/type/converter.rbi new file mode 100644 index 00000000..979159e8 --- /dev/null +++ b/rbi/lib/openai/type/converter.rbi @@ -0,0 +1,99 @@ +# typed: strong + +module OpenAI + module Type + # @api private + module Converter + Input = T.type_alias { T.any(OpenAI::Type::Converter, T::Class[T.anything]) } + + State = + T.type_alias do + { + strictness: T.any(T::Boolean, Symbol), + exactness: {yes: Integer, no: Integer, maybe: Integer}, + branched: Integer + } + end + + # @api private + sig { overridable.params(value: T.anything, state: OpenAI::Type::Converter::State).returns(T.anything) } + def coerce(value, state:) + end + + # @api private + sig { overridable.params(value: T.anything).returns(T.anything) } + def dump(value) + end + + class << self + # @api private + sig do + params( + spec: T.any( + { + const: T.nilable(T.any(NilClass, T::Boolean, Integer, Float, Symbol)), + enum: T.nilable(T.proc.returns(OpenAI::Type::Converter::Input)), + union: T.nilable(T.proc.returns(OpenAI::Type::Converter::Input)) + }, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ) + ) + .returns(T.proc.returns(T.anything)) + end + def self.type_info(spec) + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + sig do + params( + target: OpenAI::Type::Converter::Input, + value: T.anything, + state: OpenAI::Type::Converter::State + ) + .returns(T.anything) + end + def self.coerce( + target, + value, + # The `strictness` is one of `true`, `false`, or `:strong`. This informs the + # coercion strategy when we have to decide between multiple possible conversion + # targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # - `:strong`: the conversion must be exact, with no coercion, and raise an error + # if not possible. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + state: {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + ) + end + + # @api private + sig { params(target: OpenAI::Type::Converter::Input, value: T.anything).returns(T.anything) } + def self.dump(target, value) + end + end + end + end +end diff --git a/rbi/lib/openai/type/enum.rbi b/rbi/lib/openai/type/enum.rbi new file mode 100644 index 00000000..7f6fdacd --- /dev/null +++ b/rbi/lib/openai/type/enum.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module OpenAI + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + module Enum + include OpenAI::Type::Converter + + # All of the valid Symbol values for this enum. + sig { overridable.returns(T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)]) } + def values + end + + # @api private + # + # Guard against thread safety issues by instantiating `@values`. + sig { void } + private def finalize! + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + sig do + override + .params(value: T.any(String, Symbol, T.anything), state: OpenAI::Type::Converter::State) + .returns(T.any(Symbol, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig { override.params(value: T.any(Symbol, T.anything)).returns(T.any(Symbol, T.anything)) } + def dump(value) + end + end + end +end diff --git a/rbi/lib/openai/type/hash_of.rbi b/rbi/lib/openai/type/hash_of.rbi new file mode 100644 index 00000000..66bd1160 --- /dev/null +++ b/rbi/lib/openai/type/hash_of.rbi @@ -0,0 +1,86 @@ +# typed: strong + +module OpenAI + module Type + # @api private + # + # Hash of items of a given type. + class HashOf + include OpenAI::Type::Converter + + abstract! + final! + + Elem = type_member(:out) + + sig(:final) do + params( + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + # @api private + sig(:final) do + override + .params(value: T.any( + T::Hash[T.anything, T.anything], + T.anything + ), + state: OpenAI::Type::Converter::State) + .returns(T.any(OpenAI::Util::AnyHash, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig(:final) do + override + .params(value: T.any(T::Hash[T.anything, T.anything], T.anything)) + .returns(T.any(OpenAI::Util::AnyHash, T.anything)) + end + def dump(value) + end + + # @api private + sig(:final) { returns(Elem) } + protected def item_type + end + + # @api private + sig(:final) { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig(:final) do + params( + type_info: T.any( + OpenAI::Util::AnyHash, + T.proc.returns(OpenAI::Type::Converter::Input), + OpenAI::Type::Converter::Input + ), + spec: OpenAI::Util::AnyHash + ) + .void + end + def initialize(type_info, spec = {}) + end + end + end +end diff --git a/rbi/lib/openai/type/request_parameters.rbi b/rbi/lib/openai/type/request_parameters.rbi new file mode 100644 index 00000000..3d5a7c0d --- /dev/null +++ b/rbi/lib/openai/type/request_parameters.rbi @@ -0,0 +1,20 @@ +# typed: strong + +module OpenAI + module Type + # @api private + module RequestParameters + # Options to specify HTTP behaviour for this request. + sig { returns(T.any(OpenAI::RequestOptions, OpenAI::Util::AnyHash)) } + attr_accessor :request_options + + # @api private + module Converter + # @api private + sig { params(params: T.anything).returns([T.anything, OpenAI::Util::AnyHash]) } + def dump_request(params) + end + end + end + end +end diff --git a/rbi/lib/openai/type/union.rbi b/rbi/lib/openai/type/union.rbi new file mode 100644 index 00000000..bfdbfa87 --- /dev/null +++ b/rbi/lib/openai/type/union.rbi @@ -0,0 +1,66 @@ +# typed: strong + +module OpenAI + module Type + # @api private + module Union + include OpenAI::Type::Converter + + # @api private + # + # All of the specified variant info for this union. + sig { returns(T::Array[[T.nilable(Symbol), T.proc.returns(OpenAI::Type::Converter::Input)]]) } + private def known_variants + end + + # @api private + sig { returns(T::Array[[T.nilable(Symbol), T.anything]]) } + protected def derefed_variants + end + + # All of the specified variants for this union. + sig { overridable.returns(T::Array[T.anything]) } + def variants + end + + # @api private + sig { params(property: Symbol).void } + private def discriminator(property) + end + + # @api private + sig do + params( + key: T.any(Symbol, OpenAI::Util::AnyHash, T.proc.returns(T.anything), T.anything), + spec: T.any(OpenAI::Util::AnyHash, T.proc.returns(T.anything), T.anything) + ) + .void + end + private def variant(key, spec = nil) + end + + # @api private + sig { params(value: T.anything).returns(T.nilable(T.anything)) } + private def resolve_variant(value) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + # @api private + sig { override.params(value: T.anything, state: OpenAI::Type::Converter::State).returns(T.anything) } + def coerce(value, state:) + end + + # @api private + sig { override.params(value: T.anything).returns(T.anything) } + def dump(value) + end + end + end +end diff --git a/rbi/lib/openai/type/unknown.rbi b/rbi/lib/openai/type/unknown.rbi new file mode 100644 index 00000000..1df209be --- /dev/null +++ b/rbi/lib/openai/type/unknown.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module OpenAI + module Type + # @api private + # + # When we don't know what to expect for the value. + class Unknown + extend OpenAI::Type::Converter + + abstract! + final! + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig(:final) { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + sig(:final) do + override.params(value: T.anything, state: OpenAI::Type::Converter::State).returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig(:final) { override.params(value: T.anything).returns(T.anything) } + def dump(value) + end + end + end + end +end diff --git a/rbi/lib/openai/util.rbi b/rbi/lib/openai/util.rbi index fe12b3ff..79ce090a 100644 --- a/rbi/lib/openai/util.rbi +++ b/rbi/lib/openai/util.rbi @@ -3,6 +3,10 @@ module OpenAI # @api private module Util + # Due to the current WIP status of Shapes support in Sorbet, types referencing + # this alias might be refined in the future. + AnyHash = T.type_alias { T::Hash[Symbol, T.anything] } + # @api private sig { returns(Float) } def self.monotonic_secs @@ -52,6 +56,11 @@ module OpenAI end end + # Use this to indicate that a value should be explicitly removed from a data + # structure when using `OpenAI::Util.deep_merge`. + # + # e.g. merging `{a: 1}` and `{a: OMIT}` should produce `{}`, where merging + # `{a: 1}` and `{}` would produce `{a: 1}`. OMIT = T.let(T.anything, T.anything) class << self @@ -80,7 +89,7 @@ module OpenAI # @api private sig do params( - data: T.any(T::Hash[Symbol, T.anything], T::Array[T.anything], T.anything), + data: T.any(OpenAI::Util::AnyHash, T::Array[T.anything], T.anything), pick: T.nilable(T.any(Symbol, Integer, T::Array[T.any(Symbol, Integer)])), sentinel: T.nilable(T.anything), blk: T.nilable(T.proc.returns(T.anything)) @@ -118,15 +127,16 @@ module OpenAI end end - ParsedUriShape = T.type_alias do - { - scheme: T.nilable(String), - host: T.nilable(String), - port: T.nilable(Integer), - path: T.nilable(String), - query: T::Hash[String, T::Array[String]] - } - end + ParsedUriShape = + T.type_alias do + { + scheme: T.nilable(String), + host: T.nilable(String), + port: T.nilable(Integer), + path: T.nilable(String), + query: T::Hash[String, T::Array[String]] + } + end class << self # @api private @@ -248,9 +258,10 @@ module OpenAI end end - ServerSentEvent = T.type_alias do - {event: T.nilable(String), data: T.nilable(String), id: T.nilable(String), retry: T.nilable(Integer)} - end + ServerSentEvent = + T.type_alias do + {event: T.nilable(String), data: T.nilable(String), id: T.nilable(String), retry: T.nilable(Integer)} + end class << self # @api private diff --git a/rbi/lib/openai/version.rbi b/rbi/lib/openai/version.rbi index 1f42bc59..5886c95b 100644 --- a/rbi/lib/openai/version.rbi +++ b/rbi/lib/openai/version.rbi @@ -1,5 +1,5 @@ # typed: strong module OpenAI - VERSION = "0.1.0-alpha.2" + VERSION = "0.1.0-alpha.3" end diff --git a/sig/openai/base_client.rbs b/sig/openai/base_client.rbs deleted file mode 100644 index 0c19b54e..00000000 --- a/sig/openai/base_client.rbs +++ /dev/null @@ -1,106 +0,0 @@ -module OpenAI - class BaseClient - type request_components = - { - method: Symbol, - path: String | ::Array[String], - query: ::Hash[String, (::Array[String] | String)?]?, - headers: ::Hash[String, (String - | Integer - | ::Array[(String | Integer)?])?]?, - body: top?, - unwrap: Symbol?, - page: Class?, - stream: Class?, - model: OpenAI::Converter::input?, - options: OpenAI::request_opts? - } - - type request_input = - { - method: Symbol, - url: URI::Generic, - headers: ::Hash[String, String], - body: top, - max_retries: Integer, - timeout: Float - } - - MAX_REDIRECTS: 20 - - PLATFORM_HEADERS: ::Hash[String, String] - - def self.validate!: (OpenAI::BaseClient::request_components req) -> void - - def self.should_retry?: ( - Integer status, - headers: ::Hash[String, String] - ) -> bool - - def self.follow_redirect: ( - OpenAI::BaseClient::request_input request, - status: Integer, - response_headers: ::Hash[String, String] - ) -> OpenAI::BaseClient::request_input - - def self.reap_connection!: ( - Integer | OpenAI::APIConnectionError status, - stream: Enumerable[String]? - ) -> void - - # @api private - attr_accessor requester: top - - def initialize: ( - base_url: String, - timeout: Float, - max_retries: Integer, - initial_retry_delay: Float, - max_retry_delay: Float, - headers: ::Hash[String, (String - | Integer - | ::Array[(String | Integer)?])?], - idempotency_header: String? - ) -> void - - private def auth_headers: -> ::Hash[String, String] - - private def generate_idempotency_key: -> String - - private def build_request: ( - OpenAI::BaseClient::request_components req, - OpenAI::request_options opts - ) -> OpenAI::BaseClient::request_input - - private def retry_delay: ( - ::Hash[String, String] headers, - retry_count: Integer - ) -> Float - - private def send_request: ( - OpenAI::BaseClient::request_input request, - redirect_count: Integer, - retry_count: Integer, - send_retry_header: bool - ) -> [Integer, top, Enumerable[String]] - - def request: - ( - Symbol method, - String | ::Array[String] path, - query: ::Hash[String, (::Array[String] | String)?]?, - headers: ::Hash[String, (String - | Integer - | ::Array[(String | Integer)?])?]?, - body: top?, - unwrap: Symbol?, - page: Class?, - stream: Class?, - model: OpenAI::Converter::input?, - options: OpenAI::request_opts? - ) -> top - | (OpenAI::BaseClient::request_components req) -> top - - def inspect: -> String - end -end diff --git a/sig/openai/base_model.rbs b/sig/openai/base_model.rbs deleted file mode 100644 index 574847b4..00000000 --- a/sig/openai/base_model.rbs +++ /dev/null @@ -1,244 +0,0 @@ -module OpenAI - module Converter - type input = OpenAI::Converter | Class - - def coerce: (top value) -> top - - def dump: (top value) -> top - - def try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - - def self.type_info: ( - { - const: (nil | bool | Integer | Float | Symbol)?, - enum: ^-> OpenAI::Converter::input?, - union: ^-> OpenAI::Converter::input? - } - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input spec - ) -> (^-> top) - - def self.coerce: (OpenAI::Converter::input target, top value) -> top - - def self.dump: (OpenAI::Converter::input target, top value) -> top - - def self.try_strict_coerce: ( - OpenAI::Converter::input target, - top value - ) -> top - end - - class Unknown - extend OpenAI::Converter - - def self.===: (top other) -> bool - - def self.==: (top other) -> bool - - def self.coerce: (top value) -> top - - def self.dump: (top value) -> top - - def self.try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - end - - class BooleanModel - extend OpenAI::Converter - - def self.===: (top other) -> bool - - def self.==: (top other) -> bool - - def self.coerce: (bool | top value) -> (bool | top) - - def self.dump: (bool | top value) -> (bool | top) - - def self.try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - end - - class Enum - extend OpenAI::Converter - - def self.values: -> ::Array[(nil | bool | Integer | Float | Symbol)] - - private def self.finalize!: -> void - - def self.===: (top other) -> bool - - def self.==: (top other) -> bool - - def self.coerce: (String | Symbol | top value) -> (Symbol | top) - - def self.dump: (Symbol | top value) -> (Symbol | top) - - def self.try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - end - - class Union - extend OpenAI::Converter - - private def self.known_variants: -> ::Array[[Symbol?, (^-> OpenAI::Converter::input)]] - - def self.derefed_variants: -> ::Array[[Symbol?, top]] - - def self.variants: -> ::Array[top] - - private def self.discriminator: (Symbol property) -> void - - private def self.variant: ( - Symbol - | ::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input key, - ?::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input spec - ) -> void - - private def self.resolve_variant: (top value) -> OpenAI::Converter::input? - - def self.===: (top other) -> bool - - def self.==: (top other) -> bool - - def self.coerce: (top value) -> top - - def self.dump: (top value) -> top - - def self.try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - end - - class ArrayOf[Elem] - include OpenAI::Converter - - def ===: (top other) -> bool - - def ==: (top other) -> bool - - def coerce: (Enumerable[top] | top value) -> (::Array[top] | top) - - def dump: (Enumerable[top] | top value) -> (::Array[top] | top) - - def try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - - def item_type: -> Elem - - def initialize: ( - ::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input type_info, - ?::Hash[Symbol, top] spec - ) -> void - end - - class HashOf[Elem] - include OpenAI::Converter - - def ===: (top other) -> bool - - def ==: (top other) -> bool - - def coerce: (::Hash[top, top] | top value) -> (::Hash[Symbol, top] | top) - - def dump: (::Hash[top, top] | top value) -> (::Hash[Symbol, top] | top) - - def try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - - def item_type: -> Elem - - def initialize: ( - ::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input type_info, - ?::Hash[Symbol, top] spec - ) -> void - end - - class BaseModel - extend OpenAI::Converter - - type known_field = { mode: (:coerce | :dump)?, required: bool } - - def self.known_fields: -> ::Hash[Symbol, (OpenAI::BaseModel::known_field - & { type_fn: (^-> OpenAI::Converter::input) })] - - def self.fields: -> ::Hash[Symbol, (OpenAI::BaseModel::known_field - & { type: OpenAI::Converter::input })] - - def self.defaults: -> ::Hash[Symbol, (^-> Class)] - - private def self.add_field: ( - Symbol name_sym, - required: bool, - type_info: { - const: (nil | bool | Integer | Float | Symbol)?, - enum: ^-> OpenAI::Converter::input?, - union: ^-> OpenAI::Converter::input?, - api_name: Symbol - } - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input, - spec: ::Hash[Symbol, top] - ) -> void - - def self.required: ( - Symbol name_sym, - ::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input type_info, - ?::Hash[Symbol, top] spec - ) -> void - - def self.optional: ( - Symbol name_sym, - ::Hash[Symbol, top] - | ^-> OpenAI::Converter::input - | OpenAI::Converter::input type_info, - ?::Hash[Symbol, top] spec - ) -> void - - private def self.request_only: { -> void } -> void - - private def self.response_only: { -> void } -> void - - def ==: (top other) -> bool - - def self.coerce: ( - OpenAI::BaseModel | ::Hash[top, top] | top value - ) -> (instance | top) - - def self.dump: (instance | top value) -> (::Hash[top, top] | top) - - def self.try_strict_coerce: ( - top value - ) -> ([true, top, nil] | [false, bool, Integer]) - - def []: (Symbol key) -> top? - - def to_h: -> ::Hash[Symbol, top] - - alias to_hash to_h - - def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top] - - def initialize: (?::Hash[Symbol, top] | self data) -> void - - def to_s: -> String - - def inspect: -> String - end -end diff --git a/sig/openai/base_page.rbs b/sig/openai/base_page.rbs deleted file mode 100644 index 384b9d9b..00000000 --- a/sig/openai/base_page.rbs +++ /dev/null @@ -1,20 +0,0 @@ -module OpenAI - module BasePage[Elem] - def next_page?: -> bool - - def next_page: -> self - - def auto_paging_each: { (Elem arg0) -> void } -> void - - def to_enum: -> Enumerable[Elem] - - alias enum_for to_enum - - def initialize: ( - client: OpenAI::BaseClient, - req: OpenAI::BaseClient::request_components, - headers: ::Hash[String, String], - page_data: top - ) -> void - end -end diff --git a/sig/openai/base_stream.rbs b/sig/openai/base_stream.rbs deleted file mode 100644 index e5d9ec89..00000000 --- a/sig/openai/base_stream.rbs +++ /dev/null @@ -1,21 +0,0 @@ -module OpenAI - module BaseStream[Message, Elem] - def close: -> void - - private def iterator: -> Enumerable[Elem] - - def for_each: { (Elem arg0) -> void } -> void - - def to_enum: -> Enumerable[Elem] - - alias enum_for to_enum - - def initialize: ( - model: Class | OpenAI::Converter, - url: URI::Generic, - status: Integer, - response: top, - messages: Enumerable[Message] - ) -> void - end -end diff --git a/sig/openai/client.rbs b/sig/openai/client.rbs index 2d7d9a11..a7a4533d 100644 --- a/sig/openai/client.rbs +++ b/sig/openai/client.rbs @@ -1,5 +1,5 @@ module OpenAI - class Client < OpenAI::BaseClient + class Client < OpenAI::Transport::BaseClient DEFAULT_MAX_RETRIES: 2 DEFAULT_TIMEOUT_IN_SECONDS: Float @@ -45,14 +45,14 @@ module OpenAI private def auth_headers: -> ::Hash[String, String] def initialize: ( - base_url: String?, - api_key: String?, - organization: String?, - project: String?, - max_retries: Integer, - timeout: Float, - initial_retry_delay: Float, - max_retry_delay: Float + ?base_url: String?, + ?api_key: String?, + ?organization: String?, + ?project: String?, + ?max_retries: Integer, + ?timeout: Float, + ?initial_retry_delay: Float, + ?max_retry_delay: Float ) -> void end end diff --git a/sig/openai/cursor_page.rbs b/sig/openai/cursor_page.rbs index 5aa7c659..3b8ed120 100644 --- a/sig/openai/cursor_page.rbs +++ b/sig/openai/cursor_page.rbs @@ -1,9 +1,11 @@ module OpenAI class CursorPage[Elem] - include OpenAI::BasePage[Elem] + include OpenAI::Type::BasePage[Elem] attr_accessor data: ::Array[Elem]? attr_accessor has_more: bool + + def inspect: -> String end end diff --git a/sig/openai/errors.rbs b/sig/openai/errors.rbs index b5c00826..6d5804f3 100644 --- a/sig/openai/errors.rbs +++ b/sig/openai/errors.rbs @@ -21,33 +21,33 @@ module OpenAI def initialize: ( url: URI::Generic, - status: Integer?, - body: Object?, - request: nil, - response: nil, - message: String? + ?status: Integer?, + ?body: Object?, + ?request: nil, + ?response: nil, + ?message: String? ) -> void end class APIConnectionError < OpenAI::APIError def initialize: ( url: URI::Generic, - status: nil, - body: nil, - request: nil, - response: nil, - message: String? + ?status: nil, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? ) -> void end class APITimeoutError < OpenAI::APIConnectionError def initialize: ( url: URI::Generic, - status: nil, - body: nil, - request: nil, - response: nil, - message: String? + ?status: nil, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? ) -> void end @@ -58,7 +58,7 @@ module OpenAI body: Object?, request: nil, response: nil, - message: String? + ?message: String? ) -> instance def initialize: ( @@ -67,7 +67,7 @@ module OpenAI body: Object?, request: nil, response: nil, - message: String? + ?message: String? ) -> void end diff --git a/sig/openai/extern.rbs b/sig/openai/extern.rbs deleted file mode 100644 index 23069f69..00000000 --- a/sig/openai/extern.rbs +++ /dev/null @@ -1,4 +0,0 @@ -module OpenAI - module Extern - end -end diff --git a/sig/openai/models/all_models.rbs b/sig/openai/models/all_models.rbs new file mode 100644 index 00000000..77c8f9b8 --- /dev/null +++ b/sig/openai/models/all_models.rbs @@ -0,0 +1,25 @@ +module OpenAI + module Models + type all_models = + String + | OpenAI::Models::chat_model + | :"o1-pro" + | :"o1-pro-2025-03-19" + | :"computer-use-preview" + | :"computer-use-preview-2025-03-11" + + module AllModels + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model, (:"o1-pro" + | :"o1-pro-2025-03-19" + | :"computer-use-preview" + | :"computer-use-preview-2025-03-11")] + + O1_PRO: :"o1-pro" + O1_PRO_2025_03_19: :"o1-pro-2025-03-19" + COMPUTER_USE_PREVIEW: :"computer-use-preview" + COMPUTER_USE_PREVIEW_2025_03_11: :"computer-use-preview-2025-03-11" + end + end +end diff --git a/sig/openai/models/audio/speech_create_params.rbs b/sig/openai/models/audio/speech_create_params.rbs index c1e0ec60..06dd0109 100644 --- a/sig/openai/models/audio/speech_create_params.rbs +++ b/sig/openai/models/audio/speech_create_params.rbs @@ -6,13 +6,14 @@ module OpenAI input: String, model: OpenAI::Models::Audio::SpeechCreateParams::model, voice: OpenAI::Models::Audio::SpeechCreateParams::voice, + instructions: String, response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format, speed: Float } & OpenAI::request_parameters class SpeechCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor input: String @@ -21,6 +22,10 @@ module OpenAI attr_accessor voice: OpenAI::Models::Audio::SpeechCreateParams::voice + attr_reader instructions: String? + + def instructions=: (String) -> String + attr_reader response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format? def response_format=: ( @@ -31,31 +36,46 @@ module OpenAI def speed=: (Float) -> Float - def initialize: - ( - input: String, - model: OpenAI::Models::Audio::SpeechCreateParams::model, - voice: OpenAI::Models::Audio::SpeechCreateParams::voice, - response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format, - speed: Float, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Audio::speech_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + input: String, + model: OpenAI::Models::Audio::SpeechCreateParams::model, + voice: OpenAI::Models::Audio::SpeechCreateParams::voice, + ?instructions: String, + ?response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format, + ?speed: Float, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Audio::speech_create_params type model = String | OpenAI::Models::Audio::speech_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::Audio::speech_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::Audio::speech_model] end type voice = - :alloy + String + | :alloy + | :ash + | :ballad + | :coral + | :echo + | :fable + | :onyx + | :nova + | :sage + | :shimmer + | :verse + + module Voice + extend OpenAI::Union + + def self?.variants: -> [String, (:alloy | :ash + | :ballad | :coral | :echo | :fable @@ -63,10 +83,11 @@ module OpenAI | :nova | :sage | :shimmer + | :verse)] - class Voice < OpenAI::Enum ALLOY: :alloy ASH: :ash + BALLAD: :ballad CORAL: :coral ECHO: :echo FABLE: :fable @@ -74,13 +95,14 @@ module OpenAI NOVA: :nova SAGE: :sage SHIMMER: :shimmer - - def self.values: -> ::Array[OpenAI::Models::Audio::SpeechCreateParams::voice] + VERSE: :verse end type response_format = :mp3 | :opus | :aac | :flac | :wav | :pcm - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + MP3: :mp3 OPUS: :opus AAC: :aac @@ -88,7 +110,7 @@ module OpenAI WAV: :wav PCM: :pcm - def self.values: -> ::Array[OpenAI::Models::Audio::SpeechCreateParams::response_format] + def self?.values: -> ::Array[OpenAI::Models::Audio::SpeechCreateParams::response_format] end end end diff --git a/sig/openai/models/audio/speech_model.rbs b/sig/openai/models/audio/speech_model.rbs index 7ab47f1f..8fc430d6 100644 --- a/sig/openai/models/audio/speech_model.rbs +++ b/sig/openai/models/audio/speech_model.rbs @@ -1,13 +1,16 @@ module OpenAI module Models module Audio - type speech_model = :"tts-1" | :"tts-1-hd" + type speech_model = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" + + module SpeechModel + extend OpenAI::Enum - class SpeechModel < OpenAI::Enum TTS_1: :"tts-1" TTS_1_HD: :"tts-1-hd" + GPT_4O_MINI_TTS: :"gpt-4o-mini-tts" - def self.values: -> ::Array[OpenAI::Models::Audio::speech_model] + def self?.values: -> ::Array[OpenAI::Models::Audio::speech_model] end end end diff --git a/sig/openai/models/audio/transcription.rbs b/sig/openai/models/audio/transcription.rbs index 6f7b7c9f..3f9bf1d4 100644 --- a/sig/openai/models/audio/transcription.rbs +++ b/sig/openai/models/audio/transcription.rbs @@ -1,18 +1,51 @@ module OpenAI module Models module Audio - type transcription = { text: String } + type transcription = + { + text: String, + logprobs: ::Array[OpenAI::Models::Audio::Transcription::Logprob] + } class Transcription < OpenAI::BaseModel attr_accessor text: String - def initialize: - (text: String) -> void - | ( - ?OpenAI::Models::Audio::transcription | OpenAI::BaseModel data - ) -> void + attr_reader logprobs: ::Array[OpenAI::Models::Audio::Transcription::Logprob]? + + def logprobs=: ( + ::Array[OpenAI::Models::Audio::Transcription::Logprob] + ) -> ::Array[OpenAI::Models::Audio::Transcription::Logprob] + + def initialize: ( + text: String, + ?logprobs: ::Array[OpenAI::Models::Audio::Transcription::Logprob] + ) -> void def to_hash: -> OpenAI::Models::Audio::transcription + + type logprob = { token: String, bytes: ::Array[Float], logprob: Float } + + class Logprob < OpenAI::BaseModel + attr_reader token: String? + + def token=: (String) -> String + + attr_reader bytes: ::Array[Float]? + + def bytes=: (::Array[Float]) -> ::Array[Float] + + attr_reader logprob: Float? + + def logprob=: (Float) -> Float + + def initialize: ( + ?token: String, + ?bytes: ::Array[Float], + ?logprob: Float + ) -> void + + def to_hash: -> OpenAI::Models::Audio::Transcription::logprob + end end end end diff --git a/sig/openai/models/audio/transcription_create_params.rbs b/sig/openai/models/audio/transcription_create_params.rbs index 22080806..5abf1747 100644 --- a/sig/openai/models/audio/transcription_create_params.rbs +++ b/sig/openai/models/audio/transcription_create_params.rbs @@ -5,6 +5,7 @@ module OpenAI { file: (IO | StringIO), model: OpenAI::Models::Audio::TranscriptionCreateParams::model, + include: ::Array[OpenAI::Models::Audio::transcription_include], language: String, prompt: String, response_format: OpenAI::Models::audio_response_format, @@ -14,13 +15,19 @@ module OpenAI & OpenAI::request_parameters class TranscriptionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor file: IO | StringIO attr_accessor model: OpenAI::Models::Audio::TranscriptionCreateParams::model + attr_reader include: ::Array[OpenAI::Models::Audio::transcription_include]? + + def include=: ( + ::Array[OpenAI::Models::Audio::transcription_include] + ) -> ::Array[OpenAI::Models::Audio::transcription_include] + attr_reader language: String? def language=: (String) -> String @@ -45,37 +52,37 @@ module OpenAI ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity] ) -> ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity] - def initialize: - ( - file: IO | StringIO, - model: OpenAI::Models::Audio::TranscriptionCreateParams::model, - language: String, - prompt: String, - response_format: OpenAI::Models::audio_response_format, - temperature: Float, - timestamp_granularities: ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity], - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Audio::transcription_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file: IO | StringIO, + model: OpenAI::Models::Audio::TranscriptionCreateParams::model, + ?include: ::Array[OpenAI::Models::Audio::transcription_include], + ?language: String, + ?prompt: String, + ?response_format: OpenAI::Models::audio_response_format, + ?temperature: Float, + ?timestamp_granularities: ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity], + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Audio::transcription_create_params type model = String | OpenAI::Models::audio_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::audio_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::audio_model] end type timestamp_granularity = :word | :segment - class TimestampGranularity < OpenAI::Enum + module TimestampGranularity + extend OpenAI::Enum + WORD: :word SEGMENT: :segment - def self.values: -> ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity] + def self?.values: -> ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity] end end end diff --git a/sig/openai/models/audio/transcription_create_response.rbs b/sig/openai/models/audio/transcription_create_response.rbs index f0179c81..49eb0f09 100644 --- a/sig/openai/models/audio/transcription_create_response.rbs +++ b/sig/openai/models/audio/transcription_create_response.rbs @@ -5,8 +5,10 @@ module OpenAI OpenAI::Models::Audio::Transcription | OpenAI::Models::Audio::TranscriptionVerbose - class TranscriptionCreateResponse < OpenAI::Union - def self.variants: -> [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose] + module TranscriptionCreateResponse + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose] end end end diff --git a/sig/openai/models/audio/transcription_include.rbs b/sig/openai/models/audio/transcription_include.rbs new file mode 100644 index 00000000..349684b6 --- /dev/null +++ b/sig/openai/models/audio/transcription_include.rbs @@ -0,0 +1,15 @@ +module OpenAI + module Models + module Audio + type transcription_include = :logprobs + + module TranscriptionInclude + extend OpenAI::Enum + + LOGPROBS: :logprobs + + def self?.values: -> ::Array[OpenAI::Models::Audio::transcription_include] + end + end + end +end diff --git a/sig/openai/models/audio/transcription_segment.rbs b/sig/openai/models/audio/transcription_segment.rbs index a721f545..85af1669 100644 --- a/sig/openai/models/audio/transcription_segment.rbs +++ b/sig/openai/models/audio/transcription_segment.rbs @@ -36,23 +36,18 @@ module OpenAI attr_accessor tokens: ::Array[Integer] - def initialize: - ( - id: Integer, - avg_logprob: Float, - compression_ratio: Float, - end_: Float, - no_speech_prob: Float, - seek: Integer, - start: Float, - temperature: Float, - text: String, - tokens: ::Array[Integer] - ) -> void - | ( - ?OpenAI::Models::Audio::transcription_segment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: Integer, + avg_logprob: Float, + compression_ratio: Float, + end_: Float, + no_speech_prob: Float, + seek: Integer, + start: Float, + temperature: Float, + text: String, + tokens: ::Array[Integer] + ) -> void def to_hash: -> OpenAI::Models::Audio::transcription_segment end diff --git a/sig/openai/models/audio/transcription_stream_event.rbs b/sig/openai/models/audio/transcription_stream_event.rbs new file mode 100644 index 00000000..8441d201 --- /dev/null +++ b/sig/openai/models/audio/transcription_stream_event.rbs @@ -0,0 +1,15 @@ +module OpenAI + module Models + module Audio + type transcription_stream_event = + OpenAI::Models::Audio::TranscriptionTextDeltaEvent + | OpenAI::Models::Audio::TranscriptionTextDoneEvent + + module TranscriptionStreamEvent + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent] + end + end + end +end diff --git a/sig/openai/models/audio/transcription_text_delta_event.rbs b/sig/openai/models/audio/transcription_text_delta_event.rbs new file mode 100644 index 00000000..373c6aed --- /dev/null +++ b/sig/openai/models/audio/transcription_text_delta_event.rbs @@ -0,0 +1,56 @@ +module OpenAI + module Models + module Audio + type transcription_text_delta_event = + { + delta: String, + type: :"transcript.text.delta", + logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob] + } + + class TranscriptionTextDeltaEvent < OpenAI::BaseModel + attr_accessor delta: String + + attr_accessor type: :"transcript.text.delta" + + attr_reader logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob]? + + def logprobs=: ( + ::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob] + ) -> ::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob] + + def initialize: ( + delta: String, + ?logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob], + ?type: :"transcript.text.delta" + ) -> void + + def to_hash: -> OpenAI::Models::Audio::transcription_text_delta_event + + type logprob = { token: String, bytes: ::Array[top], logprob: Float } + + class Logprob < OpenAI::BaseModel + attr_reader token: String? + + def token=: (String) -> String + + attr_reader bytes: ::Array[top]? + + def bytes=: (::Array[top]) -> ::Array[top] + + attr_reader logprob: Float? + + def logprob=: (Float) -> Float + + def initialize: ( + ?token: String, + ?bytes: ::Array[top], + ?logprob: Float + ) -> void + + def to_hash: -> OpenAI::Models::Audio::TranscriptionTextDeltaEvent::logprob + end + end + end + end +end diff --git a/sig/openai/models/audio/transcription_text_done_event.rbs b/sig/openai/models/audio/transcription_text_done_event.rbs new file mode 100644 index 00000000..f1f1dd1d --- /dev/null +++ b/sig/openai/models/audio/transcription_text_done_event.rbs @@ -0,0 +1,56 @@ +module OpenAI + module Models + module Audio + type transcription_text_done_event = + { + text: String, + type: :"transcript.text.done", + logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob] + } + + class TranscriptionTextDoneEvent < OpenAI::BaseModel + attr_accessor text: String + + attr_accessor type: :"transcript.text.done" + + attr_reader logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob]? + + def logprobs=: ( + ::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob] + ) -> ::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob] + + def initialize: ( + text: String, + ?logprobs: ::Array[OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob], + ?type: :"transcript.text.done" + ) -> void + + def to_hash: -> OpenAI::Models::Audio::transcription_text_done_event + + type logprob = { token: String, bytes: ::Array[top], logprob: Float } + + class Logprob < OpenAI::BaseModel + attr_reader token: String? + + def token=: (String) -> String + + attr_reader bytes: ::Array[top]? + + def bytes=: (::Array[top]) -> ::Array[top] + + attr_reader logprob: Float? + + def logprob=: (Float) -> Float + + def initialize: ( + ?token: String, + ?bytes: ::Array[top], + ?logprob: Float + ) -> void + + def to_hash: -> OpenAI::Models::Audio::TranscriptionTextDoneEvent::logprob + end + end + end + end +end diff --git a/sig/openai/models/audio/transcription_verbose.rbs b/sig/openai/models/audio/transcription_verbose.rbs index 268831d6..9546e704 100644 --- a/sig/openai/models/audio/transcription_verbose.rbs +++ b/sig/openai/models/audio/transcription_verbose.rbs @@ -29,18 +29,13 @@ module OpenAI ::Array[OpenAI::Models::Audio::TranscriptionWord] ) -> ::Array[OpenAI::Models::Audio::TranscriptionWord] - def initialize: - ( - duration: Float, - language: String, - text: String, - segments: ::Array[OpenAI::Models::Audio::TranscriptionSegment], - words: ::Array[OpenAI::Models::Audio::TranscriptionWord] - ) -> void - | ( - ?OpenAI::Models::Audio::transcription_verbose - | OpenAI::BaseModel data - ) -> void + def initialize: ( + duration: Float, + language: String, + text: String, + ?segments: ::Array[OpenAI::Models::Audio::TranscriptionSegment], + ?words: ::Array[OpenAI::Models::Audio::TranscriptionWord] + ) -> void def to_hash: -> OpenAI::Models::Audio::transcription_verbose end diff --git a/sig/openai/models/audio/transcription_word.rbs b/sig/openai/models/audio/transcription_word.rbs index 17a2ca32..5b9eee66 100644 --- a/sig/openai/models/audio/transcription_word.rbs +++ b/sig/openai/models/audio/transcription_word.rbs @@ -10,11 +10,7 @@ module OpenAI attr_accessor word: String - def initialize: - (end_: Float, start: Float, word: String) -> void - | ( - ?OpenAI::Models::Audio::transcription_word | OpenAI::BaseModel data - ) -> void + def initialize: (end_: Float, start: Float, word: String) -> void def to_hash: -> OpenAI::Models::Audio::transcription_word end diff --git a/sig/openai/models/audio/translation.rbs b/sig/openai/models/audio/translation.rbs index e16987a3..4a88fe3f 100644 --- a/sig/openai/models/audio/translation.rbs +++ b/sig/openai/models/audio/translation.rbs @@ -6,11 +6,7 @@ module OpenAI class Translation < OpenAI::BaseModel attr_accessor text: String - def initialize: - (text: String) -> void - | ( - ?OpenAI::Models::Audio::translation | OpenAI::BaseModel data - ) -> void + def initialize: (text: String) -> void def to_hash: -> OpenAI::Models::Audio::translation end diff --git a/sig/openai/models/audio/translation_create_params.rbs b/sig/openai/models/audio/translation_create_params.rbs index 916641d5..3be91750 100644 --- a/sig/openai/models/audio/translation_create_params.rbs +++ b/sig/openai/models/audio/translation_create_params.rbs @@ -6,13 +6,13 @@ module OpenAI file: (IO | StringIO), model: OpenAI::Models::Audio::TranslationCreateParams::model, prompt: String, - response_format: OpenAI::Models::audio_response_format, + response_format: OpenAI::Models::Audio::TranslationCreateParams::response_format, temperature: Float } & OpenAI::request_parameters class TranslationCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor file: IO | StringIO @@ -23,36 +23,47 @@ module OpenAI def prompt=: (String) -> String - attr_reader response_format: OpenAI::Models::audio_response_format? + attr_reader response_format: OpenAI::Models::Audio::TranslationCreateParams::response_format? def response_format=: ( - OpenAI::Models::audio_response_format - ) -> OpenAI::Models::audio_response_format + OpenAI::Models::Audio::TranslationCreateParams::response_format + ) -> OpenAI::Models::Audio::TranslationCreateParams::response_format attr_reader temperature: Float? def temperature=: (Float) -> Float - def initialize: - ( - file: IO | StringIO, - model: OpenAI::Models::Audio::TranslationCreateParams::model, - prompt: String, - response_format: OpenAI::Models::audio_response_format, - temperature: Float, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Audio::translation_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file: IO | StringIO, + model: OpenAI::Models::Audio::TranslationCreateParams::model, + ?prompt: String, + ?response_format: OpenAI::Models::Audio::TranslationCreateParams::response_format, + ?temperature: Float, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Audio::translation_create_params type model = String | OpenAI::Models::audio_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::audio_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::audio_model] + end + + type response_format = :json | :text | :srt | :verbose_json | :vtt + + module ResponseFormat + extend OpenAI::Enum + + JSON: :json + TEXT: :text + SRT: :srt + VERBOSE_JSON: :verbose_json + VTT: :vtt + + def self?.values: -> ::Array[OpenAI::Models::Audio::TranslationCreateParams::response_format] end end end diff --git a/sig/openai/models/audio/translation_create_response.rbs b/sig/openai/models/audio/translation_create_response.rbs index d80690b9..7b88f273 100644 --- a/sig/openai/models/audio/translation_create_response.rbs +++ b/sig/openai/models/audio/translation_create_response.rbs @@ -5,8 +5,10 @@ module OpenAI OpenAI::Models::Audio::Translation | OpenAI::Models::Audio::TranslationVerbose - class TranslationCreateResponse < OpenAI::Union - def self.variants: -> [OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose] + module TranslationCreateResponse + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose] end end end diff --git a/sig/openai/models/audio/translation_verbose.rbs b/sig/openai/models/audio/translation_verbose.rbs index 0b2aeae7..0a805f53 100644 --- a/sig/openai/models/audio/translation_verbose.rbs +++ b/sig/openai/models/audio/translation_verbose.rbs @@ -22,16 +22,12 @@ module OpenAI ::Array[OpenAI::Models::Audio::TranscriptionSegment] ) -> ::Array[OpenAI::Models::Audio::TranscriptionSegment] - def initialize: - ( - duration: Float, - language: String, - text: String, - segments: ::Array[OpenAI::Models::Audio::TranscriptionSegment] - ) -> void - | ( - ?OpenAI::Models::Audio::translation_verbose | OpenAI::BaseModel data - ) -> void + def initialize: ( + duration: Float, + language: String, + text: String, + ?segments: ::Array[OpenAI::Models::Audio::TranscriptionSegment] + ) -> void def to_hash: -> OpenAI::Models::Audio::translation_verbose end diff --git a/sig/openai/models/audio_model.rbs b/sig/openai/models/audio_model.rbs index f9841d31..c5a9d284 100644 --- a/sig/openai/models/audio_model.rbs +++ b/sig/openai/models/audio_model.rbs @@ -1,11 +1,16 @@ module OpenAI module Models - type audio_model = :"whisper-1" + type audio_model = + :"whisper-1" | :"gpt-4o-transcribe" | :"gpt-4o-mini-transcribe" + + module AudioModel + extend OpenAI::Enum - class AudioModel < OpenAI::Enum WHISPER_1: :"whisper-1" + GPT_4O_TRANSCRIBE: :"gpt-4o-transcribe" + GPT_4O_MINI_TRANSCRIBE: :"gpt-4o-mini-transcribe" - def self.values: -> ::Array[OpenAI::Models::audio_model] + def self?.values: -> ::Array[OpenAI::Models::audio_model] end end end diff --git a/sig/openai/models/audio_response_format.rbs b/sig/openai/models/audio_response_format.rbs index e91a52b8..7c91cd99 100644 --- a/sig/openai/models/audio_response_format.rbs +++ b/sig/openai/models/audio_response_format.rbs @@ -2,14 +2,16 @@ module OpenAI module Models type audio_response_format = :json | :text | :srt | :verbose_json | :vtt - class AudioResponseFormat < OpenAI::Enum + module AudioResponseFormat + extend OpenAI::Enum + JSON: :json TEXT: :text SRT: :srt VERBOSE_JSON: :verbose_json VTT: :vtt - def self.values: -> ::Array[OpenAI::Models::audio_response_format] + def self?.values: -> ::Array[OpenAI::Models::audio_response_format] end end end diff --git a/sig/openai/models/auto_file_chunking_strategy_param.rbs b/sig/openai/models/auto_file_chunking_strategy_param.rbs index 85817088..49630c41 100644 --- a/sig/openai/models/auto_file_chunking_strategy_param.rbs +++ b/sig/openai/models/auto_file_chunking_strategy_param.rbs @@ -5,12 +5,7 @@ module OpenAI class AutoFileChunkingStrategyParam < OpenAI::BaseModel attr_accessor type: :auto - def initialize: - (type: :auto) -> void - | ( - ?OpenAI::Models::auto_file_chunking_strategy_param - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :auto) -> void def to_hash: -> OpenAI::Models::auto_file_chunking_strategy_param end diff --git a/sig/openai/models/batch.rbs b/sig/openai/models/batch.rbs index 97e29c54..46840a64 100644 --- a/sig/openai/models/batch.rbs +++ b/sig/openai/models/batch.rbs @@ -93,30 +93,28 @@ module OpenAI OpenAI::Models::BatchRequestCounts ) -> OpenAI::Models::BatchRequestCounts - def initialize: - ( - id: String, - completion_window: String, - created_at: Integer, - endpoint: String, - input_file_id: String, - status: OpenAI::Models::Batch::status, - cancelled_at: Integer, - cancelling_at: Integer, - completed_at: Integer, - error_file_id: String, - errors: OpenAI::Models::Batch::Errors, - expired_at: Integer, - expires_at: Integer, - failed_at: Integer, - finalizing_at: Integer, - in_progress_at: Integer, - metadata: OpenAI::Models::metadata?, - output_file_id: String, - request_counts: OpenAI::Models::BatchRequestCounts, - object: :batch - ) -> void - | (?OpenAI::Models::batch | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + completion_window: String, + created_at: Integer, + endpoint: String, + input_file_id: String, + status: OpenAI::Models::Batch::status, + ?cancelled_at: Integer, + ?cancelling_at: Integer, + ?completed_at: Integer, + ?error_file_id: String, + ?errors: OpenAI::Models::Batch::Errors, + ?expired_at: Integer, + ?expires_at: Integer, + ?failed_at: Integer, + ?finalizing_at: Integer, + ?in_progress_at: Integer, + ?metadata: OpenAI::Models::metadata?, + ?output_file_id: String, + ?request_counts: OpenAI::Models::BatchRequestCounts, + ?object: :batch + ) -> void def to_hash: -> OpenAI::Models::batch @@ -130,7 +128,9 @@ module OpenAI | :cancelling | :cancelled - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + VALIDATING: :validating FAILED: :failed IN_PROGRESS: :in_progress @@ -140,7 +140,7 @@ module OpenAI CANCELLING: :cancelling CANCELLED: :cancelled - def self.values: -> ::Array[OpenAI::Models::Batch::status] + def self?.values: -> ::Array[OpenAI::Models::Batch::status] end type errors = @@ -157,9 +157,10 @@ module OpenAI def object=: (String) -> String - def initialize: - (data: ::Array[OpenAI::Models::BatchError], object: String) -> void - | (?OpenAI::Models::Batch::errors | OpenAI::BaseModel data) -> void + def initialize: ( + ?data: ::Array[OpenAI::Models::BatchError], + ?object: String + ) -> void def to_hash: -> OpenAI::Models::Batch::errors end diff --git a/sig/openai/models/batch_cancel_params.rbs b/sig/openai/models/batch_cancel_params.rbs index 793ea0a9..887d319a 100644 --- a/sig/openai/models/batch_cancel_params.rbs +++ b/sig/openai/models/batch_cancel_params.rbs @@ -3,14 +3,10 @@ module OpenAI type batch_cancel_params = { } & OpenAI::request_parameters class BatchCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::batch_cancel_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::batch_cancel_params end diff --git a/sig/openai/models/batch_create_params.rbs b/sig/openai/models/batch_create_params.rbs index 2f317b07..a660d80f 100644 --- a/sig/openai/models/batch_create_params.rbs +++ b/sig/openai/models/batch_create_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class BatchCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor completion_window: OpenAI::Models::BatchCreateParams::completion_window @@ -21,37 +21,41 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - completion_window: OpenAI::Models::BatchCreateParams::completion_window, - endpoint: OpenAI::Models::BatchCreateParams::endpoint, - input_file_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::batch_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + completion_window: OpenAI::Models::BatchCreateParams::completion_window, + endpoint: OpenAI::Models::BatchCreateParams::endpoint, + input_file_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::batch_create_params type completion_window = :"24h" - class CompletionWindow < OpenAI::Enum + module CompletionWindow + extend OpenAI::Enum + NUMBER_24H: :"24h" - def self.values: -> ::Array[OpenAI::Models::BatchCreateParams::completion_window] + def self?.values: -> ::Array[OpenAI::Models::BatchCreateParams::completion_window] end type endpoint = - :"/v1/chat/completions" | :"/v1/embeddings" | :"/v1/completions" + :"/v1/responses" + | :"/v1/chat/completions" + | :"/v1/embeddings" + | :"/v1/completions" + + module Endpoint + extend OpenAI::Enum - class Endpoint < OpenAI::Enum + V1_RESPONSES: :"/v1/responses" V1_CHAT_COMPLETIONS: :"/v1/chat/completions" V1_EMBEDDINGS: :"/v1/embeddings" V1_COMPLETIONS: :"/v1/completions" - def self.values: -> ::Array[OpenAI::Models::BatchCreateParams::endpoint] + def self?.values: -> ::Array[OpenAI::Models::BatchCreateParams::endpoint] end end end diff --git a/sig/openai/models/batch_error.rbs b/sig/openai/models/batch_error.rbs index 4803b3cd..b2aadd8e 100644 --- a/sig/openai/models/batch_error.rbs +++ b/sig/openai/models/batch_error.rbs @@ -16,9 +16,12 @@ module OpenAI attr_accessor param: String? - def initialize: - (code: String, line: Integer?, message: String, param: String?) -> void - | (?OpenAI::Models::batch_error | OpenAI::BaseModel data) -> void + def initialize: ( + ?code: String, + ?line: Integer?, + ?message: String, + ?param: String? + ) -> void def to_hash: -> OpenAI::Models::batch_error end diff --git a/sig/openai/models/batch_list_params.rbs b/sig/openai/models/batch_list_params.rbs index e1265113..7dfa318e 100644 --- a/sig/openai/models/batch_list_params.rbs +++ b/sig/openai/models/batch_list_params.rbs @@ -4,7 +4,7 @@ module OpenAI { after: String, limit: Integer } & OpenAI::request_parameters class BatchListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -15,13 +15,11 @@ module OpenAI def limit=: (Integer) -> Integer - def initialize: - ( - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> void - | (?OpenAI::Models::batch_list_params | OpenAI::BaseModel data) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::batch_list_params end diff --git a/sig/openai/models/batch_request_counts.rbs b/sig/openai/models/batch_request_counts.rbs index d2a56b3b..0020eb38 100644 --- a/sig/openai/models/batch_request_counts.rbs +++ b/sig/openai/models/batch_request_counts.rbs @@ -10,11 +10,11 @@ module OpenAI attr_accessor total: Integer - def initialize: - (completed: Integer, failed: Integer, total: Integer) -> void - | ( - ?OpenAI::Models::batch_request_counts | OpenAI::BaseModel data - ) -> void + def initialize: ( + completed: Integer, + failed: Integer, + total: Integer + ) -> void def to_hash: -> OpenAI::Models::batch_request_counts end diff --git a/sig/openai/models/batch_retrieve_params.rbs b/sig/openai/models/batch_retrieve_params.rbs index e3af551a..c6dcd6ae 100644 --- a/sig/openai/models/batch_retrieve_params.rbs +++ b/sig/openai/models/batch_retrieve_params.rbs @@ -3,14 +3,10 @@ module OpenAI type batch_retrieve_params = { } & OpenAI::request_parameters class BatchRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::batch_retrieve_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::batch_retrieve_params end diff --git a/sig/openai/models/beta/assistant.rbs b/sig/openai/models/beta/assistant.rbs index 5e7d12d3..91f1b5ee 100644 --- a/sig/openai/models/beta/assistant.rbs +++ b/sig/openai/models/beta/assistant.rbs @@ -45,23 +45,21 @@ module OpenAI attr_accessor top_p: Float? - def initialize: - ( - id: String, - created_at: Integer, - description: String?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - model: String, - name: String?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_resources: OpenAI::Models::Beta::Assistant::ToolResources?, - top_p: Float?, - object: :assistant - ) -> void - | (?OpenAI::Models::Beta::assistant | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + created_at: Integer, + description: String?, + instructions: String?, + metadata: OpenAI::Models::metadata?, + model: String, + name: String?, + tools: ::Array[OpenAI::Models::Beta::assistant_tool], + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_resources: OpenAI::Models::Beta::Assistant::ToolResources?, + ?top_p: Float?, + ?object: :assistant + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant @@ -84,15 +82,10 @@ module OpenAI OpenAI::Models::Beta::Assistant::ToolResources::FileSearch ) -> OpenAI::Models::Beta::Assistant::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::Assistant::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::Assistant::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::Assistant::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::Assistant::tool_resources @@ -103,12 +96,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::Assistant::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::Assistant::ToolResources::code_interpreter end @@ -120,12 +108,7 @@ module OpenAI def vector_store_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (vector_store_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::Assistant::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?vector_store_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::Assistant::ToolResources::file_search end diff --git a/sig/openai/models/beta/assistant_create_params.rbs b/sig/openai/models/beta/assistant_create_params.rbs index 21b76a8c..e1cf13a2 100644 --- a/sig/openai/models/beta/assistant_create_params.rbs +++ b/sig/openai/models/beta/assistant_create_params.rbs @@ -18,7 +18,7 @@ module OpenAI & OpenAI::request_parameters class AssistantCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor model: OpenAI::Models::Beta::AssistantCreateParams::model @@ -47,32 +47,29 @@ module OpenAI attr_accessor top_p: Float? - def initialize: - ( - model: OpenAI::Models::Beta::AssistantCreateParams::model, - description: String?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - name: String?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_resources: OpenAI::Models::Beta::AssistantCreateParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - top_p: Float?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::assistant_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + model: OpenAI::Models::Beta::AssistantCreateParams::model, + ?description: String?, + ?instructions: String?, + ?metadata: OpenAI::Models::metadata?, + ?name: String?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_resources: OpenAI::Models::Beta::AssistantCreateParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool], + ?top_p: Float?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant_create_params type model = String | OpenAI::Models::chat_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model] end type tool_resources = @@ -94,15 +91,10 @@ module OpenAI OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch ) -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::tool_resources @@ -113,12 +105,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::code_interpreter end @@ -140,15 +127,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore] ) -> ::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore] - def initialize: - ( - vector_store_ids: ::Array[String], - vector_stores: ::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore] - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?vector_store_ids: ::Array[String], + ?vector_stores: ::Array[OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore] + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::file_search @@ -172,16 +154,11 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - chunking_strategy: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::chunking_strategy, - file_ids: ::Array[String], - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::vector_store - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?chunking_strategy: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::chunking_strategy, + ?file_ids: ::Array[String], + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::vector_store @@ -189,18 +166,15 @@ module OpenAI OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto | OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + type auto = { type: :auto } class Auto < OpenAI::BaseModel attr_accessor type: :auto - def initialize: - (type: :auto) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :auto) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto end @@ -216,15 +190,10 @@ module OpenAI attr_accessor type: :static - def initialize: - ( - static: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, - type: :static - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + static: OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + ?type: :static + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static @@ -239,21 +208,16 @@ module OpenAI attr_accessor max_chunk_size_tokens: Integer - def initialize: - ( - chunk_overlap_tokens: Integer, - max_chunk_size_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + chunk_overlap_tokens: Integer, + max_chunk_size_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static end end - def self.variants: -> [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + def self?.variants: -> [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] end end end diff --git a/sig/openai/models/beta/assistant_delete_params.rbs b/sig/openai/models/beta/assistant_delete_params.rbs index fae651c6..cbab3d6b 100644 --- a/sig/openai/models/beta/assistant_delete_params.rbs +++ b/sig/openai/models/beta/assistant_delete_params.rbs @@ -4,15 +4,10 @@ module OpenAI type assistant_delete_params = { } & OpenAI::request_parameters class AssistantDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::assistant_delete_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Beta::assistant_delete_params end diff --git a/sig/openai/models/beta/assistant_deleted.rbs b/sig/openai/models/beta/assistant_deleted.rbs index 655b5bdc..39b34057 100644 --- a/sig/openai/models/beta/assistant_deleted.rbs +++ b/sig/openai/models/beta/assistant_deleted.rbs @@ -11,11 +11,11 @@ module OpenAI attr_accessor object: :"assistant.deleted" - def initialize: - (id: String, deleted: bool, object: :"assistant.deleted") -> void - | ( - ?OpenAI::Models::Beta::assistant_deleted | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"assistant.deleted" + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant_deleted end diff --git a/sig/openai/models/beta/assistant_list_params.rbs b/sig/openai/models/beta/assistant_list_params.rbs index c2254036..42c3c994 100644 --- a/sig/openai/models/beta/assistant_list_params.rbs +++ b/sig/openai/models/beta/assistant_list_params.rbs @@ -11,7 +11,7 @@ module OpenAI & OpenAI::request_parameters class AssistantListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -32,28 +32,25 @@ module OpenAI OpenAI::Models::Beta::AssistantListParams::order ) -> OpenAI::Models::Beta::AssistantListParams::order - def initialize: - ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::AssistantListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::assistant_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::AssistantListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Beta::AssistantListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Beta::AssistantListParams::order] end end end diff --git a/sig/openai/models/beta/assistant_response_format_option.rbs b/sig/openai/models/beta/assistant_response_format_option.rbs index 158a3a03..3b848b00 100644 --- a/sig/openai/models/beta/assistant_response_format_option.rbs +++ b/sig/openai/models/beta/assistant_response_format_option.rbs @@ -7,8 +7,10 @@ module OpenAI | OpenAI::Models::ResponseFormatJSONObject | OpenAI::Models::ResponseFormatJSONSchema - class AssistantResponseFormatOption < OpenAI::Union - def self.variants: -> [:auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema] + module AssistantResponseFormatOption + extend OpenAI::Union + + def self?.variants: -> [:auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema] end end end diff --git a/sig/openai/models/beta/assistant_retrieve_params.rbs b/sig/openai/models/beta/assistant_retrieve_params.rbs index a1148ac9..8f5e9d53 100644 --- a/sig/openai/models/beta/assistant_retrieve_params.rbs +++ b/sig/openai/models/beta/assistant_retrieve_params.rbs @@ -4,15 +4,10 @@ module OpenAI type assistant_retrieve_params = { } & OpenAI::request_parameters class AssistantRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::assistant_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Beta::assistant_retrieve_params end diff --git a/sig/openai/models/beta/assistant_stream_event.rbs b/sig/openai/models/beta/assistant_stream_event.rbs index 37d03210..ae88c40e 100644 --- a/sig/openai/models/beta/assistant_stream_event.rbs +++ b/sig/openai/models/beta/assistant_stream_event.rbs @@ -27,7 +27,9 @@ module OpenAI | OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete | OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent - class AssistantStreamEvent < OpenAI::Union + module AssistantStreamEvent + extend OpenAI::Union + type thread_created = { data: OpenAI::Models::Beta::Thread, @@ -44,16 +46,11 @@ module OpenAI def enabled=: (bool) -> bool - def initialize: - ( - data: OpenAI::Models::Beta::Thread, - enabled: bool, - event: :"thread.created" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Thread, + ?enabled: bool, + ?event: :"thread.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_created end @@ -69,15 +66,10 @@ module OpenAI attr_accessor event: :"thread.run.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.created" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_created end @@ -93,15 +85,10 @@ module OpenAI attr_accessor event: :"thread.run.queued" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.queued" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_queued - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.queued" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_queued end @@ -117,15 +104,10 @@ module OpenAI attr_accessor event: :"thread.run.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_in_progress end @@ -141,15 +123,10 @@ module OpenAI attr_accessor event: :"thread.run.requires_action" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.requires_action" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_requires_action - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.requires_action" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_requires_action end @@ -165,15 +142,10 @@ module OpenAI attr_accessor event: :"thread.run.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_completed end @@ -189,15 +161,10 @@ module OpenAI attr_accessor event: :"thread.run.incomplete" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.incomplete" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_incomplete - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.incomplete" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_incomplete end @@ -213,15 +180,10 @@ module OpenAI attr_accessor event: :"thread.run.failed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.failed" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_failed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.failed" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_failed end @@ -237,15 +199,10 @@ module OpenAI attr_accessor event: :"thread.run.cancelling" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.cancelling" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_cancelling - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.cancelling" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_cancelling end @@ -261,15 +218,10 @@ module OpenAI attr_accessor event: :"thread.run.cancelled" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.cancelled" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_cancelled - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.cancelled" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_cancelled end @@ -285,15 +237,10 @@ module OpenAI attr_accessor event: :"thread.run.expired" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.expired" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_expired - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.expired" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_expired end @@ -309,15 +256,10 @@ module OpenAI attr_accessor event: :"thread.run.step.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.created" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_created end @@ -333,15 +275,10 @@ module OpenAI attr_accessor event: :"thread.run.step.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_in_progress end @@ -357,15 +294,10 @@ module OpenAI attr_accessor event: :"thread.run.step.delta" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, - event: :"thread.run.step.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, + ?event: :"thread.run.step.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_delta end @@ -381,15 +313,10 @@ module OpenAI attr_accessor event: :"thread.run.step.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_completed end @@ -405,15 +332,10 @@ module OpenAI attr_accessor event: :"thread.run.step.failed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.failed" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_failed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.failed" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_failed end @@ -429,15 +351,10 @@ module OpenAI attr_accessor event: :"thread.run.step.cancelled" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.cancelled" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_cancelled - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.cancelled" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_cancelled end @@ -453,15 +370,10 @@ module OpenAI attr_accessor event: :"thread.run.step.expired" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.expired" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_expired - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.expired" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_run_step_expired end @@ -477,15 +389,10 @@ module OpenAI attr_accessor event: :"thread.message.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.created" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_message_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_message_created end @@ -501,15 +408,10 @@ module OpenAI attr_accessor event: :"thread.message.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_message_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_message_in_progress end @@ -525,15 +427,10 @@ module OpenAI attr_accessor event: :"thread.message.delta" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, - event: :"thread.message.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_message_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, + ?event: :"thread.message.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_message_delta end @@ -549,15 +446,10 @@ module OpenAI attr_accessor event: :"thread.message.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_message_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_message_completed end @@ -573,15 +465,10 @@ module OpenAI attr_accessor event: :"thread.message.incomplete" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.incomplete" - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::thread_message_incomplete - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.incomplete" + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::thread_message_incomplete end @@ -593,17 +480,15 @@ module OpenAI attr_accessor event: :error - def initialize: - (data: OpenAI::Models::ErrorObject, event: :error) -> void - | ( - ?OpenAI::Models::Beta::AssistantStreamEvent::error_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::ErrorObject, + ?event: :error + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantStreamEvent::error_event end - def self.variants: -> [OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent] + def self?.variants: -> [OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent] end end end diff --git a/sig/openai/models/beta/assistant_tool.rbs b/sig/openai/models/beta/assistant_tool.rbs index 5421e7bc..d3a43fed 100644 --- a/sig/openai/models/beta/assistant_tool.rbs +++ b/sig/openai/models/beta/assistant_tool.rbs @@ -6,8 +6,10 @@ module OpenAI | OpenAI::Models::Beta::FileSearchTool | OpenAI::Models::Beta::FunctionTool - class AssistantTool < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] + module AssistantTool + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] end end end diff --git a/sig/openai/models/beta/assistant_tool_choice.rbs b/sig/openai/models/beta/assistant_tool_choice.rbs index e3234bbe..69e6e1b5 100644 --- a/sig/openai/models/beta/assistant_tool_choice.rbs +++ b/sig/openai/models/beta/assistant_tool_choice.rbs @@ -16,26 +16,23 @@ module OpenAI OpenAI::Models::Beta::AssistantToolChoiceFunction ) -> OpenAI::Models::Beta::AssistantToolChoiceFunction - def initialize: - ( - type: OpenAI::Models::Beta::AssistantToolChoice::type_, - function: OpenAI::Models::Beta::AssistantToolChoiceFunction - ) -> void - | ( - ?OpenAI::Models::Beta::assistant_tool_choice - | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Beta::AssistantToolChoice::type_, + ?function: OpenAI::Models::Beta::AssistantToolChoiceFunction + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant_tool_choice type type_ = :function | :code_interpreter | :file_search - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FUNCTION: :function CODE_INTERPRETER: :code_interpreter FILE_SEARCH: :file_search - def self.values: -> ::Array[OpenAI::Models::Beta::AssistantToolChoice::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::AssistantToolChoice::type_] end end end diff --git a/sig/openai/models/beta/assistant_tool_choice_function.rbs b/sig/openai/models/beta/assistant_tool_choice_function.rbs index f10e8dd0..ab112b3d 100644 --- a/sig/openai/models/beta/assistant_tool_choice_function.rbs +++ b/sig/openai/models/beta/assistant_tool_choice_function.rbs @@ -6,12 +6,7 @@ module OpenAI class AssistantToolChoiceFunction < OpenAI::BaseModel attr_accessor name: String - def initialize: - (name: String) -> void - | ( - ?OpenAI::Models::Beta::assistant_tool_choice_function - | OpenAI::BaseModel data - ) -> void + def initialize: (name: String) -> void def to_hash: -> OpenAI::Models::Beta::assistant_tool_choice_function end diff --git a/sig/openai/models/beta/assistant_tool_choice_option.rbs b/sig/openai/models/beta/assistant_tool_choice_option.rbs index f7886116..4b1d9ff3 100644 --- a/sig/openai/models/beta/assistant_tool_choice_option.rbs +++ b/sig/openai/models/beta/assistant_tool_choice_option.rbs @@ -5,18 +5,22 @@ module OpenAI OpenAI::Models::Beta::AssistantToolChoiceOption::auto | OpenAI::Models::Beta::AssistantToolChoice - class AssistantToolChoiceOption < OpenAI::Union + module AssistantToolChoiceOption + extend OpenAI::Union + type auto = :none | :auto | :required - class Auto < OpenAI::Enum + module Auto + extend OpenAI::Enum + NONE: :none AUTO: :auto REQUIRED: :required - def self.values: -> ::Array[OpenAI::Models::Beta::AssistantToolChoiceOption::auto] + def self?.values: -> ::Array[OpenAI::Models::Beta::AssistantToolChoiceOption::auto] end - def self.variants: -> [OpenAI::Models::Beta::AssistantToolChoiceOption::auto, OpenAI::Models::Beta::AssistantToolChoice] + def self?.variants: -> [OpenAI::Models::Beta::AssistantToolChoiceOption::auto, OpenAI::Models::Beta::AssistantToolChoice] end end end diff --git a/sig/openai/models/beta/assistant_update_params.rbs b/sig/openai/models/beta/assistant_update_params.rbs index 39a0d8e2..eec6b058 100644 --- a/sig/openai/models/beta/assistant_update_params.rbs +++ b/sig/openai/models/beta/assistant_update_params.rbs @@ -18,7 +18,7 @@ module OpenAI & OpenAI::request_parameters class AssistantUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor description: String? @@ -51,25 +51,20 @@ module OpenAI attr_accessor top_p: Float? - def initialize: - ( - description: String?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::AssistantUpdateParams::model, - name: String?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_resources: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - top_p: Float?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::assistant_update_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?description: String?, + ?instructions: String?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::AssistantUpdateParams::model, + ?name: String?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_resources: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool], + ?top_p: Float?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::assistant_update_params @@ -106,8 +101,10 @@ module OpenAI | :"gpt-3.5-turbo-0125" | :"gpt-3.5-turbo-16k-0613" - class Model < OpenAI::Union - def self.variants: -> [String, (:"o3-mini" + module Model + extend OpenAI::Union + + def self?.variants: -> [String, (:"o3-mini" | :"o3-mini-2025-01-31" | :o1 | :"o1-2024-12-17" @@ -137,6 +134,37 @@ module OpenAI | :"gpt-3.5-turbo-1106" | :"gpt-3.5-turbo-0125" | :"gpt-3.5-turbo-16k-0613")] + + O3_MINI: :"o3-mini" + O3_MINI_2025_01_31: :"o3-mini-2025-01-31" + O1: :o1 + O1_2024_12_17: :"o1-2024-12-17" + GPT_4O: :"gpt-4o" + GPT_4O_2024_11_20: :"gpt-4o-2024-11-20" + GPT_4O_2024_08_06: :"gpt-4o-2024-08-06" + GPT_4O_2024_05_13: :"gpt-4o-2024-05-13" + GPT_4O_MINI: :"gpt-4o-mini" + GPT_4O_MINI_2024_07_18: :"gpt-4o-mini-2024-07-18" + GPT_4_5_PREVIEW: :"gpt-4.5-preview" + GPT_4_5_PREVIEW_2025_02_27: :"gpt-4.5-preview-2025-02-27" + GPT_4_TURBO: :"gpt-4-turbo" + GPT_4_TURBO_2024_04_09: :"gpt-4-turbo-2024-04-09" + GPT_4_0125_PREVIEW: :"gpt-4-0125-preview" + GPT_4_TURBO_PREVIEW: :"gpt-4-turbo-preview" + GPT_4_1106_PREVIEW: :"gpt-4-1106-preview" + GPT_4_VISION_PREVIEW: :"gpt-4-vision-preview" + GPT_4: :"gpt-4" + GPT_4_0314: :"gpt-4-0314" + GPT_4_0613: :"gpt-4-0613" + GPT_4_32K: :"gpt-4-32k" + GPT_4_32K_0314: :"gpt-4-32k-0314" + GPT_4_32K_0613: :"gpt-4-32k-0613" + GPT_3_5_TURBO: :"gpt-3.5-turbo" + GPT_3_5_TURBO_16K: :"gpt-3.5-turbo-16k" + GPT_3_5_TURBO_0613: :"gpt-3.5-turbo-0613" + GPT_3_5_TURBO_1106: :"gpt-3.5-turbo-1106" + GPT_3_5_TURBO_0125: :"gpt-3.5-turbo-0125" + GPT_3_5_TURBO_16K_0613: :"gpt-3.5-turbo-16k-0613" end type tool_resources = @@ -158,15 +186,10 @@ module OpenAI OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch ) -> OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::AssistantUpdateParams::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::AssistantUpdateParams::tool_resources @@ -177,12 +200,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::code_interpreter end @@ -194,12 +212,7 @@ module OpenAI def vector_store_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (vector_store_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?vector_store_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::file_search end diff --git a/sig/openai/models/beta/code_interpreter_tool.rbs b/sig/openai/models/beta/code_interpreter_tool.rbs index 31372e23..3855b043 100644 --- a/sig/openai/models/beta/code_interpreter_tool.rbs +++ b/sig/openai/models/beta/code_interpreter_tool.rbs @@ -6,12 +6,7 @@ module OpenAI class CodeInterpreterTool < OpenAI::BaseModel attr_accessor type: :code_interpreter - def initialize: - (type: :code_interpreter) -> void - | ( - ?OpenAI::Models::Beta::code_interpreter_tool - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :code_interpreter) -> void def to_hash: -> OpenAI::Models::Beta::code_interpreter_tool end diff --git a/sig/openai/models/beta/file_search_tool.rbs b/sig/openai/models/beta/file_search_tool.rbs index 731166b6..c18305c9 100644 --- a/sig/openai/models/beta/file_search_tool.rbs +++ b/sig/openai/models/beta/file_search_tool.rbs @@ -16,14 +16,10 @@ module OpenAI OpenAI::Models::Beta::FileSearchTool::FileSearch ) -> OpenAI::Models::Beta::FileSearchTool::FileSearch - def initialize: - ( - file_search: OpenAI::Models::Beta::FileSearchTool::FileSearch, - type: :file_search - ) -> void - | ( - ?OpenAI::Models::Beta::file_search_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_search: OpenAI::Models::Beta::FileSearchTool::FileSearch, + ?type: :file_search + ) -> void def to_hash: -> OpenAI::Models::Beta::file_search_tool @@ -44,15 +40,10 @@ module OpenAI OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions ) -> OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions - def initialize: - ( - max_num_results: Integer, - ranking_options: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions - ) -> void - | ( - ?OpenAI::Models::Beta::FileSearchTool::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?max_num_results: Integer, + ?ranking_options: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions + ) -> void def to_hash: -> OpenAI::Models::Beta::FileSearchTool::file_search @@ -71,25 +62,22 @@ module OpenAI OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker ) -> OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker - def initialize: - ( - score_threshold: Float, - ranker: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker - ) -> void - | ( - ?OpenAI::Models::Beta::FileSearchTool::FileSearch::ranking_options - | OpenAI::BaseModel data - ) -> void + def initialize: ( + score_threshold: Float, + ?ranker: OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker + ) -> void def to_hash: -> OpenAI::Models::Beta::FileSearchTool::FileSearch::ranking_options type ranker = :auto | :default_2024_08_21 - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO: :auto DEFAULT_2024_08_21: :default_2024_08_21 - def self.values: -> ::Array[OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker] + def self?.values: -> ::Array[OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::ranker] end end end diff --git a/sig/openai/models/beta/function_tool.rbs b/sig/openai/models/beta/function_tool.rbs index 43a63e37..72724066 100644 --- a/sig/openai/models/beta/function_tool.rbs +++ b/sig/openai/models/beta/function_tool.rbs @@ -9,14 +9,10 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - function: OpenAI::Models::FunctionDefinition, - type: :function - ) -> void - | ( - ?OpenAI::Models::Beta::function_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + function: OpenAI::Models::FunctionDefinition, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Beta::function_tool end diff --git a/sig/openai/models/beta/message_stream_event.rbs b/sig/openai/models/beta/message_stream_event.rbs index d46abf27..fb0a513a 100644 --- a/sig/openai/models/beta/message_stream_event.rbs +++ b/sig/openai/models/beta/message_stream_event.rbs @@ -8,7 +8,9 @@ module OpenAI | OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted | OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete - class MessageStreamEvent < OpenAI::Union + module MessageStreamEvent + extend OpenAI::Union + type thread_message_created = { data: OpenAI::Models::Beta::Threads::Message, @@ -20,15 +22,10 @@ module OpenAI attr_accessor event: :"thread.message.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.created" - ) -> void - | ( - ?OpenAI::Models::Beta::MessageStreamEvent::thread_message_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::MessageStreamEvent::thread_message_created end @@ -44,15 +41,10 @@ module OpenAI attr_accessor event: :"thread.message.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::MessageStreamEvent::thread_message_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::MessageStreamEvent::thread_message_in_progress end @@ -68,15 +60,10 @@ module OpenAI attr_accessor event: :"thread.message.delta" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, - event: :"thread.message.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::MessageStreamEvent::thread_message_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::MessageDeltaEvent, + ?event: :"thread.message.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::MessageStreamEvent::thread_message_delta end @@ -92,15 +79,10 @@ module OpenAI attr_accessor event: :"thread.message.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::MessageStreamEvent::thread_message_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::MessageStreamEvent::thread_message_completed end @@ -116,20 +98,15 @@ module OpenAI attr_accessor event: :"thread.message.incomplete" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Message, - event: :"thread.message.incomplete" - ) -> void - | ( - ?OpenAI::Models::Beta::MessageStreamEvent::thread_message_incomplete - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Message, + ?event: :"thread.message.incomplete" + ) -> void def to_hash: -> OpenAI::Models::Beta::MessageStreamEvent::thread_message_incomplete end - def self.variants: -> [OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete] + def self?.variants: -> [OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete] end end end diff --git a/sig/openai/models/beta/run_step_stream_event.rbs b/sig/openai/models/beta/run_step_stream_event.rbs index b0c1a0a3..027b49a0 100644 --- a/sig/openai/models/beta/run_step_stream_event.rbs +++ b/sig/openai/models/beta/run_step_stream_event.rbs @@ -10,7 +10,9 @@ module OpenAI | OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled | OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired - class RunStepStreamEvent < OpenAI::Union + module RunStepStreamEvent + extend OpenAI::Union + type thread_run_step_created = { data: OpenAI::Models::Beta::Threads::Runs::RunStep, @@ -22,15 +24,10 @@ module OpenAI attr_accessor event: :"thread.run.step.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.created" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_created end @@ -46,15 +43,10 @@ module OpenAI attr_accessor event: :"thread.run.step.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_in_progress end @@ -70,15 +62,10 @@ module OpenAI attr_accessor event: :"thread.run.step.delta" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, - event: :"thread.run.step.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent, + ?event: :"thread.run.step.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_delta end @@ -94,15 +81,10 @@ module OpenAI attr_accessor event: :"thread.run.step.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_completed end @@ -118,15 +100,10 @@ module OpenAI attr_accessor event: :"thread.run.step.failed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.failed" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_failed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.failed" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_failed end @@ -142,15 +119,10 @@ module OpenAI attr_accessor event: :"thread.run.step.cancelled" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.cancelled" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_cancelled - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.cancelled" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_cancelled end @@ -166,20 +138,15 @@ module OpenAI attr_accessor event: :"thread.run.step.expired" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Runs::RunStep, - event: :"thread.run.step.expired" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_expired - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Runs::RunStep, + ?event: :"thread.run.step.expired" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStepStreamEvent::thread_run_step_expired end - def self.variants: -> [OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired] + def self?.variants: -> [OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired] end end end diff --git a/sig/openai/models/beta/run_stream_event.rbs b/sig/openai/models/beta/run_stream_event.rbs index 650253ce..87e168ab 100644 --- a/sig/openai/models/beta/run_stream_event.rbs +++ b/sig/openai/models/beta/run_stream_event.rbs @@ -13,7 +13,9 @@ module OpenAI | OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled | OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired - class RunStreamEvent < OpenAI::Union + module RunStreamEvent + extend OpenAI::Union + type thread_run_created = { data: OpenAI::Models::Beta::Threads::Run, @@ -25,15 +27,10 @@ module OpenAI attr_accessor event: :"thread.run.created" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.created" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_created - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_created end @@ -49,15 +46,10 @@ module OpenAI attr_accessor event: :"thread.run.queued" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.queued" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_queued - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.queued" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_queued end @@ -73,15 +65,10 @@ module OpenAI attr_accessor event: :"thread.run.in_progress" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.in_progress" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_in_progress - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_in_progress end @@ -97,15 +84,10 @@ module OpenAI attr_accessor event: :"thread.run.requires_action" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.requires_action" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_requires_action - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.requires_action" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_requires_action end @@ -121,15 +103,10 @@ module OpenAI attr_accessor event: :"thread.run.completed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.completed" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_completed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.completed" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_completed end @@ -145,15 +122,10 @@ module OpenAI attr_accessor event: :"thread.run.incomplete" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.incomplete" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_incomplete - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.incomplete" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_incomplete end @@ -169,15 +141,10 @@ module OpenAI attr_accessor event: :"thread.run.failed" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.failed" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_failed - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.failed" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_failed end @@ -193,15 +160,10 @@ module OpenAI attr_accessor event: :"thread.run.cancelling" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.cancelling" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_cancelling - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.cancelling" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_cancelling end @@ -217,15 +179,10 @@ module OpenAI attr_accessor event: :"thread.run.cancelled" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.cancelled" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_cancelled - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.cancelled" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_cancelled end @@ -241,20 +198,15 @@ module OpenAI attr_accessor event: :"thread.run.expired" - def initialize: - ( - data: OpenAI::Models::Beta::Threads::Run, - event: :"thread.run.expired" - ) -> void - | ( - ?OpenAI::Models::Beta::RunStreamEvent::thread_run_expired - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Threads::Run, + ?event: :"thread.run.expired" + ) -> void def to_hash: -> OpenAI::Models::Beta::RunStreamEvent::thread_run_expired end - def self.variants: -> [OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired] + def self?.variants: -> [OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired] end end end diff --git a/sig/openai/models/beta/thread.rbs b/sig/openai/models/beta/thread.rbs index 14d481b1..1fdf76c8 100644 --- a/sig/openai/models/beta/thread.rbs +++ b/sig/openai/models/beta/thread.rbs @@ -21,15 +21,13 @@ module OpenAI attr_accessor tool_resources: OpenAI::Models::Beta::Thread::ToolResources? - def initialize: - ( - id: String, - created_at: Integer, - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::Thread::ToolResources?, - object: :thread - ) -> void - | (?OpenAI::Models::Beta::thread | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + created_at: Integer, + metadata: OpenAI::Models::metadata?, + tool_resources: OpenAI::Models::Beta::Thread::ToolResources?, + ?object: :thread + ) -> void def to_hash: -> OpenAI::Models::Beta::thread @@ -52,15 +50,10 @@ module OpenAI OpenAI::Models::Beta::Thread::ToolResources::FileSearch ) -> OpenAI::Models::Beta::Thread::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::Thread::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::Thread::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::Thread::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::Thread::tool_resources @@ -71,12 +64,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::Thread::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::Thread::ToolResources::code_interpreter end @@ -88,12 +76,7 @@ module OpenAI def vector_store_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (vector_store_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::Thread::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?vector_store_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::Thread::ToolResources::file_search end diff --git a/sig/openai/models/beta/thread_create_and_run_params.rbs b/sig/openai/models/beta/thread_create_and_run_params.rbs index 76bb1909..28e49216 100644 --- a/sig/openai/models/beta/thread_create_and_run_params.rbs +++ b/sig/openai/models/beta/thread_create_and_run_params.rbs @@ -22,7 +22,7 @@ module OpenAI & OpenAI::request_parameters class ThreadCreateAndRunParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor assistant_id: String @@ -61,36 +61,33 @@ module OpenAI attr_accessor truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy? - def initialize: - ( - assistant_id: String, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, - parallel_tool_calls: bool, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::thread_create_and_run_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + assistant_id: String, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, + ?parallel_tool_calls: bool, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::thread_create_and_run_params type model = String | OpenAI::Models::chat_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model] end type thread = @@ -111,16 +108,11 @@ module OpenAI attr_accessor tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources? - def initialize: - ( - messages: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message], - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::thread - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?messages: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message], + ?metadata: OpenAI::Models::metadata?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::thread @@ -141,17 +133,12 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - content: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::content, - role: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::role, - attachments: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]?, - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::content, + role: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::role, + ?attachments: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]?, + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::message @@ -159,22 +146,26 @@ module OpenAI String | ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] + type message_content_part_param_array = ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] MessageContentPartParamArray: message_content_part_param_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] end type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::role] end type attachment = @@ -194,15 +185,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::tool] ) -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::tool] - def initialize: - ( - file_id: String, - tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::tool] - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::attachment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_id: String, + ?tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::tool] + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::attachment @@ -210,23 +196,20 @@ module OpenAI OpenAI::Models::Beta::CodeInterpreterTool | OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + type file_search = { type: :file_search } class FileSearch < OpenAI::BaseModel attr_accessor type: :file_search - def initialize: - (type: :file_search) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :file_search) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::file_search end - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch] + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch] end end end @@ -250,15 +233,10 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch ) -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::tool_resources @@ -269,12 +247,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::code_interpreter end @@ -296,15 +269,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] ) -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] - def initialize: - ( - vector_store_ids: ::Array[String], - vector_stores: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?vector_store_ids: ::Array[String], + ?vector_stores: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore] + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::file_search @@ -328,16 +296,11 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - chunking_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::chunking_strategy, - file_ids: ::Array[String], - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::vector_store - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?chunking_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::chunking_strategy, + ?file_ids: ::Array[String], + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::vector_store @@ -345,18 +308,15 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto | OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + type auto = { type: :auto } class Auto < OpenAI::BaseModel attr_accessor type: :auto - def initialize: - (type: :auto) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :auto) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto end @@ -372,15 +332,10 @@ module OpenAI attr_accessor type: :static - def initialize: - ( - static: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, - type: :static - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + static: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + ?type: :static + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static @@ -395,21 +350,16 @@ module OpenAI attr_accessor max_chunk_size_tokens: Integer - def initialize: - ( - chunk_overlap_tokens: Integer, - max_chunk_size_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + chunk_overlap_tokens: Integer, + max_chunk_size_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static end end - def self.variants: -> [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + def self?.variants: -> [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] end end end @@ -435,15 +385,10 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch ) -> OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::tool_resources @@ -454,12 +399,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::code_interpreter end @@ -471,12 +411,7 @@ module OpenAI def vector_store_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (vector_store_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?vector_store_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::file_search end @@ -487,8 +422,10 @@ module OpenAI | OpenAI::Models::Beta::FileSearchTool | OpenAI::Models::Beta::FunctionTool - class Tool < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] + module Tool + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool] end type truncation_strategy = @@ -502,25 +439,22 @@ module OpenAI attr_accessor last_messages: Integer? - def initialize: - ( - type: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::type_, - last_messages: Integer? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateAndRunParams::truncation_strategy - | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::type_, + ?last_messages: Integer? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateAndRunParams::truncation_strategy type type_ = :auto | :last_messages - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO: :auto LAST_MESSAGES: :last_messages - def self.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::type_] end end end diff --git a/sig/openai/models/beta/thread_create_params.rbs b/sig/openai/models/beta/thread_create_params.rbs index 8de821f1..ba9059a3 100644 --- a/sig/openai/models/beta/thread_create_params.rbs +++ b/sig/openai/models/beta/thread_create_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class ThreadCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader messages: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message]? @@ -23,16 +23,12 @@ module OpenAI attr_accessor tool_resources: OpenAI::Models::Beta::ThreadCreateParams::ToolResources? - def initialize: - ( - messages: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::ThreadCreateParams::ToolResources?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::thread_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?messages: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], + ?metadata: OpenAI::Models::metadata?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateParams::ToolResources?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::thread_create_params @@ -53,17 +49,12 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - content: OpenAI::Models::Beta::ThreadCreateParams::Message::content, - role: OpenAI::Models::Beta::ThreadCreateParams::Message::role, - attachments: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment]?, - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Beta::ThreadCreateParams::Message::content, + role: OpenAI::Models::Beta::ThreadCreateParams::Message::role, + ?attachments: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment]?, + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::message @@ -71,22 +62,26 @@ module OpenAI String | ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] + type message_content_part_param_array = ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] MessageContentPartParamArray: message_content_part_param_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] end type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::role] end type attachment = @@ -106,15 +101,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::tool] ) -> ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::tool] - def initialize: - ( - file_id: String, - tools: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::tool] - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::Message::attachment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_id: String, + ?tools: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::tool] + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::Message::attachment @@ -122,23 +112,20 @@ module OpenAI OpenAI::Models::Beta::CodeInterpreterTool | OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + type file_search = { type: :file_search } class FileSearch < OpenAI::BaseModel attr_accessor type: :file_search - def initialize: - (type: :file_search) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :file_search) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::file_search end - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch] + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch] end end end @@ -162,15 +149,10 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch ) -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::tool_resources @@ -181,12 +163,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::code_interpreter end @@ -208,15 +185,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] ) -> ::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] - def initialize: - ( - vector_store_ids: ::Array[String], - vector_stores: ::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?vector_store_ids: ::Array[String], + ?vector_stores: ::Array[OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore] + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::file_search @@ -240,16 +212,11 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - chunking_strategy: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::chunking_strategy, - file_ids: ::Array[String], - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::vector_store - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?chunking_strategy: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::chunking_strategy, + ?file_ids: ::Array[String], + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::vector_store @@ -257,18 +224,15 @@ module OpenAI OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto | OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static - class ChunkingStrategy < OpenAI::Union + module ChunkingStrategy + extend OpenAI::Union + type auto = { type: :auto } class Auto < OpenAI::BaseModel attr_accessor type: :auto - def initialize: - (type: :auto) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :auto) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::auto end @@ -284,15 +248,10 @@ module OpenAI attr_accessor type: :static - def initialize: - ( - static: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, - type: :static - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + static: OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static, + ?type: :static + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::static @@ -307,21 +266,16 @@ module OpenAI attr_accessor max_chunk_size_tokens: Integer - def initialize: - ( - chunk_overlap_tokens: Integer, - max_chunk_size_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static - | OpenAI::BaseModel data - ) -> void + def initialize: ( + chunk_overlap_tokens: Integer, + max_chunk_size_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::static end end - def self.variants: -> [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] + def self?.variants: -> [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] end end end diff --git a/sig/openai/models/beta/thread_delete_params.rbs b/sig/openai/models/beta/thread_delete_params.rbs index 42d8665e..9440978b 100644 --- a/sig/openai/models/beta/thread_delete_params.rbs +++ b/sig/openai/models/beta/thread_delete_params.rbs @@ -4,14 +4,10 @@ module OpenAI type thread_delete_params = { } & OpenAI::request_parameters class ThreadDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::thread_delete_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Beta::thread_delete_params end diff --git a/sig/openai/models/beta/thread_deleted.rbs b/sig/openai/models/beta/thread_deleted.rbs index 137eb97d..c3b1ff2b 100644 --- a/sig/openai/models/beta/thread_deleted.rbs +++ b/sig/openai/models/beta/thread_deleted.rbs @@ -11,11 +11,11 @@ module OpenAI attr_accessor object: :"thread.deleted" - def initialize: - (id: String, deleted: bool, object: :"thread.deleted") -> void - | ( - ?OpenAI::Models::Beta::thread_deleted | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"thread.deleted" + ) -> void def to_hash: -> OpenAI::Models::Beta::thread_deleted end diff --git a/sig/openai/models/beta/thread_retrieve_params.rbs b/sig/openai/models/beta/thread_retrieve_params.rbs index fd9a2212..e259fb2d 100644 --- a/sig/openai/models/beta/thread_retrieve_params.rbs +++ b/sig/openai/models/beta/thread_retrieve_params.rbs @@ -4,15 +4,10 @@ module OpenAI type thread_retrieve_params = { } & OpenAI::request_parameters class ThreadRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::thread_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Beta::thread_retrieve_params end diff --git a/sig/openai/models/beta/thread_stream_event.rbs b/sig/openai/models/beta/thread_stream_event.rbs index 51deb8c1..672ef1d6 100644 --- a/sig/openai/models/beta/thread_stream_event.rbs +++ b/sig/openai/models/beta/thread_stream_event.rbs @@ -17,15 +17,11 @@ module OpenAI def enabled=: (bool) -> bool - def initialize: - ( - data: OpenAI::Models::Beta::Thread, - enabled: bool, - event: :"thread.created" - ) -> void - | ( - ?OpenAI::Models::Beta::thread_stream_event | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: OpenAI::Models::Beta::Thread, + ?enabled: bool, + ?event: :"thread.created" + ) -> void def to_hash: -> OpenAI::Models::Beta::thread_stream_event end diff --git a/sig/openai/models/beta/thread_update_params.rbs b/sig/openai/models/beta/thread_update_params.rbs index 4462d12c..f725515f 100644 --- a/sig/openai/models/beta/thread_update_params.rbs +++ b/sig/openai/models/beta/thread_update_params.rbs @@ -9,22 +9,18 @@ module OpenAI & OpenAI::request_parameters class ThreadUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor metadata: OpenAI::Models::metadata? attr_accessor tool_resources: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources? - def initialize: - ( - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::thread_update_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?metadata: OpenAI::Models::metadata?, + ?tool_resources: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::thread_update_params @@ -47,15 +43,10 @@ module OpenAI OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch ) -> OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch - def initialize: - ( - code_interpreter: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, - file_search: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch - ) -> void - | ( - ?OpenAI::Models::Beta::ThreadUpdateParams::tool_resources - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?code_interpreter: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, + ?file_search: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch + ) -> void def to_hash: -> OpenAI::Models::Beta::ThreadUpdateParams::tool_resources @@ -66,12 +57,7 @@ module OpenAI def file_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (file_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::code_interpreter end @@ -83,12 +69,7 @@ module OpenAI def vector_store_ids=: (::Array[String]) -> ::Array[String] - def initialize: - (vector_store_ids: ::Array[String]) -> void - | ( - ?OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?vector_store_ids: ::Array[String]) -> void def to_hash: -> OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::file_search end diff --git a/sig/openai/models/beta/threads/annotation.rbs b/sig/openai/models/beta/threads/annotation.rbs index 527a6e58..00961486 100644 --- a/sig/openai/models/beta/threads/annotation.rbs +++ b/sig/openai/models/beta/threads/annotation.rbs @@ -6,8 +6,10 @@ module OpenAI OpenAI::Models::Beta::Threads::FileCitationAnnotation | OpenAI::Models::Beta::Threads::FilePathAnnotation - class Annotation < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation] + module Annotation + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation] end end end diff --git a/sig/openai/models/beta/threads/annotation_delta.rbs b/sig/openai/models/beta/threads/annotation_delta.rbs index 21dee9df..84b0d6a2 100644 --- a/sig/openai/models/beta/threads/annotation_delta.rbs +++ b/sig/openai/models/beta/threads/annotation_delta.rbs @@ -6,8 +6,10 @@ module OpenAI OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation | OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation - class AnnotationDelta < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation] + module AnnotationDelta + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation] end end end diff --git a/sig/openai/models/beta/threads/file_citation_annotation.rbs b/sig/openai/models/beta/threads/file_citation_annotation.rbs index 8c9eadaa..da859605 100644 --- a/sig/openai/models/beta/threads/file_citation_annotation.rbs +++ b/sig/openai/models/beta/threads/file_citation_annotation.rbs @@ -22,18 +22,13 @@ module OpenAI attr_accessor type: :file_citation - def initialize: - ( - end_index: Integer, - file_citation: OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation, - start_index: Integer, - text: String, - type: :file_citation - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::file_citation_annotation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + end_index: Integer, + file_citation: OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation, + start_index: Integer, + text: String, + ?type: :file_citation + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::file_citation_annotation @@ -42,12 +37,7 @@ module OpenAI class FileCitation < OpenAI::BaseModel attr_accessor file_id: String - def initialize: - (file_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::FileCitationAnnotation::file_citation - | OpenAI::BaseModel data - ) -> void + def initialize: (file_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::FileCitationAnnotation::file_citation end diff --git a/sig/openai/models/beta/threads/file_citation_delta_annotation.rbs b/sig/openai/models/beta/threads/file_citation_delta_annotation.rbs index 933da760..09994a1b 100644 --- a/sig/openai/models/beta/threads/file_citation_delta_annotation.rbs +++ b/sig/openai/models/beta/threads/file_citation_delta_annotation.rbs @@ -35,19 +35,14 @@ module OpenAI def text=: (String) -> String - def initialize: - ( - index: Integer, - end_index: Integer, - file_citation: OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, - start_index: Integer, - text: String, - type: :file_citation - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::file_citation_delta_annotation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?end_index: Integer, + ?file_citation: OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, + ?start_index: Integer, + ?text: String, + ?type: :file_citation + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::file_citation_delta_annotation @@ -62,12 +57,7 @@ module OpenAI def quote=: (String) -> String - def initialize: - (file_id: String, quote: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::file_citation - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_id: String, ?quote: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::file_citation end diff --git a/sig/openai/models/beta/threads/file_path_annotation.rbs b/sig/openai/models/beta/threads/file_path_annotation.rbs index 7c590adb..d3e7acc5 100644 --- a/sig/openai/models/beta/threads/file_path_annotation.rbs +++ b/sig/openai/models/beta/threads/file_path_annotation.rbs @@ -22,18 +22,13 @@ module OpenAI attr_accessor type: :file_path - def initialize: - ( - end_index: Integer, - file_path: OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath, - start_index: Integer, - text: String, - type: :file_path - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::file_path_annotation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + end_index: Integer, + file_path: OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath, + start_index: Integer, + text: String, + ?type: :file_path + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::file_path_annotation @@ -42,12 +37,7 @@ module OpenAI class FilePath < OpenAI::BaseModel attr_accessor file_id: String - def initialize: - (file_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::FilePathAnnotation::file_path - | OpenAI::BaseModel data - ) -> void + def initialize: (file_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::FilePathAnnotation::file_path end diff --git a/sig/openai/models/beta/threads/file_path_delta_annotation.rbs b/sig/openai/models/beta/threads/file_path_delta_annotation.rbs index 536a311d..6c8e2380 100644 --- a/sig/openai/models/beta/threads/file_path_delta_annotation.rbs +++ b/sig/openai/models/beta/threads/file_path_delta_annotation.rbs @@ -35,19 +35,14 @@ module OpenAI def text=: (String) -> String - def initialize: - ( - index: Integer, - end_index: Integer, - file_path: OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, - start_index: Integer, - text: String, - type: :file_path - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::file_path_delta_annotation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?end_index: Integer, + ?file_path: OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, + ?start_index: Integer, + ?text: String, + ?type: :file_path + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::file_path_delta_annotation @@ -58,12 +53,7 @@ module OpenAI def file_id=: (String) -> String - def initialize: - (file_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::file_path - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::file_path end diff --git a/sig/openai/models/beta/threads/image_file.rbs b/sig/openai/models/beta/threads/image_file.rbs index 2d2fb9e4..0fb507cc 100644 --- a/sig/openai/models/beta/threads/image_file.rbs +++ b/sig/openai/models/beta/threads/image_file.rbs @@ -17,26 +17,23 @@ module OpenAI OpenAI::Models::Beta::Threads::ImageFile::detail ) -> OpenAI::Models::Beta::Threads::ImageFile::detail - def initialize: - ( - file_id: String, - detail: OpenAI::Models::Beta::Threads::ImageFile::detail - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_file - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + ?detail: OpenAI::Models::Beta::Threads::ImageFile::detail + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_file type detail = :auto | :low | :high - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO: :auto LOW: :low HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageFile::detail] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageFile::detail] end end end diff --git a/sig/openai/models/beta/threads/image_file_content_block.rbs b/sig/openai/models/beta/threads/image_file_content_block.rbs index 5267e2c7..7f0e99ee 100644 --- a/sig/openai/models/beta/threads/image_file_content_block.rbs +++ b/sig/openai/models/beta/threads/image_file_content_block.rbs @@ -13,15 +13,10 @@ module OpenAI attr_accessor type: :image_file - def initialize: - ( - image_file: OpenAI::Models::Beta::Threads::ImageFile, - type: :image_file - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_file_content_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + image_file: OpenAI::Models::Beta::Threads::ImageFile, + ?type: :image_file + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_file_content_block end diff --git a/sig/openai/models/beta/threads/image_file_delta.rbs b/sig/openai/models/beta/threads/image_file_delta.rbs index bf715b22..f645c00f 100644 --- a/sig/openai/models/beta/threads/image_file_delta.rbs +++ b/sig/openai/models/beta/threads/image_file_delta.rbs @@ -19,26 +19,23 @@ module OpenAI def file_id=: (String) -> String - def initialize: - ( - detail: OpenAI::Models::Beta::Threads::ImageFileDelta::detail, - file_id: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_file_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?detail: OpenAI::Models::Beta::Threads::ImageFileDelta::detail, + ?file_id: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_file_delta type detail = :auto | :low | :high - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO: :auto LOW: :low HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageFileDelta::detail] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageFileDelta::detail] end end end diff --git a/sig/openai/models/beta/threads/image_file_delta_block.rbs b/sig/openai/models/beta/threads/image_file_delta_block.rbs index 1dc26a44..e7e85e2b 100644 --- a/sig/openai/models/beta/threads/image_file_delta_block.rbs +++ b/sig/openai/models/beta/threads/image_file_delta_block.rbs @@ -20,16 +20,11 @@ module OpenAI OpenAI::Models::Beta::Threads::ImageFileDelta ) -> OpenAI::Models::Beta::Threads::ImageFileDelta - def initialize: - ( - index: Integer, - image_file: OpenAI::Models::Beta::Threads::ImageFileDelta, - type: :image_file - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_file_delta_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?image_file: OpenAI::Models::Beta::Threads::ImageFileDelta, + ?type: :image_file + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_file_delta_block end diff --git a/sig/openai/models/beta/threads/image_url.rbs b/sig/openai/models/beta/threads/image_url.rbs index f786387e..6039ca67 100644 --- a/sig/openai/models/beta/threads/image_url.rbs +++ b/sig/openai/models/beta/threads/image_url.rbs @@ -17,25 +17,23 @@ module OpenAI OpenAI::Models::Beta::Threads::ImageURL::detail ) -> OpenAI::Models::Beta::Threads::ImageURL::detail - def initialize: - ( - url: String, - detail: OpenAI::Models::Beta::Threads::ImageURL::detail - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_url | OpenAI::BaseModel data - ) -> void + def initialize: ( + url: String, + ?detail: OpenAI::Models::Beta::Threads::ImageURL::detail + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_url type detail = :auto | :low | :high - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO: :auto LOW: :low HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageURL::detail] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageURL::detail] end end end diff --git a/sig/openai/models/beta/threads/image_url_content_block.rbs b/sig/openai/models/beta/threads/image_url_content_block.rbs index 13d90d01..bd4eb8a7 100644 --- a/sig/openai/models/beta/threads/image_url_content_block.rbs +++ b/sig/openai/models/beta/threads/image_url_content_block.rbs @@ -13,15 +13,10 @@ module OpenAI attr_accessor type: :image_url - def initialize: - ( - image_url: OpenAI::Models::Beta::Threads::ImageURL, - type: :image_url - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_url_content_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + image_url: OpenAI::Models::Beta::Threads::ImageURL, + ?type: :image_url + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_url_content_block end diff --git a/sig/openai/models/beta/threads/image_url_delta.rbs b/sig/openai/models/beta/threads/image_url_delta.rbs index 6f5c92ca..9cd1c721 100644 --- a/sig/openai/models/beta/threads/image_url_delta.rbs +++ b/sig/openai/models/beta/threads/image_url_delta.rbs @@ -19,26 +19,23 @@ module OpenAI def url=: (String) -> String - def initialize: - ( - detail: OpenAI::Models::Beta::Threads::ImageURLDelta::detail, - url: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_url_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?detail: OpenAI::Models::Beta::Threads::ImageURLDelta::detail, + ?url: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_url_delta type detail = :auto | :low | :high - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO: :auto LOW: :low HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageURLDelta::detail] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::ImageURLDelta::detail] end end end diff --git a/sig/openai/models/beta/threads/image_url_delta_block.rbs b/sig/openai/models/beta/threads/image_url_delta_block.rbs index 37b1861a..7e548334 100644 --- a/sig/openai/models/beta/threads/image_url_delta_block.rbs +++ b/sig/openai/models/beta/threads/image_url_delta_block.rbs @@ -20,16 +20,11 @@ module OpenAI OpenAI::Models::Beta::Threads::ImageURLDelta ) -> OpenAI::Models::Beta::Threads::ImageURLDelta - def initialize: - ( - index: Integer, - image_url: OpenAI::Models::Beta::Threads::ImageURLDelta, - type: :image_url - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::image_url_delta_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?image_url: OpenAI::Models::Beta::Threads::ImageURLDelta, + ?type: :image_url + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::image_url_delta_block end diff --git a/sig/openai/models/beta/threads/message.rbs b/sig/openai/models/beta/threads/message.rbs index 40d2be8d..e9a83633 100644 --- a/sig/openai/models/beta/threads/message.rbs +++ b/sig/openai/models/beta/threads/message.rbs @@ -49,26 +49,22 @@ module OpenAI attr_accessor thread_id: String - def initialize: - ( - id: String, - assistant_id: String?, - attachments: ::Array[OpenAI::Models::Beta::Threads::Message::Attachment]?, - completed_at: Integer?, - content: ::Array[OpenAI::Models::Beta::Threads::message_content], - created_at: Integer, - incomplete_at: Integer?, - incomplete_details: OpenAI::Models::Beta::Threads::Message::IncompleteDetails?, - metadata: OpenAI::Models::metadata?, - role: OpenAI::Models::Beta::Threads::Message::role, - run_id: String?, - status: OpenAI::Models::Beta::Threads::Message::status, - thread_id: String, - object: :"thread.message" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + assistant_id: String?, + attachments: ::Array[OpenAI::Models::Beta::Threads::Message::Attachment]?, + completed_at: Integer?, + content: ::Array[OpenAI::Models::Beta::Threads::message_content], + created_at: Integer, + incomplete_at: Integer?, + incomplete_details: OpenAI::Models::Beta::Threads::Message::IncompleteDetails?, + metadata: OpenAI::Models::metadata?, + role: OpenAI::Models::Beta::Threads::Message::role, + run_id: String?, + status: OpenAI::Models::Beta::Threads::Message::status, + thread_id: String, + ?object: :"thread.message" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message @@ -89,15 +85,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Message::Attachment::tool] ) -> ::Array[OpenAI::Models::Beta::Threads::Message::Attachment::tool] - def initialize: - ( - file_id: String, - tools: ::Array[OpenAI::Models::Beta::Threads::Message::Attachment::tool] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Message::attachment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_id: String, + ?tools: ::Array[OpenAI::Models::Beta::Threads::Message::Attachment::tool] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Message::attachment @@ -105,24 +96,21 @@ module OpenAI OpenAI::Models::Beta::CodeInterpreterTool | OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + type assistant_tools_file_search_type_only = { type: :file_search } class AssistantToolsFileSearchTypeOnly < OpenAI::BaseModel attr_accessor type: :file_search - def initialize: - (type: :file_search) -> void - | ( - ?OpenAI::Models::Beta::Threads::Message::Attachment::Tool::assistant_tools_file_search_type_only - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :file_search) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Message::Attachment::Tool::assistant_tools_file_search_type_only end - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly] + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly] end end @@ -134,14 +122,9 @@ module OpenAI class IncompleteDetails < OpenAI::BaseModel attr_accessor reason: OpenAI::Models::Beta::Threads::Message::IncompleteDetails::reason - def initialize: - ( - reason: OpenAI::Models::Beta::Threads::Message::IncompleteDetails::reason - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Message::incomplete_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + reason: OpenAI::Models::Beta::Threads::Message::IncompleteDetails::reason + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Message::incomplete_details @@ -152,34 +135,40 @@ module OpenAI | :run_expired | :run_failed - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + CONTENT_FILTER: :content_filter MAX_TOKENS: :max_tokens RUN_CANCELLED: :run_cancelled RUN_EXPIRED: :run_expired RUN_FAILED: :run_failed - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::IncompleteDetails::reason] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::IncompleteDetails::reason] end end type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::role] end type status = :in_progress | :incomplete | :completed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress INCOMPLETE: :incomplete COMPLETED: :completed - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::status] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Message::status] end end end diff --git a/sig/openai/models/beta/threads/message_content.rbs b/sig/openai/models/beta/threads/message_content.rbs index 252bb7ff..fda3bd19 100644 --- a/sig/openai/models/beta/threads/message_content.rbs +++ b/sig/openai/models/beta/threads/message_content.rbs @@ -8,8 +8,10 @@ module OpenAI | OpenAI::Models::Beta::Threads::TextContentBlock | OpenAI::Models::Beta::Threads::RefusalContentBlock - class MessageContent < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock] + module MessageContent + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock] end end end diff --git a/sig/openai/models/beta/threads/message_content_delta.rbs b/sig/openai/models/beta/threads/message_content_delta.rbs index aab10ba6..c143f0ac 100644 --- a/sig/openai/models/beta/threads/message_content_delta.rbs +++ b/sig/openai/models/beta/threads/message_content_delta.rbs @@ -8,8 +8,10 @@ module OpenAI | OpenAI::Models::Beta::Threads::RefusalDeltaBlock | OpenAI::Models::Beta::Threads::ImageURLDeltaBlock - class MessageContentDelta < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock] + module MessageContentDelta + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock] end end end diff --git a/sig/openai/models/beta/threads/message_content_part_param.rbs b/sig/openai/models/beta/threads/message_content_part_param.rbs index 39228e33..9749af26 100644 --- a/sig/openai/models/beta/threads/message_content_part_param.rbs +++ b/sig/openai/models/beta/threads/message_content_part_param.rbs @@ -7,8 +7,10 @@ module OpenAI | OpenAI::Models::Beta::Threads::ImageURLContentBlock | OpenAI::Models::Beta::Threads::TextContentBlockParam - class MessageContentPartParam < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam] + module MessageContentPartParam + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam] end end end diff --git a/sig/openai/models/beta/threads/message_create_params.rbs b/sig/openai/models/beta/threads/message_create_params.rbs index 9e3451c3..0c2147d8 100644 --- a/sig/openai/models/beta/threads/message_create_params.rbs +++ b/sig/openai/models/beta/threads/message_create_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class MessageCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor content: OpenAI::Models::Beta::Threads::MessageCreateParams::content @@ -23,18 +23,13 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - content: OpenAI::Models::Beta::Threads::MessageCreateParams::content, - role: OpenAI::Models::Beta::Threads::MessageCreateParams::role, - attachments: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]?, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Beta::Threads::MessageCreateParams::content, + role: OpenAI::Models::Beta::Threads::MessageCreateParams::role, + ?attachments: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]?, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_create_params @@ -42,22 +37,26 @@ module OpenAI String | ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] + type message_content_part_param_array = ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] MessageContentPartParamArray: message_content_part_param_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] end type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::role] end type attachment = @@ -77,15 +76,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::tool] ) -> ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::tool] - def initialize: - ( - file_id: String, - tools: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::tool] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::MessageCreateParams::attachment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_id: String, + ?tools: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::tool] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::MessageCreateParams::attachment @@ -93,23 +87,20 @@ module OpenAI OpenAI::Models::Beta::CodeInterpreterTool | OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + type file_search = { type: :file_search } class FileSearch < OpenAI::BaseModel attr_accessor type: :file_search - def initialize: - (type: :file_search) -> void - | ( - ?OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :file_search) -> void def to_hash: -> OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::file_search end - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch] + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch] end end end diff --git a/sig/openai/models/beta/threads/message_delete_params.rbs b/sig/openai/models/beta/threads/message_delete_params.rbs index 0b6c4e94..fb823dfa 100644 --- a/sig/openai/models/beta/threads/message_delete_params.rbs +++ b/sig/openai/models/beta/threads/message_delete_params.rbs @@ -6,17 +6,15 @@ module OpenAI { thread_id: String } & OpenAI::request_parameters class MessageDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String - def initialize: - (thread_id: String, request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_delete_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_delete_params end diff --git a/sig/openai/models/beta/threads/message_deleted.rbs b/sig/openai/models/beta/threads/message_deleted.rbs index 58941655..f6d3a96e 100644 --- a/sig/openai/models/beta/threads/message_deleted.rbs +++ b/sig/openai/models/beta/threads/message_deleted.rbs @@ -12,16 +12,11 @@ module OpenAI attr_accessor object: :"thread.message.deleted" - def initialize: - ( - id: String, - deleted: bool, - object: :"thread.message.deleted" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_deleted - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"thread.message.deleted" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_deleted end diff --git a/sig/openai/models/beta/threads/message_delta.rbs b/sig/openai/models/beta/threads/message_delta.rbs index 2c4dd70b..f40f44ea 100644 --- a/sig/openai/models/beta/threads/message_delta.rbs +++ b/sig/openai/models/beta/threads/message_delta.rbs @@ -21,25 +21,22 @@ module OpenAI OpenAI::Models::Beta::Threads::MessageDelta::role ) -> OpenAI::Models::Beta::Threads::MessageDelta::role - def initialize: - ( - content: ::Array[OpenAI::Models::Beta::Threads::message_content_delta], - role: OpenAI::Models::Beta::Threads::MessageDelta::role - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?content: ::Array[OpenAI::Models::Beta::Threads::message_content_delta], + ?role: OpenAI::Models::Beta::Threads::MessageDelta::role + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_delta type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageDelta::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageDelta::role] end end end diff --git a/sig/openai/models/beta/threads/message_delta_event.rbs b/sig/openai/models/beta/threads/message_delta_event.rbs index f682114b..d34c13f6 100644 --- a/sig/openai/models/beta/threads/message_delta_event.rbs +++ b/sig/openai/models/beta/threads/message_delta_event.rbs @@ -16,16 +16,11 @@ module OpenAI attr_accessor object: :"thread.message.delta" - def initialize: - ( - id: String, - delta: OpenAI::Models::Beta::Threads::MessageDelta, - object: :"thread.message.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + delta: OpenAI::Models::Beta::Threads::MessageDelta, + ?object: :"thread.message.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_delta_event end diff --git a/sig/openai/models/beta/threads/message_list_params.rbs b/sig/openai/models/beta/threads/message_list_params.rbs index ec8567b0..66fd88db 100644 --- a/sig/openai/models/beta/threads/message_list_params.rbs +++ b/sig/openai/models/beta/threads/message_list_params.rbs @@ -13,7 +13,7 @@ module OpenAI & OpenAI::request_parameters class MessageListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -38,29 +38,26 @@ module OpenAI def run_id=: (String) -> String - def initialize: - ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::Threads::MessageListParams::order, - run_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::MessageListParams::order, + ?run_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::MessageListParams::order] end end end diff --git a/sig/openai/models/beta/threads/message_retrieve_params.rbs b/sig/openai/models/beta/threads/message_retrieve_params.rbs index f5475f00..29cfa699 100644 --- a/sig/openai/models/beta/threads/message_retrieve_params.rbs +++ b/sig/openai/models/beta/threads/message_retrieve_params.rbs @@ -6,17 +6,15 @@ module OpenAI { thread_id: String } & OpenAI::request_parameters class MessageRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String - def initialize: - (thread_id: String, request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_retrieve_params end diff --git a/sig/openai/models/beta/threads/message_update_params.rbs b/sig/openai/models/beta/threads/message_update_params.rbs index 5fb9f563..5ccea8ed 100644 --- a/sig/openai/models/beta/threads/message_update_params.rbs +++ b/sig/openai/models/beta/threads/message_update_params.rbs @@ -7,23 +7,18 @@ module OpenAI & OpenAI::request_parameters class MessageUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - thread_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::message_update_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::message_update_params end diff --git a/sig/openai/models/beta/threads/refusal_content_block.rbs b/sig/openai/models/beta/threads/refusal_content_block.rbs index b44bf064..041435a5 100644 --- a/sig/openai/models/beta/threads/refusal_content_block.rbs +++ b/sig/openai/models/beta/threads/refusal_content_block.rbs @@ -9,12 +9,7 @@ module OpenAI attr_accessor type: :refusal - def initialize: - (refusal: String, type: :refusal) -> void - | ( - ?OpenAI::Models::Beta::Threads::refusal_content_block - | OpenAI::BaseModel data - ) -> void + def initialize: (refusal: String, ?type: :refusal) -> void def to_hash: -> OpenAI::Models::Beta::Threads::refusal_content_block end diff --git a/sig/openai/models/beta/threads/refusal_delta_block.rbs b/sig/openai/models/beta/threads/refusal_delta_block.rbs index eae553e9..635407d5 100644 --- a/sig/openai/models/beta/threads/refusal_delta_block.rbs +++ b/sig/openai/models/beta/threads/refusal_delta_block.rbs @@ -14,12 +14,11 @@ module OpenAI def refusal=: (String) -> String - def initialize: - (index: Integer, refusal: String, type: :refusal) -> void - | ( - ?OpenAI::Models::Beta::Threads::refusal_delta_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?refusal: String, + ?type: :refusal + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::refusal_delta_block end diff --git a/sig/openai/models/beta/threads/required_action_function_tool_call.rbs b/sig/openai/models/beta/threads/required_action_function_tool_call.rbs index 3b4334bf..9429819f 100644 --- a/sig/openai/models/beta/threads/required_action_function_tool_call.rbs +++ b/sig/openai/models/beta/threads/required_action_function_tool_call.rbs @@ -16,16 +16,11 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - id: String, - function: OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function, - type: :function - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::required_action_function_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + function: OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::required_action_function_tool_call @@ -36,12 +31,7 @@ module OpenAI attr_accessor name: String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::function - | OpenAI::BaseModel data - ) -> void + def initialize: (arguments: String, name: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::function end diff --git a/sig/openai/models/beta/threads/run.rbs b/sig/openai/models/beta/threads/run.rbs index fc4b4d57..c36d145c 100644 --- a/sig/openai/models/beta/threads/run.rbs +++ b/sig/openai/models/beta/threads/run.rbs @@ -88,39 +88,35 @@ module OpenAI attr_accessor top_p: Float? - def initialize: - ( - id: String, - assistant_id: String, - cancelled_at: Integer?, - completed_at: Integer?, - created_at: Integer, - expires_at: Integer?, - failed_at: Integer?, - incomplete_details: OpenAI::Models::Beta::Threads::Run::IncompleteDetails?, - instructions: String, - last_error: OpenAI::Models::Beta::Threads::Run::LastError?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: String, - parallel_tool_calls: bool, - required_action: OpenAI::Models::Beta::Threads::Run::RequiredAction?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - started_at: Integer?, - status: OpenAI::Models::Beta::Threads::run_status, - thread_id: String, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - truncation_strategy: OpenAI::Models::Beta::Threads::Run::TruncationStrategy?, - usage: OpenAI::Models::Beta::Threads::Run::Usage?, - temperature: Float?, - top_p: Float?, - object: :"thread.run" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::run | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + assistant_id: String, + cancelled_at: Integer?, + completed_at: Integer?, + created_at: Integer, + expires_at: Integer?, + failed_at: Integer?, + incomplete_details: OpenAI::Models::Beta::Threads::Run::IncompleteDetails?, + instructions: String, + last_error: OpenAI::Models::Beta::Threads::Run::LastError?, + max_completion_tokens: Integer?, + max_prompt_tokens: Integer?, + metadata: OpenAI::Models::metadata?, + model: String, + parallel_tool_calls: bool, + required_action: OpenAI::Models::Beta::Threads::Run::RequiredAction?, + response_format: OpenAI::Models::Beta::assistant_response_format_option?, + started_at: Integer?, + status: OpenAI::Models::Beta::Threads::run_status, + thread_id: String, + tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + tools: ::Array[OpenAI::Models::Beta::assistant_tool], + truncation_strategy: OpenAI::Models::Beta::Threads::Run::TruncationStrategy?, + usage: OpenAI::Models::Beta::Threads::Run::Usage?, + ?temperature: Float?, + ?top_p: Float?, + ?object: :"thread.run" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run @@ -136,24 +132,21 @@ module OpenAI OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason ) -> OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason - def initialize: - ( - reason: OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::incomplete_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?reason: OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::incomplete_details type reason = :max_completion_tokens | :max_prompt_tokens - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + MAX_COMPLETION_TOKENS: :max_completion_tokens MAX_PROMPT_TOKENS: :max_prompt_tokens - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::IncompleteDetails::reason] end end @@ -168,26 +161,23 @@ module OpenAI attr_accessor message: String - def initialize: - ( - code: OpenAI::Models::Beta::Threads::Run::LastError::code, - message: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::last_error - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: OpenAI::Models::Beta::Threads::Run::LastError::code, + message: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::last_error type code = :server_error | :rate_limit_exceeded | :invalid_prompt - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR: :server_error RATE_LIMIT_EXCEEDED: :rate_limit_exceeded INVALID_PROMPT: :invalid_prompt - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::LastError::code] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::LastError::code] end end @@ -202,15 +192,10 @@ module OpenAI attr_accessor type: :submit_tool_outputs - def initialize: - ( - submit_tool_outputs: OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs, - type: :submit_tool_outputs - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::required_action - | OpenAI::BaseModel data - ) -> void + def initialize: ( + submit_tool_outputs: OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs, + ?type: :submit_tool_outputs + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::required_action @@ -222,14 +207,9 @@ module OpenAI class SubmitToolOutputs < OpenAI::BaseModel attr_accessor tool_calls: ::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall] - def initialize: - ( - tool_calls: ::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::RequiredAction::submit_tool_outputs - | OpenAI::BaseModel data - ) -> void + def initialize: ( + tool_calls: ::Array[OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::RequiredAction::submit_tool_outputs end @@ -246,25 +226,22 @@ module OpenAI attr_accessor last_messages: Integer? - def initialize: - ( - type: OpenAI::Models::Beta::Threads::Run::TruncationStrategy::type_, - last_messages: Integer? - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::truncation_strategy - | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Beta::Threads::Run::TruncationStrategy::type_, + ?last_messages: Integer? + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::truncation_strategy type type_ = :auto | :last_messages - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO: :auto LAST_MESSAGES: :last_messages - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::TruncationStrategy::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Run::TruncationStrategy::type_] end end @@ -282,16 +259,11 @@ module OpenAI attr_accessor total_tokens: Integer - def initialize: - ( - completion_tokens: Integer, - prompt_tokens: Integer, - total_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Run::usage - | OpenAI::BaseModel data - ) -> void + def initialize: ( + completion_tokens: Integer, + prompt_tokens: Integer, + total_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Run::usage end diff --git a/sig/openai/models/beta/threads/run_cancel_params.rbs b/sig/openai/models/beta/threads/run_cancel_params.rbs index 34ea5c7f..93ad8eb6 100644 --- a/sig/openai/models/beta/threads/run_cancel_params.rbs +++ b/sig/openai/models/beta/threads/run_cancel_params.rbs @@ -6,17 +6,15 @@ module OpenAI { thread_id: String } & OpenAI::request_parameters class RunCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String - def initialize: - (thread_id: String, request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_cancel_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_cancel_params end diff --git a/sig/openai/models/beta/threads/run_create_params.rbs b/sig/openai/models/beta/threads/run_create_params.rbs index 09105c8f..3ed348c1 100644 --- a/sig/openai/models/beta/threads/run_create_params.rbs +++ b/sig/openai/models/beta/threads/run_create_params.rbs @@ -25,7 +25,7 @@ module OpenAI & OpenAI::request_parameters class RunCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor assistant_id: String @@ -68,31 +68,26 @@ module OpenAI attr_accessor truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy? - def initialize: - ( - assistant_id: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - additional_instructions: String?, - additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, - parallel_tool_calls: bool, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + assistant_id: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?additional_instructions: String?, + ?additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, + ?parallel_tool_calls: bool, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_create_params @@ -113,17 +108,12 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - content: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::content, - role: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::role, - attachments: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]?, - metadata: OpenAI::Models::metadata? - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::RunCreateParams::additional_message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::content, + role: OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::role, + ?attachments: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]?, + ?metadata: OpenAI::Models::metadata? + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RunCreateParams::additional_message @@ -131,22 +121,26 @@ module OpenAI String | ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] + type message_content_part_param_array = ::Array[OpenAI::Models::Beta::Threads::message_content_part_param] MessageContentPartParamArray: message_content_part_param_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Beta::Threads::message_content_part_param]] end type role = :user | :assistant - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::role] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::role] end type attachment = @@ -166,15 +160,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::tool] ) -> ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::tool] - def initialize: - ( - file_id: String, - tools: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::tool] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::attachment - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_id: String, + ?tools: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::tool] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::attachment @@ -182,31 +171,30 @@ module OpenAI OpenAI::Models::Beta::CodeInterpreterTool | OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch - class Tool < OpenAI::Union + module Tool + extend OpenAI::Union + type file_search = { type: :file_search } class FileSearch < OpenAI::BaseModel attr_accessor type: :file_search - def initialize: - (type: :file_search) -> void - | ( - ?OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :file_search) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::file_search end - def self.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch] + def self?.variants: -> [OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch] end end end type model = String | OpenAI::Models::chat_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model] end type truncation_strategy = @@ -220,25 +208,22 @@ module OpenAI attr_accessor last_messages: Integer? - def initialize: - ( - type: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::type_, - last_messages: Integer? - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::RunCreateParams::truncation_strategy - | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::type_, + ?last_messages: Integer? + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RunCreateParams::truncation_strategy type type_ = :auto | :last_messages - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AUTO: :auto LAST_MESSAGES: :last_messages - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::type_] end end end diff --git a/sig/openai/models/beta/threads/run_list_params.rbs b/sig/openai/models/beta/threads/run_list_params.rbs index ba37749f..15e3c05c 100644 --- a/sig/openai/models/beta/threads/run_list_params.rbs +++ b/sig/openai/models/beta/threads/run_list_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class RunListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -33,28 +33,25 @@ module OpenAI OpenAI::Models::Beta::Threads::RunListParams::order ) -> OpenAI::Models::Beta::Threads::RunListParams::order - def initialize: - ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::Threads::RunListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::RunListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::RunListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::RunListParams::order] end end end diff --git a/sig/openai/models/beta/threads/run_retrieve_params.rbs b/sig/openai/models/beta/threads/run_retrieve_params.rbs index 44423e27..ab99f4b4 100644 --- a/sig/openai/models/beta/threads/run_retrieve_params.rbs +++ b/sig/openai/models/beta/threads/run_retrieve_params.rbs @@ -6,17 +6,15 @@ module OpenAI { thread_id: String } & OpenAI::request_parameters class RunRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String - def initialize: - (thread_id: String, request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_retrieve_params end diff --git a/sig/openai/models/beta/threads/run_status.rbs b/sig/openai/models/beta/threads/run_status.rbs index cfc75c7b..4b0e430b 100644 --- a/sig/openai/models/beta/threads/run_status.rbs +++ b/sig/openai/models/beta/threads/run_status.rbs @@ -13,7 +13,9 @@ module OpenAI | :incomplete | :expired - class RunStatus < OpenAI::Enum + module RunStatus + extend OpenAI::Enum + QUEUED: :queued IN_PROGRESS: :in_progress REQUIRES_ACTION: :requires_action @@ -24,7 +26,7 @@ module OpenAI INCOMPLETE: :incomplete EXPIRED: :expired - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::run_status] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::run_status] end end end diff --git a/sig/openai/models/beta/threads/run_submit_tool_outputs_params.rbs b/sig/openai/models/beta/threads/run_submit_tool_outputs_params.rbs index d044c675..6619a57c 100644 --- a/sig/openai/models/beta/threads/run_submit_tool_outputs_params.rbs +++ b/sig/openai/models/beta/threads/run_submit_tool_outputs_params.rbs @@ -10,23 +10,18 @@ module OpenAI & OpenAI::request_parameters class RunSubmitToolOutputsParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String attr_accessor tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput] - def initialize: - ( - thread_id: String, - tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_submit_tool_outputs_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_submit_tool_outputs_params @@ -41,12 +36,7 @@ module OpenAI def tool_call_id=: (String) -> String - def initialize: - (output: String, tool_call_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::tool_output - | OpenAI::BaseModel data - ) -> void + def initialize: (?output: String, ?tool_call_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::tool_output end diff --git a/sig/openai/models/beta/threads/run_update_params.rbs b/sig/openai/models/beta/threads/run_update_params.rbs index ad8a6e84..2e8e547d 100644 --- a/sig/openai/models/beta/threads/run_update_params.rbs +++ b/sig/openai/models/beta/threads/run_update_params.rbs @@ -7,23 +7,18 @@ module OpenAI & OpenAI::request_parameters class RunUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - thread_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::run_update_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::run_update_params end diff --git a/sig/openai/models/beta/threads/runs/code_interpreter_logs.rbs b/sig/openai/models/beta/threads/runs/code_interpreter_logs.rbs index d62fbb78..85c320b0 100644 --- a/sig/openai/models/beta/threads/runs/code_interpreter_logs.rbs +++ b/sig/openai/models/beta/threads/runs/code_interpreter_logs.rbs @@ -15,12 +15,11 @@ module OpenAI def logs=: (String) -> String - def initialize: - (index: Integer, logs: String, type: :logs) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::code_interpreter_logs - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?logs: String, + ?type: :logs + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::code_interpreter_logs end diff --git a/sig/openai/models/beta/threads/runs/code_interpreter_output_image.rbs b/sig/openai/models/beta/threads/runs/code_interpreter_output_image.rbs index 2560a0c4..f640b74e 100644 --- a/sig/openai/models/beta/threads/runs/code_interpreter_output_image.rbs +++ b/sig/openai/models/beta/threads/runs/code_interpreter_output_image.rbs @@ -21,16 +21,11 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image ) -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image - def initialize: - ( - index: Integer, - image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, - type: :image - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::code_interpreter_output_image - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, + ?type: :image + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::code_interpreter_output_image @@ -41,12 +36,7 @@ module OpenAI def file_id=: (String) -> String - def initialize: - (file_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::image - | OpenAI::BaseModel data - ) -> void + def initialize: (?file_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::image end diff --git a/sig/openai/models/beta/threads/runs/code_interpreter_tool_call.rbs b/sig/openai/models/beta/threads/runs/code_interpreter_tool_call.rbs index 41731b5a..fa6f7865 100644 --- a/sig/openai/models/beta/threads/runs/code_interpreter_tool_call.rbs +++ b/sig/openai/models/beta/threads/runs/code_interpreter_tool_call.rbs @@ -17,16 +17,11 @@ module OpenAI attr_accessor type: :code_interpreter - def initialize: - ( - id: String, - code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter, - type: :code_interpreter - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::code_interpreter_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter, + ?type: :code_interpreter + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::code_interpreter_tool_call @@ -41,15 +36,10 @@ module OpenAI attr_accessor outputs: ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::output] - def initialize: - ( - input: String, - outputs: ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::output] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: ( + input: String, + outputs: ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::output] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::code_interpreter @@ -57,7 +47,9 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs | OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image - class Output < OpenAI::Union + module Output + extend OpenAI::Union + type logs = { logs: String, type: :logs } class Logs < OpenAI::BaseModel @@ -65,12 +57,7 @@ module OpenAI attr_accessor type: :logs - def initialize: - (logs: String, type: :logs) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::logs - | OpenAI::BaseModel data - ) -> void + def initialize: (logs: String, ?type: :logs) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::logs end @@ -86,15 +73,10 @@ module OpenAI attr_accessor type: :image - def initialize: - ( - image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image, - type: :image - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::image - | OpenAI::BaseModel data - ) -> void + def initialize: ( + image: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image, + ?type: :image + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::image @@ -103,18 +85,13 @@ module OpenAI class Image < OpenAI::BaseModel attr_accessor file_id: String - def initialize: - (file_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::image - | OpenAI::BaseModel data - ) -> void + def initialize: (file_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::image end end - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image] + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image] end end end diff --git a/sig/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbs b/sig/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbs index 7a808c31..32dc3fb8 100644 --- a/sig/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbs +++ b/sig/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rbs @@ -26,17 +26,12 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter ) -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter - def initialize: - ( - index: Integer, - id: String, - code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, - type: :code_interpreter - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::code_interpreter_tool_call_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?id: String, + ?code_interpreter: OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, + ?type: :code_interpreter + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::code_interpreter_tool_call_delta @@ -57,15 +52,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter::output] ) -> ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter::output] - def initialize: - ( - input: String, - outputs: ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter::output] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::code_interpreter - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?input: String, + ?outputs: ::Array[OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter::output] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::code_interpreter @@ -73,8 +63,10 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs | OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage - class Output < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage] + module Output + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage] end end end diff --git a/sig/openai/models/beta/threads/runs/file_search_tool_call.rbs b/sig/openai/models/beta/threads/runs/file_search_tool_call.rbs index e8476225..f5a993d3 100644 --- a/sig/openai/models/beta/threads/runs/file_search_tool_call.rbs +++ b/sig/openai/models/beta/threads/runs/file_search_tool_call.rbs @@ -17,16 +17,11 @@ module OpenAI attr_accessor type: :file_search - def initialize: - ( - id: String, - file_search: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch, - type: :file_search - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::file_search_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + file_search: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch, + ?type: :file_search + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::file_search_tool_call @@ -49,15 +44,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result] ) -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result] - def initialize: - ( - ranking_options: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, - results: ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::file_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?ranking_options: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, + ?results: ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::file_search @@ -72,25 +62,22 @@ module OpenAI attr_accessor score_threshold: Float - def initialize: - ( - ranker: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::ranker, - score_threshold: Float - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::ranking_options - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ranker: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::ranker, + score_threshold: Float + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::ranking_options type ranker = :auto | :default_2024_08_21 - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO: :auto DEFAULT_2024_08_21: :default_2024_08_21 - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::ranker] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::ranker] end end @@ -115,17 +102,12 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content] ) -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content] - def initialize: - ( - file_id: String, - file_name: String, - score: Float, - content: ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content] - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::result - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + file_name: String, + score: Float, + ?content: ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content] + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::result @@ -146,24 +128,21 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_ ) -> OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_ - def initialize: - ( - text: String, - type: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_ - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::content - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?text: String, + ?type: OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_ + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::content type type_ = :text - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::type_] end end end diff --git a/sig/openai/models/beta/threads/runs/file_search_tool_call_delta.rbs b/sig/openai/models/beta/threads/runs/file_search_tool_call_delta.rbs index 91172bba..11ae3dc7 100644 --- a/sig/openai/models/beta/threads/runs/file_search_tool_call_delta.rbs +++ b/sig/openai/models/beta/threads/runs/file_search_tool_call_delta.rbs @@ -17,17 +17,12 @@ module OpenAI def id=: (String) -> String - def initialize: - ( - file_search: top, - index: Integer, - id: String, - type: :file_search - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::file_search_tool_call_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_search: top, + index: Integer, + ?id: String, + ?type: :file_search + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::file_search_tool_call_delta end diff --git a/sig/openai/models/beta/threads/runs/function_tool_call.rbs b/sig/openai/models/beta/threads/runs/function_tool_call.rbs index d3c415c2..c3e9168a 100644 --- a/sig/openai/models/beta/threads/runs/function_tool_call.rbs +++ b/sig/openai/models/beta/threads/runs/function_tool_call.rbs @@ -17,16 +17,11 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - id: String, - function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function, - type: :function - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::function_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::function_tool_call @@ -39,12 +34,11 @@ module OpenAI attr_accessor output: String? - def initialize: - (arguments: String, name: String, output: String?) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::function - | OpenAI::BaseModel data - ) -> void + def initialize: ( + arguments: String, + name: String, + output: String? + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::function end diff --git a/sig/openai/models/beta/threads/runs/function_tool_call_delta.rbs b/sig/openai/models/beta/threads/runs/function_tool_call_delta.rbs index 8a6261a4..f6a01247 100644 --- a/sig/openai/models/beta/threads/runs/function_tool_call_delta.rbs +++ b/sig/openai/models/beta/threads/runs/function_tool_call_delta.rbs @@ -26,17 +26,12 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function ) -> OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function - def initialize: - ( - index: Integer, - id: String, - function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, - type: :function - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::function_tool_call_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?id: String, + ?function: OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::function_tool_call_delta @@ -53,12 +48,11 @@ module OpenAI attr_accessor output: String? - def initialize: - (arguments: String, name: String, output: String?) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::function - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?arguments: String, + ?name: String, + ?output: String? + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::function end diff --git a/sig/openai/models/beta/threads/runs/message_creation_step_details.rbs b/sig/openai/models/beta/threads/runs/message_creation_step_details.rbs index 5eb94efe..3ddacf7b 100644 --- a/sig/openai/models/beta/threads/runs/message_creation_step_details.rbs +++ b/sig/openai/models/beta/threads/runs/message_creation_step_details.rbs @@ -14,15 +14,10 @@ module OpenAI attr_accessor type: :message_creation - def initialize: - ( - message_creation: OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation, - type: :message_creation - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::message_creation_step_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + message_creation: OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation, + ?type: :message_creation + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::message_creation_step_details @@ -31,12 +26,7 @@ module OpenAI class MessageCreation < OpenAI::BaseModel attr_accessor message_id: String - def initialize: - (message_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::message_creation - | OpenAI::BaseModel data - ) -> void + def initialize: (message_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::message_creation end diff --git a/sig/openai/models/beta/threads/runs/run_step.rbs b/sig/openai/models/beta/threads/runs/run_step.rbs index af3c7db7..a60e10a6 100644 --- a/sig/openai/models/beta/threads/runs/run_step.rbs +++ b/sig/openai/models/beta/threads/runs/run_step.rbs @@ -2,7 +2,6 @@ module OpenAI module Models module Beta module Threads - class RunStep = Runs::RunStep module Runs @@ -59,29 +58,24 @@ module OpenAI attr_accessor usage: OpenAI::Models::Beta::Threads::Runs::RunStep::Usage? - def initialize: - ( - id: String, - assistant_id: String, - cancelled_at: Integer?, - completed_at: Integer?, - created_at: Integer, - expired_at: Integer?, - failed_at: Integer?, - last_error: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError?, - metadata: OpenAI::Models::metadata?, - run_id: String, - status: OpenAI::Models::Beta::Threads::Runs::RunStep::status, - step_details: OpenAI::Models::Beta::Threads::Runs::RunStep::step_details, - thread_id: String, - type: OpenAI::Models::Beta::Threads::Runs::RunStep::type_, - usage: OpenAI::Models::Beta::Threads::Runs::RunStep::Usage?, - object: :"thread.run.step" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::run_step - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + assistant_id: String, + cancelled_at: Integer?, + completed_at: Integer?, + created_at: Integer, + expired_at: Integer?, + failed_at: Integer?, + last_error: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError?, + metadata: OpenAI::Models::metadata?, + run_id: String, + status: OpenAI::Models::Beta::Threads::Runs::RunStep::status, + step_details: OpenAI::Models::Beta::Threads::Runs::RunStep::step_details, + thread_id: String, + type: OpenAI::Models::Beta::Threads::Runs::RunStep::type_, + usage: OpenAI::Models::Beta::Threads::Runs::RunStep::Usage?, + ?object: :"thread.run.step" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::run_step @@ -96,56 +90,59 @@ module OpenAI attr_accessor message: String - def initialize: - ( - code: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::code, - message: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::RunStep::last_error - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::code, + message: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::RunStep::last_error type code = :server_error | :rate_limit_exceeded - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR: :server_error RATE_LIMIT_EXCEEDED: :rate_limit_exceeded - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::code] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::code] end end type status = :in_progress | :cancelled | :failed | :completed | :expired - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress CANCELLED: :cancelled FAILED: :failed COMPLETED: :completed EXPIRED: :expired - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::status] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::status] end type step_details = OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails | OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails - class StepDetails < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails] + module StepDetails + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails] end type type_ = :message_creation | :tool_calls - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE_CREATION: :message_creation TOOL_CALLS: :tool_calls - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::type_] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::RunStep::type_] end type usage = @@ -162,16 +159,11 @@ module OpenAI attr_accessor total_tokens: Integer - def initialize: - ( - completion_tokens: Integer, - prompt_tokens: Integer, - total_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::RunStep::usage - | OpenAI::BaseModel data - ) -> void + def initialize: ( + completion_tokens: Integer, + prompt_tokens: Integer, + total_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::RunStep::usage end diff --git a/sig/openai/models/beta/threads/runs/run_step_delta.rbs b/sig/openai/models/beta/threads/runs/run_step_delta.rbs index 9c5a49d3..45b48449 100644 --- a/sig/openai/models/beta/threads/runs/run_step_delta.rbs +++ b/sig/openai/models/beta/threads/runs/run_step_delta.rbs @@ -2,7 +2,6 @@ module OpenAI module Models module Beta module Threads - class RunStepDelta = Runs::RunStepDelta module Runs @@ -18,14 +17,9 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::RunStepDelta::step_details ) -> OpenAI::Models::Beta::Threads::Runs::RunStepDelta::step_details - def initialize: - ( - step_details: OpenAI::Models::Beta::Threads::Runs::RunStepDelta::step_details - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::run_step_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?step_details: OpenAI::Models::Beta::Threads::Runs::RunStepDelta::step_details + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::run_step_delta @@ -33,8 +27,10 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta | OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject - class StepDetails < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject] + module StepDetails + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject] end end end diff --git a/sig/openai/models/beta/threads/runs/run_step_delta_event.rbs b/sig/openai/models/beta/threads/runs/run_step_delta_event.rbs index 717849fb..295594a8 100644 --- a/sig/openai/models/beta/threads/runs/run_step_delta_event.rbs +++ b/sig/openai/models/beta/threads/runs/run_step_delta_event.rbs @@ -2,7 +2,6 @@ module OpenAI module Models module Beta module Threads - class RunStepDeltaEvent = Runs::RunStepDeltaEvent module Runs @@ -20,16 +19,11 @@ module OpenAI attr_accessor object: :"thread.run.step.delta" - def initialize: - ( - id: String, - delta: OpenAI::Models::Beta::Threads::Runs::RunStepDelta, - object: :"thread.run.step.delta" - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::run_step_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + delta: OpenAI::Models::Beta::Threads::Runs::RunStepDelta, + ?object: :"thread.run.step.delta" + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::run_step_delta_event end diff --git a/sig/openai/models/beta/threads/runs/run_step_delta_message_delta.rbs b/sig/openai/models/beta/threads/runs/run_step_delta_message_delta.rbs index cd740a0f..d1daf15e 100644 --- a/sig/openai/models/beta/threads/runs/run_step_delta_message_delta.rbs +++ b/sig/openai/models/beta/threads/runs/run_step_delta_message_delta.rbs @@ -2,7 +2,6 @@ module OpenAI module Models module Beta module Threads - class RunStepDeltaMessageDelta = Runs::RunStepDeltaMessageDelta module Runs @@ -21,15 +20,10 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation ) -> OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation - def initialize: - ( - message_creation: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, - type: :message_creation - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::run_step_delta_message_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?message_creation: OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, + ?type: :message_creation + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::run_step_delta_message_delta @@ -40,12 +34,7 @@ module OpenAI def message_id=: (String) -> String - def initialize: - (message_id: String) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::message_creation - | OpenAI::BaseModel data - ) -> void + def initialize: (?message_id: String) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::message_creation end diff --git a/sig/openai/models/beta/threads/runs/run_step_include.rbs b/sig/openai/models/beta/threads/runs/run_step_include.rbs index be00b41f..529038db 100644 --- a/sig/openai/models/beta/threads/runs/run_step_include.rbs +++ b/sig/openai/models/beta/threads/runs/run_step_include.rbs @@ -2,17 +2,18 @@ module OpenAI module Models module Beta module Threads - - class RunStepInclude = Runs::RunStepInclude + module RunStepInclude = Runs::RunStepInclude module Runs type run_step_include = :"step_details.tool_calls[*].file_search.results[*].content" - class RunStepInclude < OpenAI::Enum + module RunStepInclude + extend OpenAI::Enum + STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT: :"step_details.tool_calls[*].file_search.results[*].content" - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include] end end end diff --git a/sig/openai/models/beta/threads/runs/step_list_params.rbs b/sig/openai/models/beta/threads/runs/step_list_params.rbs index 1ff2c6fc..ee7ffc2d 100644 --- a/sig/openai/models/beta/threads/runs/step_list_params.rbs +++ b/sig/openai/models/beta/threads/runs/step_list_params.rbs @@ -15,7 +15,7 @@ module OpenAI & OpenAI::request_parameters class StepListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String @@ -44,30 +44,27 @@ module OpenAI OpenAI::Models::Beta::Threads::Runs::StepListParams::order ) -> OpenAI::Models::Beta::Threads::Runs::StepListParams::order - def initialize: - ( - thread_id: String, - after: String, - before: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - limit: Integer, - order: OpenAI::Models::Beta::Threads::Runs::StepListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::step_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + ?after: String, + ?before: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::Runs::StepListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::step_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::StepListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Beta::Threads::Runs::StepListParams::order] end end end diff --git a/sig/openai/models/beta/threads/runs/step_retrieve_params.rbs b/sig/openai/models/beta/threads/runs/step_retrieve_params.rbs index cfeb8e95..08140619 100644 --- a/sig/openai/models/beta/threads/runs/step_retrieve_params.rbs +++ b/sig/openai/models/beta/threads/runs/step_retrieve_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class StepRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor thread_id: String @@ -25,17 +25,12 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include] ) -> ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include] - def initialize: - ( - thread_id: String, - run_id: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::step_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + thread_id: String, + run_id: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::step_retrieve_params end diff --git a/sig/openai/models/beta/threads/runs/tool_call.rbs b/sig/openai/models/beta/threads/runs/tool_call.rbs index 42300b3c..2d13d06d 100644 --- a/sig/openai/models/beta/threads/runs/tool_call.rbs +++ b/sig/openai/models/beta/threads/runs/tool_call.rbs @@ -8,8 +8,10 @@ module OpenAI | OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall | OpenAI::Models::Beta::Threads::Runs::FunctionToolCall - class ToolCall < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall] + module ToolCall + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall] end end end diff --git a/sig/openai/models/beta/threads/runs/tool_call_delta.rbs b/sig/openai/models/beta/threads/runs/tool_call_delta.rbs index 6c3c0ec7..2e349dcd 100644 --- a/sig/openai/models/beta/threads/runs/tool_call_delta.rbs +++ b/sig/openai/models/beta/threads/runs/tool_call_delta.rbs @@ -8,8 +8,10 @@ module OpenAI | OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta | OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta - class ToolCallDelta < OpenAI::Union - def self.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta] + module ToolCallDelta + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta] end end end diff --git a/sig/openai/models/beta/threads/runs/tool_call_delta_object.rbs b/sig/openai/models/beta/threads/runs/tool_call_delta_object.rbs index 68e23f3a..50619aae 100644 --- a/sig/openai/models/beta/threads/runs/tool_call_delta_object.rbs +++ b/sig/openai/models/beta/threads/runs/tool_call_delta_object.rbs @@ -18,15 +18,10 @@ module OpenAI ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call_delta] ) -> ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call_delta] - def initialize: - ( - tool_calls: ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call_delta], - type: :tool_calls - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::tool_call_delta_object - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?tool_calls: ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call_delta], + ?type: :tool_calls + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::tool_call_delta_object end diff --git a/sig/openai/models/beta/threads/runs/tool_calls_step_details.rbs b/sig/openai/models/beta/threads/runs/tool_calls_step_details.rbs index 156c02c6..7f5c8851 100644 --- a/sig/openai/models/beta/threads/runs/tool_calls_step_details.rbs +++ b/sig/openai/models/beta/threads/runs/tool_calls_step_details.rbs @@ -14,15 +14,10 @@ module OpenAI attr_accessor type: :tool_calls - def initialize: - ( - tool_calls: ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call], - type: :tool_calls - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::Runs::tool_calls_step_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + tool_calls: ::Array[OpenAI::Models::Beta::Threads::Runs::tool_call], + ?type: :tool_calls + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::Runs::tool_calls_step_details end diff --git a/sig/openai/models/beta/threads/text.rbs b/sig/openai/models/beta/threads/text.rbs index 4311ade7..1c4ebeb3 100644 --- a/sig/openai/models/beta/threads/text.rbs +++ b/sig/openai/models/beta/threads/text.rbs @@ -13,14 +13,10 @@ module OpenAI attr_accessor value: String - def initialize: - ( - annotations: ::Array[OpenAI::Models::Beta::Threads::annotation], - value: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::text | OpenAI::BaseModel data - ) -> void + def initialize: ( + annotations: ::Array[OpenAI::Models::Beta::Threads::annotation], + value: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::text end diff --git a/sig/openai/models/beta/threads/text_content_block.rbs b/sig/openai/models/beta/threads/text_content_block.rbs index 57b71af4..b83f4585 100644 --- a/sig/openai/models/beta/threads/text_content_block.rbs +++ b/sig/openai/models/beta/threads/text_content_block.rbs @@ -10,12 +10,10 @@ module OpenAI attr_accessor type: :text - def initialize: - (text: OpenAI::Models::Beta::Threads::Text, type: :text) -> void - | ( - ?OpenAI::Models::Beta::Threads::text_content_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + text: OpenAI::Models::Beta::Threads::Text, + ?type: :text + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::text_content_block end diff --git a/sig/openai/models/beta/threads/text_content_block_param.rbs b/sig/openai/models/beta/threads/text_content_block_param.rbs index 669f9eed..bf0b5b7e 100644 --- a/sig/openai/models/beta/threads/text_content_block_param.rbs +++ b/sig/openai/models/beta/threads/text_content_block_param.rbs @@ -9,12 +9,7 @@ module OpenAI attr_accessor type: :text - def initialize: - (text: String, type: :text) -> void - | ( - ?OpenAI::Models::Beta::Threads::text_content_block_param - | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :text) -> void def to_hash: -> OpenAI::Models::Beta::Threads::text_content_block_param end diff --git a/sig/openai/models/beta/threads/text_delta.rbs b/sig/openai/models/beta/threads/text_delta.rbs index 9156cf24..721b012e 100644 --- a/sig/openai/models/beta/threads/text_delta.rbs +++ b/sig/openai/models/beta/threads/text_delta.rbs @@ -19,15 +19,10 @@ module OpenAI def value=: (String) -> String - def initialize: - ( - annotations: ::Array[OpenAI::Models::Beta::Threads::annotation_delta], - value: String - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::text_delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?annotations: ::Array[OpenAI::Models::Beta::Threads::annotation_delta], + ?value: String + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::text_delta end diff --git a/sig/openai/models/beta/threads/text_delta_block.rbs b/sig/openai/models/beta/threads/text_delta_block.rbs index 263bd619..2a03d985 100644 --- a/sig/openai/models/beta/threads/text_delta_block.rbs +++ b/sig/openai/models/beta/threads/text_delta_block.rbs @@ -20,16 +20,11 @@ module OpenAI OpenAI::Models::Beta::Threads::TextDelta ) -> OpenAI::Models::Beta::Threads::TextDelta - def initialize: - ( - index: Integer, - text: OpenAI::Models::Beta::Threads::TextDelta, - type: :text - ) -> void - | ( - ?OpenAI::Models::Beta::Threads::text_delta_block - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?text: OpenAI::Models::Beta::Threads::TextDelta, + ?type: :text + ) -> void def to_hash: -> OpenAI::Models::Beta::Threads::text_delta_block end diff --git a/sig/openai/models/chat/chat_completion.rbs b/sig/openai/models/chat/chat_completion.rbs index b0f0b6b3..b0013010 100644 --- a/sig/openai/models/chat/chat_completion.rbs +++ b/sig/openai/models/chat/chat_completion.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletion = Chat::ChatCompletion module Chat @@ -39,20 +38,16 @@ module OpenAI OpenAI::Models::CompletionUsage ) -> OpenAI::Models::CompletionUsage - def initialize: - ( - id: String, - choices: ::Array[OpenAI::Models::Chat::ChatCompletion::Choice], - created: Integer, - model: String, - service_tier: OpenAI::Models::Chat::ChatCompletion::service_tier?, - system_fingerprint: String, - usage: OpenAI::Models::CompletionUsage, - object: :"chat.completion" - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + choices: ::Array[OpenAI::Models::Chat::ChatCompletion::Choice], + created: Integer, + model: String, + ?service_tier: OpenAI::Models::Chat::ChatCompletion::service_tier?, + ?system_fingerprint: String, + ?usage: OpenAI::Models::CompletionUsage, + ?object: :"chat.completion" + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion @@ -73,31 +68,28 @@ module OpenAI attr_accessor message: OpenAI::Models::Chat::ChatCompletionMessage - def initialize: - ( - finish_reason: OpenAI::Models::Chat::ChatCompletion::Choice::finish_reason, - index: Integer, - logprobs: OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs?, - message: OpenAI::Models::Chat::ChatCompletionMessage - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletion::choice - | OpenAI::BaseModel data - ) -> void + def initialize: ( + finish_reason: OpenAI::Models::Chat::ChatCompletion::Choice::finish_reason, + index: Integer, + logprobs: OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs?, + message: OpenAI::Models::Chat::ChatCompletionMessage + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletion::choice type finish_reason = :stop | :length | :tool_calls | :content_filter | :function_call - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP: :stop LENGTH: :length TOOL_CALLS: :tool_calls CONTENT_FILTER: :content_filter FUNCTION_CALL: :function_call - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletion::Choice::finish_reason] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletion::Choice::finish_reason] end type logprobs = @@ -111,15 +103,10 @@ module OpenAI attr_accessor refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? - def initialize: - ( - content: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]?, - refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletion::Choice::logprobs - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]?, + refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletion::Choice::logprobs end @@ -127,11 +114,13 @@ module OpenAI type service_tier = :scale | :default - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + SCALE: :scale DEFAULT: :default - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletion::service_tier] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletion::service_tier] end end end diff --git a/sig/openai/models/chat/chat_completion_assistant_message_param.rbs b/sig/openai/models/chat/chat_completion_assistant_message_param.rbs index f481adde..968d73be 100644 --- a/sig/openai/models/chat/chat_completion_assistant_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_assistant_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionAssistantMessageParam = Chat::ChatCompletionAssistantMessageParam module Chat @@ -36,20 +35,15 @@ module OpenAI ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall] ) -> ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall] - def initialize: - ( - audio: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio?, - content: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::content?, - function_call: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall?, - name: String, - refusal: String?, - tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], - role: :assistant - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_assistant_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?audio: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio?, + ?content: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::content?, + ?function_call: OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall?, + ?name: String, + ?refusal: String?, + ?tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], + ?role: :assistant + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_assistant_message_param @@ -58,12 +52,7 @@ module OpenAI class Audio < OpenAI::BaseModel attr_accessor id: String - def initialize: - (id: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::audio - | OpenAI::BaseModel data - ) -> void + def initialize: (id: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::audio end @@ -72,21 +61,25 @@ module OpenAI String | ::Array[OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::array_of_content_part] - class Content < OpenAI::Union - type array_of_content_part_array = - ::Array[OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::array_of_content_part] - - ArrayOfContentPartArray: array_of_content_part_array + module Content + extend OpenAI::Union type array_of_content_part = OpenAI::Models::Chat::ChatCompletionContentPartText | OpenAI::Models::Chat::ChatCompletionContentPartRefusal - class ArrayOfContentPart < OpenAI::Union - def self.variants: -> [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal] + module ArrayOfContentPart + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal] end - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::array_of_content_part]] + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::array_of_content_part]] + + type array_of_content_part_array = + ::Array[OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::array_of_content_part] + + ArrayOfContentPartArray: array_of_content_part_array end type function_call = { arguments: String, name: String } @@ -96,12 +89,7 @@ module OpenAI attr_accessor name: String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::function_call - | OpenAI::BaseModel data - ) -> void + def initialize: (arguments: String, name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::function_call end diff --git a/sig/openai/models/chat/chat_completion_audio.rbs b/sig/openai/models/chat/chat_completion_audio.rbs index f7d13734..a3b3cda4 100644 --- a/sig/openai/models/chat/chat_completion_audio.rbs +++ b/sig/openai/models/chat/chat_completion_audio.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionAudio = Chat::ChatCompletionAudio module Chat @@ -16,17 +15,12 @@ module OpenAI attr_accessor transcript: String - def initialize: - ( - id: String, - data: String, - expires_at: Integer, - transcript: String - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_audio - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + data: String, + expires_at: Integer, + transcript: String + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_audio end diff --git a/sig/openai/models/chat/chat_completion_audio_param.rbs b/sig/openai/models/chat/chat_completion_audio_param.rbs index 6a35e189..dc4be41d 100644 --- a/sig/openai/models/chat/chat_completion_audio_param.rbs +++ b/sig/openai/models/chat/chat_completion_audio_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionAudioParam = Chat::ChatCompletionAudioParam module Chat @@ -15,44 +14,67 @@ module OpenAI attr_accessor voice: OpenAI::Models::Chat::ChatCompletionAudioParam::voice - def initialize: - ( - format_: OpenAI::Models::Chat::ChatCompletionAudioParam::format_, - voice: OpenAI::Models::Chat::ChatCompletionAudioParam::voice - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_audio_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + format_: OpenAI::Models::Chat::ChatCompletionAudioParam::format_, + voice: OpenAI::Models::Chat::ChatCompletionAudioParam::voice + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_audio_param type format_ = :wav | :mp3 | :flac | :opus | :pcm16 - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + WAV: :wav MP3: :mp3 FLAC: :flac OPUS: :opus PCM16: :pcm16 - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionAudioParam::format_] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionAudioParam::format_] end type voice = - :alloy | :ash | :ballad | :coral | :echo | :sage | :shimmer | :verse + String + | :alloy + | :ash + | :ballad + | :coral + | :echo + | :fable + | :onyx + | :nova + | :sage + | :shimmer + | :verse + + module Voice + extend OpenAI::Union + + def self?.variants: -> [String, (:alloy + | :ash + | :ballad + | :coral + | :echo + | :fable + | :onyx + | :nova + | :sage + | :shimmer + | :verse)] - class Voice < OpenAI::Enum ALLOY: :alloy ASH: :ash BALLAD: :ballad CORAL: :coral ECHO: :echo + FABLE: :fable + ONYX: :onyx + NOVA: :nova SAGE: :sage SHIMMER: :shimmer VERSE: :verse - - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionAudioParam::voice] end end end diff --git a/sig/openai/models/chat/chat_completion_chunk.rbs b/sig/openai/models/chat/chat_completion_chunk.rbs index 980b2889..1ec7aadf 100644 --- a/sig/openai/models/chat/chat_completion_chunk.rbs +++ b/sig/openai/models/chat/chat_completion_chunk.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionChunk = Chat::ChatCompletionChunk module Chat @@ -35,21 +34,16 @@ module OpenAI attr_accessor usage: OpenAI::Models::CompletionUsage? - def initialize: - ( - id: String, - choices: ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice], - created: Integer, - model: String, - service_tier: OpenAI::Models::Chat::ChatCompletionChunk::service_tier?, - system_fingerprint: String, - usage: OpenAI::Models::CompletionUsage?, - object: :"chat.completion.chunk" - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_chunk - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + choices: ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice], + created: Integer, + model: String, + ?service_tier: OpenAI::Models::Chat::ChatCompletionChunk::service_tier?, + ?system_fingerprint: String, + ?usage: OpenAI::Models::CompletionUsage?, + ?object: :"chat.completion.chunk" + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_chunk @@ -70,17 +64,12 @@ module OpenAI attr_accessor logprobs: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs? - def initialize: - ( - delta: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, - finish_reason: OpenAI::Models::Chat::ChatCompletionChunk::Choice::finish_reason?, - index: Integer, - logprobs: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs? - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::choice - | OpenAI::BaseModel data - ) -> void + def initialize: ( + delta: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta, + finish_reason: OpenAI::Models::Chat::ChatCompletionChunk::Choice::finish_reason?, + index: Integer, + ?logprobs: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs? + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::choice @@ -116,18 +105,13 @@ module OpenAI ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] ) -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] - def initialize: - ( - content: String?, - function_call: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, - refusal: String?, - role: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::role, - tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::Choice::delta - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?content: String?, + ?function_call: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, + ?refusal: String?, + ?role: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::role, + ?tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall] + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::delta @@ -142,26 +126,23 @@ module OpenAI def name=: (String) -> String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::function_call - | OpenAI::BaseModel data - ) -> void + def initialize: (?arguments: String, ?name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::function_call end type role = :developer | :system | :user | :assistant | :tool - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + DEVELOPER: :developer SYSTEM: :system USER: :user ASSISTANT: :assistant TOOL: :tool - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::role] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::role] end type tool_call = @@ -191,17 +172,12 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_ ) -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_ - def initialize: - ( - index: Integer, - id: String, - function: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, - type: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_ - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + index: Integer, + ?id: String, + ?function: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, + ?type: OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_ + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::tool_call @@ -216,22 +192,19 @@ module OpenAI def name=: (String) -> String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::function - | OpenAI::BaseModel data - ) -> void + def initialize: (?arguments: String, ?name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::function end type type_ = :function - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FUNCTION: :function - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::type_] end end end @@ -239,14 +212,16 @@ module OpenAI type finish_reason = :stop | :length | :tool_calls | :content_filter | :function_call - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP: :stop LENGTH: :length TOOL_CALLS: :tool_calls CONTENT_FILTER: :content_filter FUNCTION_CALL: :function_call - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::finish_reason] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Choice::finish_reason] end type logprobs = @@ -260,15 +235,10 @@ module OpenAI attr_accessor refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? - def initialize: - ( - content: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]?, - refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionChunk::Choice::logprobs - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]?, + refusal: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob]? + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionChunk::Choice::logprobs end @@ -276,11 +246,13 @@ module OpenAI type service_tier = :scale | :default - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + SCALE: :scale DEFAULT: :default - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::service_tier] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionChunk::service_tier] end end end diff --git a/sig/openai/models/chat/chat_completion_content_part.rbs b/sig/openai/models/chat/chat_completion_content_part.rbs index 31333ab5..df907b34 100644 --- a/sig/openai/models/chat/chat_completion_content_part.rbs +++ b/sig/openai/models/chat/chat_completion_content_part.rbs @@ -1,7 +1,6 @@ module OpenAI module Models - - class ChatCompletionContentPart = Chat::ChatCompletionContentPart + module ChatCompletionContentPart = Chat::ChatCompletionContentPart module Chat type chat_completion_content_part = @@ -10,7 +9,9 @@ module OpenAI | OpenAI::Models::Chat::ChatCompletionContentPartInputAudio | OpenAI::Models::Chat::ChatCompletionContentPart::File - class ChatCompletionContentPart < OpenAI::Union + module ChatCompletionContentPart + extend OpenAI::Union + type file = { file: OpenAI::Models::Chat::ChatCompletionContentPart::File::File, @@ -22,19 +23,14 @@ module OpenAI attr_accessor type: :file - def initialize: - ( - file: OpenAI::Models::Chat::ChatCompletionContentPart::File::File, - type: :file - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionContentPart::file - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file: OpenAI::Models::Chat::ChatCompletionContentPart::File::File, + ?type: :file + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionContentPart::file - type file = { file_data: String, file_id: String, file_name: String } + type file = { file_data: String, file_id: String, filename: String } class File < OpenAI::BaseModel attr_reader file_data: String? @@ -45,22 +41,21 @@ module OpenAI def file_id=: (String) -> String - attr_reader file_name: String? + attr_reader filename: String? - def file_name=: (String) -> String + def filename=: (String) -> String - def initialize: - (file_data: String, file_id: String, file_name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionContentPart::File::file - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_data: String, + ?file_id: String, + ?filename: String + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionContentPart::File::file end end - def self.variants: -> [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File] + def self?.variants: -> [OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File] end end end diff --git a/sig/openai/models/chat/chat_completion_content_part_image.rbs b/sig/openai/models/chat/chat_completion_content_part_image.rbs index df324202..d8ca22d9 100644 --- a/sig/openai/models/chat/chat_completion_content_part_image.rbs +++ b/sig/openai/models/chat/chat_completion_content_part_image.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionContentPartImage = Chat::ChatCompletionContentPartImage module Chat @@ -15,15 +14,10 @@ module OpenAI attr_accessor type: :image_url - def initialize: - ( - image_url: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL, - type: :image_url - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_content_part_image - | OpenAI::BaseModel data - ) -> void + def initialize: ( + image_url: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL, + ?type: :image_url + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_content_part_image @@ -42,26 +36,23 @@ module OpenAI OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail ) -> OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail - def initialize: - ( - url: String, - detail: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionContentPartImage::image_url - | OpenAI::BaseModel data - ) -> void + def initialize: ( + url: String, + ?detail: OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionContentPartImage::image_url type detail = :auto | :low | :high - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + AUTO: :auto LOW: :low HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::detail] end end end diff --git a/sig/openai/models/chat/chat_completion_content_part_input_audio.rbs b/sig/openai/models/chat/chat_completion_content_part_input_audio.rbs index 5bec0fc3..8d40f203 100644 --- a/sig/openai/models/chat/chat_completion_content_part_input_audio.rbs +++ b/sig/openai/models/chat/chat_completion_content_part_input_audio.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionContentPartInputAudio = Chat::ChatCompletionContentPartInputAudio module Chat @@ -15,15 +14,10 @@ module OpenAI attr_accessor type: :input_audio - def initialize: - ( - input_audio: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio, - type: :input_audio - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_content_part_input_audio - | OpenAI::BaseModel data - ) -> void + def initialize: ( + input_audio: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio, + ?type: :input_audio + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_content_part_input_audio @@ -38,25 +32,22 @@ module OpenAI attr_accessor format_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::format_ - def initialize: - ( - data: String, - format_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::format_ - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::input_audio - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: String, + format_: OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::format_ + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::input_audio type format_ = :wav | :mp3 - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + WAV: :wav MP3: :mp3 - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::format_] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::format_] end end end diff --git a/sig/openai/models/chat/chat_completion_content_part_refusal.rbs b/sig/openai/models/chat/chat_completion_content_part_refusal.rbs index 98e94526..e715e480 100644 --- a/sig/openai/models/chat/chat_completion_content_part_refusal.rbs +++ b/sig/openai/models/chat/chat_completion_content_part_refusal.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionContentPartRefusal = Chat::ChatCompletionContentPartRefusal module Chat @@ -12,12 +11,7 @@ module OpenAI attr_accessor type: :refusal - def initialize: - (refusal: String, type: :refusal) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_content_part_refusal - | OpenAI::BaseModel data - ) -> void + def initialize: (refusal: String, ?type: :refusal) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_content_part_refusal end diff --git a/sig/openai/models/chat/chat_completion_content_part_text.rbs b/sig/openai/models/chat/chat_completion_content_part_text.rbs index 36f4b5a1..638f5e4e 100644 --- a/sig/openai/models/chat/chat_completion_content_part_text.rbs +++ b/sig/openai/models/chat/chat_completion_content_part_text.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionContentPartText = Chat::ChatCompletionContentPartText module Chat @@ -11,12 +10,7 @@ module OpenAI attr_accessor type: :text - def initialize: - (text: String, type: :text) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_content_part_text - | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :text) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_content_part_text end diff --git a/sig/openai/models/chat/chat_completion_deleted.rbs b/sig/openai/models/chat/chat_completion_deleted.rbs index 824a0a21..e776fc71 100644 --- a/sig/openai/models/chat/chat_completion_deleted.rbs +++ b/sig/openai/models/chat/chat_completion_deleted.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionDeleted = Chat::ChatCompletionDeleted module Chat @@ -14,16 +13,11 @@ module OpenAI attr_accessor object: :"chat.completion.deleted" - def initialize: - ( - id: String, - deleted: bool, - object: :"chat.completion.deleted" - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_deleted - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"chat.completion.deleted" + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_deleted end diff --git a/sig/openai/models/chat/chat_completion_developer_message_param.rbs b/sig/openai/models/chat/chat_completion_developer_message_param.rbs index bcc12871..9bd2727c 100644 --- a/sig/openai/models/chat/chat_completion_developer_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_developer_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionDeveloperMessageParam = Chat::ChatCompletionDeveloperMessageParam module Chat @@ -20,29 +19,26 @@ module OpenAI def name=: (String) -> String - def initialize: - ( - content: OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam::content, - name: String, - role: :developer - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_developer_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam::content, + ?name: String, + ?role: :developer + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_developer_message_param type content = String | ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] + type chat_completion_content_part_text_array = ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] ChatCompletionContentPartTextArray: chat_completion_content_part_text_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] end end end diff --git a/sig/openai/models/chat/chat_completion_function_call_option.rbs b/sig/openai/models/chat/chat_completion_function_call_option.rbs index fdc44315..e7067a87 100644 --- a/sig/openai/models/chat/chat_completion_function_call_option.rbs +++ b/sig/openai/models/chat/chat_completion_function_call_option.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionFunctionCallOption = Chat::ChatCompletionFunctionCallOption module Chat @@ -9,12 +8,7 @@ module OpenAI class ChatCompletionFunctionCallOption < OpenAI::BaseModel attr_accessor name: String - def initialize: - (name: String) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_function_call_option - | OpenAI::BaseModel data - ) -> void + def initialize: (name: String) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_function_call_option end diff --git a/sig/openai/models/chat/chat_completion_function_message_param.rbs b/sig/openai/models/chat/chat_completion_function_message_param.rbs index dca0f275..fad91c63 100644 --- a/sig/openai/models/chat/chat_completion_function_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_function_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionFunctionMessageParam = Chat::ChatCompletionFunctionMessageParam module Chat @@ -14,12 +13,11 @@ module OpenAI attr_accessor role: :function - def initialize: - (content: String?, name: String, role: :function) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_function_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: String?, + name: String, + ?role: :function + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_function_message_param end diff --git a/sig/openai/models/chat/chat_completion_message.rbs b/sig/openai/models/chat/chat_completion_message.rbs index 16b8a72a..d3668749 100644 --- a/sig/openai/models/chat/chat_completion_message.rbs +++ b/sig/openai/models/chat/chat_completion_message.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionMessage = Chat::ChatCompletionMessage module Chat @@ -42,20 +41,15 @@ module OpenAI ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall] ) -> ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall] - def initialize: - ( - content: String?, - refusal: String?, - annotations: ::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation], - audio: OpenAI::Models::Chat::ChatCompletionAudio?, - function_call: OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, - tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], - role: :assistant - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: String?, + refusal: String?, + ?annotations: ::Array[OpenAI::Models::Chat::ChatCompletionMessage::Annotation], + ?audio: OpenAI::Models::Chat::ChatCompletionAudio?, + ?function_call: OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, + ?tool_calls: ::Array[OpenAI::Models::Chat::ChatCompletionMessageToolCall], + ?role: :assistant + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_message @@ -70,15 +64,10 @@ module OpenAI attr_accessor url_citation: OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation - def initialize: - ( - url_citation: OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation, - type: :url_citation - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionMessage::annotation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + url_citation: OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation, + ?type: :url_citation + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionMessage::annotation @@ -99,17 +88,12 @@ module OpenAI attr_accessor url: String - def initialize: - ( - end_index: Integer, - start_index: Integer, - title: String, - url: String - ) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionMessage::Annotation::url_citation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + end_index: Integer, + start_index: Integer, + title: String, + url: String + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionMessage::Annotation::url_citation end @@ -122,12 +106,7 @@ module OpenAI attr_accessor name: String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionMessage::function_call - | OpenAI::BaseModel data - ) -> void + def initialize: (arguments: String, name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionMessage::function_call end diff --git a/sig/openai/models/chat/chat_completion_message_param.rbs b/sig/openai/models/chat/chat_completion_message_param.rbs index a42d88ca..557d3c2c 100644 --- a/sig/openai/models/chat/chat_completion_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_message_param.rbs @@ -1,7 +1,6 @@ module OpenAI module Models - - class ChatCompletionMessageParam = Chat::ChatCompletionMessageParam + module ChatCompletionMessageParam = Chat::ChatCompletionMessageParam module Chat type chat_completion_message_param = @@ -12,8 +11,10 @@ module OpenAI | OpenAI::Models::Chat::ChatCompletionToolMessageParam | OpenAI::Models::Chat::ChatCompletionFunctionMessageParam - class ChatCompletionMessageParam < OpenAI::Union - def self.variants: -> [OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam] + module ChatCompletionMessageParam + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam] end end end diff --git a/sig/openai/models/chat/chat_completion_message_tool_call.rbs b/sig/openai/models/chat/chat_completion_message_tool_call.rbs index 797c8c1c..cd147e2d 100644 --- a/sig/openai/models/chat/chat_completion_message_tool_call.rbs +++ b/sig/openai/models/chat/chat_completion_message_tool_call.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionMessageToolCall = Chat::ChatCompletionMessageToolCall module Chat @@ -18,16 +17,11 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - id: String, - function: OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function, - type: :function - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_message_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + function: OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_message_tool_call @@ -38,12 +32,7 @@ module OpenAI attr_accessor name: String - def initialize: - (arguments: String, name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionMessageToolCall::function - | OpenAI::BaseModel data - ) -> void + def initialize: (arguments: String, name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionMessageToolCall::function end diff --git a/sig/openai/models/chat/chat_completion_modality.rbs b/sig/openai/models/chat/chat_completion_modality.rbs index e8df5962..b634c024 100644 --- a/sig/openai/models/chat/chat_completion_modality.rbs +++ b/sig/openai/models/chat/chat_completion_modality.rbs @@ -1,16 +1,17 @@ module OpenAI module Models - - class ChatCompletionModality = Chat::ChatCompletionModality + module ChatCompletionModality = Chat::ChatCompletionModality module Chat type chat_completion_modality = :text | :audio - class ChatCompletionModality < OpenAI::Enum + module ChatCompletionModality + extend OpenAI::Enum + TEXT: :text AUDIO: :audio - def self.values: -> ::Array[OpenAI::Models::Chat::chat_completion_modality] + def self?.values: -> ::Array[OpenAI::Models::Chat::chat_completion_modality] end end end diff --git a/sig/openai/models/chat/chat_completion_named_tool_choice.rbs b/sig/openai/models/chat/chat_completion_named_tool_choice.rbs index e71c5191..62feb1bf 100644 --- a/sig/openai/models/chat/chat_completion_named_tool_choice.rbs +++ b/sig/openai/models/chat/chat_completion_named_tool_choice.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionNamedToolChoice = Chat::ChatCompletionNamedToolChoice module Chat @@ -15,15 +14,10 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - function: OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function, - type: :function - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_named_tool_choice - | OpenAI::BaseModel data - ) -> void + def initialize: ( + function: OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_named_tool_choice @@ -32,12 +26,7 @@ module OpenAI class Function < OpenAI::BaseModel attr_accessor name: String - def initialize: - (name: String) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionNamedToolChoice::function - | OpenAI::BaseModel data - ) -> void + def initialize: (name: String) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionNamedToolChoice::function end diff --git a/sig/openai/models/chat/chat_completion_prediction_content.rbs b/sig/openai/models/chat/chat_completion_prediction_content.rbs index c04d1cc4..cbf6347c 100644 --- a/sig/openai/models/chat/chat_completion_prediction_content.rbs +++ b/sig/openai/models/chat/chat_completion_prediction_content.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionPredictionContent = Chat::ChatCompletionPredictionContent module Chat @@ -15,28 +14,25 @@ module OpenAI attr_accessor type: :content - def initialize: - ( - content: OpenAI::Models::Chat::ChatCompletionPredictionContent::content, - type: :content - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_prediction_content - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Chat::ChatCompletionPredictionContent::content, + ?type: :content + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_prediction_content type content = String | ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] + type chat_completion_content_part_text_array = ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] ChatCompletionContentPartTextArray: chat_completion_content_part_text_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] end end end diff --git a/sig/openai/models/chat/chat_completion_reasoning_effort.rbs b/sig/openai/models/chat/chat_completion_reasoning_effort.rbs index 0d91a009..28d9e504 100644 --- a/sig/openai/models/chat/chat_completion_reasoning_effort.rbs +++ b/sig/openai/models/chat/chat_completion_reasoning_effort.rbs @@ -1,11 +1,9 @@ module OpenAI module Models - - class ChatCompletionReasoningEffort = Chat::ChatCompletionReasoningEffort + module ChatCompletionReasoningEffort = Chat::ChatCompletionReasoningEffort module Chat - - class ChatCompletionReasoningEffort = OpenAI::Models::ReasoningEffort + module ChatCompletionReasoningEffort = OpenAI::Models::ReasoningEffort end end end diff --git a/sig/openai/models/chat/chat_completion_role.rbs b/sig/openai/models/chat/chat_completion_role.rbs index be395c69..4744870b 100644 --- a/sig/openai/models/chat/chat_completion_role.rbs +++ b/sig/openai/models/chat/chat_completion_role.rbs @@ -1,13 +1,14 @@ module OpenAI module Models - - class ChatCompletionRole = Chat::ChatCompletionRole + module ChatCompletionRole = Chat::ChatCompletionRole module Chat type chat_completion_role = :developer | :system | :user | :assistant | :tool | :function - class ChatCompletionRole < OpenAI::Enum + module ChatCompletionRole + extend OpenAI::Enum + DEVELOPER: :developer SYSTEM: :system USER: :user @@ -15,7 +16,7 @@ module OpenAI TOOL: :tool FUNCTION: :function - def self.values: -> ::Array[OpenAI::Models::Chat::chat_completion_role] + def self?.values: -> ::Array[OpenAI::Models::Chat::chat_completion_role] end end end diff --git a/sig/openai/models/chat/chat_completion_store_message.rbs b/sig/openai/models/chat/chat_completion_store_message.rbs index e96afacc..75e77b6c 100644 --- a/sig/openai/models/chat/chat_completion_store_message.rbs +++ b/sig/openai/models/chat/chat_completion_store_message.rbs @@ -1,20 +1,16 @@ module OpenAI module Models - class ChatCompletionStoreMessage = Chat::ChatCompletionStoreMessage module Chat type chat_completion_store_message = { id: String } class ChatCompletionStoreMessage < OpenAI::Models::Chat::ChatCompletionMessage - attr_accessor id: String + def id: -> String - def initialize: - (id: String) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_store_message - | OpenAI::BaseModel data - ) -> void + def id=: (String _) -> String + + def initialize: (id: String) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_store_message end diff --git a/sig/openai/models/chat/chat_completion_stream_options.rbs b/sig/openai/models/chat/chat_completion_stream_options.rbs index 8c4502bd..7fed3536 100644 --- a/sig/openai/models/chat/chat_completion_stream_options.rbs +++ b/sig/openai/models/chat/chat_completion_stream_options.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionStreamOptions = Chat::ChatCompletionStreamOptions module Chat @@ -11,12 +10,7 @@ module OpenAI def include_usage=: (bool) -> bool - def initialize: - (include_usage: bool) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_stream_options - | OpenAI::BaseModel data - ) -> void + def initialize: (?include_usage: bool) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_stream_options end diff --git a/sig/openai/models/chat/chat_completion_system_message_param.rbs b/sig/openai/models/chat/chat_completion_system_message_param.rbs index 7501e229..56a477ec 100644 --- a/sig/openai/models/chat/chat_completion_system_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_system_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionSystemMessageParam = Chat::ChatCompletionSystemMessageParam module Chat @@ -20,29 +19,26 @@ module OpenAI def name=: (String) -> String - def initialize: - ( - content: OpenAI::Models::Chat::ChatCompletionSystemMessageParam::content, - name: String, - role: :system - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_system_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Chat::ChatCompletionSystemMessageParam::content, + ?name: String, + ?role: :system + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_system_message_param type content = String | ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] + type chat_completion_content_part_text_array = ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] ChatCompletionContentPartTextArray: chat_completion_content_part_text_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] end end end diff --git a/sig/openai/models/chat/chat_completion_token_logprob.rbs b/sig/openai/models/chat/chat_completion_token_logprob.rbs index cd55959d..a076afef 100644 --- a/sig/openai/models/chat/chat_completion_token_logprob.rbs +++ b/sig/openai/models/chat/chat_completion_token_logprob.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionTokenLogprob = Chat::ChatCompletionTokenLogprob module Chat @@ -21,17 +20,12 @@ module OpenAI attr_accessor top_logprobs: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob] - def initialize: - ( - token: String, - bytes: ::Array[Integer]?, - logprob: Float, - top_logprobs: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob] - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_token_logprob - | OpenAI::BaseModel data - ) -> void + def initialize: ( + token: String, + bytes: ::Array[Integer]?, + logprob: Float, + top_logprobs: ::Array[OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob] + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_token_logprob @@ -45,12 +39,11 @@ module OpenAI attr_accessor logprob: Float - def initialize: - (token: String, bytes: ::Array[Integer]?, logprob: Float) -> void - | ( - ?OpenAI::Models::Chat::ChatCompletionTokenLogprob::top_logprob - | OpenAI::BaseModel data - ) -> void + def initialize: ( + token: String, + bytes: ::Array[Integer]?, + logprob: Float + ) -> void def to_hash: -> OpenAI::Models::Chat::ChatCompletionTokenLogprob::top_logprob end diff --git a/sig/openai/models/chat/chat_completion_tool.rbs b/sig/openai/models/chat/chat_completion_tool.rbs index 6dc1b119..d465043d 100644 --- a/sig/openai/models/chat/chat_completion_tool.rbs +++ b/sig/openai/models/chat/chat_completion_tool.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionTool = Chat::ChatCompletionTool module Chat @@ -12,14 +11,10 @@ module OpenAI attr_accessor type: :function - def initialize: - ( - function: OpenAI::Models::FunctionDefinition, - type: :function - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + function: OpenAI::Models::FunctionDefinition, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_tool end diff --git a/sig/openai/models/chat/chat_completion_tool_choice_option.rbs b/sig/openai/models/chat/chat_completion_tool_choice_option.rbs index e6c246ee..114b7588 100644 --- a/sig/openai/models/chat/chat_completion_tool_choice_option.rbs +++ b/sig/openai/models/chat/chat_completion_tool_choice_option.rbs @@ -1,25 +1,28 @@ module OpenAI module Models - - class ChatCompletionToolChoiceOption = Chat::ChatCompletionToolChoiceOption + module ChatCompletionToolChoiceOption = Chat::ChatCompletionToolChoiceOption module Chat type chat_completion_tool_choice_option = OpenAI::Models::Chat::ChatCompletionToolChoiceOption::auto | OpenAI::Models::Chat::ChatCompletionNamedToolChoice - class ChatCompletionToolChoiceOption < OpenAI::Union + module ChatCompletionToolChoiceOption + extend OpenAI::Union + type auto = :none | :auto | :required - class Auto < OpenAI::Enum + module Auto + extend OpenAI::Enum + NONE: :none AUTO: :auto REQUIRED: :required - def self.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionToolChoiceOption::auto] + def self?.values: -> ::Array[OpenAI::Models::Chat::ChatCompletionToolChoiceOption::auto] end - def self.variants: -> [OpenAI::Models::Chat::ChatCompletionToolChoiceOption::auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] + def self?.variants: -> [OpenAI::Models::Chat::ChatCompletionToolChoiceOption::auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] end end end diff --git a/sig/openai/models/chat/chat_completion_tool_message_param.rbs b/sig/openai/models/chat/chat_completion_tool_message_param.rbs index 90f917db..e0e31f90 100644 --- a/sig/openai/models/chat/chat_completion_tool_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_tool_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionToolMessageParam = Chat::ChatCompletionToolMessageParam module Chat @@ -18,29 +17,26 @@ module OpenAI attr_accessor tool_call_id: String - def initialize: - ( - content: OpenAI::Models::Chat::ChatCompletionToolMessageParam::content, - tool_call_id: String, - role: :tool - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_tool_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Chat::ChatCompletionToolMessageParam::content, + tool_call_id: String, + ?role: :tool + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_tool_message_param type content = String | ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] + type chat_completion_content_part_text_array = ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText] ChatCompletionContentPartTextArray: chat_completion_content_part_text_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::ChatCompletionContentPartText]] end end end diff --git a/sig/openai/models/chat/chat_completion_user_message_param.rbs b/sig/openai/models/chat/chat_completion_user_message_param.rbs index 75491108..308744d9 100644 --- a/sig/openai/models/chat/chat_completion_user_message_param.rbs +++ b/sig/openai/models/chat/chat_completion_user_message_param.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class ChatCompletionUserMessageParam = Chat::ChatCompletionUserMessageParam module Chat @@ -20,29 +19,26 @@ module OpenAI def name=: (String) -> String - def initialize: - ( - content: OpenAI::Models::Chat::ChatCompletionUserMessageParam::content, - name: String, - role: :user - ) -> void - | ( - ?OpenAI::Models::Chat::chat_completion_user_message_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Chat::ChatCompletionUserMessageParam::content, + ?name: String, + ?role: :user + ) -> void def to_hash: -> OpenAI::Models::Chat::chat_completion_user_message_param type content = String | ::Array[OpenAI::Models::Chat::chat_completion_content_part] - class Content < OpenAI::Union + module Content + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[OpenAI::Models::Chat::chat_completion_content_part]] + type chat_completion_content_part_array = ::Array[OpenAI::Models::Chat::chat_completion_content_part] ChatCompletionContentPartArray: chat_completion_content_part_array - - def self.variants: -> [String, ::Array[OpenAI::Models::Chat::chat_completion_content_part]] end end end diff --git a/sig/openai/models/chat/completion_create_params.rbs b/sig/openai/models/chat/completion_create_params.rbs index 17fd54d4..19e7aa49 100644 --- a/sig/openai/models/chat/completion_create_params.rbs +++ b/sig/openai/models/chat/completion_create_params.rbs @@ -37,7 +37,7 @@ module OpenAI & OpenAI::request_parameters class CompletionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param] @@ -128,68 +128,69 @@ module OpenAI OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions ) -> OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions - def initialize: - ( - messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], - model: OpenAI::Models::Chat::CompletionCreateParams::model, - audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, - frequency_penalty: Float?, - function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, - functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: bool?, - max_completion_tokens: Integer?, - max_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, - n: Integer?, - parallel_tool_calls: bool, - prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, - presence_penalty: Float?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, - seed: Integer?, - service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, - stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, - store: bool?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - temperature: Float?, - tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, - tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], - top_logprobs: Integer?, - top_p: Float?, - user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Chat::completion_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], + model: OpenAI::Models::Chat::CompletionCreateParams::model, + ?audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, + ?frequency_penalty: Float?, + ?function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, + ?functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: bool?, + ?max_completion_tokens: Integer?, + ?max_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, + ?n: Integer?, + ?parallel_tool_calls: bool, + ?prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, + ?presence_penalty: Float?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, + ?seed: Integer?, + ?service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, + ?stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, + ?store: bool?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, + ?tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], + ?top_logprobs: Integer?, + ?top_p: Float?, + ?user: String, + ?web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Chat::completion_create_params type model = String | OpenAI::Models::chat_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model] end type function_call = OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::function_call_mode | OpenAI::Models::Chat::ChatCompletionFunctionCallOption - class FunctionCall < OpenAI::Union + module FunctionCall + extend OpenAI::Union + type function_call_mode = :none | :auto - class FunctionCallMode < OpenAI::Enum + module FunctionCallMode + extend OpenAI::Enum + NONE: :none AUTO: :auto - def self.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::function_call_mode] + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::function_call_mode] end - def self.variants: -> [OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::function_call_mode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] + def self?.variants: -> [OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::function_call_mode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] end type function = @@ -212,27 +213,24 @@ module OpenAI OpenAI::Models::function_parameters ) -> OpenAI::Models::function_parameters - def initialize: - ( - name: String, - description: String, - parameters: OpenAI::Models::function_parameters - ) -> void - | ( - ?OpenAI::Models::Chat::CompletionCreateParams::function - | OpenAI::BaseModel data - ) -> void + def initialize: ( + name: String, + ?description: String, + ?parameters: OpenAI::Models::function_parameters + ) -> void def to_hash: -> OpenAI::Models::Chat::CompletionCreateParams::function end type modality = :text | :audio - class Modality < OpenAI::Enum + module Modality + extend OpenAI::Enum + TEXT: :text AUDIO: :audio - def self.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality] + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality] end type response_format = @@ -240,27 +238,33 @@ module OpenAI | OpenAI::Models::ResponseFormatJSONSchema | OpenAI::Models::ResponseFormatJSONObject - class ResponseFormat < OpenAI::Union - def self.variants: -> [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] + module ResponseFormat + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] end type service_tier = :auto | :default - class ServiceTier < OpenAI::Enum + module ServiceTier + extend OpenAI::Enum + AUTO: :auto DEFAULT: :default - def self.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::service_tier] + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::service_tier] end type stop = (String | ::Array[String])? - class Stop < OpenAI::Union + module Stop + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String]] + type string_array = ::Array[String] StringArray: string_array - - def self.variants: -> [String, ::Array[String]] end type web_search_options = @@ -278,26 +282,23 @@ module OpenAI attr_accessor user_location: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation? - def initialize: - ( - search_context_size: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::search_context_size, - user_location: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation? - ) -> void - | ( - ?OpenAI::Models::Chat::CompletionCreateParams::web_search_options - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?search_context_size: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::search_context_size, + ?user_location: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation? + ) -> void def to_hash: -> OpenAI::Models::Chat::CompletionCreateParams::web_search_options type search_context_size = :low | :medium | :high - class SearchContextSize < OpenAI::Enum + module SearchContextSize + extend OpenAI::Enum + LOW: :low MEDIUM: :medium HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::search_context_size] + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::search_context_size] end type user_location = @@ -311,15 +312,10 @@ module OpenAI attr_accessor type: :approximate - def initialize: - ( - approximate: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate, - type: :approximate - ) -> void - | ( - ?OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::user_location - | OpenAI::BaseModel data - ) -> void + def initialize: ( + approximate: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate, + ?type: :approximate + ) -> void def to_hash: -> OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::user_location @@ -348,17 +344,12 @@ module OpenAI def timezone=: (String) -> String - def initialize: - ( - city: String, - country: String, - region: String, - timezone: String - ) -> void - | ( - ?OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::approximate - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?city: String, + ?country: String, + ?region: String, + ?timezone: String + ) -> void def to_hash: -> OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::approximate end diff --git a/sig/openai/models/chat/completion_delete_params.rbs b/sig/openai/models/chat/completion_delete_params.rbs index ea7b5315..b5abb861 100644 --- a/sig/openai/models/chat/completion_delete_params.rbs +++ b/sig/openai/models/chat/completion_delete_params.rbs @@ -4,15 +4,10 @@ module OpenAI type completion_delete_params = { } & OpenAI::request_parameters class CompletionDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Chat::completion_delete_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Chat::completion_delete_params end diff --git a/sig/openai/models/chat/completion_list_params.rbs b/sig/openai/models/chat/completion_list_params.rbs index b135cfcf..533ec07c 100644 --- a/sig/openai/models/chat/completion_list_params.rbs +++ b/sig/openai/models/chat/completion_list_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class CompletionListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -35,29 +35,26 @@ module OpenAI OpenAI::Models::Chat::CompletionListParams::order ) -> OpenAI::Models::Chat::CompletionListParams::order - def initialize: - ( - after: String, - limit: Integer, - metadata: OpenAI::Models::metadata?, - model: String, - order: OpenAI::Models::Chat::CompletionListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Chat::completion_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?metadata: OpenAI::Models::metadata?, + ?model: String, + ?order: OpenAI::Models::Chat::CompletionListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Chat::completion_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Chat::CompletionListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionListParams::order] end end end diff --git a/sig/openai/models/chat/completion_retrieve_params.rbs b/sig/openai/models/chat/completion_retrieve_params.rbs index e29df6fe..8b07c987 100644 --- a/sig/openai/models/chat/completion_retrieve_params.rbs +++ b/sig/openai/models/chat/completion_retrieve_params.rbs @@ -4,15 +4,10 @@ module OpenAI type completion_retrieve_params = { } & OpenAI::request_parameters class CompletionRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Chat::completion_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Chat::completion_retrieve_params end diff --git a/sig/openai/models/chat/completion_update_params.rbs b/sig/openai/models/chat/completion_update_params.rbs index 7551639e..31894b01 100644 --- a/sig/openai/models/chat/completion_update_params.rbs +++ b/sig/openai/models/chat/completion_update_params.rbs @@ -5,20 +5,15 @@ module OpenAI { metadata: OpenAI::Models::metadata? } & OpenAI::request_parameters class CompletionUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor metadata: OpenAI::Models::metadata? - def initialize: - ( - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Chat::completion_update_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Chat::completion_update_params end diff --git a/sig/openai/models/chat/completions/message_list_params.rbs b/sig/openai/models/chat/completions/message_list_params.rbs index 232ef376..08d092c8 100644 --- a/sig/openai/models/chat/completions/message_list_params.rbs +++ b/sig/openai/models/chat/completions/message_list_params.rbs @@ -11,7 +11,7 @@ module OpenAI & OpenAI::request_parameters class MessageListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -28,27 +28,24 @@ module OpenAI OpenAI::Models::Chat::Completions::MessageListParams::order ) -> OpenAI::Models::Chat::Completions::MessageListParams::order - def initialize: - ( - after: String, - limit: Integer, - order: OpenAI::Models::Chat::Completions::MessageListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Chat::Completions::message_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?order: OpenAI::Models::Chat::Completions::MessageListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Chat::Completions::message_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Chat::Completions::MessageListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Chat::Completions::MessageListParams::order] end end end diff --git a/sig/openai/models/chat_model.rbs b/sig/openai/models/chat_model.rbs index 5940f36f..d0aa3240 100644 --- a/sig/openai/models/chat_model.rbs +++ b/sig/openai/models/chat_model.rbs @@ -9,11 +9,6 @@ module OpenAI | :"o1-preview-2024-09-12" | :"o1-mini" | :"o1-mini-2024-09-12" - | :"computer-use-preview" - | :"computer-use-preview-2025-02-04" - | :"computer-use-preview-2025-03-11" - | :"gpt-4.5-preview" - | :"gpt-4.5-preview-2025-02-27" | :"gpt-4o" | :"gpt-4o-2024-11-20" | :"gpt-4o-2024-08-06" @@ -23,6 +18,10 @@ module OpenAI | :"gpt-4o-audio-preview-2024-12-17" | :"gpt-4o-mini-audio-preview" | :"gpt-4o-mini-audio-preview-2024-12-17" + | :"gpt-4o-search-preview" + | :"gpt-4o-mini-search-preview" + | :"gpt-4o-search-preview-2025-03-11" + | :"gpt-4o-mini-search-preview-2025-03-11" | :"chatgpt-4o-latest" | :"gpt-4o-mini" | :"gpt-4o-mini-2024-07-18" @@ -46,7 +45,9 @@ module OpenAI | :"gpt-3.5-turbo-0125" | :"gpt-3.5-turbo-16k-0613" - class ChatModel < OpenAI::Enum + module ChatModel + extend OpenAI::Enum + O3_MINI: :"o3-mini" O3_MINI_2025_01_31: :"o3-mini-2025-01-31" O1: :o1 @@ -55,11 +56,6 @@ module OpenAI O1_PREVIEW_2024_09_12: :"o1-preview-2024-09-12" O1_MINI: :"o1-mini" O1_MINI_2024_09_12: :"o1-mini-2024-09-12" - COMPUTER_USE_PREVIEW: :"computer-use-preview" - COMPUTER_USE_PREVIEW_2025_02_04: :"computer-use-preview-2025-02-04" - COMPUTER_USE_PREVIEW_2025_03_11: :"computer-use-preview-2025-03-11" - GPT_4_5_PREVIEW: :"gpt-4.5-preview" - GPT_4_5_PREVIEW_2025_02_27: :"gpt-4.5-preview-2025-02-27" GPT_4O: :"gpt-4o" GPT_4O_2024_11_20: :"gpt-4o-2024-11-20" GPT_4O_2024_08_06: :"gpt-4o-2024-08-06" @@ -69,6 +65,10 @@ module OpenAI GPT_4O_AUDIO_PREVIEW_2024_12_17: :"gpt-4o-audio-preview-2024-12-17" GPT_4O_MINI_AUDIO_PREVIEW: :"gpt-4o-mini-audio-preview" GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17: :"gpt-4o-mini-audio-preview-2024-12-17" + GPT_4O_SEARCH_PREVIEW: :"gpt-4o-search-preview" + GPT_4O_MINI_SEARCH_PREVIEW: :"gpt-4o-mini-search-preview" + GPT_4O_SEARCH_PREVIEW_2025_03_11: :"gpt-4o-search-preview-2025-03-11" + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11: :"gpt-4o-mini-search-preview-2025-03-11" CHATGPT_4O_LATEST: :"chatgpt-4o-latest" GPT_4O_MINI: :"gpt-4o-mini" GPT_4O_MINI_2024_07_18: :"gpt-4o-mini-2024-07-18" @@ -92,7 +92,7 @@ module OpenAI GPT_3_5_TURBO_0125: :"gpt-3.5-turbo-0125" GPT_3_5_TURBO_16K_0613: :"gpt-3.5-turbo-16k-0613" - def self.values: -> ::Array[OpenAI::Models::chat_model] + def self?.values: -> ::Array[OpenAI::Models::chat_model] end end end diff --git a/sig/openai/models/comparison_filter.rbs b/sig/openai/models/comparison_filter.rbs index 02a4b26d..8d14f63b 100644 --- a/sig/openai/models/comparison_filter.rbs +++ b/sig/openai/models/comparison_filter.rbs @@ -14,19 +14,19 @@ module OpenAI attr_accessor value: OpenAI::Models::ComparisonFilter::value - def initialize: - ( - key: String, - type: OpenAI::Models::ComparisonFilter::type_, - value: OpenAI::Models::ComparisonFilter::value - ) -> void - | (?OpenAI::Models::comparison_filter | OpenAI::BaseModel data) -> void + def initialize: ( + key: String, + type: OpenAI::Models::ComparisonFilter::type_, + value: OpenAI::Models::ComparisonFilter::value + ) -> void def to_hash: -> OpenAI::Models::comparison_filter type type_ = :eq | :ne | :gt | :gte | :lt | :lte - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + EQ: :eq NE: :ne GT: :gt @@ -34,13 +34,15 @@ module OpenAI LT: :lt LTE: :lte - def self.values: -> ::Array[OpenAI::Models::ComparisonFilter::type_] + def self?.values: -> ::Array[OpenAI::Models::ComparisonFilter::type_] end type value = String | Float | bool - class Value < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Value + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/completion.rbs b/sig/openai/models/completion.rbs index 4394b753..0e189869 100644 --- a/sig/openai/models/completion.rbs +++ b/sig/openai/models/completion.rbs @@ -32,17 +32,15 @@ module OpenAI OpenAI::Models::CompletionUsage ) -> OpenAI::Models::CompletionUsage - def initialize: - ( - id: String, - choices: ::Array[OpenAI::Models::CompletionChoice], - created: Integer, - model: String, - system_fingerprint: String, - usage: OpenAI::Models::CompletionUsage, - object: :text_completion - ) -> void - | (?OpenAI::Models::completion | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + choices: ::Array[OpenAI::Models::CompletionChoice], + created: Integer, + model: String, + ?system_fingerprint: String, + ?usage: OpenAI::Models::CompletionUsage, + ?object: :text_completion + ) -> void def to_hash: -> OpenAI::Models::completion end diff --git a/sig/openai/models/completion_choice.rbs b/sig/openai/models/completion_choice.rbs index 847712cf..e506a455 100644 --- a/sig/openai/models/completion_choice.rbs +++ b/sig/openai/models/completion_choice.rbs @@ -17,25 +17,25 @@ module OpenAI attr_accessor text: String - def initialize: - ( - finish_reason: OpenAI::Models::CompletionChoice::finish_reason, - index: Integer, - logprobs: OpenAI::Models::CompletionChoice::Logprobs?, - text: String - ) -> void - | (?OpenAI::Models::completion_choice | OpenAI::BaseModel data) -> void + def initialize: ( + finish_reason: OpenAI::Models::CompletionChoice::finish_reason, + index: Integer, + logprobs: OpenAI::Models::CompletionChoice::Logprobs?, + text: String + ) -> void def to_hash: -> OpenAI::Models::completion_choice type finish_reason = :stop | :length | :content_filter - class FinishReason < OpenAI::Enum + module FinishReason + extend OpenAI::Enum + STOP: :stop LENGTH: :length CONTENT_FILTER: :content_filter - def self.values: -> ::Array[OpenAI::Models::CompletionChoice::finish_reason] + def self?.values: -> ::Array[OpenAI::Models::CompletionChoice::finish_reason] end type logprobs = @@ -65,16 +65,12 @@ module OpenAI ::Array[::Hash[Symbol, Float]] ) -> ::Array[::Hash[Symbol, Float]] - def initialize: - ( - text_offset: ::Array[Integer], - token_logprobs: ::Array[Float], - tokens: ::Array[String], - top_logprobs: ::Array[::Hash[Symbol, Float]] - ) -> void - | ( - ?OpenAI::Models::CompletionChoice::logprobs | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?text_offset: ::Array[Integer], + ?token_logprobs: ::Array[Float], + ?tokens: ::Array[String], + ?top_logprobs: ::Array[::Hash[Symbol, Float]] + ) -> void def to_hash: -> OpenAI::Models::CompletionChoice::logprobs end diff --git a/sig/openai/models/completion_create_params.rbs b/sig/openai/models/completion_create_params.rbs index 131c7bd7..99d092d2 100644 --- a/sig/openai/models/completion_create_params.rbs +++ b/sig/openai/models/completion_create_params.rbs @@ -23,7 +23,7 @@ module OpenAI & OpenAI::request_parameters class CompletionCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor model: OpenAI::Models::CompletionCreateParams::model @@ -62,46 +62,52 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - model: OpenAI::Models::CompletionCreateParams::model, - prompt: OpenAI::Models::CompletionCreateParams::prompt?, - best_of: Integer?, - echo: bool?, - frequency_penalty: Float?, - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: Integer?, - max_tokens: Integer?, - n: Integer?, - presence_penalty: Float?, - seed: Integer?, - stop: OpenAI::Models::CompletionCreateParams::stop?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - suffix: String?, - temperature: Float?, - top_p: Float?, - user: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::completion_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + model: OpenAI::Models::CompletionCreateParams::model, + prompt: OpenAI::Models::CompletionCreateParams::prompt?, + ?best_of: Integer?, + ?echo: bool?, + ?frequency_penalty: Float?, + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: Integer?, + ?max_tokens: Integer?, + ?n: Integer?, + ?presence_penalty: Float?, + ?seed: Integer?, + ?stop: OpenAI::Models::CompletionCreateParams::stop?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?suffix: String?, + ?temperature: Float?, + ?top_p: Float?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::completion_create_params type model = String | :"gpt-3.5-turbo-instruct" | :"davinci-002" | :"babbage-002" - class Model < OpenAI::Union - def self.variants: -> [String, (:"gpt-3.5-turbo-instruct" + module Model + extend OpenAI::Union + + def self?.variants: -> [String, (:"gpt-3.5-turbo-instruct" | :"davinci-002" | :"babbage-002")] + + GPT_3_5_TURBO_INSTRUCT: :"gpt-3.5-turbo-instruct" + DAVINCI_002: :"davinci-002" + BABBAGE_002: :"babbage-002" end type prompt = String | ::Array[String] | ::Array[Integer] | ::Array[::Array[Integer]] - class Prompt < OpenAI::Union + module Prompt + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String], ::Array[Integer], ::Array[::Array[Integer]]] + type string_array = ::Array[String] StringArray: string_array @@ -113,18 +119,18 @@ module OpenAI type array_of_token2_d_array = ::Array[::Array[Integer]] ArrayOfToken2DArray: array_of_token2_d_array - - def self.variants: -> [String, ::Array[String], ::Array[Integer], ::Array[::Array[Integer]]] end type stop = (String | ::Array[String])? - class Stop < OpenAI::Union + module Stop + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String]] + type string_array = ::Array[String] StringArray: string_array - - def self.variants: -> [String, ::Array[String]] end end end diff --git a/sig/openai/models/completion_usage.rbs b/sig/openai/models/completion_usage.rbs index 3c334ef6..fe20a24b 100644 --- a/sig/openai/models/completion_usage.rbs +++ b/sig/openai/models/completion_usage.rbs @@ -28,15 +28,13 @@ module OpenAI OpenAI::Models::CompletionUsage::PromptTokensDetails ) -> OpenAI::Models::CompletionUsage::PromptTokensDetails - def initialize: - ( - completion_tokens: Integer, - prompt_tokens: Integer, - total_tokens: Integer, - completion_tokens_details: OpenAI::Models::CompletionUsage::CompletionTokensDetails, - prompt_tokens_details: OpenAI::Models::CompletionUsage::PromptTokensDetails - ) -> void - | (?OpenAI::Models::completion_usage | OpenAI::BaseModel data) -> void + def initialize: ( + completion_tokens: Integer, + prompt_tokens: Integer, + total_tokens: Integer, + ?completion_tokens_details: OpenAI::Models::CompletionUsage::CompletionTokensDetails, + ?prompt_tokens_details: OpenAI::Models::CompletionUsage::PromptTokensDetails + ) -> void def to_hash: -> OpenAI::Models::completion_usage @@ -65,17 +63,12 @@ module OpenAI def rejected_prediction_tokens=: (Integer) -> Integer - def initialize: - ( - accepted_prediction_tokens: Integer, - audio_tokens: Integer, - reasoning_tokens: Integer, - rejected_prediction_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::CompletionUsage::completion_tokens_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?accepted_prediction_tokens: Integer, + ?audio_tokens: Integer, + ?reasoning_tokens: Integer, + ?rejected_prediction_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::CompletionUsage::completion_tokens_details end @@ -92,12 +85,10 @@ module OpenAI def cached_tokens=: (Integer) -> Integer - def initialize: - (audio_tokens: Integer, cached_tokens: Integer) -> void - | ( - ?OpenAI::Models::CompletionUsage::prompt_tokens_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?audio_tokens: Integer, + ?cached_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::CompletionUsage::prompt_tokens_details end diff --git a/sig/openai/models/compound_filter.rbs b/sig/openai/models/compound_filter.rbs index ddbe75e7..211de484 100644 --- a/sig/openai/models/compound_filter.rbs +++ b/sig/openai/models/compound_filter.rbs @@ -11,28 +11,30 @@ module OpenAI attr_accessor type: OpenAI::Models::CompoundFilter::type_ - def initialize: - ( - filters: ::Array[OpenAI::Models::CompoundFilter::filter], - type: OpenAI::Models::CompoundFilter::type_ - ) -> void - | (?OpenAI::Models::compound_filter | OpenAI::BaseModel data) -> void + def initialize: ( + filters: ::Array[OpenAI::Models::CompoundFilter::filter], + type: OpenAI::Models::CompoundFilter::type_ + ) -> void def to_hash: -> OpenAI::Models::compound_filter type filter = OpenAI::Models::ComparisonFilter | top - class Filter < OpenAI::Union - def self.variants: -> [OpenAI::Models::ComparisonFilter, top] + module Filter + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ComparisonFilter, top] end type type_ = :and | :or - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + AND: :and OR: :or - def self.values: -> ::Array[OpenAI::Models::CompoundFilter::type_] + def self?.values: -> ::Array[OpenAI::Models::CompoundFilter::type_] end end end diff --git a/sig/openai/models/create_embedding_response.rbs b/sig/openai/models/create_embedding_response.rbs index d6fa5f3d..e9ae13dc 100644 --- a/sig/openai/models/create_embedding_response.rbs +++ b/sig/openai/models/create_embedding_response.rbs @@ -17,16 +17,12 @@ module OpenAI attr_accessor usage: OpenAI::Models::CreateEmbeddingResponse::Usage - def initialize: - ( - data: ::Array[OpenAI::Models::Embedding], - model: String, - usage: OpenAI::Models::CreateEmbeddingResponse::Usage, - object: :list - ) -> void - | ( - ?OpenAI::Models::create_embedding_response | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: ::Array[OpenAI::Models::Embedding], + model: String, + usage: OpenAI::Models::CreateEmbeddingResponse::Usage, + ?object: :list + ) -> void def to_hash: -> OpenAI::Models::create_embedding_response @@ -37,12 +33,7 @@ module OpenAI attr_accessor total_tokens: Integer - def initialize: - (prompt_tokens: Integer, total_tokens: Integer) -> void - | ( - ?OpenAI::Models::CreateEmbeddingResponse::usage - | OpenAI::BaseModel data - ) -> void + def initialize: (prompt_tokens: Integer, total_tokens: Integer) -> void def to_hash: -> OpenAI::Models::CreateEmbeddingResponse::usage end diff --git a/sig/openai/models/embedding.rbs b/sig/openai/models/embedding.rbs index 997cabfc..08eb26a7 100644 --- a/sig/openai/models/embedding.rbs +++ b/sig/openai/models/embedding.rbs @@ -10,9 +10,11 @@ module OpenAI attr_accessor object: :embedding - def initialize: - (embedding: ::Array[Float], index: Integer, object: :embedding) -> void - | (?OpenAI::Models::embedding | OpenAI::BaseModel data) -> void + def initialize: ( + embedding: ::Array[Float], + index: Integer, + ?object: :embedding + ) -> void def to_hash: -> OpenAI::Models::embedding end diff --git a/sig/openai/models/embedding_create_params.rbs b/sig/openai/models/embedding_create_params.rbs index 4e32f5ba..31ad63d5 100644 --- a/sig/openai/models/embedding_create_params.rbs +++ b/sig/openai/models/embedding_create_params.rbs @@ -11,7 +11,7 @@ module OpenAI & OpenAI::request_parameters class EmbeddingCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor input: OpenAI::Models::EmbeddingCreateParams::input @@ -32,25 +32,25 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - input: OpenAI::Models::EmbeddingCreateParams::input, - model: OpenAI::Models::EmbeddingCreateParams::model, - dimensions: Integer, - encoding_format: OpenAI::Models::EmbeddingCreateParams::encoding_format, - user: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::embedding_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + input: OpenAI::Models::EmbeddingCreateParams::input, + model: OpenAI::Models::EmbeddingCreateParams::model, + ?dimensions: Integer, + ?encoding_format: OpenAI::Models::EmbeddingCreateParams::encoding_format, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::embedding_create_params type input = String | ::Array[String] | ::Array[Integer] | ::Array[::Array[Integer]] - class Input < OpenAI::Union + module Input + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String], ::Array[Integer], ::Array[::Array[Integer]]] + type string_array = ::Array[String] StringArray: string_array @@ -62,23 +62,25 @@ module OpenAI type array_of_token2_d_array = ::Array[::Array[Integer]] ArrayOfToken2DArray: array_of_token2_d_array - - def self.variants: -> [String, ::Array[String], ::Array[Integer], ::Array[::Array[Integer]]] end type model = String | OpenAI::Models::embedding_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::embedding_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::embedding_model] end type encoding_format = :float | :base64 - class EncodingFormat < OpenAI::Enum + module EncodingFormat + extend OpenAI::Enum + FLOAT: :float BASE64: :base64 - def self.values: -> ::Array[OpenAI::Models::EmbeddingCreateParams::encoding_format] + def self?.values: -> ::Array[OpenAI::Models::EmbeddingCreateParams::encoding_format] end end end diff --git a/sig/openai/models/embedding_model.rbs b/sig/openai/models/embedding_model.rbs index c334a8a5..30fd2a8a 100644 --- a/sig/openai/models/embedding_model.rbs +++ b/sig/openai/models/embedding_model.rbs @@ -5,12 +5,14 @@ module OpenAI | :"text-embedding-3-small" | :"text-embedding-3-large" - class EmbeddingModel < OpenAI::Enum + module EmbeddingModel + extend OpenAI::Enum + TEXT_EMBEDDING_ADA_002: :"text-embedding-ada-002" TEXT_EMBEDDING_3_SMALL: :"text-embedding-3-small" TEXT_EMBEDDING_3_LARGE: :"text-embedding-3-large" - def self.values: -> ::Array[OpenAI::Models::embedding_model] + def self?.values: -> ::Array[OpenAI::Models::embedding_model] end end end diff --git a/sig/openai/models/error_object.rbs b/sig/openai/models/error_object.rbs index 1e44e215..bd0ae3a7 100644 --- a/sig/openai/models/error_object.rbs +++ b/sig/openai/models/error_object.rbs @@ -12,9 +12,12 @@ module OpenAI attr_accessor type: String - def initialize: - (code: String?, message: String, param: String?, type: String) -> void - | (?OpenAI::Models::error_object | OpenAI::BaseModel data) -> void + def initialize: ( + code: String?, + message: String, + param: String?, + type: String + ) -> void def to_hash: -> OpenAI::Models::error_object end diff --git a/sig/openai/models/file_chunking_strategy.rbs b/sig/openai/models/file_chunking_strategy.rbs index d287b675..7ac3728a 100644 --- a/sig/openai/models/file_chunking_strategy.rbs +++ b/sig/openai/models/file_chunking_strategy.rbs @@ -4,8 +4,10 @@ module OpenAI OpenAI::Models::StaticFileChunkingStrategyObject | OpenAI::Models::OtherFileChunkingStrategyObject - class FileChunkingStrategy < OpenAI::Union - def self.variants: -> [OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject] + module FileChunkingStrategy + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject] end end end diff --git a/sig/openai/models/file_chunking_strategy_param.rbs b/sig/openai/models/file_chunking_strategy_param.rbs index f5f9f28a..df5528b1 100644 --- a/sig/openai/models/file_chunking_strategy_param.rbs +++ b/sig/openai/models/file_chunking_strategy_param.rbs @@ -4,8 +4,10 @@ module OpenAI OpenAI::Models::AutoFileChunkingStrategyParam | OpenAI::Models::StaticFileChunkingStrategyObjectParam - class FileChunkingStrategyParam < OpenAI::Union - def self.variants: -> [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] + module FileChunkingStrategyParam + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] end end end diff --git a/sig/openai/models/file_content_params.rbs b/sig/openai/models/file_content_params.rbs index 0ecb693f..e875dcbb 100644 --- a/sig/openai/models/file_content_params.rbs +++ b/sig/openai/models/file_content_params.rbs @@ -3,14 +3,10 @@ module OpenAI type file_content_params = { } & OpenAI::request_parameters class FileContentParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::file_content_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::file_content_params end diff --git a/sig/openai/models/file_create_params.rbs b/sig/openai/models/file_create_params.rbs index 70531f53..fb34d5b0 100644 --- a/sig/openai/models/file_create_params.rbs +++ b/sig/openai/models/file_create_params.rbs @@ -5,20 +5,18 @@ module OpenAI & OpenAI::request_parameters class FileCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor file: IO | StringIO attr_accessor purpose: OpenAI::Models::file_purpose - def initialize: - ( - file: IO | StringIO, - purpose: OpenAI::Models::file_purpose, - request_options: OpenAI::request_opts - ) -> void - | (?OpenAI::Models::file_create_params | OpenAI::BaseModel data) -> void + def initialize: ( + file: IO | StringIO, + purpose: OpenAI::Models::file_purpose, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::file_create_params end diff --git a/sig/openai/models/file_delete_params.rbs b/sig/openai/models/file_delete_params.rbs index fa6918f3..88f704ae 100644 --- a/sig/openai/models/file_delete_params.rbs +++ b/sig/openai/models/file_delete_params.rbs @@ -3,12 +3,10 @@ module OpenAI type file_delete_params = { } & OpenAI::request_parameters class FileDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | (?OpenAI::Models::file_delete_params | OpenAI::BaseModel data) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::file_delete_params end diff --git a/sig/openai/models/file_deleted.rbs b/sig/openai/models/file_deleted.rbs index a691b96b..04eef616 100644 --- a/sig/openai/models/file_deleted.rbs +++ b/sig/openai/models/file_deleted.rbs @@ -9,9 +9,7 @@ module OpenAI attr_accessor object: :file - def initialize: - (id: String, deleted: bool, object: :file) -> void - | (?OpenAI::Models::file_deleted | OpenAI::BaseModel data) -> void + def initialize: (id: String, deleted: bool, ?object: :file) -> void def to_hash: -> OpenAI::Models::file_deleted end diff --git a/sig/openai/models/file_list_params.rbs b/sig/openai/models/file_list_params.rbs index 4b92a0e8..d4b2cc4c 100644 --- a/sig/openai/models/file_list_params.rbs +++ b/sig/openai/models/file_list_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class FileListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -31,25 +31,25 @@ module OpenAI def purpose=: (String) -> String - def initialize: - ( - after: String, - limit: Integer, - order: OpenAI::Models::FileListParams::order, - purpose: String, - request_options: OpenAI::request_opts - ) -> void - | (?OpenAI::Models::file_list_params | OpenAI::BaseModel data) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?order: OpenAI::Models::FileListParams::order, + ?purpose: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::file_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::FileListParams::order] + def self?.values: -> ::Array[OpenAI::Models::FileListParams::order] end end end diff --git a/sig/openai/models/file_object.rbs b/sig/openai/models/file_object.rbs index 1b0a4939..c4b2cd6b 100644 --- a/sig/openai/models/file_object.rbs +++ b/sig/openai/models/file_object.rbs @@ -36,19 +36,17 @@ module OpenAI def status_details=: (String) -> String - def initialize: - ( - id: String, - bytes: Integer, - created_at: Integer, - filename: String, - purpose: OpenAI::Models::FileObject::purpose, - status: OpenAI::Models::FileObject::status, - expires_at: Integer, - status_details: String, - object: :file - ) -> void - | (?OpenAI::Models::file_object | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + bytes: Integer, + created_at: Integer, + filename: String, + purpose: OpenAI::Models::FileObject::purpose, + status: OpenAI::Models::FileObject::status, + ?expires_at: Integer, + ?status_details: String, + ?object: :file + ) -> void def to_hash: -> OpenAI::Models::file_object @@ -61,7 +59,9 @@ module OpenAI | :"fine-tune-results" | :vision - class Purpose < OpenAI::Enum + module Purpose + extend OpenAI::Enum + ASSISTANTS: :assistants ASSISTANTS_OUTPUT: :assistants_output BATCH: :batch @@ -70,17 +70,19 @@ module OpenAI FINE_TUNE_RESULTS: :"fine-tune-results" VISION: :vision - def self.values: -> ::Array[OpenAI::Models::FileObject::purpose] + def self?.values: -> ::Array[OpenAI::Models::FileObject::purpose] end type status = :uploaded | :processed | :error - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + UPLOADED: :uploaded PROCESSED: :processed ERROR: :error - def self.values: -> ::Array[OpenAI::Models::FileObject::status] + def self?.values: -> ::Array[OpenAI::Models::FileObject::status] end end end diff --git a/sig/openai/models/file_purpose.rbs b/sig/openai/models/file_purpose.rbs index cf532f5b..84067b2c 100644 --- a/sig/openai/models/file_purpose.rbs +++ b/sig/openai/models/file_purpose.rbs @@ -3,7 +3,9 @@ module OpenAI type file_purpose = :assistants | :batch | :"fine-tune" | :vision | :user_data | :evals - class FilePurpose < OpenAI::Enum + module FilePurpose + extend OpenAI::Enum + ASSISTANTS: :assistants BATCH: :batch FINE_TUNE: :"fine-tune" @@ -11,7 +13,7 @@ module OpenAI USER_DATA: :user_data EVALS: :evals - def self.values: -> ::Array[OpenAI::Models::file_purpose] + def self?.values: -> ::Array[OpenAI::Models::file_purpose] end end end diff --git a/sig/openai/models/file_retrieve_params.rbs b/sig/openai/models/file_retrieve_params.rbs index dc986a6b..28a27398 100644 --- a/sig/openai/models/file_retrieve_params.rbs +++ b/sig/openai/models/file_retrieve_params.rbs @@ -3,14 +3,10 @@ module OpenAI type file_retrieve_params = { } & OpenAI::request_parameters class FileRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::file_retrieve_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::file_retrieve_params end diff --git a/sig/openai/models/fine_tuning/fine_tuning_job.rbs b/sig/openai/models/fine_tuning/fine_tuning_job.rbs index 12dfc6a9..b939849a 100644 --- a/sig/openai/models/fine_tuning/fine_tuning_job.rbs +++ b/sig/openai/models/fine_tuning/fine_tuning_job.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class FineTuningJob = FineTuning::FineTuningJob module FineTuning @@ -70,32 +69,27 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method ) -> OpenAI::Models::FineTuning::FineTuningJob::Method - def initialize: - ( - id: String, - created_at: Integer, - error: OpenAI::Models::FineTuning::FineTuningJob::Error?, - fine_tuned_model: String?, - finished_at: Integer?, - hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters, - model: String, - organization_id: String, - result_files: ::Array[String], - seed: Integer, - status: OpenAI::Models::FineTuning::FineTuningJob::status, - trained_tokens: Integer?, - training_file: String, - validation_file: String?, - estimated_finish: Integer?, - integrations: ::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject]?, - metadata: OpenAI::Models::metadata?, - method_: OpenAI::Models::FineTuning::FineTuningJob::Method, - object: :"fine_tuning.job" - ) -> void - | ( - ?OpenAI::Models::FineTuning::fine_tuning_job - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + error: OpenAI::Models::FineTuning::FineTuningJob::Error?, + fine_tuned_model: String?, + finished_at: Integer?, + hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters, + model: String, + organization_id: String, + result_files: ::Array[String], + seed: Integer, + status: OpenAI::Models::FineTuning::FineTuningJob::status, + trained_tokens: Integer?, + training_file: String, + validation_file: String?, + ?estimated_finish: Integer?, + ?integrations: ::Array[OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject]?, + ?metadata: OpenAI::Models::metadata?, + ?method_: OpenAI::Models::FineTuning::FineTuningJob::Method, + ?object: :"fine_tuning.job" + ) -> void def to_hash: -> OpenAI::Models::FineTuning::fine_tuning_job @@ -108,12 +102,11 @@ module OpenAI attr_accessor param: String? - def initialize: - (code: String, message: String, param: String?) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::error - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: String, + message: String, + param: String? + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::error end @@ -144,35 +137,36 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::batch_size, - learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::batch_size, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end @@ -184,7 +178,9 @@ module OpenAI | :failed | :cancelled - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + VALIDATING_FILES: :validating_files QUEUED: :queued RUNNING: :running @@ -192,7 +188,7 @@ module OpenAI FAILED: :failed CANCELLED: :cancelled - def self.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJob::status] + def self?.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJob::status] end type method_ = @@ -221,16 +217,11 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method::type_ ) -> OpenAI::Models::FineTuning::FineTuningJob::Method::type_ - def initialize: - ( - dpo: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, - supervised: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, - type: OpenAI::Models::FineTuning::FineTuningJob::Method::type_ - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::method_ - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?dpo: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo, + ?supervised: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised, + ?type: OpenAI::Models::FineTuning::FineTuningJob::Method::type_ + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::method_ @@ -246,14 +237,9 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters ) -> OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters - def initialize: - ( - hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::Method::dpo - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::Method::dpo @@ -290,42 +276,45 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::batch_size, - beta: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::beta, - learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::batch_size, + ?beta: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::beta, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::Method::Dpo::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type beta = :auto | Float - class Beta < OpenAI::Union - def self.variants: -> [:auto, Float] + module Beta + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end end @@ -342,14 +331,9 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters ) -> OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters - def initialize: - ( - hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::Method::supervised - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?hyperparameters: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::Method::supervised @@ -379,46 +363,49 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::batch_size, - learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::batch_size, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::FineTuningJob::Method::Supervised::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end end type type_ = :supervised | :dpo - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + SUPERVISED: :supervised DPO: :dpo - def self.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJob::Method::type_] + def self?.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJob::Method::type_] end end end diff --git a/sig/openai/models/fine_tuning/fine_tuning_job_event.rbs b/sig/openai/models/fine_tuning/fine_tuning_job_event.rbs index 53287f13..e9f208ef 100644 --- a/sig/openai/models/fine_tuning/fine_tuning_job_event.rbs +++ b/sig/openai/models/fine_tuning/fine_tuning_job_event.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class FineTuningJobEvent = FineTuning::FineTuningJobEvent module FineTuning @@ -36,40 +35,39 @@ module OpenAI OpenAI::Models::FineTuning::FineTuningJobEvent::type_ ) -> OpenAI::Models::FineTuning::FineTuningJobEvent::type_ - def initialize: - ( - id: String, - created_at: Integer, - level: OpenAI::Models::FineTuning::FineTuningJobEvent::level, - message: String, - data: top, - type: OpenAI::Models::FineTuning::FineTuningJobEvent::type_, - object: :"fine_tuning.job.event" - ) -> void - | ( - ?OpenAI::Models::FineTuning::fine_tuning_job_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + level: OpenAI::Models::FineTuning::FineTuningJobEvent::level, + message: String, + ?data: top, + ?type: OpenAI::Models::FineTuning::FineTuningJobEvent::type_, + ?object: :"fine_tuning.job.event" + ) -> void def to_hash: -> OpenAI::Models::FineTuning::fine_tuning_job_event type level = :info | :warn | :error - class Level < OpenAI::Enum + module Level + extend OpenAI::Enum + INFO: :info WARN: :warn ERROR: :error - def self.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::level] + def self?.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::level] end type type_ = :message | :metrics - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE: :message METRICS: :metrics - def self.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::type_] + def self?.values: -> ::Array[OpenAI::Models::FineTuning::FineTuningJobEvent::type_] end end end diff --git a/sig/openai/models/fine_tuning/fine_tuning_job_integration.rbs b/sig/openai/models/fine_tuning/fine_tuning_job_integration.rbs index 55ed40a2..ada2b1f0 100644 --- a/sig/openai/models/fine_tuning/fine_tuning_job_integration.rbs +++ b/sig/openai/models/fine_tuning/fine_tuning_job_integration.rbs @@ -1,10 +1,8 @@ module OpenAI module Models - class FineTuningJobIntegration = FineTuning::FineTuningJobIntegration module FineTuning - class FineTuningJobIntegration = OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject end end diff --git a/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbs b/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbs index 47f895a9..f5fc5cec 100644 --- a/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbs +++ b/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class FineTuningJobWandbIntegration = FineTuning::FineTuningJobWandbIntegration module FineTuning @@ -23,17 +22,12 @@ module OpenAI def tags=: (::Array[String]) -> ::Array[String] - def initialize: - ( - project: String, - entity: String?, - name: String?, - tags: ::Array[String] - ) -> void - | ( - ?OpenAI::Models::FineTuning::fine_tuning_job_wandb_integration - | OpenAI::BaseModel data - ) -> void + def initialize: ( + project: String, + ?entity: String?, + ?name: String?, + ?tags: ::Array[String] + ) -> void def to_hash: -> OpenAI::Models::FineTuning::fine_tuning_job_wandb_integration end diff --git a/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbs b/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbs index f9039369..e156cf05 100644 --- a/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbs +++ b/sig/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class FineTuningJobWandbIntegrationObject = FineTuning::FineTuningJobWandbIntegrationObject module FineTuning @@ -15,15 +14,10 @@ module OpenAI attr_accessor wandb: OpenAI::Models::FineTuning::FineTuningJobWandbIntegration - def initialize: - ( - wandb: OpenAI::Models::FineTuning::FineTuningJobWandbIntegration, - type: :wandb - ) -> void - | ( - ?OpenAI::Models::FineTuning::fine_tuning_job_wandb_integration_object - | OpenAI::BaseModel data - ) -> void + def initialize: ( + wandb: OpenAI::Models::FineTuning::FineTuningJobWandbIntegration, + ?type: :wandb + ) -> void def to_hash: -> OpenAI::Models::FineTuning::fine_tuning_job_wandb_integration_object end diff --git a/sig/openai/models/fine_tuning/job_cancel_params.rbs b/sig/openai/models/fine_tuning/job_cancel_params.rbs index 922d99dc..adc3eb00 100644 --- a/sig/openai/models/fine_tuning/job_cancel_params.rbs +++ b/sig/openai/models/fine_tuning/job_cancel_params.rbs @@ -4,15 +4,10 @@ module OpenAI type job_cancel_params = { } & OpenAI::request_parameters class JobCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::FineTuning::job_cancel_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::FineTuning::job_cancel_params end diff --git a/sig/openai/models/fine_tuning/job_create_params.rbs b/sig/openai/models/fine_tuning/job_create_params.rbs index 468dee15..faedfe50 100644 --- a/sig/openai/models/fine_tuning/job_create_params.rbs +++ b/sig/openai/models/fine_tuning/job_create_params.rbs @@ -16,7 +16,7 @@ module OpenAI & OpenAI::request_parameters class JobCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor model: OpenAI::Models::FineTuning::JobCreateParams::model @@ -45,23 +45,18 @@ module OpenAI attr_accessor validation_file: String? - def initialize: - ( - model: OpenAI::Models::FineTuning::JobCreateParams::model, - training_file: String, - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, - integrations: ::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]?, - metadata: OpenAI::Models::metadata?, - method_: OpenAI::Models::FineTuning::JobCreateParams::Method, - seed: Integer?, - suffix: String?, - validation_file: String?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::FineTuning::job_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + model: OpenAI::Models::FineTuning::JobCreateParams::model, + training_file: String, + ?hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, + ?integrations: ::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]?, + ?metadata: OpenAI::Models::metadata?, + ?method_: OpenAI::Models::FineTuning::JobCreateParams::Method, + ?seed: Integer?, + ?suffix: String?, + ?validation_file: String?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::FineTuning::job_create_params @@ -72,11 +67,18 @@ module OpenAI | :"gpt-3.5-turbo" | :"gpt-4o-mini" - class Model < OpenAI::Union - def self.variants: -> [String, (:"babbage-002" + module Model + extend OpenAI::Union + + def self?.variants: -> [String, (:"babbage-002" | :"davinci-002" | :"gpt-3.5-turbo" | :"gpt-4o-mini")] + + BABBAGE_002: :"babbage-002" + DAVINCI_002: :"davinci-002" + GPT_3_5_TURBO: :"gpt-3.5-turbo" + GPT_4O_MINI: :"gpt-4o-mini" end type hyperparameters = @@ -105,35 +107,36 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::batch_size, - learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::batch_size, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end @@ -148,15 +151,10 @@ module OpenAI attr_accessor wandb: OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb - def initialize: - ( - wandb: OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb, - type: :wandb - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::integration - | OpenAI::BaseModel data - ) -> void + def initialize: ( + wandb: OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb, + ?type: :wandb + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::integration @@ -179,17 +177,12 @@ module OpenAI def tags=: (::Array[String]) -> ::Array[String] - def initialize: - ( - project: String, - entity: String?, - name: String?, - tags: ::Array[String] - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::Integration::wandb - | OpenAI::BaseModel data - ) -> void + def initialize: ( + project: String, + ?entity: String?, + ?name: String?, + ?tags: ::Array[String] + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::Integration::wandb end @@ -221,16 +214,11 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Method::type_ ) -> OpenAI::Models::FineTuning::JobCreateParams::Method::type_ - def initialize: - ( - dpo: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, - supervised: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, - type: OpenAI::Models::FineTuning::JobCreateParams::Method::type_ - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::method_ - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?dpo: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo, + ?supervised: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised, + ?type: OpenAI::Models::FineTuning::JobCreateParams::Method::type_ + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::method_ @@ -246,14 +234,9 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters ) -> OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters - def initialize: - ( - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::Method::dpo - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::Method::dpo @@ -290,42 +273,45 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::batch_size, - beta: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::beta, - learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::batch_size, + ?beta: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::beta, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::Method::Dpo::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type beta = :auto | Float - class Beta < OpenAI::Union - def self.variants: -> [:auto, Float] + module Beta + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end end @@ -342,14 +328,9 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters ) -> OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters - def initialize: - ( - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::Method::supervised - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::Method::supervised @@ -379,46 +360,49 @@ module OpenAI OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::n_epochs ) -> OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::n_epochs - def initialize: - ( - batch_size: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::batch_size, - learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::learning_rate_multiplier, - n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::n_epochs - ) -> void - | ( - ?OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::hyperparameters - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?batch_size: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::batch_size, + ?learning_rate_multiplier: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::learning_rate_multiplier, + ?n_epochs: OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::Hyperparameters::n_epochs + ) -> void def to_hash: -> OpenAI::Models::FineTuning::JobCreateParams::Method::Supervised::hyperparameters type batch_size = :auto | Integer - class BatchSize < OpenAI::Union - def self.variants: -> [:auto, Integer] + module BatchSize + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end type learning_rate_multiplier = :auto | Float - class LearningRateMultiplier < OpenAI::Union - def self.variants: -> [:auto, Float] + module LearningRateMultiplier + extend OpenAI::Union + + def self?.variants: -> [:auto, Float] end type n_epochs = :auto | Integer - class NEpochs < OpenAI::Union - def self.variants: -> [:auto, Integer] + module NEpochs + extend OpenAI::Union + + def self?.variants: -> [:auto, Integer] end end end type type_ = :supervised | :dpo - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + SUPERVISED: :supervised DPO: :dpo - def self.values: -> ::Array[OpenAI::Models::FineTuning::JobCreateParams::Method::type_] + def self?.values: -> ::Array[OpenAI::Models::FineTuning::JobCreateParams::Method::type_] end end end diff --git a/sig/openai/models/fine_tuning/job_list_events_params.rbs b/sig/openai/models/fine_tuning/job_list_events_params.rbs index b14a4ba2..8159d7f4 100644 --- a/sig/openai/models/fine_tuning/job_list_events_params.rbs +++ b/sig/openai/models/fine_tuning/job_list_events_params.rbs @@ -5,7 +5,7 @@ module OpenAI { after: String, limit: Integer } & OpenAI::request_parameters class JobListEventsParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -16,16 +16,11 @@ module OpenAI def limit=: (Integer) -> Integer - def initialize: - ( - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::FineTuning::job_list_events_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::FineTuning::job_list_events_params end diff --git a/sig/openai/models/fine_tuning/job_list_params.rbs b/sig/openai/models/fine_tuning/job_list_params.rbs index f4fc50fc..fe78d5ad 100644 --- a/sig/openai/models/fine_tuning/job_list_params.rbs +++ b/sig/openai/models/fine_tuning/job_list_params.rbs @@ -6,7 +6,7 @@ module OpenAI & OpenAI::request_parameters class JobListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -19,17 +19,12 @@ module OpenAI attr_accessor metadata: ::Hash[Symbol, String]? - def initialize: - ( - after: String, - limit: Integer, - metadata: ::Hash[Symbol, String]?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::FineTuning::job_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?metadata: ::Hash[Symbol, String]?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::FineTuning::job_list_params end diff --git a/sig/openai/models/fine_tuning/job_retrieve_params.rbs b/sig/openai/models/fine_tuning/job_retrieve_params.rbs index 53329e19..5306f28a 100644 --- a/sig/openai/models/fine_tuning/job_retrieve_params.rbs +++ b/sig/openai/models/fine_tuning/job_retrieve_params.rbs @@ -4,15 +4,10 @@ module OpenAI type job_retrieve_params = { } & OpenAI::request_parameters class JobRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::FineTuning::job_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::FineTuning::job_retrieve_params end diff --git a/sig/openai/models/fine_tuning/jobs/checkpoint_list_params.rbs b/sig/openai/models/fine_tuning/jobs/checkpoint_list_params.rbs index 5c8dec0b..e5377848 100644 --- a/sig/openai/models/fine_tuning/jobs/checkpoint_list_params.rbs +++ b/sig/openai/models/fine_tuning/jobs/checkpoint_list_params.rbs @@ -6,7 +6,7 @@ module OpenAI { after: String, limit: Integer } & OpenAI::request_parameters class CheckpointListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -17,16 +17,11 @@ module OpenAI def limit=: (Integer) -> Integer - def initialize: - ( - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::FineTuning::Jobs::checkpoint_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::FineTuning::Jobs::checkpoint_list_params end diff --git a/sig/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbs b/sig/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbs index e3b4c10a..4f7cf1b7 100644 --- a/sig/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbs +++ b/sig/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rbs @@ -28,20 +28,15 @@ module OpenAI attr_accessor step_number: Integer - def initialize: - ( - id: String, - created_at: Integer, - fine_tuned_model_checkpoint: String, - fine_tuning_job_id: String, - metrics: OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics, - step_number: Integer, - object: :"fine_tuning.job.checkpoint" - ) -> void - | ( - ?OpenAI::Models::FineTuning::Jobs::fine_tuning_job_checkpoint - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + fine_tuned_model_checkpoint: String, + fine_tuning_job_id: String, + metrics: OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics, + step_number: Integer, + ?object: :"fine_tuning.job.checkpoint" + ) -> void def to_hash: -> OpenAI::Models::FineTuning::Jobs::fine_tuning_job_checkpoint @@ -85,20 +80,15 @@ module OpenAI def valid_mean_token_accuracy=: (Float) -> Float - def initialize: - ( - full_valid_loss: Float, - full_valid_mean_token_accuracy: Float, - step: Float, - train_loss: Float, - train_mean_token_accuracy: Float, - valid_loss: Float, - valid_mean_token_accuracy: Float - ) -> void - | ( - ?OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::metrics - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?full_valid_loss: Float, + ?full_valid_mean_token_accuracy: Float, + ?step: Float, + ?train_loss: Float, + ?train_mean_token_accuracy: Float, + ?valid_loss: Float, + ?valid_mean_token_accuracy: Float + ) -> void def to_hash: -> OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::metrics end diff --git a/sig/openai/models/function_definition.rbs b/sig/openai/models/function_definition.rbs index edff252f..194ec56f 100644 --- a/sig/openai/models/function_definition.rbs +++ b/sig/openai/models/function_definition.rbs @@ -23,16 +23,12 @@ module OpenAI attr_accessor strict: bool? - def initialize: - ( - name: String, - description: String, - parameters: OpenAI::Models::function_parameters, - strict: bool? - ) -> void - | ( - ?OpenAI::Models::function_definition | OpenAI::BaseModel data - ) -> void + def initialize: ( + name: String, + ?description: String, + ?parameters: OpenAI::Models::function_parameters, + ?strict: bool? + ) -> void def to_hash: -> OpenAI::Models::function_definition end diff --git a/sig/openai/models/image.rbs b/sig/openai/models/image.rbs index 3c094e5d..ed120c3b 100644 --- a/sig/openai/models/image.rbs +++ b/sig/openai/models/image.rbs @@ -15,9 +15,11 @@ module OpenAI def url=: (String) -> String - def initialize: - (b64_json: String, revised_prompt: String, url: String) -> void - | (?OpenAI::Models::image | OpenAI::BaseModel data) -> void + def initialize: ( + ?b64_json: String, + ?revised_prompt: String, + ?url: String + ) -> void def to_hash: -> OpenAI::Models::image end diff --git a/sig/openai/models/image_create_variation_params.rbs b/sig/openai/models/image_create_variation_params.rbs index 2cb6174c..23a37ecd 100644 --- a/sig/openai/models/image_create_variation_params.rbs +++ b/sig/openai/models/image_create_variation_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class ImageCreateVariationParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor image: IO | StringIO @@ -29,46 +29,47 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - image: IO | StringIO, - model: OpenAI::Models::ImageCreateVariationParams::model?, - n: Integer?, - response_format: OpenAI::Models::ImageCreateVariationParams::response_format?, - size: OpenAI::Models::ImageCreateVariationParams::size?, - user: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::image_create_variation_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + image: IO | StringIO, + ?model: OpenAI::Models::ImageCreateVariationParams::model?, + ?n: Integer?, + ?response_format: OpenAI::Models::ImageCreateVariationParams::response_format?, + ?size: OpenAI::Models::ImageCreateVariationParams::size?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::image_create_variation_params type model = String | OpenAI::Models::image_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::image_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::image_model] end type response_format = :url | :b64_json - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL: :url B64_JSON: :b64_json - def self.values: -> ::Array[OpenAI::Models::ImageCreateVariationParams::response_format] + def self?.values: -> ::Array[OpenAI::Models::ImageCreateVariationParams::response_format] end type size = :"256x256" | :"512x512" | :"1024x1024" - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256: :"256x256" NUMBER_512X512: :"512x512" NUMBER_1024X1024: :"1024x1024" - def self.values: -> ::Array[OpenAI::Models::ImageCreateVariationParams::size] + def self?.values: -> ::Array[OpenAI::Models::ImageCreateVariationParams::size] end end end diff --git a/sig/openai/models/image_edit_params.rbs b/sig/openai/models/image_edit_params.rbs index 17f6d2a5..12dc8ce9 100644 --- a/sig/openai/models/image_edit_params.rbs +++ b/sig/openai/models/image_edit_params.rbs @@ -14,7 +14,7 @@ module OpenAI & OpenAI::request_parameters class ImageEditParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor image: IO | StringIO @@ -37,45 +37,49 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - image: IO | StringIO, - prompt: String, - mask: IO | StringIO, - model: OpenAI::Models::ImageEditParams::model?, - n: Integer?, - response_format: OpenAI::Models::ImageEditParams::response_format?, - size: OpenAI::Models::ImageEditParams::size?, - user: String, - request_options: OpenAI::request_opts - ) -> void - | (?OpenAI::Models::image_edit_params | OpenAI::BaseModel data) -> void + def initialize: ( + image: IO | StringIO, + prompt: String, + ?mask: IO | StringIO, + ?model: OpenAI::Models::ImageEditParams::model?, + ?n: Integer?, + ?response_format: OpenAI::Models::ImageEditParams::response_format?, + ?size: OpenAI::Models::ImageEditParams::size?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::image_edit_params type model = String | OpenAI::Models::image_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::image_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::image_model] end type response_format = :url | :b64_json - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL: :url B64_JSON: :b64_json - def self.values: -> ::Array[OpenAI::Models::ImageEditParams::response_format] + def self?.values: -> ::Array[OpenAI::Models::ImageEditParams::response_format] end type size = :"256x256" | :"512x512" | :"1024x1024" - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256: :"256x256" NUMBER_512X512: :"512x512" NUMBER_1024X1024: :"1024x1024" - def self.values: -> ::Array[OpenAI::Models::ImageEditParams::size] + def self?.values: -> ::Array[OpenAI::Models::ImageEditParams::size] end end end diff --git a/sig/openai/models/image_generate_params.rbs b/sig/openai/models/image_generate_params.rbs index ebeabef9..b9283099 100644 --- a/sig/openai/models/image_generate_params.rbs +++ b/sig/openai/models/image_generate_params.rbs @@ -14,7 +14,7 @@ module OpenAI & OpenAI::request_parameters class ImageGenerateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor prompt: String @@ -39,68 +39,74 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - prompt: String, - model: OpenAI::Models::ImageGenerateParams::model?, - n: Integer?, - quality: OpenAI::Models::ImageGenerateParams::quality, - response_format: OpenAI::Models::ImageGenerateParams::response_format?, - size: OpenAI::Models::ImageGenerateParams::size?, - style: OpenAI::Models::ImageGenerateParams::style?, - user: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::image_generate_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + prompt: String, + ?model: OpenAI::Models::ImageGenerateParams::model?, + ?n: Integer?, + ?quality: OpenAI::Models::ImageGenerateParams::quality, + ?response_format: OpenAI::Models::ImageGenerateParams::response_format?, + ?size: OpenAI::Models::ImageGenerateParams::size?, + ?style: OpenAI::Models::ImageGenerateParams::style?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::image_generate_params type model = String | OpenAI::Models::image_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::image_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::image_model] end type quality = :standard | :hd - class Quality < OpenAI::Enum + module Quality + extend OpenAI::Enum + STANDARD: :standard HD: :hd - def self.values: -> ::Array[OpenAI::Models::ImageGenerateParams::quality] + def self?.values: -> ::Array[OpenAI::Models::ImageGenerateParams::quality] end type response_format = :url | :b64_json - class ResponseFormat < OpenAI::Enum + module ResponseFormat + extend OpenAI::Enum + URL: :url B64_JSON: :b64_json - def self.values: -> ::Array[OpenAI::Models::ImageGenerateParams::response_format] + def self?.values: -> ::Array[OpenAI::Models::ImageGenerateParams::response_format] end type size = :"256x256" | :"512x512" | :"1024x1024" | :"1792x1024" | :"1024x1792" - class Size < OpenAI::Enum + module Size + extend OpenAI::Enum + NUMBER_256X256: :"256x256" NUMBER_512X512: :"512x512" NUMBER_1024X1024: :"1024x1024" NUMBER_1792X1024: :"1792x1024" NUMBER_1024X1792: :"1024x1792" - def self.values: -> ::Array[OpenAI::Models::ImageGenerateParams::size] + def self?.values: -> ::Array[OpenAI::Models::ImageGenerateParams::size] end type style = :vivid | :natural - class Style < OpenAI::Enum + module Style + extend OpenAI::Enum + VIVID: :vivid NATURAL: :natural - def self.values: -> ::Array[OpenAI::Models::ImageGenerateParams::style] + def self?.values: -> ::Array[OpenAI::Models::ImageGenerateParams::style] end end end diff --git a/sig/openai/models/image_model.rbs b/sig/openai/models/image_model.rbs index 1151fd9b..97e2e64f 100644 --- a/sig/openai/models/image_model.rbs +++ b/sig/openai/models/image_model.rbs @@ -2,11 +2,13 @@ module OpenAI module Models type image_model = :"dall-e-2" | :"dall-e-3" - class ImageModel < OpenAI::Enum + module ImageModel + extend OpenAI::Enum + DALL_E_2: :"dall-e-2" DALL_E_3: :"dall-e-3" - def self.values: -> ::Array[OpenAI::Models::image_model] + def self?.values: -> ::Array[OpenAI::Models::image_model] end end end diff --git a/sig/openai/models/images_response.rbs b/sig/openai/models/images_response.rbs index 97764d62..cafb98c6 100644 --- a/sig/openai/models/images_response.rbs +++ b/sig/openai/models/images_response.rbs @@ -8,9 +8,10 @@ module OpenAI attr_accessor data: ::Array[OpenAI::Models::Image] - def initialize: - (created: Integer, data: ::Array[OpenAI::Models::Image]) -> void - | (?OpenAI::Models::images_response | OpenAI::BaseModel data) -> void + def initialize: ( + created: Integer, + data: ::Array[OpenAI::Models::Image] + ) -> void def to_hash: -> OpenAI::Models::images_response end diff --git a/sig/openai/models/model.rbs b/sig/openai/models/model.rbs index 4d5cd661..3540d0d1 100644 --- a/sig/openai/models/model.rbs +++ b/sig/openai/models/model.rbs @@ -12,9 +12,12 @@ module OpenAI attr_accessor owned_by: String - def initialize: - (id: String, created: Integer, owned_by: String, object: :model) -> void - | (?OpenAI::Models::model | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + created: Integer, + owned_by: String, + ?object: :model + ) -> void def to_hash: -> OpenAI::Models::model end diff --git a/sig/openai/models/model_delete_params.rbs b/sig/openai/models/model_delete_params.rbs index 4ea85eb1..a4ac1b91 100644 --- a/sig/openai/models/model_delete_params.rbs +++ b/sig/openai/models/model_delete_params.rbs @@ -3,14 +3,10 @@ module OpenAI type model_delete_params = { } & OpenAI::request_parameters class ModelDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::model_delete_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::model_delete_params end diff --git a/sig/openai/models/model_deleted.rbs b/sig/openai/models/model_deleted.rbs index 47e9b6bb..6297c483 100644 --- a/sig/openai/models/model_deleted.rbs +++ b/sig/openai/models/model_deleted.rbs @@ -9,9 +9,7 @@ module OpenAI attr_accessor object: String - def initialize: - (id: String, deleted: bool, object: String) -> void - | (?OpenAI::Models::model_deleted | OpenAI::BaseModel data) -> void + def initialize: (id: String, deleted: bool, object: String) -> void def to_hash: -> OpenAI::Models::model_deleted end diff --git a/sig/openai/models/model_list_params.rbs b/sig/openai/models/model_list_params.rbs index 258c64c8..15ed4c2f 100644 --- a/sig/openai/models/model_list_params.rbs +++ b/sig/openai/models/model_list_params.rbs @@ -3,12 +3,10 @@ module OpenAI type model_list_params = { } & OpenAI::request_parameters class ModelListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | (?OpenAI::Models::model_list_params | OpenAI::BaseModel data) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::model_list_params end diff --git a/sig/openai/models/model_retrieve_params.rbs b/sig/openai/models/model_retrieve_params.rbs index 78cbe28c..5293679d 100644 --- a/sig/openai/models/model_retrieve_params.rbs +++ b/sig/openai/models/model_retrieve_params.rbs @@ -3,14 +3,10 @@ module OpenAI type model_retrieve_params = { } & OpenAI::request_parameters class ModelRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::model_retrieve_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::model_retrieve_params end diff --git a/sig/openai/models/moderation.rbs b/sig/openai/models/moderation.rbs index a3717393..9967761f 100644 --- a/sig/openai/models/moderation.rbs +++ b/sig/openai/models/moderation.rbs @@ -17,14 +17,12 @@ module OpenAI attr_accessor flagged: bool - def initialize: - ( - categories: OpenAI::Models::Moderation::Categories, - category_applied_input_types: OpenAI::Models::Moderation::CategoryAppliedInputTypes, - category_scores: OpenAI::Models::Moderation::CategoryScores, - flagged: bool - ) -> void - | (?OpenAI::Models::moderation | OpenAI::BaseModel data) -> void + def initialize: ( + categories: OpenAI::Models::Moderation::Categories, + category_applied_input_types: OpenAI::Models::Moderation::CategoryAppliedInputTypes, + category_scores: OpenAI::Models::Moderation::CategoryScores, + flagged: bool + ) -> void def to_hash: -> OpenAI::Models::moderation @@ -72,25 +70,21 @@ module OpenAI attr_accessor violence_graphic: bool - def initialize: - ( - harassment: bool, - harassment_threatening: bool, - hate: bool, - hate_threatening: bool, - illicit: bool?, - illicit_violent: bool?, - self_harm: bool, - self_harm_instructions: bool, - self_harm_intent: bool, - sexual: bool, - sexual_minors: bool, - violence: bool, - violence_graphic: bool - ) -> void - | ( - ?OpenAI::Models::Moderation::categories | OpenAI::BaseModel data - ) -> void + def initialize: ( + harassment: bool, + harassment_threatening: bool, + hate: bool, + hate_threatening: bool, + illicit: bool?, + illicit_violent: bool?, + self_harm: bool, + self_harm_instructions: bool, + self_harm_intent: bool, + sexual: bool, + sexual_minors: bool, + violence: bool, + violence_graphic: bool + ) -> void def to_hash: -> OpenAI::Models::Moderation::categories end @@ -139,137 +133,158 @@ module OpenAI attr_accessor violence_graphic: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence_graphic] - def initialize: - ( - harassment: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment], - harassment_threatening: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment_threatening], - hate: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate], - hate_threatening: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate_threatening], - illicit: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit], - illicit_violent: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit_violent], - self_harm: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm], - self_harm_instructions: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_instruction], - self_harm_intent: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_intent], - sexual: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual], - sexual_minors: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual_minor], - violence: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence], - violence_graphic: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence_graphic] - ) -> void - | ( - ?OpenAI::Models::Moderation::category_applied_input_types - | OpenAI::BaseModel data - ) -> void + def initialize: ( + harassment: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment], + harassment_threatening: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment_threatening], + hate: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate], + hate_threatening: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate_threatening], + illicit: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit], + illicit_violent: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit_violent], + self_harm: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm], + self_harm_instructions: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_instruction], + self_harm_intent: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_intent], + sexual: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual], + sexual_minors: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual_minor], + violence: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence], + violence_graphic: ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence_graphic] + ) -> void def to_hash: -> OpenAI::Models::Moderation::category_applied_input_types type harassment = :text - class Harassment < OpenAI::Enum + module Harassment + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment] end type harassment_threatening = :text - class HarassmentThreatening < OpenAI::Enum + module HarassmentThreatening + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment_threatening] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::harassment_threatening] end type hate = :text - class Hate < OpenAI::Enum + module Hate + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate] end type hate_threatening = :text - class HateThreatening < OpenAI::Enum + module HateThreatening + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate_threatening] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::hate_threatening] end type illicit = :text - class Illicit < OpenAI::Enum + module Illicit + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit] end type illicit_violent = :text - class IllicitViolent < OpenAI::Enum + module IllicitViolent + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit_violent] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::illicit_violent] end type self_harm = :text | :image - class SelfHarm < OpenAI::Enum + module SelfHarm + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm] end type self_harm_instruction = :text | :image - class SelfHarmInstruction < OpenAI::Enum + module SelfHarmInstruction + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_instruction] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_instruction] end type self_harm_intent = :text | :image - class SelfHarmIntent < OpenAI::Enum + module SelfHarmIntent + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_intent] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::self_harm_intent] end type sexual = :text | :image - class Sexual < OpenAI::Enum + module Sexual + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual] end type sexual_minor = :text - class SexualMinor < OpenAI::Enum + module SexualMinor + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual_minor] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::sexual_minor] end type violence = :text | :image - class Violence < OpenAI::Enum + module Violence + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence] end type violence_graphic = :text | :image - class ViolenceGraphic < OpenAI::Enum + module ViolenceGraphic + extend OpenAI::Enum + TEXT: :text IMAGE: :image - def self.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence_graphic] + def self?.values: -> ::Array[OpenAI::Models::Moderation::CategoryAppliedInputTypes::violence_graphic] end end @@ -317,26 +332,21 @@ module OpenAI attr_accessor violence_graphic: Float - def initialize: - ( - harassment: Float, - harassment_threatening: Float, - hate: Float, - hate_threatening: Float, - illicit: Float, - illicit_violent: Float, - self_harm: Float, - self_harm_instructions: Float, - self_harm_intent: Float, - sexual: Float, - sexual_minors: Float, - violence: Float, - violence_graphic: Float - ) -> void - | ( - ?OpenAI::Models::Moderation::category_scores - | OpenAI::BaseModel data - ) -> void + def initialize: ( + harassment: Float, + harassment_threatening: Float, + hate: Float, + hate_threatening: Float, + illicit: Float, + illicit_violent: Float, + self_harm: Float, + self_harm_instructions: Float, + self_harm_intent: Float, + sexual: Float, + sexual_minors: Float, + violence: Float, + violence_graphic: Float + ) -> void def to_hash: -> OpenAI::Models::Moderation::category_scores end diff --git a/sig/openai/models/moderation_create_params.rbs b/sig/openai/models/moderation_create_params.rbs index e5c23167..7067fe66 100644 --- a/sig/openai/models/moderation_create_params.rbs +++ b/sig/openai/models/moderation_create_params.rbs @@ -8,7 +8,7 @@ module OpenAI & OpenAI::request_parameters class ModerationCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor input: OpenAI::Models::ModerationCreateParams::input @@ -19,15 +19,11 @@ module OpenAI OpenAI::Models::ModerationCreateParams::model ) -> OpenAI::Models::ModerationCreateParams::model - def initialize: - ( - input: OpenAI::Models::ModerationCreateParams::input, - model: OpenAI::Models::ModerationCreateParams::model, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::moderation_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + input: OpenAI::Models::ModerationCreateParams::input, + ?model: OpenAI::Models::ModerationCreateParams::model, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::moderation_create_params @@ -36,7 +32,11 @@ module OpenAI | ::Array[String] | ::Array[OpenAI::Models::moderation_multi_modal_input] - class Input < OpenAI::Union + module Input + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String], ::Array[OpenAI::Models::moderation_multi_modal_input]] + type string_array = ::Array[String] StringArray: string_array @@ -45,14 +45,14 @@ module OpenAI ::Array[OpenAI::Models::moderation_multi_modal_input] ModerationMultiModalInputArray: moderation_multi_modal_input_array - - def self.variants: -> [String, ::Array[String], ::Array[OpenAI::Models::moderation_multi_modal_input]] end type model = String | OpenAI::Models::moderation_model - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::moderation_model] + module Model + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::moderation_model] end end end diff --git a/sig/openai/models/moderation_create_response.rbs b/sig/openai/models/moderation_create_response.rbs index faa955af..5934337f 100644 --- a/sig/openai/models/moderation_create_response.rbs +++ b/sig/openai/models/moderation_create_response.rbs @@ -14,15 +14,11 @@ module OpenAI attr_accessor results: ::Array[OpenAI::Models::Moderation] - def initialize: - ( - id: String, - model: String, - results: ::Array[OpenAI::Models::Moderation] - ) -> void - | ( - ?OpenAI::Models::moderation_create_response | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + model: String, + results: ::Array[OpenAI::Models::Moderation] + ) -> void def to_hash: -> OpenAI::Models::moderation_create_response end diff --git a/sig/openai/models/moderation_image_url_input.rbs b/sig/openai/models/moderation_image_url_input.rbs index b780a3e0..e23f649d 100644 --- a/sig/openai/models/moderation_image_url_input.rbs +++ b/sig/openai/models/moderation_image_url_input.rbs @@ -11,14 +11,10 @@ module OpenAI attr_accessor type: :image_url - def initialize: - ( - image_url: OpenAI::Models::ModerationImageURLInput::ImageURL, - type: :image_url - ) -> void - | ( - ?OpenAI::Models::moderation_image_url_input | OpenAI::BaseModel data - ) -> void + def initialize: ( + image_url: OpenAI::Models::ModerationImageURLInput::ImageURL, + ?type: :image_url + ) -> void def to_hash: -> OpenAI::Models::moderation_image_url_input @@ -27,12 +23,7 @@ module OpenAI class ImageURL < OpenAI::BaseModel attr_accessor url: String - def initialize: - (url: String) -> void - | ( - ?OpenAI::Models::ModerationImageURLInput::image_url - | OpenAI::BaseModel data - ) -> void + def initialize: (url: String) -> void def to_hash: -> OpenAI::Models::ModerationImageURLInput::image_url end diff --git a/sig/openai/models/moderation_model.rbs b/sig/openai/models/moderation_model.rbs index 6fb884f3..1f6ab3fd 100644 --- a/sig/openai/models/moderation_model.rbs +++ b/sig/openai/models/moderation_model.rbs @@ -6,13 +6,15 @@ module OpenAI | :"text-moderation-latest" | :"text-moderation-stable" - class ModerationModel < OpenAI::Enum + module ModerationModel + extend OpenAI::Enum + OMNI_MODERATION_LATEST: :"omni-moderation-latest" OMNI_MODERATION_2024_09_26: :"omni-moderation-2024-09-26" TEXT_MODERATION_LATEST: :"text-moderation-latest" TEXT_MODERATION_STABLE: :"text-moderation-stable" - def self.values: -> ::Array[OpenAI::Models::moderation_model] + def self?.values: -> ::Array[OpenAI::Models::moderation_model] end end end diff --git a/sig/openai/models/moderation_multi_modal_input.rbs b/sig/openai/models/moderation_multi_modal_input.rbs index c98cd3a4..967234fc 100644 --- a/sig/openai/models/moderation_multi_modal_input.rbs +++ b/sig/openai/models/moderation_multi_modal_input.rbs @@ -4,8 +4,10 @@ module OpenAI OpenAI::Models::ModerationImageURLInput | OpenAI::Models::ModerationTextInput - class ModerationMultiModalInput < OpenAI::Union - def self.variants: -> [OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput] + module ModerationMultiModalInput + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput] end end end diff --git a/sig/openai/models/moderation_text_input.rbs b/sig/openai/models/moderation_text_input.rbs index 58c7920b..45143b65 100644 --- a/sig/openai/models/moderation_text_input.rbs +++ b/sig/openai/models/moderation_text_input.rbs @@ -7,11 +7,7 @@ module OpenAI attr_accessor type: :text - def initialize: - (text: String, type: :text) -> void - | ( - ?OpenAI::Models::moderation_text_input | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :text) -> void def to_hash: -> OpenAI::Models::moderation_text_input end diff --git a/sig/openai/models/other_file_chunking_strategy_object.rbs b/sig/openai/models/other_file_chunking_strategy_object.rbs index 253ded71..60c24b65 100644 --- a/sig/openai/models/other_file_chunking_strategy_object.rbs +++ b/sig/openai/models/other_file_chunking_strategy_object.rbs @@ -5,12 +5,7 @@ module OpenAI class OtherFileChunkingStrategyObject < OpenAI::BaseModel attr_accessor type: :other - def initialize: - (type: :other) -> void - | ( - ?OpenAI::Models::other_file_chunking_strategy_object - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :other) -> void def to_hash: -> OpenAI::Models::other_file_chunking_strategy_object end diff --git a/sig/openai/models/reasoning.rbs b/sig/openai/models/reasoning.rbs index 3a38b298..d4060722 100644 --- a/sig/openai/models/reasoning.rbs +++ b/sig/openai/models/reasoning.rbs @@ -11,22 +11,22 @@ module OpenAI attr_accessor generate_summary: OpenAI::Models::Reasoning::generate_summary? - def initialize: - ( - effort: OpenAI::Models::reasoning_effort?, - generate_summary: OpenAI::Models::Reasoning::generate_summary? - ) -> void - | (?OpenAI::Models::reasoning | OpenAI::BaseModel data) -> void + def initialize: ( + ?effort: OpenAI::Models::reasoning_effort?, + ?generate_summary: OpenAI::Models::Reasoning::generate_summary? + ) -> void def to_hash: -> OpenAI::Models::reasoning type generate_summary = :concise | :detailed - class GenerateSummary < OpenAI::Enum + module GenerateSummary + extend OpenAI::Enum + CONCISE: :concise DETAILED: :detailed - def self.values: -> ::Array[OpenAI::Models::Reasoning::generate_summary] + def self?.values: -> ::Array[OpenAI::Models::Reasoning::generate_summary] end end end diff --git a/sig/openai/models/reasoning_effort.rbs b/sig/openai/models/reasoning_effort.rbs index 57327554..7ee7ea11 100644 --- a/sig/openai/models/reasoning_effort.rbs +++ b/sig/openai/models/reasoning_effort.rbs @@ -2,12 +2,14 @@ module OpenAI module Models type reasoning_effort = :low | :medium | :high - class ReasoningEffort < OpenAI::Enum + module ReasoningEffort + extend OpenAI::Enum + LOW: :low MEDIUM: :medium HIGH: :high - def self.values: -> ::Array[OpenAI::Models::reasoning_effort] + def self?.values: -> ::Array[OpenAI::Models::reasoning_effort] end end end diff --git a/sig/openai/models/response_format_json_object.rbs b/sig/openai/models/response_format_json_object.rbs index 3e129a52..f228d234 100644 --- a/sig/openai/models/response_format_json_object.rbs +++ b/sig/openai/models/response_format_json_object.rbs @@ -5,11 +5,7 @@ module OpenAI class ResponseFormatJSONObject < OpenAI::BaseModel attr_accessor type: :json_object - def initialize: - (type: :json_object) -> void - | ( - ?OpenAI::Models::response_format_json_object | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :json_object) -> void def to_hash: -> OpenAI::Models::response_format_json_object end diff --git a/sig/openai/models/response_format_json_schema.rbs b/sig/openai/models/response_format_json_schema.rbs index 7b3816a5..05e4a025 100644 --- a/sig/openai/models/response_format_json_schema.rbs +++ b/sig/openai/models/response_format_json_schema.rbs @@ -11,14 +11,10 @@ module OpenAI attr_accessor type: :json_schema - def initialize: - ( - json_schema: OpenAI::Models::ResponseFormatJSONSchema::JSONSchema, - type: :json_schema - ) -> void - | ( - ?OpenAI::Models::response_format_json_schema | OpenAI::BaseModel data - ) -> void + def initialize: ( + json_schema: OpenAI::Models::ResponseFormatJSONSchema::JSONSchema, + ?type: :json_schema + ) -> void def to_hash: -> OpenAI::Models::response_format_json_schema @@ -43,17 +39,12 @@ module OpenAI attr_accessor strict: bool? - def initialize: - ( - name: String, - description: String, - schema: ::Hash[Symbol, top], - strict: bool? - ) -> void - | ( - ?OpenAI::Models::ResponseFormatJSONSchema::json_schema - | OpenAI::BaseModel data - ) -> void + def initialize: ( + name: String, + ?description: String, + ?schema: ::Hash[Symbol, top], + ?strict: bool? + ) -> void def to_hash: -> OpenAI::Models::ResponseFormatJSONSchema::json_schema end diff --git a/sig/openai/models/response_format_text.rbs b/sig/openai/models/response_format_text.rbs index c6c2619d..691bace2 100644 --- a/sig/openai/models/response_format_text.rbs +++ b/sig/openai/models/response_format_text.rbs @@ -5,11 +5,7 @@ module OpenAI class ResponseFormatText < OpenAI::BaseModel attr_accessor type: :text - def initialize: - (type: :text) -> void - | ( - ?OpenAI::Models::response_format_text | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :text) -> void def to_hash: -> OpenAI::Models::response_format_text end diff --git a/sig/openai/models/responses/computer_tool.rbs b/sig/openai/models/responses/computer_tool.rbs index 39cc531c..0b984fde 100644 --- a/sig/openai/models/responses/computer_tool.rbs +++ b/sig/openai/models/responses/computer_tool.rbs @@ -18,28 +18,26 @@ module OpenAI attr_accessor type: :computer_use_preview - def initialize: - ( - display_height: Float, - display_width: Float, - environment: OpenAI::Models::Responses::ComputerTool::environment, - type: :computer_use_preview - ) -> void - | ( - ?OpenAI::Models::Responses::computer_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + display_height: Float, + display_width: Float, + environment: OpenAI::Models::Responses::ComputerTool::environment, + ?type: :computer_use_preview + ) -> void def to_hash: -> OpenAI::Models::Responses::computer_tool type environment = :mac | :windows | :ubuntu | :browser - class Environment < OpenAI::Enum + module Environment + extend OpenAI::Enum + MAC: :mac WINDOWS: :windows UBUNTU: :ubuntu BROWSER: :browser - def self.values: -> ::Array[OpenAI::Models::Responses::ComputerTool::environment] + def self?.values: -> ::Array[OpenAI::Models::Responses::ComputerTool::environment] end end end diff --git a/sig/openai/models/responses/easy_input_message.rbs b/sig/openai/models/responses/easy_input_message.rbs index 7347e123..04936217 100644 --- a/sig/openai/models/responses/easy_input_message.rbs +++ b/sig/openai/models/responses/easy_input_message.rbs @@ -19,16 +19,11 @@ module OpenAI OpenAI::Models::Responses::EasyInputMessage::type_ ) -> OpenAI::Models::Responses::EasyInputMessage::type_ - def initialize: - ( - content: OpenAI::Models::Responses::EasyInputMessage::content, - role: OpenAI::Models::Responses::EasyInputMessage::role, - type: OpenAI::Models::Responses::EasyInputMessage::type_ - ) -> void - | ( - ?OpenAI::Models::Responses::easy_input_message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Responses::EasyInputMessage::content, + role: OpenAI::Models::Responses::EasyInputMessage::role, + ?type: OpenAI::Models::Responses::EasyInputMessage::type_ + ) -> void def to_hash: -> OpenAI::Models::Responses::easy_input_message @@ -36,27 +31,33 @@ module OpenAI String | OpenAI::Models::Responses::response_input_message_content_list - class Content < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::Responses::response_input_message_content_list] + module Content + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::Responses::response_input_message_content_list] end type role = :user | :assistant | :system | :developer - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user ASSISTANT: :assistant SYSTEM: :system DEVELOPER: :developer - def self.values: -> ::Array[OpenAI::Models::Responses::EasyInputMessage::role] + def self?.values: -> ::Array[OpenAI::Models::Responses::EasyInputMessage::role] end type type_ = :message - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE: :message - def self.values: -> ::Array[OpenAI::Models::Responses::EasyInputMessage::type_] + def self?.values: -> ::Array[OpenAI::Models::Responses::EasyInputMessage::type_] end end end diff --git a/sig/openai/models/responses/file_search_tool.rbs b/sig/openai/models/responses/file_search_tool.rbs index 32c08269..69476cbd 100644 --- a/sig/openai/models/responses/file_search_tool.rbs +++ b/sig/openai/models/responses/file_search_tool.rbs @@ -31,26 +31,23 @@ module OpenAI OpenAI::Models::Responses::FileSearchTool::RankingOptions ) -> OpenAI::Models::Responses::FileSearchTool::RankingOptions - def initialize: - ( - vector_store_ids: ::Array[String], - filters: OpenAI::Models::Responses::FileSearchTool::filters, - max_num_results: Integer, - ranking_options: OpenAI::Models::Responses::FileSearchTool::RankingOptions, - type: :file_search - ) -> void - | ( - ?OpenAI::Models::Responses::file_search_tool - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_ids: ::Array[String], + ?filters: OpenAI::Models::Responses::FileSearchTool::filters, + ?max_num_results: Integer, + ?ranking_options: OpenAI::Models::Responses::FileSearchTool::RankingOptions, + ?type: :file_search + ) -> void def to_hash: -> OpenAI::Models::Responses::file_search_tool type filters = OpenAI::Models::ComparisonFilter | OpenAI::Models::CompoundFilter - class Filters < OpenAI::Union - def self.variants: -> [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] + module Filters + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] end type ranking_options = @@ -70,25 +67,22 @@ module OpenAI def score_threshold=: (Float) -> Float - def initialize: - ( - ranker: OpenAI::Models::Responses::FileSearchTool::RankingOptions::ranker, - score_threshold: Float - ) -> void - | ( - ?OpenAI::Models::Responses::FileSearchTool::ranking_options - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?ranker: OpenAI::Models::Responses::FileSearchTool::RankingOptions::ranker, + ?score_threshold: Float + ) -> void def to_hash: -> OpenAI::Models::Responses::FileSearchTool::ranking_options type ranker = :auto | :"default-2024-11-15" - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO: :auto DEFAULT_2024_11_15: :"default-2024-11-15" - def self.values: -> ::Array[OpenAI::Models::Responses::FileSearchTool::RankingOptions::ranker] + def self?.values: -> ::Array[OpenAI::Models::Responses::FileSearchTool::RankingOptions::ranker] end end end diff --git a/sig/openai/models/responses/function_tool.rbs b/sig/openai/models/responses/function_tool.rbs index 3a052a98..b0e5aa03 100644 --- a/sig/openai/models/responses/function_tool.rbs +++ b/sig/openai/models/responses/function_tool.rbs @@ -21,17 +21,13 @@ module OpenAI attr_accessor description: String? - def initialize: - ( - name: String, - parameters: ::Hash[Symbol, top], - strict: bool, - description: String?, - type: :function - ) -> void - | ( - ?OpenAI::Models::Responses::function_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + name: String, + parameters: ::Hash[Symbol, top], + strict: bool, + ?description: String?, + ?type: :function + ) -> void def to_hash: -> OpenAI::Models::Responses::function_tool end diff --git a/sig/openai/models/responses/input_item_list_params.rbs b/sig/openai/models/responses/input_item_list_params.rbs index e9993f02..d4b3d62b 100644 --- a/sig/openai/models/responses/input_item_list_params.rbs +++ b/sig/openai/models/responses/input_item_list_params.rbs @@ -5,13 +5,14 @@ module OpenAI { after: String, before: String, + include: ::Array[OpenAI::Models::Responses::response_includable], limit: Integer, order: OpenAI::Models::Responses::InputItemListParams::order } & OpenAI::request_parameters class InputItemListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -22,6 +23,12 @@ module OpenAI def before=: (String) -> String + attr_reader include: ::Array[OpenAI::Models::Responses::response_includable]? + + def include=: ( + ::Array[OpenAI::Models::Responses::response_includable] + ) -> ::Array[OpenAI::Models::Responses::response_includable] + attr_reader limit: Integer? def limit=: (Integer) -> Integer @@ -32,28 +39,26 @@ module OpenAI OpenAI::Models::Responses::InputItemListParams::order ) -> OpenAI::Models::Responses::InputItemListParams::order - def initialize: - ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Responses::InputItemListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Responses::input_item_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?include: ::Array[OpenAI::Models::Responses::response_includable], + ?limit: Integer, + ?order: OpenAI::Models::Responses::InputItemListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Responses::input_item_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::Responses::InputItemListParams::order] + def self?.values: -> ::Array[OpenAI::Models::Responses::InputItemListParams::order] end end end diff --git a/sig/openai/models/responses/response.rbs b/sig/openai/models/responses/response.rbs index 2fa4632c..254aa7e1 100644 --- a/sig/openai/models/responses/response.rbs +++ b/sig/openai/models/responses/response.rbs @@ -9,7 +9,7 @@ module OpenAI incomplete_details: OpenAI::Models::Responses::Response::IncompleteDetails?, instructions: String?, metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Responses::Response::model, + model: OpenAI::Models::responses_model, object: :response, output: ::Array[OpenAI::Models::Responses::response_output_item], parallel_tool_calls: bool, @@ -40,7 +40,7 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? - attr_accessor model: OpenAI::Models::Responses::Response::model + attr_accessor model: OpenAI::Models::responses_model attr_accessor object: :response @@ -86,34 +86,30 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - id: String, - created_at: Float, - error: OpenAI::Models::Responses::ResponseError?, - incomplete_details: OpenAI::Models::Responses::Response::IncompleteDetails?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Responses::Response::model, - output: ::Array[OpenAI::Models::Responses::response_output_item], - parallel_tool_calls: bool, - temperature: Float?, - tool_choice: OpenAI::Models::Responses::Response::tool_choice, - tools: ::Array[OpenAI::Models::Responses::tool], - top_p: Float?, - max_output_tokens: Integer?, - previous_response_id: String?, - reasoning: OpenAI::Models::Reasoning?, - status: OpenAI::Models::Responses::response_status, - text: OpenAI::Models::Responses::ResponseTextConfig, - truncation: OpenAI::Models::Responses::Response::truncation?, - usage: OpenAI::Models::Responses::ResponseUsage, - user: String, - object: :response - ) -> void - | ( - ?OpenAI::Models::Responses::response | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Float, + error: OpenAI::Models::Responses::ResponseError?, + incomplete_details: OpenAI::Models::Responses::Response::IncompleteDetails?, + instructions: String?, + metadata: OpenAI::Models::metadata?, + model: OpenAI::Models::responses_model, + output: ::Array[OpenAI::Models::Responses::response_output_item], + parallel_tool_calls: bool, + temperature: Float?, + tool_choice: OpenAI::Models::Responses::Response::tool_choice, + tools: ::Array[OpenAI::Models::Responses::tool], + top_p: Float?, + ?max_output_tokens: Integer?, + ?previous_response_id: String?, + ?reasoning: OpenAI::Models::Reasoning?, + ?status: OpenAI::Models::Responses::response_status, + ?text: OpenAI::Models::Responses::ResponseTextConfig, + ?truncation: OpenAI::Models::Responses::Response::truncation?, + ?usage: OpenAI::Models::Responses::ResponseUsage, + ?user: String, + ?object: :response + ) -> void def to_hash: -> OpenAI::Models::Responses::response @@ -129,49 +125,44 @@ module OpenAI OpenAI::Models::Responses::Response::IncompleteDetails::reason ) -> OpenAI::Models::Responses::Response::IncompleteDetails::reason - def initialize: - ( - reason: OpenAI::Models::Responses::Response::IncompleteDetails::reason - ) -> void - | ( - ?OpenAI::Models::Responses::Response::incomplete_details - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?reason: OpenAI::Models::Responses::Response::IncompleteDetails::reason + ) -> void def to_hash: -> OpenAI::Models::Responses::Response::incomplete_details type reason = :max_output_tokens | :content_filter - class Reason < OpenAI::Enum + module Reason + extend OpenAI::Enum + MAX_OUTPUT_TOKENS: :max_output_tokens CONTENT_FILTER: :content_filter - def self.values: -> ::Array[OpenAI::Models::Responses::Response::IncompleteDetails::reason] + def self?.values: -> ::Array[OpenAI::Models::Responses::Response::IncompleteDetails::reason] end end - type model = String | OpenAI::Models::chat_model - - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] - end - type tool_choice = OpenAI::Models::Responses::tool_choice_options | OpenAI::Models::Responses::ToolChoiceTypes | OpenAI::Models::Responses::ToolChoiceFunction - class ToolChoice < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::tool_choice_options, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] + module ToolChoice + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::tool_choice_options, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] end type truncation = :auto | :disabled - class Truncation < OpenAI::Enum + module Truncation + extend OpenAI::Enum + AUTO: :auto DISABLED: :disabled - def self.values: -> ::Array[OpenAI::Models::Responses::Response::truncation] + def self?.values: -> ::Array[OpenAI::Models::Responses::Response::truncation] end end end diff --git a/sig/openai/models/responses/response_audio_delta_event.rbs b/sig/openai/models/responses/response_audio_delta_event.rbs index 3f1416c2..f6a9c6fd 100644 --- a/sig/openai/models/responses/response_audio_delta_event.rbs +++ b/sig/openai/models/responses/response_audio_delta_event.rbs @@ -9,12 +9,7 @@ module OpenAI attr_accessor type: :"response.audio.delta" - def initialize: - (delta: String, type: :"response.audio.delta") -> void - | ( - ?OpenAI::Models::Responses::response_audio_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: (delta: String, ?type: :"response.audio.delta") -> void def to_hash: -> OpenAI::Models::Responses::response_audio_delta_event end diff --git a/sig/openai/models/responses/response_audio_done_event.rbs b/sig/openai/models/responses/response_audio_done_event.rbs index 2e521bbe..9449f329 100644 --- a/sig/openai/models/responses/response_audio_done_event.rbs +++ b/sig/openai/models/responses/response_audio_done_event.rbs @@ -6,12 +6,7 @@ module OpenAI class ResponseAudioDoneEvent < OpenAI::BaseModel attr_accessor type: :"response.audio.done" - def initialize: - (type: :"response.audio.done") -> void - | ( - ?OpenAI::Models::Responses::response_audio_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :"response.audio.done") -> void def to_hash: -> OpenAI::Models::Responses::response_audio_done_event end diff --git a/sig/openai/models/responses/response_audio_transcript_delta_event.rbs b/sig/openai/models/responses/response_audio_transcript_delta_event.rbs index 047e0072..b1e7a534 100644 --- a/sig/openai/models/responses/response_audio_transcript_delta_event.rbs +++ b/sig/openai/models/responses/response_audio_transcript_delta_event.rbs @@ -9,12 +9,10 @@ module OpenAI attr_accessor type: :"response.audio.transcript.delta" - def initialize: - (delta: String, type: :"response.audio.transcript.delta") -> void - | ( - ?OpenAI::Models::Responses::response_audio_transcript_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + delta: String, + ?type: :"response.audio.transcript.delta" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_audio_transcript_delta_event end diff --git a/sig/openai/models/responses/response_audio_transcript_done_event.rbs b/sig/openai/models/responses/response_audio_transcript_done_event.rbs index 225a0012..ca5e5241 100644 --- a/sig/openai/models/responses/response_audio_transcript_done_event.rbs +++ b/sig/openai/models/responses/response_audio_transcript_done_event.rbs @@ -7,12 +7,7 @@ module OpenAI class ResponseAudioTranscriptDoneEvent < OpenAI::BaseModel attr_accessor type: :"response.audio.transcript.done" - def initialize: - (type: :"response.audio.transcript.done") -> void - | ( - ?OpenAI::Models::Responses::response_audio_transcript_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :"response.audio.transcript.done") -> void def to_hash: -> OpenAI::Models::Responses::response_audio_transcript_done_event end diff --git a/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs b/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs index edd9f658..a330e86c 100644 --- a/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs +++ b/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.code_interpreter_call.code.delta" - def initialize: - ( - delta: String, - output_index: Integer, - type: :"response.code_interpreter_call.code.delta" - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_call_code_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + delta: String, + output_index: Integer, + ?type: :"response.code_interpreter_call.code.delta" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_call_code_delta_event end diff --git a/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs b/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs index 91d301fe..45e0a1fd 100644 --- a/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs +++ b/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.code_interpreter_call.code.done" - def initialize: - ( - code: String, - output_index: Integer, - type: :"response.code_interpreter_call.code.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_call_code_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: String, + output_index: Integer, + ?type: :"response.code_interpreter_call.code.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_call_code_done_event end diff --git a/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs b/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs index 8faa1b2d..46aae17c 100644 --- a/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs +++ b/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.code_interpreter_call.completed" - def initialize: - ( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, - output_index: Integer, - type: :"response.code_interpreter_call.completed" - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_call_completed_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + output_index: Integer, + ?type: :"response.code_interpreter_call.completed" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_call_completed_event end diff --git a/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs b/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs index ee6b0ff0..a5384a8c 100644 --- a/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs +++ b/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.code_interpreter_call.in_progress" - def initialize: - ( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, - output_index: Integer, - type: :"response.code_interpreter_call.in_progress" - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_call_in_progress_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + output_index: Integer, + ?type: :"response.code_interpreter_call.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_call_in_progress_event end diff --git a/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs b/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs index a8ed5522..3fcff8bf 100644 --- a/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs +++ b/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.code_interpreter_call.interpreting" - def initialize: - ( - code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, - output_index: Integer, - type: :"response.code_interpreter_call.interpreting" - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_call_interpreting_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code_interpreter_call: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, + output_index: Integer, + ?type: :"response.code_interpreter_call.interpreting" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_call_interpreting_event end diff --git a/sig/openai/models/responses/response_code_interpreter_tool_call.rbs b/sig/openai/models/responses/response_code_interpreter_tool_call.rbs index f57c376a..0a64a853 100644 --- a/sig/openai/models/responses/response_code_interpreter_tool_call.rbs +++ b/sig/openai/models/responses/response_code_interpreter_tool_call.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :code_interpreter_call - def initialize: - ( - id: String, - code: String, - results: ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::result], - status: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::status, - type: :code_interpreter_call - ) -> void - | ( - ?OpenAI::Models::Responses::response_code_interpreter_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + code: String, + results: ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::result], + status: OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::status, + ?type: :code_interpreter_call + ) -> void def to_hash: -> OpenAI::Models::Responses::response_code_interpreter_tool_call @@ -40,7 +35,9 @@ module OpenAI OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs | OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files - class Result < OpenAI::Union + module Result + extend OpenAI::Union + type logs = { logs: String, type: :logs } class Logs < OpenAI::BaseModel @@ -48,12 +45,7 @@ module OpenAI attr_accessor type: :logs - def initialize: - (logs: String, type: :logs) -> void - | ( - ?OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::logs - | OpenAI::BaseModel data - ) -> void + def initialize: (logs: String, ?type: :logs) -> void def to_hash: -> OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::logs end @@ -69,15 +61,10 @@ module OpenAI attr_accessor type: :files - def initialize: - ( - files: ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File], - type: :files - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::files - | OpenAI::BaseModel data - ) -> void + def initialize: ( + files: ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::File], + ?type: :files + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::files @@ -88,28 +75,25 @@ module OpenAI attr_accessor mime_type: String - def initialize: - (file_id: String, mime_type: String) -> void - | ( - ?OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::file - | OpenAI::BaseModel data - ) -> void + def initialize: (file_id: String, mime_type: String) -> void def to_hash: -> OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files::file end end - def self.variants: -> [OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files] + def self?.variants: -> [OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Result::Files] end type status = :in_progress | :interpreting | :completed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress INTERPRETING: :interpreting COMPLETED: :completed - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::status] end end end diff --git a/sig/openai/models/responses/response_completed_event.rbs b/sig/openai/models/responses/response_completed_event.rbs index 05a0a5ab..372c8eb9 100644 --- a/sig/openai/models/responses/response_completed_event.rbs +++ b/sig/openai/models/responses/response_completed_event.rbs @@ -12,15 +12,10 @@ module OpenAI attr_accessor type: :"response.completed" - def initialize: - ( - response: OpenAI::Models::Responses::Response, - type: :"response.completed" - ) -> void - | ( - ?OpenAI::Models::Responses::response_completed_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + response: OpenAI::Models::Responses::Response, + ?type: :"response.completed" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_completed_event end diff --git a/sig/openai/models/responses/response_computer_tool_call.rbs b/sig/openai/models/responses/response_computer_tool_call.rbs index 7cc62b09..1cf4a066 100644 --- a/sig/openai/models/responses/response_computer_tool_call.rbs +++ b/sig/openai/models/responses/response_computer_tool_call.rbs @@ -24,19 +24,14 @@ module OpenAI attr_accessor type: OpenAI::Models::Responses::ResponseComputerToolCall::type_ - def initialize: - ( - id: String, - action: OpenAI::Models::Responses::ResponseComputerToolCall::action, - call_id: String, - pending_safety_checks: ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck], - status: OpenAI::Models::Responses::ResponseComputerToolCall::status, - type: OpenAI::Models::Responses::ResponseComputerToolCall::type_ - ) -> void - | ( - ?OpenAI::Models::Responses::response_computer_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + action: OpenAI::Models::Responses::ResponseComputerToolCall::action, + call_id: String, + pending_safety_checks: ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck], + status: OpenAI::Models::Responses::ResponseComputerToolCall::status, + type: OpenAI::Models::Responses::ResponseComputerToolCall::type_ + ) -> void def to_hash: -> OpenAI::Models::Responses::response_computer_tool_call @@ -51,7 +46,9 @@ module OpenAI | OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type | OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait - class Action < OpenAI::Union + module Action + extend OpenAI::Union + type click = { button: OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::button, @@ -69,30 +66,27 @@ module OpenAI attr_accessor y_: Integer - def initialize: - ( - button: OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::button, - x: Integer, - y_: Integer, - type: :click - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::click - | OpenAI::BaseModel data - ) -> void + def initialize: ( + button: OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::button, + x: Integer, + y_: Integer, + ?type: :click + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::click type button = :left | :right | :wheel | :back | :forward - class Button < OpenAI::Enum + module Button + extend OpenAI::Enum + LEFT: :left RIGHT: :right WHEEL: :wheel BACK: :back FORWARD: :forward - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::button] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::button] end end @@ -105,12 +99,11 @@ module OpenAI attr_accessor y_: Integer - def initialize: - (x: Integer, y_: Integer, type: :double_click) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::double_click - | OpenAI::BaseModel data - ) -> void + def initialize: ( + x: Integer, + y_: Integer, + ?type: :double_click + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::double_click end @@ -126,15 +119,10 @@ module OpenAI attr_accessor type: :drag - def initialize: - ( - path: ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path], - type: :drag - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::drag - | OpenAI::BaseModel data - ) -> void + def initialize: ( + path: ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path], + ?type: :drag + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::drag @@ -145,12 +133,7 @@ module OpenAI attr_accessor y_: Integer - def initialize: - (x: Integer, y_: Integer) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::path - | OpenAI::BaseModel data - ) -> void + def initialize: (x: Integer, y_: Integer) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::path end @@ -163,12 +146,7 @@ module OpenAI attr_accessor type: :keypress - def initialize: - (keys: ::Array[String], type: :keypress) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::keypress - | OpenAI::BaseModel data - ) -> void + def initialize: (keys: ::Array[String], ?type: :keypress) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::keypress end @@ -182,12 +160,7 @@ module OpenAI attr_accessor y_: Integer - def initialize: - (x: Integer, y_: Integer, type: :move) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::move - | OpenAI::BaseModel data - ) -> void + def initialize: (x: Integer, y_: Integer, ?type: :move) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::move end @@ -197,12 +170,7 @@ module OpenAI class Screenshot < OpenAI::BaseModel attr_accessor type: :screenshot - def initialize: - (type: :screenshot) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::screenshot - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :screenshot) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::screenshot end @@ -227,18 +195,13 @@ module OpenAI attr_accessor y_: Integer - def initialize: - ( - scroll_x: Integer, - scroll_y: Integer, - x: Integer, - y_: Integer, - type: :scroll - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::scroll - | OpenAI::BaseModel data - ) -> void + def initialize: ( + scroll_x: Integer, + scroll_y: Integer, + x: Integer, + y_: Integer, + ?type: :scroll + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::scroll end @@ -250,12 +213,7 @@ module OpenAI attr_accessor type: :type - def initialize: - (text: String, type: :type) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::type_ - | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :type) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::type_ end @@ -265,17 +223,12 @@ module OpenAI class Wait < OpenAI::BaseModel attr_accessor type: :wait - def initialize: - (type: :wait) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::Action::wait - | OpenAI::BaseModel data - ) -> void + def initialize: (?type: :wait) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::Action::wait end - def self.variants: -> [OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait] + def self?.variants: -> [OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait] end type pending_safety_check = @@ -288,32 +241,31 @@ module OpenAI attr_accessor message: String - def initialize: - (id: String, code: String, message: String) -> void - | ( - ?OpenAI::Models::Responses::ResponseComputerToolCall::pending_safety_check - | OpenAI::BaseModel data - ) -> void + def initialize: (id: String, code: String, message: String) -> void def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCall::pending_safety_check end type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::status] end type type_ = :computer_call - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + COMPUTER_CALL: :computer_call - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::type_] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCall::type_] end end end diff --git a/sig/openai/models/responses/response_computer_tool_call_output_item.rbs b/sig/openai/models/responses/response_computer_tool_call_output_item.rbs new file mode 100644 index 00000000..793ed85e --- /dev/null +++ b/sig/openai/models/responses/response_computer_tool_call_output_item.rbs @@ -0,0 +1,75 @@ +module OpenAI + module Models + module Responses + type response_computer_tool_call_output_item = + { + id: String, + call_id: String, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, + type: :computer_call_output, + acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck], + status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status + } + + class ResponseComputerToolCallOutputItem < OpenAI::BaseModel + attr_accessor id: String + + attr_accessor call_id: String + + attr_accessor output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot + + attr_accessor type: :computer_call_output + + attr_reader acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck]? + + def acknowledged_safety_checks=: ( + ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck] + ) -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck] + + attr_reader status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status? + + def status=: ( + OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status + ) -> OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status + + def initialize: ( + id: String, + call_id: String, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, + ?acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck], + ?status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status, + ?type: :computer_call_output + ) -> void + + def to_hash: -> OpenAI::Models::Responses::response_computer_tool_call_output_item + + type acknowledged_safety_check = + { id: String, code: String, message: String } + + class AcknowledgedSafetyCheck < OpenAI::BaseModel + attr_accessor id: String + + attr_accessor code: String + + attr_accessor message: String + + def initialize: (id: String, code: String, message: String) -> void + + def to_hash: -> OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::acknowledged_safety_check + end + + type status = :in_progress | :completed | :incomplete + + module Status + extend OpenAI::Enum + + IN_PROGRESS: :in_progress + COMPLETED: :completed + INCOMPLETE: :incomplete + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::status] + end + end + end + end +end diff --git a/sig/openai/models/responses/response_computer_tool_call_output_screenshot.rbs b/sig/openai/models/responses/response_computer_tool_call_output_screenshot.rbs new file mode 100644 index 00000000..3d8cc77b --- /dev/null +++ b/sig/openai/models/responses/response_computer_tool_call_output_screenshot.rbs @@ -0,0 +1,28 @@ +module OpenAI + module Models + module Responses + type response_computer_tool_call_output_screenshot = + { type: :computer_screenshot, file_id: String, image_url: String } + + class ResponseComputerToolCallOutputScreenshot < OpenAI::BaseModel + attr_accessor type: :computer_screenshot + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader image_url: String? + + def image_url=: (String) -> String + + def initialize: ( + ?file_id: String, + ?image_url: String, + ?type: :computer_screenshot + ) -> void + + def to_hash: -> OpenAI::Models::Responses::response_computer_tool_call_output_screenshot + end + end + end +end diff --git a/sig/openai/models/responses/response_content.rbs b/sig/openai/models/responses/response_content.rbs index c7bb377e..d8469d84 100644 --- a/sig/openai/models/responses/response_content.rbs +++ b/sig/openai/models/responses/response_content.rbs @@ -8,8 +8,10 @@ module OpenAI | OpenAI::Models::Responses::ResponseOutputText | OpenAI::Models::Responses::ResponseOutputRefusal - class ResponseContent < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] + module ResponseContent + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] end end end diff --git a/sig/openai/models/responses/response_content_part_added_event.rbs b/sig/openai/models/responses/response_content_part_added_event.rbs index 5bbbdac3..f4ca687c 100644 --- a/sig/openai/models/responses/response_content_part_added_event.rbs +++ b/sig/openai/models/responses/response_content_part_added_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.content_part.added" - def initialize: - ( - content_index: Integer, - item_id: String, - output_index: Integer, - part: OpenAI::Models::Responses::ResponseContentPartAddedEvent::part, - type: :"response.content_part.added" - ) -> void - | ( - ?OpenAI::Models::Responses::response_content_part_added_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + item_id: String, + output_index: Integer, + part: OpenAI::Models::Responses::ResponseContentPartAddedEvent::part, + ?type: :"response.content_part.added" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_content_part_added_event @@ -40,8 +35,10 @@ module OpenAI OpenAI::Models::Responses::ResponseOutputText | OpenAI::Models::Responses::ResponseOutputRefusal - class Part < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] + module Part + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] end end end diff --git a/sig/openai/models/responses/response_content_part_done_event.rbs b/sig/openai/models/responses/response_content_part_done_event.rbs index b915c001..4ffbc22b 100644 --- a/sig/openai/models/responses/response_content_part_done_event.rbs +++ b/sig/openai/models/responses/response_content_part_done_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.content_part.done" - def initialize: - ( - content_index: Integer, - item_id: String, - output_index: Integer, - part: OpenAI::Models::Responses::ResponseContentPartDoneEvent::part, - type: :"response.content_part.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_content_part_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + item_id: String, + output_index: Integer, + part: OpenAI::Models::Responses::ResponseContentPartDoneEvent::part, + ?type: :"response.content_part.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_content_part_done_event @@ -40,8 +35,10 @@ module OpenAI OpenAI::Models::Responses::ResponseOutputText | OpenAI::Models::Responses::ResponseOutputRefusal - class Part < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] + module Part + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] end end end diff --git a/sig/openai/models/responses/response_create_params.rbs b/sig/openai/models/responses/response_create_params.rbs index d9049e41..c5fb416a 100644 --- a/sig/openai/models/responses/response_create_params.rbs +++ b/sig/openai/models/responses/response_create_params.rbs @@ -4,7 +4,7 @@ module OpenAI type response_create_params = { input: OpenAI::Models::Responses::ResponseCreateParams::input, - model: OpenAI::Models::Responses::ResponseCreateParams::model, + model: OpenAI::Models::responses_model, include: ::Array[OpenAI::Models::Responses::response_includable]?, instructions: String?, max_output_tokens: Integer?, @@ -24,12 +24,12 @@ module OpenAI & OpenAI::request_parameters class ResponseCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor input: OpenAI::Models::Responses::ResponseCreateParams::input - attr_accessor model: OpenAI::Models::Responses::ResponseCreateParams::model + attr_accessor model: OpenAI::Models::responses_model attr_accessor include: ::Array[OpenAI::Models::Responses::response_includable]? @@ -75,44 +75,35 @@ module OpenAI def user=: (String) -> String - def initialize: - ( - input: OpenAI::Models::Responses::ResponseCreateParams::input, - model: OpenAI::Models::Responses::ResponseCreateParams::model, - include: ::Array[OpenAI::Models::Responses::response_includable]?, - instructions: String?, - max_output_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - parallel_tool_calls: bool?, - previous_response_id: String?, - reasoning: OpenAI::Models::Reasoning?, - store: bool?, - temperature: Float?, - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, - tools: ::Array[OpenAI::Models::Responses::tool], - top_p: Float?, - truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, - user: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Responses::response_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + input: OpenAI::Models::Responses::ResponseCreateParams::input, + model: OpenAI::Models::responses_model, + ?include: ::Array[OpenAI::Models::Responses::response_includable]?, + ?instructions: String?, + ?max_output_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?parallel_tool_calls: bool?, + ?previous_response_id: String?, + ?reasoning: OpenAI::Models::Reasoning?, + ?store: bool?, + ?temperature: Float?, + ?text: OpenAI::Models::Responses::ResponseTextConfig, + ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, + ?tools: ::Array[OpenAI::Models::Responses::tool], + ?top_p: Float?, + ?truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Responses::response_create_params type input = String | OpenAI::Models::Responses::response_input - class Input < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::Responses::response_input] - end - - type model = String | OpenAI::Models::chat_model + module Input + extend OpenAI::Union - class Model < OpenAI::Union - def self.variants: -> [String, OpenAI::Models::chat_model] + def self?.variants: -> [String, OpenAI::Models::Responses::response_input] end type tool_choice = @@ -120,17 +111,21 @@ module OpenAI | OpenAI::Models::Responses::ToolChoiceTypes | OpenAI::Models::Responses::ToolChoiceFunction - class ToolChoice < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::tool_choice_options, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] + module ToolChoice + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::tool_choice_options, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] end type truncation = :auto | :disabled - class Truncation < OpenAI::Enum + module Truncation + extend OpenAI::Enum + AUTO: :auto DISABLED: :disabled - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseCreateParams::truncation] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseCreateParams::truncation] end end end diff --git a/sig/openai/models/responses/response_created_event.rbs b/sig/openai/models/responses/response_created_event.rbs index 6a67bba2..bd5a386a 100644 --- a/sig/openai/models/responses/response_created_event.rbs +++ b/sig/openai/models/responses/response_created_event.rbs @@ -12,15 +12,10 @@ module OpenAI attr_accessor type: :"response.created" - def initialize: - ( - response: OpenAI::Models::Responses::Response, - type: :"response.created" - ) -> void - | ( - ?OpenAI::Models::Responses::response_created_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + response: OpenAI::Models::Responses::Response, + ?type: :"response.created" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_created_event end diff --git a/sig/openai/models/responses/response_delete_params.rbs b/sig/openai/models/responses/response_delete_params.rbs index 509b3360..48a494f2 100644 --- a/sig/openai/models/responses/response_delete_params.rbs +++ b/sig/openai/models/responses/response_delete_params.rbs @@ -4,15 +4,10 @@ module OpenAI type response_delete_params = { } & OpenAI::request_parameters class ResponseDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Responses::response_delete_params - | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::Responses::response_delete_params end diff --git a/sig/openai/models/responses/response_error.rbs b/sig/openai/models/responses/response_error.rbs index 0adca85b..4187ffad 100644 --- a/sig/openai/models/responses/response_error.rbs +++ b/sig/openai/models/responses/response_error.rbs @@ -12,14 +12,10 @@ module OpenAI attr_accessor message: String - def initialize: - ( - code: OpenAI::Models::Responses::ResponseError::code, - message: String - ) -> void - | ( - ?OpenAI::Models::Responses::response_error | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: OpenAI::Models::Responses::ResponseError::code, + message: String + ) -> void def to_hash: -> OpenAI::Models::Responses::response_error @@ -43,7 +39,9 @@ module OpenAI | :failed_to_download_image | :image_file_not_found - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR: :server_error RATE_LIMIT_EXCEEDED: :rate_limit_exceeded INVALID_PROMPT: :invalid_prompt @@ -63,7 +61,7 @@ module OpenAI FAILED_TO_DOWNLOAD_IMAGE: :failed_to_download_image IMAGE_FILE_NOT_FOUND: :image_file_not_found - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseError::code] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseError::code] end end end diff --git a/sig/openai/models/responses/response_error_event.rbs b/sig/openai/models/responses/response_error_event.rbs index ddfbd3d6..2c037b8a 100644 --- a/sig/openai/models/responses/response_error_event.rbs +++ b/sig/openai/models/responses/response_error_event.rbs @@ -13,12 +13,12 @@ module OpenAI attr_accessor type: :error - def initialize: - (code: String?, message: String, param: String?, type: :error) -> void - | ( - ?OpenAI::Models::Responses::response_error_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: String?, + message: String, + param: String?, + ?type: :error + ) -> void def to_hash: -> OpenAI::Models::Responses::response_error_event end diff --git a/sig/openai/models/responses/response_failed_event.rbs b/sig/openai/models/responses/response_failed_event.rbs index 1edd4ecc..5747ae10 100644 --- a/sig/openai/models/responses/response_failed_event.rbs +++ b/sig/openai/models/responses/response_failed_event.rbs @@ -12,15 +12,10 @@ module OpenAI attr_accessor type: :"response.failed" - def initialize: - ( - response: OpenAI::Models::Responses::Response, - type: :"response.failed" - ) -> void - | ( - ?OpenAI::Models::Responses::response_failed_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + response: OpenAI::Models::Responses::Response, + ?type: :"response.failed" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_failed_event end diff --git a/sig/openai/models/responses/response_file_search_call_completed_event.rbs b/sig/openai/models/responses/response_file_search_call_completed_event.rbs index 7f8857c3..069463fe 100644 --- a/sig/openai/models/responses/response_file_search_call_completed_event.rbs +++ b/sig/openai/models/responses/response_file_search_call_completed_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.file_search_call.completed" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.file_search_call.completed" - ) -> void - | ( - ?OpenAI::Models::Responses::response_file_search_call_completed_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.file_search_call.completed" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_file_search_call_completed_event end diff --git a/sig/openai/models/responses/response_file_search_call_in_progress_event.rbs b/sig/openai/models/responses/response_file_search_call_in_progress_event.rbs index d5e5064e..e8163f14 100644 --- a/sig/openai/models/responses/response_file_search_call_in_progress_event.rbs +++ b/sig/openai/models/responses/response_file_search_call_in_progress_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.file_search_call.in_progress" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.file_search_call.in_progress" - ) -> void - | ( - ?OpenAI::Models::Responses::response_file_search_call_in_progress_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.file_search_call.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_file_search_call_in_progress_event end diff --git a/sig/openai/models/responses/response_file_search_call_searching_event.rbs b/sig/openai/models/responses/response_file_search_call_searching_event.rbs index 14f56371..1745ca78 100644 --- a/sig/openai/models/responses/response_file_search_call_searching_event.rbs +++ b/sig/openai/models/responses/response_file_search_call_searching_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.file_search_call.searching" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.file_search_call.searching" - ) -> void - | ( - ?OpenAI::Models::Responses::response_file_search_call_searching_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.file_search_call.searching" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_file_search_call_searching_event end diff --git a/sig/openai/models/responses/response_file_search_tool_call.rbs b/sig/openai/models/responses/response_file_search_tool_call.rbs index 42d71f9c..c42ff6ab 100644 --- a/sig/openai/models/responses/response_file_search_tool_call.rbs +++ b/sig/openai/models/responses/response_file_search_tool_call.rbs @@ -21,32 +21,29 @@ module OpenAI attr_accessor results: ::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result]? - def initialize: - ( - id: String, - queries: ::Array[String], - status: OpenAI::Models::Responses::ResponseFileSearchToolCall::status, - results: ::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result]?, - type: :file_search_call - ) -> void - | ( - ?OpenAI::Models::Responses::response_file_search_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + queries: ::Array[String], + status: OpenAI::Models::Responses::ResponseFileSearchToolCall::status, + ?results: ::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::Result]?, + ?type: :file_search_call + ) -> void def to_hash: -> OpenAI::Models::Responses::response_file_search_tool_call type status = :in_progress | :searching | :completed | :incomplete | :failed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress SEARCHING: :searching COMPLETED: :completed INCOMPLETE: :incomplete FAILED: :failed - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseFileSearchToolCall::status] end type result = @@ -77,25 +74,22 @@ module OpenAI def text=: (String) -> String - def initialize: - ( - attributes: ::Hash[Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Result::attribute]?, - file_id: String, - filename: String, - score: Float, - text: String - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseFileSearchToolCall::result - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?attributes: ::Hash[Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Result::attribute]?, + ?file_id: String, + ?filename: String, + ?score: Float, + ?text: String + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseFileSearchToolCall::result type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/responses/response_format_text_config.rbs b/sig/openai/models/responses/response_format_text_config.rbs index 7a38cb8e..a78a0964 100644 --- a/sig/openai/models/responses/response_format_text_config.rbs +++ b/sig/openai/models/responses/response_format_text_config.rbs @@ -6,8 +6,10 @@ module OpenAI | OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig | OpenAI::Models::ResponseFormatJSONObject - class ResponseFormatTextConfig < OpenAI::Union - def self.variants: -> [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] + module ResponseFormatTextConfig + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] end end end diff --git a/sig/openai/models/responses/response_format_text_json_schema_config.rbs b/sig/openai/models/responses/response_format_text_json_schema_config.rbs index a539a703..899ff7bb 100644 --- a/sig/openai/models/responses/response_format_text_json_schema_config.rbs +++ b/sig/openai/models/responses/response_format_text_json_schema_config.rbs @@ -3,14 +3,16 @@ module OpenAI module Responses type response_format_text_json_schema_config = { + name: String, schema: ::Hash[Symbol, top], type: :json_schema, description: String, - name: String, strict: bool? } class ResponseFormatTextJSONSchemaConfig < OpenAI::BaseModel + attr_accessor name: String + attr_accessor schema: ::Hash[Symbol, top] attr_accessor type: :json_schema @@ -19,24 +21,15 @@ module OpenAI def description=: (String) -> String - attr_reader name: String? - - def name=: (String) -> String - attr_accessor strict: bool? - def initialize: - ( - schema: ::Hash[Symbol, top], - description: String, - name: String, - strict: bool?, - type: :json_schema - ) -> void - | ( - ?OpenAI::Models::Responses::response_format_text_json_schema_config - | OpenAI::BaseModel data - ) -> void + def initialize: ( + name: String, + schema: ::Hash[Symbol, top], + ?description: String, + ?strict: bool?, + ?type: :json_schema + ) -> void def to_hash: -> OpenAI::Models::Responses::response_format_text_json_schema_config end diff --git a/sig/openai/models/responses/response_function_call_arguments_delta_event.rbs b/sig/openai/models/responses/response_function_call_arguments_delta_event.rbs index 0a9a828b..afcf88ef 100644 --- a/sig/openai/models/responses/response_function_call_arguments_delta_event.rbs +++ b/sig/openai/models/responses/response_function_call_arguments_delta_event.rbs @@ -18,17 +18,12 @@ module OpenAI attr_accessor type: :"response.function_call_arguments.delta" - def initialize: - ( - delta: String, - item_id: String, - output_index: Integer, - type: :"response.function_call_arguments.delta" - ) -> void - | ( - ?OpenAI::Models::Responses::response_function_call_arguments_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + delta: String, + item_id: String, + output_index: Integer, + ?type: :"response.function_call_arguments.delta" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_function_call_arguments_delta_event end diff --git a/sig/openai/models/responses/response_function_call_arguments_done_event.rbs b/sig/openai/models/responses/response_function_call_arguments_done_event.rbs index fc573721..5a0dc613 100644 --- a/sig/openai/models/responses/response_function_call_arguments_done_event.rbs +++ b/sig/openai/models/responses/response_function_call_arguments_done_event.rbs @@ -18,17 +18,12 @@ module OpenAI attr_accessor type: :"response.function_call_arguments.done" - def initialize: - ( - arguments: String, - item_id: String, - output_index: Integer, - type: :"response.function_call_arguments.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_function_call_arguments_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + arguments: String, + item_id: String, + output_index: Integer, + ?type: :"response.function_call_arguments.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_function_call_arguments_done_event end diff --git a/sig/openai/models/responses/response_function_tool_call.rbs b/sig/openai/models/responses/response_function_tool_call.rbs index 1314a1f4..af876b35 100644 --- a/sig/openai/models/responses/response_function_tool_call.rbs +++ b/sig/openai/models/responses/response_function_tool_call.rbs @@ -3,17 +3,15 @@ module OpenAI module Responses type response_function_tool_call = { - id: String, arguments: String, call_id: String, name: String, type: :function_call, + id: String, status: OpenAI::Models::Responses::ResponseFunctionToolCall::status } class ResponseFunctionToolCall < OpenAI::BaseModel - attr_accessor id: String - attr_accessor arguments: String attr_accessor call_id: String @@ -22,36 +20,37 @@ module OpenAI attr_accessor type: :function_call + attr_reader id: String? + + def id=: (String) -> String + attr_reader status: OpenAI::Models::Responses::ResponseFunctionToolCall::status? def status=: ( OpenAI::Models::Responses::ResponseFunctionToolCall::status ) -> OpenAI::Models::Responses::ResponseFunctionToolCall::status - def initialize: - ( - id: String, - arguments: String, - call_id: String, - name: String, - status: OpenAI::Models::Responses::ResponseFunctionToolCall::status, - type: :function_call - ) -> void - | ( - ?OpenAI::Models::Responses::response_function_tool_call - | OpenAI::BaseModel data - ) -> void + def initialize: ( + arguments: String, + call_id: String, + name: String, + ?id: String, + ?status: OpenAI::Models::Responses::ResponseFunctionToolCall::status, + ?type: :function_call + ) -> void def to_hash: -> OpenAI::Models::Responses::response_function_tool_call type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseFunctionToolCall::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseFunctionToolCall::status] end end end diff --git a/sig/openai/models/responses/response_function_tool_call_item.rbs b/sig/openai/models/responses/response_function_tool_call_item.rbs new file mode 100644 index 00000000..86727e9b --- /dev/null +++ b/sig/openai/models/responses/response_function_tool_call_item.rbs @@ -0,0 +1,17 @@ +module OpenAI + module Models + module Responses + type response_function_tool_call_item = { id: String } + + class ResponseFunctionToolCallItem < OpenAI::Models::Responses::ResponseFunctionToolCall + def id: -> String + + def id=: (String _) -> String + + def initialize: (id: String) -> void + + def to_hash: -> OpenAI::Models::Responses::response_function_tool_call_item + end + end + end +end diff --git a/sig/openai/models/responses/response_function_tool_call_output_item.rbs b/sig/openai/models/responses/response_function_tool_call_output_item.rbs new file mode 100644 index 00000000..8feafadc --- /dev/null +++ b/sig/openai/models/responses/response_function_tool_call_output_item.rbs @@ -0,0 +1,52 @@ +module OpenAI + module Models + module Responses + type response_function_tool_call_output_item = + { + id: String, + call_id: String, + output: String, + type: :function_call_output, + status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status + } + + class ResponseFunctionToolCallOutputItem < OpenAI::BaseModel + attr_accessor id: String + + attr_accessor call_id: String + + attr_accessor output: String + + attr_accessor type: :function_call_output + + attr_reader status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status? + + def status=: ( + OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status + ) -> OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status + + def initialize: ( + id: String, + call_id: String, + output: String, + ?status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status, + ?type: :function_call_output + ) -> void + + def to_hash: -> OpenAI::Models::Responses::response_function_tool_call_output_item + + type status = :in_progress | :completed | :incomplete + + module Status + extend OpenAI::Enum + + IN_PROGRESS: :in_progress + COMPLETED: :completed + INCOMPLETE: :incomplete + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status] + end + end + end + end +end diff --git a/sig/openai/models/responses/response_function_web_search.rbs b/sig/openai/models/responses/response_function_web_search.rbs index 198d14e2..4b1b18f8 100644 --- a/sig/openai/models/responses/response_function_web_search.rbs +++ b/sig/openai/models/responses/response_function_web_search.rbs @@ -15,28 +15,25 @@ module OpenAI attr_accessor type: :web_search_call - def initialize: - ( - id: String, - status: OpenAI::Models::Responses::ResponseFunctionWebSearch::status, - type: :web_search_call - ) -> void - | ( - ?OpenAI::Models::Responses::response_function_web_search - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + status: OpenAI::Models::Responses::ResponseFunctionWebSearch::status, + ?type: :web_search_call + ) -> void def to_hash: -> OpenAI::Models::Responses::response_function_web_search type status = :in_progress | :searching | :completed | :failed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress SEARCHING: :searching COMPLETED: :completed FAILED: :failed - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseFunctionWebSearch::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseFunctionWebSearch::status] end end end diff --git a/sig/openai/models/responses/response_in_progress_event.rbs b/sig/openai/models/responses/response_in_progress_event.rbs index 2649e5cb..35845e80 100644 --- a/sig/openai/models/responses/response_in_progress_event.rbs +++ b/sig/openai/models/responses/response_in_progress_event.rbs @@ -12,15 +12,10 @@ module OpenAI attr_accessor type: :"response.in_progress" - def initialize: - ( - response: OpenAI::Models::Responses::Response, - type: :"response.in_progress" - ) -> void - | ( - ?OpenAI::Models::Responses::response_in_progress_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + response: OpenAI::Models::Responses::Response, + ?type: :"response.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_in_progress_event end diff --git a/sig/openai/models/responses/response_includable.rbs b/sig/openai/models/responses/response_includable.rbs index b2a08af5..17f0b9d0 100644 --- a/sig/openai/models/responses/response_includable.rbs +++ b/sig/openai/models/responses/response_includable.rbs @@ -6,12 +6,14 @@ module OpenAI | :"message.input_image.image_url" | :"computer_call_output.output.image_url" - class ResponseIncludable < OpenAI::Enum + module ResponseIncludable + extend OpenAI::Enum + FILE_SEARCH_CALL_RESULTS: :"file_search_call.results" MESSAGE_INPUT_IMAGE_IMAGE_URL: :"message.input_image.image_url" COMPUTER_CALL_OUTPUT_OUTPUT_IMAGE_URL: :"computer_call_output.output.image_url" - def self.values: -> ::Array[OpenAI::Models::Responses::response_includable] + def self?.values: -> ::Array[OpenAI::Models::Responses::response_includable] end end end diff --git a/sig/openai/models/responses/response_incomplete_event.rbs b/sig/openai/models/responses/response_incomplete_event.rbs index 270ea93d..24d172fe 100644 --- a/sig/openai/models/responses/response_incomplete_event.rbs +++ b/sig/openai/models/responses/response_incomplete_event.rbs @@ -12,15 +12,10 @@ module OpenAI attr_accessor type: :"response.incomplete" - def initialize: - ( - response: OpenAI::Models::Responses::Response, - type: :"response.incomplete" - ) -> void - | ( - ?OpenAI::Models::Responses::response_incomplete_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + response: OpenAI::Models::Responses::Response, + ?type: :"response.incomplete" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_incomplete_event end diff --git a/sig/openai/models/responses/response_input_audio.rbs b/sig/openai/models/responses/response_input_audio.rbs index a076443c..cebca75a 100644 --- a/sig/openai/models/responses/response_input_audio.rbs +++ b/sig/openai/models/responses/response_input_audio.rbs @@ -15,26 +15,23 @@ module OpenAI attr_accessor type: :input_audio - def initialize: - ( - data: String, - format_: OpenAI::Models::Responses::ResponseInputAudio::format_, - type: :input_audio - ) -> void - | ( - ?OpenAI::Models::Responses::response_input_audio - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: String, + format_: OpenAI::Models::Responses::ResponseInputAudio::format_, + ?type: :input_audio + ) -> void def to_hash: -> OpenAI::Models::Responses::response_input_audio type format_ = :mp3 | :wav - class Format < OpenAI::Enum + module Format + extend OpenAI::Enum + MP3: :mp3 WAV: :wav - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputAudio::format_] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputAudio::format_] end end end diff --git a/sig/openai/models/responses/response_input_content.rbs b/sig/openai/models/responses/response_input_content.rbs index 004cfa5c..b94f1f20 100644 --- a/sig/openai/models/responses/response_input_content.rbs +++ b/sig/openai/models/responses/response_input_content.rbs @@ -6,8 +6,10 @@ module OpenAI | OpenAI::Models::Responses::ResponseInputImage | OpenAI::Models::Responses::ResponseInputFile - class ResponseInputContent < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile] + module ResponseInputContent + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile] end end end diff --git a/sig/openai/models/responses/response_input_file.rbs b/sig/openai/models/responses/response_input_file.rbs index 90aaf6d9..4c336cd6 100644 --- a/sig/openai/models/responses/response_input_file.rbs +++ b/sig/openai/models/responses/response_input_file.rbs @@ -24,17 +24,12 @@ module OpenAI def filename=: (String) -> String - def initialize: - ( - file_data: String, - file_id: String, - filename: String, - type: :input_file - ) -> void - | ( - ?OpenAI::Models::Responses::response_input_file - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?file_data: String, + ?file_id: String, + ?filename: String, + ?type: :input_file + ) -> void def to_hash: -> OpenAI::Models::Responses::response_input_file end diff --git a/sig/openai/models/responses/response_input_image.rbs b/sig/openai/models/responses/response_input_image.rbs index 18ac35c5..18b3631c 100644 --- a/sig/openai/models/responses/response_input_image.rbs +++ b/sig/openai/models/responses/response_input_image.rbs @@ -18,28 +18,25 @@ module OpenAI attr_accessor image_url: String? - def initialize: - ( - detail: OpenAI::Models::Responses::ResponseInputImage::detail, - file_id: String?, - image_url: String?, - type: :input_image - ) -> void - | ( - ?OpenAI::Models::Responses::response_input_image - | OpenAI::BaseModel data - ) -> void + def initialize: ( + detail: OpenAI::Models::Responses::ResponseInputImage::detail, + ?file_id: String?, + ?image_url: String?, + ?type: :input_image + ) -> void def to_hash: -> OpenAI::Models::Responses::response_input_image type detail = :high | :low | :auto - class Detail < OpenAI::Enum + module Detail + extend OpenAI::Enum + HIGH: :high LOW: :low AUTO: :auto - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputImage::detail] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputImage::detail] end end end diff --git a/sig/openai/models/responses/response_input_item.rbs b/sig/openai/models/responses/response_input_item.rbs index b60c6d6a..ec441979 100644 --- a/sig/openai/models/responses/response_input_item.rbs +++ b/sig/openai/models/responses/response_input_item.rbs @@ -14,7 +14,9 @@ module OpenAI | OpenAI::Models::Responses::ResponseReasoningItem | OpenAI::Models::Responses::ResponseInputItem::ItemReference - class ResponseInputItem < OpenAI::Union + module ResponseInputItem + extend OpenAI::Union + type message = { content: OpenAI::Models::Responses::response_input_message_content_list, @@ -40,53 +42,54 @@ module OpenAI OpenAI::Models::Responses::ResponseInputItem::Message::type_ ) -> OpenAI::Models::Responses::ResponseInputItem::Message::type_ - def initialize: - ( - content: OpenAI::Models::Responses::response_input_message_content_list, - role: OpenAI::Models::Responses::ResponseInputItem::Message::role, - status: OpenAI::Models::Responses::ResponseInputItem::Message::status, - type: OpenAI::Models::Responses::ResponseInputItem::Message::type_ - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content: OpenAI::Models::Responses::response_input_message_content_list, + role: OpenAI::Models::Responses::ResponseInputItem::Message::role, + ?status: OpenAI::Models::Responses::ResponseInputItem::Message::status, + ?type: OpenAI::Models::Responses::ResponseInputItem::Message::type_ + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::message type role = :user | :system | :developer - class Role < OpenAI::Enum + module Role + extend OpenAI::Enum + USER: :user SYSTEM: :system DEVELOPER: :developer - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::role] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::role] end type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::status] end type type_ = :message - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + MESSAGE: :message - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::type_] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::Message::type_] end end type computer_call_output = { call_id: String, - output: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, type: :computer_call_output, id: String, acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck], @@ -96,7 +99,7 @@ module OpenAI class ComputerCallOutput < OpenAI::BaseModel attr_accessor call_id: String - attr_accessor output: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output + attr_accessor output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot attr_accessor type: :computer_call_output @@ -116,50 +119,17 @@ module OpenAI OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status ) -> OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status - def initialize: - ( - call_id: String, - output: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Output, - id: String, - acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck], - status: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status, - type: :computer_call_output - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::computer_call_output - | OpenAI::BaseModel data - ) -> void + def initialize: ( + call_id: String, + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, + ?id: String, + ?acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck], + ?status: OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status, + ?type: :computer_call_output + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::computer_call_output - type output = - { type: :computer_screenshot, file_id: String, image_url: String } - - class Output < OpenAI::BaseModel - attr_accessor type: :computer_screenshot - - attr_reader file_id: String? - - def file_id=: (String) -> String - - attr_reader image_url: String? - - def image_url=: (String) -> String - - def initialize: - ( - file_id: String, - image_url: String, - type: :computer_screenshot - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::output - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::output - end - type acknowledged_safety_check = { id: String, code: String, message: String } @@ -170,24 +140,21 @@ module OpenAI attr_accessor message: String - def initialize: - (id: String, code: String, message: String) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::acknowledged_safety_check - | OpenAI::BaseModel data - ) -> void + def initialize: (id: String, code: String, message: String) -> void def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::acknowledged_safety_check end type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::status] end end @@ -217,29 +184,26 @@ module OpenAI OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status ) -> OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status - def initialize: - ( - call_id: String, - output: String, - id: String, - status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status, - type: :function_call_output - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::function_call_output - | OpenAI::BaseModel data - ) -> void + def initialize: ( + call_id: String, + output: String, + ?id: String, + ?status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status, + ?type: :function_call_output + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::function_call_output type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status] end end @@ -250,17 +214,12 @@ module OpenAI attr_accessor type: :item_reference - def initialize: - (id: String, type: :item_reference) -> void - | ( - ?OpenAI::Models::Responses::ResponseInputItem::item_reference - | OpenAI::BaseModel data - ) -> void + def initialize: (id: String, ?type: :item_reference) -> void def to_hash: -> OpenAI::Models::Responses::ResponseInputItem::item_reference end - def self.variants: -> [OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ItemReference] + def self?.variants: -> [OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ItemReference] end end end diff --git a/sig/openai/models/responses/response_input_message_item.rbs b/sig/openai/models/responses/response_input_message_item.rbs new file mode 100644 index 00000000..e0a6c449 --- /dev/null +++ b/sig/openai/models/responses/response_input_message_item.rbs @@ -0,0 +1,78 @@ +module OpenAI + module Models + module Responses + type response_input_message_item = + { + id: String, + content: OpenAI::Models::Responses::response_input_message_content_list, + role: OpenAI::Models::Responses::ResponseInputMessageItem::role, + status: OpenAI::Models::Responses::ResponseInputMessageItem::status, + type: OpenAI::Models::Responses::ResponseInputMessageItem::type_ + } + + class ResponseInputMessageItem < OpenAI::BaseModel + attr_accessor id: String + + attr_accessor content: OpenAI::Models::Responses::response_input_message_content_list + + attr_accessor role: OpenAI::Models::Responses::ResponseInputMessageItem::role + + attr_reader status: OpenAI::Models::Responses::ResponseInputMessageItem::status? + + def status=: ( + OpenAI::Models::Responses::ResponseInputMessageItem::status + ) -> OpenAI::Models::Responses::ResponseInputMessageItem::status + + attr_reader type: OpenAI::Models::Responses::ResponseInputMessageItem::type_? + + def type=: ( + OpenAI::Models::Responses::ResponseInputMessageItem::type_ + ) -> OpenAI::Models::Responses::ResponseInputMessageItem::type_ + + def initialize: ( + id: String, + content: OpenAI::Models::Responses::response_input_message_content_list, + role: OpenAI::Models::Responses::ResponseInputMessageItem::role, + ?status: OpenAI::Models::Responses::ResponseInputMessageItem::status, + ?type: OpenAI::Models::Responses::ResponseInputMessageItem::type_ + ) -> void + + def to_hash: -> OpenAI::Models::Responses::response_input_message_item + + type role = :user | :system | :developer + + module Role + extend OpenAI::Enum + + USER: :user + SYSTEM: :system + DEVELOPER: :developer + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputMessageItem::role] + end + + type status = :in_progress | :completed | :incomplete + + module Status + extend OpenAI::Enum + + IN_PROGRESS: :in_progress + COMPLETED: :completed + INCOMPLETE: :incomplete + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputMessageItem::status] + end + + type type_ = :message + + module Type + extend OpenAI::Enum + + MESSAGE: :message + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputMessageItem::type_] + end + end + end + end +end diff --git a/sig/openai/models/responses/response_input_text.rbs b/sig/openai/models/responses/response_input_text.rbs index df1540c3..c41c7537 100644 --- a/sig/openai/models/responses/response_input_text.rbs +++ b/sig/openai/models/responses/response_input_text.rbs @@ -8,12 +8,7 @@ module OpenAI attr_accessor type: :input_text - def initialize: - (text: String, type: :input_text) -> void - | ( - ?OpenAI::Models::Responses::response_input_text - | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :input_text) -> void def to_hash: -> OpenAI::Models::Responses::response_input_text end diff --git a/sig/openai/models/responses/response_item.rbs b/sig/openai/models/responses/response_item.rbs new file mode 100644 index 00000000..59b6a1f5 --- /dev/null +++ b/sig/openai/models/responses/response_item.rbs @@ -0,0 +1,21 @@ +module OpenAI + module Models + module Responses + type response_item = + OpenAI::Models::Responses::ResponseInputMessageItem + | OpenAI::Models::Responses::ResponseOutputMessage + | OpenAI::Models::Responses::ResponseFileSearchToolCall + | OpenAI::Models::Responses::ResponseComputerToolCall + | OpenAI::Models::Responses::ResponseComputerToolCallOutputItem + | OpenAI::Models::Responses::ResponseFunctionWebSearch + | OpenAI::Models::Responses::ResponseFunctionToolCallItem + | OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem + + module ResponseItem + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem] + end + end + end +end diff --git a/sig/openai/models/responses/response_item_list.rbs b/sig/openai/models/responses/response_item_list.rbs index a8d0d3fc..dbed0410 100644 --- a/sig/openai/models/responses/response_item_list.rbs +++ b/sig/openai/models/responses/response_item_list.rbs @@ -1,12 +1,11 @@ module OpenAI module Models - class ResponseItemList = Responses::ResponseItemList module Responses type response_item_list = { - data: ::Array[OpenAI::Models::Responses::ResponseItemList::data], + data: ::Array[OpenAI::Models::Responses::response_item], first_id: String, has_more: bool, last_id: String, @@ -14,7 +13,7 @@ module OpenAI } class ResponseItemList < OpenAI::BaseModel - attr_accessor data: ::Array[OpenAI::Models::Responses::ResponseItemList::data] + attr_accessor data: ::Array[OpenAI::Models::Responses::response_item] attr_accessor first_id: String @@ -24,262 +23,15 @@ module OpenAI attr_accessor object: :list - def initialize: - ( - data: ::Array[OpenAI::Models::Responses::ResponseItemList::data], - first_id: String, - has_more: bool, - last_id: String, - object: :list - ) -> void - | ( - ?OpenAI::Models::Responses::response_item_list - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: ::Array[OpenAI::Models::Responses::response_item], + first_id: String, + has_more: bool, + last_id: String, + ?object: :list + ) -> void def to_hash: -> OpenAI::Models::Responses::response_item_list - - type data = - OpenAI::Models::Responses::ResponseItemList::Data::Message - | OpenAI::Models::Responses::ResponseOutputMessage - | OpenAI::Models::Responses::ResponseFileSearchToolCall - | OpenAI::Models::Responses::ResponseComputerToolCall - | OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput - | OpenAI::Models::Responses::ResponseFunctionWebSearch - | OpenAI::Models::Responses::ResponseFunctionToolCall - | OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput - - class Data < OpenAI::Union - type message = - { - id: String, - content: OpenAI::Models::Responses::response_input_message_content_list, - role: OpenAI::Models::Responses::ResponseItemList::Data::Message::role, - status: OpenAI::Models::Responses::ResponseItemList::Data::Message::status, - type: OpenAI::Models::Responses::ResponseItemList::Data::Message::type_ - } - - class Message < OpenAI::BaseModel - attr_accessor id: String - - attr_accessor content: OpenAI::Models::Responses::response_input_message_content_list - - attr_accessor role: OpenAI::Models::Responses::ResponseItemList::Data::Message::role - - attr_reader status: OpenAI::Models::Responses::ResponseItemList::Data::Message::status? - - def status=: ( - OpenAI::Models::Responses::ResponseItemList::Data::Message::status - ) -> OpenAI::Models::Responses::ResponseItemList::Data::Message::status - - attr_reader type: OpenAI::Models::Responses::ResponseItemList::Data::Message::type_? - - def type=: ( - OpenAI::Models::Responses::ResponseItemList::Data::Message::type_ - ) -> OpenAI::Models::Responses::ResponseItemList::Data::Message::type_ - - def initialize: - ( - id: String, - content: OpenAI::Models::Responses::response_input_message_content_list, - role: OpenAI::Models::Responses::ResponseItemList::Data::Message::role, - status: OpenAI::Models::Responses::ResponseItemList::Data::Message::status, - type: OpenAI::Models::Responses::ResponseItemList::Data::Message::type_ - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseItemList::Data::message - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseItemList::Data::message - - type role = :user | :system | :developer - - class Role < OpenAI::Enum - USER: :user - SYSTEM: :system - DEVELOPER: :developer - - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::Message::role] - end - - type status = :in_progress | :completed | :incomplete - - class Status < OpenAI::Enum - IN_PROGRESS: :in_progress - COMPLETED: :completed - INCOMPLETE: :incomplete - - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::Message::status] - end - - type type_ = :message - - class Type < OpenAI::Enum - MESSAGE: :message - - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::Message::type_] - end - end - - type computer_call_output = - { - id: String, - call_id: String, - output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output, - type: :computer_call_output, - acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck], - status: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status - } - - class ComputerCallOutput < OpenAI::BaseModel - attr_accessor id: String - - attr_accessor call_id: String - - attr_accessor output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output - - attr_accessor type: :computer_call_output - - attr_reader acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck]? - - def acknowledged_safety_checks=: ( - ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] - ) -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck] - - attr_reader status: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status? - - def status=: ( - OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status - ) -> OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status - - def initialize: - ( - id: String, - call_id: String, - output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output, - acknowledged_safety_checks: ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck], - status: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status, - type: :computer_call_output - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseItemList::Data::computer_call_output - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseItemList::Data::computer_call_output - - type output = - { type: :computer_screenshot, file_id: String, image_url: String } - - class Output < OpenAI::BaseModel - attr_accessor type: :computer_screenshot - - attr_reader file_id: String? - - def file_id=: (String) -> String - - attr_reader image_url: String? - - def image_url=: (String) -> String - - def initialize: - ( - file_id: String, - image_url: String, - type: :computer_screenshot - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::output - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::output - end - - type acknowledged_safety_check = - { id: String, code: String, message: String } - - class AcknowledgedSafetyCheck < OpenAI::BaseModel - attr_accessor id: String - - attr_accessor code: String - - attr_accessor message: String - - def initialize: - (id: String, code: String, message: String) -> void - | ( - ?OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::acknowledged_safety_check - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::acknowledged_safety_check - end - - type status = :in_progress | :completed | :incomplete - - class Status < OpenAI::Enum - IN_PROGRESS: :in_progress - COMPLETED: :completed - INCOMPLETE: :incomplete - - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::status] - end - end - - type function_call_output = - { - id: String, - call_id: String, - output: String, - type: :function_call_output, - status: OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status - } - - class FunctionCallOutput < OpenAI::BaseModel - attr_accessor id: String - - attr_accessor call_id: String - - attr_accessor output: String - - attr_accessor type: :function_call_output - - attr_reader status: OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status? - - def status=: ( - OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status - ) -> OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status - - def initialize: - ( - id: String, - call_id: String, - output: String, - status: OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status, - type: :function_call_output - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseItemList::Data::function_call_output - | OpenAI::BaseModel data - ) -> void - - def to_hash: -> OpenAI::Models::Responses::ResponseItemList::Data::function_call_output - - type status = :in_progress | :completed | :incomplete - - class Status < OpenAI::Enum - IN_PROGRESS: :in_progress - COMPLETED: :completed - INCOMPLETE: :incomplete - - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::status] - end - end - - def self.variants: -> [OpenAI::Models::Responses::ResponseItemList::Data::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput] - end end end end diff --git a/sig/openai/models/responses/response_output_audio.rbs b/sig/openai/models/responses/response_output_audio.rbs index 79e1d98c..1f90e75d 100644 --- a/sig/openai/models/responses/response_output_audio.rbs +++ b/sig/openai/models/responses/response_output_audio.rbs @@ -11,12 +11,11 @@ module OpenAI attr_accessor type: :output_audio - def initialize: - (data: String, transcript: String, type: :output_audio) -> void - | ( - ?OpenAI::Models::Responses::response_output_audio - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: String, + transcript: String, + ?type: :output_audio + ) -> void def to_hash: -> OpenAI::Models::Responses::response_output_audio end diff --git a/sig/openai/models/responses/response_output_item.rbs b/sig/openai/models/responses/response_output_item.rbs index e01fe1b2..fb0c190a 100644 --- a/sig/openai/models/responses/response_output_item.rbs +++ b/sig/openai/models/responses/response_output_item.rbs @@ -9,8 +9,10 @@ module OpenAI | OpenAI::Models::Responses::ResponseComputerToolCall | OpenAI::Models::Responses::ResponseReasoningItem - class ResponseOutputItem < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem] + module ResponseOutputItem + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem] end end end diff --git a/sig/openai/models/responses/response_output_item_added_event.rbs b/sig/openai/models/responses/response_output_item_added_event.rbs index a8576913..e59d12f3 100644 --- a/sig/openai/models/responses/response_output_item_added_event.rbs +++ b/sig/openai/models/responses/response_output_item_added_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.output_item.added" - def initialize: - ( - item: OpenAI::Models::Responses::response_output_item, - output_index: Integer, - type: :"response.output_item.added" - ) -> void - | ( - ?OpenAI::Models::Responses::response_output_item_added_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item: OpenAI::Models::Responses::response_output_item, + output_index: Integer, + ?type: :"response.output_item.added" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_output_item_added_event end diff --git a/sig/openai/models/responses/response_output_item_done_event.rbs b/sig/openai/models/responses/response_output_item_done_event.rbs index 9f91df23..c4df8604 100644 --- a/sig/openai/models/responses/response_output_item_done_event.rbs +++ b/sig/openai/models/responses/response_output_item_done_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.output_item.done" - def initialize: - ( - item: OpenAI::Models::Responses::response_output_item, - output_index: Integer, - type: :"response.output_item.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_output_item_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item: OpenAI::Models::Responses::response_output_item, + output_index: Integer, + ?type: :"response.output_item.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_output_item_done_event end diff --git a/sig/openai/models/responses/response_output_message.rbs b/sig/openai/models/responses/response_output_message.rbs index c1bbed4a..dd1c2a28 100644 --- a/sig/openai/models/responses/response_output_message.rbs +++ b/sig/openai/models/responses/response_output_message.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :message - def initialize: - ( - id: String, - content: ::Array[OpenAI::Models::Responses::ResponseOutputMessage::content], - status: OpenAI::Models::Responses::ResponseOutputMessage::status, - role: :assistant, - type: :message - ) -> void - | ( - ?OpenAI::Models::Responses::response_output_message - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + content: ::Array[OpenAI::Models::Responses::ResponseOutputMessage::content], + status: OpenAI::Models::Responses::ResponseOutputMessage::status, + ?role: :assistant, + ?type: :message + ) -> void def to_hash: -> OpenAI::Models::Responses::response_output_message @@ -40,18 +35,22 @@ module OpenAI OpenAI::Models::Responses::ResponseOutputText | OpenAI::Models::Responses::ResponseOutputRefusal - class Content < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] + module Content + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] end type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseOutputMessage::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseOutputMessage::status] end end end diff --git a/sig/openai/models/responses/response_output_refusal.rbs b/sig/openai/models/responses/response_output_refusal.rbs index adbcb084..f1743e42 100644 --- a/sig/openai/models/responses/response_output_refusal.rbs +++ b/sig/openai/models/responses/response_output_refusal.rbs @@ -8,12 +8,7 @@ module OpenAI attr_accessor type: :refusal - def initialize: - (refusal: String, type: :refusal) -> void - | ( - ?OpenAI::Models::Responses::response_output_refusal - | OpenAI::BaseModel data - ) -> void + def initialize: (refusal: String, ?type: :refusal) -> void def to_hash: -> OpenAI::Models::Responses::response_output_refusal end diff --git a/sig/openai/models/responses/response_output_text.rbs b/sig/openai/models/responses/response_output_text.rbs index f8da61b0..51f31ba9 100644 --- a/sig/openai/models/responses/response_output_text.rbs +++ b/sig/openai/models/responses/response_output_text.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :output_text - def initialize: - ( - annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation], - text: String, - type: :output_text - ) -> void - | ( - ?OpenAI::Models::Responses::response_output_text - | OpenAI::BaseModel data - ) -> void + def initialize: ( + annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation], + text: String, + ?type: :output_text + ) -> void def to_hash: -> OpenAI::Models::Responses::response_output_text @@ -33,7 +28,9 @@ module OpenAI | OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation | OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath - class Annotation < OpenAI::Union + module Annotation + extend OpenAI::Union + type file_citation = { file_id: String, index: Integer, type: :file_citation } @@ -44,12 +41,11 @@ module OpenAI attr_accessor type: :file_citation - def initialize: - (file_id: String, index: Integer, type: :file_citation) -> void - | ( - ?OpenAI::Models::Responses::ResponseOutputText::Annotation::file_citation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + index: Integer, + ?type: :file_citation + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseOutputText::Annotation::file_citation end @@ -74,18 +70,13 @@ module OpenAI attr_accessor url: String - def initialize: - ( - end_index: Integer, - start_index: Integer, - title: String, - url: String, - type: :url_citation - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseOutputText::Annotation::url_citation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + end_index: Integer, + start_index: Integer, + title: String, + url: String, + ?type: :url_citation + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseOutputText::Annotation::url_citation end @@ -99,17 +90,16 @@ module OpenAI attr_accessor type: :file_path - def initialize: - (file_id: String, index: Integer, type: :file_path) -> void - | ( - ?OpenAI::Models::Responses::ResponseOutputText::Annotation::file_path - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + index: Integer, + ?type: :file_path + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseOutputText::Annotation::file_path end - def self.variants: -> [OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath] + def self?.variants: -> [OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath] end end end diff --git a/sig/openai/models/responses/response_reasoning_item.rbs b/sig/openai/models/responses/response_reasoning_item.rbs index b9b01efa..9c17d2fd 100644 --- a/sig/openai/models/responses/response_reasoning_item.rbs +++ b/sig/openai/models/responses/response_reasoning_item.rbs @@ -22,17 +22,12 @@ module OpenAI OpenAI::Models::Responses::ResponseReasoningItem::status ) -> OpenAI::Models::Responses::ResponseReasoningItem::status - def initialize: - ( - id: String, - summary: ::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary], - status: OpenAI::Models::Responses::ResponseReasoningItem::status, - type: :reasoning - ) -> void - | ( - ?OpenAI::Models::Responses::response_reasoning_item - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + summary: ::Array[OpenAI::Models::Responses::ResponseReasoningItem::Summary], + ?status: OpenAI::Models::Responses::ResponseReasoningItem::status, + ?type: :reasoning + ) -> void def to_hash: -> OpenAI::Models::Responses::response_reasoning_item @@ -43,24 +38,21 @@ module OpenAI attr_accessor type: :summary_text - def initialize: - (text: String, type: :summary_text) -> void - | ( - ?OpenAI::Models::Responses::ResponseReasoningItem::summary - | OpenAI::BaseModel data - ) -> void + def initialize: (text: String, ?type: :summary_text) -> void def to_hash: -> OpenAI::Models::Responses::ResponseReasoningItem::summary end type status = :in_progress | :completed | :incomplete - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::ResponseReasoningItem::status] + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseReasoningItem::status] end end end diff --git a/sig/openai/models/responses/response_refusal_delta_event.rbs b/sig/openai/models/responses/response_refusal_delta_event.rbs index eb50a0ed..6d26e2d3 100644 --- a/sig/openai/models/responses/response_refusal_delta_event.rbs +++ b/sig/openai/models/responses/response_refusal_delta_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.refusal.delta" - def initialize: - ( - content_index: Integer, - delta: String, - item_id: String, - output_index: Integer, - type: :"response.refusal.delta" - ) -> void - | ( - ?OpenAI::Models::Responses::response_refusal_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + delta: String, + item_id: String, + output_index: Integer, + ?type: :"response.refusal.delta" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_refusal_delta_event end diff --git a/sig/openai/models/responses/response_refusal_done_event.rbs b/sig/openai/models/responses/response_refusal_done_event.rbs index 0fbfff6e..693e0216 100644 --- a/sig/openai/models/responses/response_refusal_done_event.rbs +++ b/sig/openai/models/responses/response_refusal_done_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.refusal.done" - def initialize: - ( - content_index: Integer, - item_id: String, - output_index: Integer, - refusal: String, - type: :"response.refusal.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_refusal_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + item_id: String, + output_index: Integer, + refusal: String, + ?type: :"response.refusal.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_refusal_done_event end diff --git a/sig/openai/models/responses/response_retrieve_params.rbs b/sig/openai/models/responses/response_retrieve_params.rbs index 23530635..76a68008 100644 --- a/sig/openai/models/responses/response_retrieve_params.rbs +++ b/sig/openai/models/responses/response_retrieve_params.rbs @@ -6,7 +6,7 @@ module OpenAI & OpenAI::request_parameters class ResponseRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader include: ::Array[OpenAI::Models::Responses::response_includable]? @@ -15,15 +15,10 @@ module OpenAI ::Array[OpenAI::Models::Responses::response_includable] ) -> ::Array[OpenAI::Models::Responses::response_includable] - def initialize: - ( - include: ::Array[OpenAI::Models::Responses::response_includable], - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::Responses::response_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?include: ::Array[OpenAI::Models::Responses::response_includable], + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Responses::response_retrieve_params end diff --git a/sig/openai/models/responses/response_status.rbs b/sig/openai/models/responses/response_status.rbs index 17349a0c..cc7c73f5 100644 --- a/sig/openai/models/responses/response_status.rbs +++ b/sig/openai/models/responses/response_status.rbs @@ -3,13 +3,15 @@ module OpenAI module Responses type response_status = :completed | :failed | :in_progress | :incomplete - class ResponseStatus < OpenAI::Enum + module ResponseStatus + extend OpenAI::Enum + COMPLETED: :completed FAILED: :failed IN_PROGRESS: :in_progress INCOMPLETE: :incomplete - def self.values: -> ::Array[OpenAI::Models::Responses::response_status] + def self?.values: -> ::Array[OpenAI::Models::Responses::response_status] end end end diff --git a/sig/openai/models/responses/response_stream_event.rbs b/sig/openai/models/responses/response_stream_event.rbs index 0d48dfd6..a73d12f4 100644 --- a/sig/openai/models/responses/response_stream_event.rbs +++ b/sig/openai/models/responses/response_stream_event.rbs @@ -35,8 +35,10 @@ module OpenAI | OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent | OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent - class ResponseStreamEvent < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent] + module ResponseStreamEvent + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent] end end end diff --git a/sig/openai/models/responses/response_text_annotation_delta_event.rbs b/sig/openai/models/responses/response_text_annotation_delta_event.rbs index 9030b65e..71096d81 100644 --- a/sig/openai/models/responses/response_text_annotation_delta_event.rbs +++ b/sig/openai/models/responses/response_text_annotation_delta_event.rbs @@ -24,19 +24,14 @@ module OpenAI attr_accessor type: :"response.output_text.annotation.added" - def initialize: - ( - annotation: OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::annotation, - annotation_index: Integer, - content_index: Integer, - item_id: String, - output_index: Integer, - type: :"response.output_text.annotation.added" - ) -> void - | ( - ?OpenAI::Models::Responses::response_text_annotation_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + annotation: OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::annotation, + annotation_index: Integer, + content_index: Integer, + item_id: String, + output_index: Integer, + ?type: :"response.output_text.annotation.added" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_text_annotation_delta_event @@ -45,7 +40,9 @@ module OpenAI | OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation | OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath - class Annotation < OpenAI::Union + module Annotation + extend OpenAI::Union + type file_citation = { file_id: String, index: Integer, type: :file_citation } @@ -56,12 +53,11 @@ module OpenAI attr_accessor type: :file_citation - def initialize: - (file_id: String, index: Integer, type: :file_citation) -> void - | ( - ?OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::file_citation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + index: Integer, + ?type: :file_citation + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::file_citation end @@ -86,18 +82,13 @@ module OpenAI attr_accessor url: String - def initialize: - ( - end_index: Integer, - start_index: Integer, - title: String, - url: String, - type: :url_citation - ) -> void - | ( - ?OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::url_citation - | OpenAI::BaseModel data - ) -> void + def initialize: ( + end_index: Integer, + start_index: Integer, + title: String, + url: String, + ?type: :url_citation + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::url_citation end @@ -111,17 +102,16 @@ module OpenAI attr_accessor type: :file_path - def initialize: - (file_id: String, index: Integer, type: :file_path) -> void - | ( - ?OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::file_path - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + index: Integer, + ?type: :file_path + ) -> void def to_hash: -> OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::file_path end - def self.variants: -> [OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath] + def self?.variants: -> [OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FileCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::URLCitation, OpenAI::Models::Responses::ResponseTextAnnotationDeltaEvent::Annotation::FilePath] end end end diff --git a/sig/openai/models/responses/response_text_config.rbs b/sig/openai/models/responses/response_text_config.rbs index 0957217a..2429e169 100644 --- a/sig/openai/models/responses/response_text_config.rbs +++ b/sig/openai/models/responses/response_text_config.rbs @@ -11,14 +11,9 @@ module OpenAI OpenAI::Models::Responses::response_format_text_config ) -> OpenAI::Models::Responses::response_format_text_config - def initialize: - ( - format_: OpenAI::Models::Responses::response_format_text_config - ) -> void - | ( - ?OpenAI::Models::Responses::response_text_config - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void def to_hash: -> OpenAI::Models::Responses::response_text_config end diff --git a/sig/openai/models/responses/response_text_delta_event.rbs b/sig/openai/models/responses/response_text_delta_event.rbs index 5a692585..45cfac57 100644 --- a/sig/openai/models/responses/response_text_delta_event.rbs +++ b/sig/openai/models/responses/response_text_delta_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.output_text.delta" - def initialize: - ( - content_index: Integer, - delta: String, - item_id: String, - output_index: Integer, - type: :"response.output_text.delta" - ) -> void - | ( - ?OpenAI::Models::Responses::response_text_delta_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + delta: String, + item_id: String, + output_index: Integer, + ?type: :"response.output_text.delta" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_text_delta_event end diff --git a/sig/openai/models/responses/response_text_done_event.rbs b/sig/openai/models/responses/response_text_done_event.rbs index 8cda3224..bc4c94d4 100644 --- a/sig/openai/models/responses/response_text_done_event.rbs +++ b/sig/openai/models/responses/response_text_done_event.rbs @@ -21,18 +21,13 @@ module OpenAI attr_accessor type: :"response.output_text.done" - def initialize: - ( - content_index: Integer, - item_id: String, - output_index: Integer, - text: String, - type: :"response.output_text.done" - ) -> void - | ( - ?OpenAI::Models::Responses::response_text_done_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + content_index: Integer, + item_id: String, + output_index: Integer, + text: String, + ?type: :"response.output_text.done" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_text_done_event end diff --git a/sig/openai/models/responses/response_usage.rbs b/sig/openai/models/responses/response_usage.rbs index cca39c67..8f4d0dac 100644 --- a/sig/openai/models/responses/response_usage.rbs +++ b/sig/openai/models/responses/response_usage.rbs @@ -4,6 +4,7 @@ module OpenAI type response_usage = { input_tokens: Integer, + input_tokens_details: OpenAI::Models::Responses::ResponseUsage::InputTokensDetails, output_tokens: Integer, output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, total_tokens: Integer @@ -12,36 +13,40 @@ module OpenAI class ResponseUsage < OpenAI::BaseModel attr_accessor input_tokens: Integer + attr_accessor input_tokens_details: OpenAI::Models::Responses::ResponseUsage::InputTokensDetails + attr_accessor output_tokens: Integer attr_accessor output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails attr_accessor total_tokens: Integer - def initialize: - ( - input_tokens: Integer, - output_tokens: Integer, - output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, - total_tokens: Integer - ) -> void - | ( - ?OpenAI::Models::Responses::response_usage | OpenAI::BaseModel data - ) -> void + def initialize: ( + input_tokens: Integer, + input_tokens_details: OpenAI::Models::Responses::ResponseUsage::InputTokensDetails, + output_tokens: Integer, + output_tokens_details: OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails, + total_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::Responses::response_usage + type input_tokens_details = { cached_tokens: Integer } + + class InputTokensDetails < OpenAI::BaseModel + attr_accessor cached_tokens: Integer + + def initialize: (cached_tokens: Integer) -> void + + def to_hash: -> OpenAI::Models::Responses::ResponseUsage::input_tokens_details + end + type output_tokens_details = { reasoning_tokens: Integer } class OutputTokensDetails < OpenAI::BaseModel attr_accessor reasoning_tokens: Integer - def initialize: - (reasoning_tokens: Integer) -> void - | ( - ?OpenAI::Models::Responses::ResponseUsage::output_tokens_details - | OpenAI::BaseModel data - ) -> void + def initialize: (reasoning_tokens: Integer) -> void def to_hash: -> OpenAI::Models::Responses::ResponseUsage::output_tokens_details end diff --git a/sig/openai/models/responses/response_web_search_call_completed_event.rbs b/sig/openai/models/responses/response_web_search_call_completed_event.rbs index 3be8bb79..bc8d0e77 100644 --- a/sig/openai/models/responses/response_web_search_call_completed_event.rbs +++ b/sig/openai/models/responses/response_web_search_call_completed_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.web_search_call.completed" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.web_search_call.completed" - ) -> void - | ( - ?OpenAI::Models::Responses::response_web_search_call_completed_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.web_search_call.completed" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_web_search_call_completed_event end diff --git a/sig/openai/models/responses/response_web_search_call_in_progress_event.rbs b/sig/openai/models/responses/response_web_search_call_in_progress_event.rbs index f8d56aa4..34cdc0c4 100644 --- a/sig/openai/models/responses/response_web_search_call_in_progress_event.rbs +++ b/sig/openai/models/responses/response_web_search_call_in_progress_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.web_search_call.in_progress" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.web_search_call.in_progress" - ) -> void - | ( - ?OpenAI::Models::Responses::response_web_search_call_in_progress_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.web_search_call.in_progress" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_web_search_call_in_progress_event end diff --git a/sig/openai/models/responses/response_web_search_call_searching_event.rbs b/sig/openai/models/responses/response_web_search_call_searching_event.rbs index 0e2a2c23..f03cf1a9 100644 --- a/sig/openai/models/responses/response_web_search_call_searching_event.rbs +++ b/sig/openai/models/responses/response_web_search_call_searching_event.rbs @@ -15,16 +15,11 @@ module OpenAI attr_accessor type: :"response.web_search_call.searching" - def initialize: - ( - item_id: String, - output_index: Integer, - type: :"response.web_search_call.searching" - ) -> void - | ( - ?OpenAI::Models::Responses::response_web_search_call_searching_event - | OpenAI::BaseModel data - ) -> void + def initialize: ( + item_id: String, + output_index: Integer, + ?type: :"response.web_search_call.searching" + ) -> void def to_hash: -> OpenAI::Models::Responses::response_web_search_call_searching_event end diff --git a/sig/openai/models/responses/tool.rbs b/sig/openai/models/responses/tool.rbs index 642f7196..c3b27fe5 100644 --- a/sig/openai/models/responses/tool.rbs +++ b/sig/openai/models/responses/tool.rbs @@ -7,8 +7,10 @@ module OpenAI | OpenAI::Models::Responses::ComputerTool | OpenAI::Models::Responses::WebSearchTool - class Tool < OpenAI::Union - def self.variants: -> [OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool] + module Tool + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::WebSearchTool] end end end diff --git a/sig/openai/models/responses/tool_choice_function.rbs b/sig/openai/models/responses/tool_choice_function.rbs index 7dbf4708..bf83f1a7 100644 --- a/sig/openai/models/responses/tool_choice_function.rbs +++ b/sig/openai/models/responses/tool_choice_function.rbs @@ -8,12 +8,7 @@ module OpenAI attr_accessor type: :function - def initialize: - (name: String, type: :function) -> void - | ( - ?OpenAI::Models::Responses::tool_choice_function - | OpenAI::BaseModel data - ) -> void + def initialize: (name: String, ?type: :function) -> void def to_hash: -> OpenAI::Models::Responses::tool_choice_function end diff --git a/sig/openai/models/responses/tool_choice_options.rbs b/sig/openai/models/responses/tool_choice_options.rbs index e902ea2c..44974540 100644 --- a/sig/openai/models/responses/tool_choice_options.rbs +++ b/sig/openai/models/responses/tool_choice_options.rbs @@ -3,12 +3,14 @@ module OpenAI module Responses type tool_choice_options = :none | :auto | :required - class ToolChoiceOptions < OpenAI::Enum + module ToolChoiceOptions + extend OpenAI::Enum + NONE: :none AUTO: :auto REQUIRED: :required - def self.values: -> ::Array[OpenAI::Models::Responses::tool_choice_options] + def self?.values: -> ::Array[OpenAI::Models::Responses::tool_choice_options] end end end diff --git a/sig/openai/models/responses/tool_choice_types.rbs b/sig/openai/models/responses/tool_choice_types.rbs index 66e763a9..b0562635 100644 --- a/sig/openai/models/responses/tool_choice_types.rbs +++ b/sig/openai/models/responses/tool_choice_types.rbs @@ -7,12 +7,9 @@ module OpenAI class ToolChoiceTypes < OpenAI::BaseModel attr_accessor type: OpenAI::Models::Responses::ToolChoiceTypes::type_ - def initialize: - (type: OpenAI::Models::Responses::ToolChoiceTypes::type_) -> void - | ( - ?OpenAI::Models::Responses::tool_choice_types - | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Responses::ToolChoiceTypes::type_ + ) -> void def to_hash: -> OpenAI::Models::Responses::tool_choice_types @@ -22,13 +19,15 @@ module OpenAI | :computer_use_preview | :web_search_preview_2025_03_11 - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + FILE_SEARCH: :file_search WEB_SEARCH_PREVIEW: :web_search_preview COMPUTER_USE_PREVIEW: :computer_use_preview WEB_SEARCH_PREVIEW_2025_03_11: :web_search_preview_2025_03_11 - def self.values: -> ::Array[OpenAI::Models::Responses::ToolChoiceTypes::type_] + def self?.values: -> ::Array[OpenAI::Models::Responses::ToolChoiceTypes::type_] end end end diff --git a/sig/openai/models/responses/web_search_tool.rbs b/sig/openai/models/responses/web_search_tool.rbs index e815a5e3..cb6606be 100644 --- a/sig/openai/models/responses/web_search_tool.rbs +++ b/sig/openai/models/responses/web_search_tool.rbs @@ -19,35 +19,35 @@ module OpenAI attr_accessor user_location: OpenAI::Models::Responses::WebSearchTool::UserLocation? - def initialize: - ( - type: OpenAI::Models::Responses::WebSearchTool::type_, - search_context_size: OpenAI::Models::Responses::WebSearchTool::search_context_size, - user_location: OpenAI::Models::Responses::WebSearchTool::UserLocation? - ) -> void - | ( - ?OpenAI::Models::Responses::web_search_tool | OpenAI::BaseModel data - ) -> void + def initialize: ( + type: OpenAI::Models::Responses::WebSearchTool::type_, + ?search_context_size: OpenAI::Models::Responses::WebSearchTool::search_context_size, + ?user_location: OpenAI::Models::Responses::WebSearchTool::UserLocation? + ) -> void def to_hash: -> OpenAI::Models::Responses::web_search_tool type type_ = :web_search_preview | :web_search_preview_2025_03_11 - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + WEB_SEARCH_PREVIEW: :web_search_preview WEB_SEARCH_PREVIEW_2025_03_11: :web_search_preview_2025_03_11 - def self.values: -> ::Array[OpenAI::Models::Responses::WebSearchTool::type_] + def self?.values: -> ::Array[OpenAI::Models::Responses::WebSearchTool::type_] end type search_context_size = :low | :medium | :high - class SearchContextSize < OpenAI::Enum + module SearchContextSize + extend OpenAI::Enum + LOW: :low MEDIUM: :medium HIGH: :high - def self.values: -> ::Array[OpenAI::Models::Responses::WebSearchTool::search_context_size] + def self?.values: -> ::Array[OpenAI::Models::Responses::WebSearchTool::search_context_size] end type user_location = @@ -78,18 +78,13 @@ module OpenAI def timezone=: (String) -> String - def initialize: - ( - city: String, - country: String, - region: String, - timezone: String, - type: :approximate - ) -> void - | ( - ?OpenAI::Models::Responses::WebSearchTool::user_location - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?city: String, + ?country: String, + ?region: String, + ?timezone: String, + ?type: :approximate + ) -> void def to_hash: -> OpenAI::Models::Responses::WebSearchTool::user_location end diff --git a/sig/openai/models/responses_model.rbs b/sig/openai/models/responses_model.rbs new file mode 100644 index 00000000..5e0a2660 --- /dev/null +++ b/sig/openai/models/responses_model.rbs @@ -0,0 +1,25 @@ +module OpenAI + module Models + type responses_model = + String + | OpenAI::Models::chat_model + | :"o1-pro" + | :"o1-pro-2025-03-19" + | :"computer-use-preview" + | :"computer-use-preview-2025-03-11" + + module ResponsesModel + extend OpenAI::Union + + def self?.variants: -> [String, OpenAI::Models::chat_model, (:"o1-pro" + | :"o1-pro-2025-03-19" + | :"computer-use-preview" + | :"computer-use-preview-2025-03-11")] + + O1_PRO: :"o1-pro" + O1_PRO_2025_03_19: :"o1-pro-2025-03-19" + COMPUTER_USE_PREVIEW: :"computer-use-preview" + COMPUTER_USE_PREVIEW_2025_03_11: :"computer-use-preview-2025-03-11" + end + end +end diff --git a/sig/openai/models/static_file_chunking_strategy.rbs b/sig/openai/models/static_file_chunking_strategy.rbs index a10dab32..e77bd4ac 100644 --- a/sig/openai/models/static_file_chunking_strategy.rbs +++ b/sig/openai/models/static_file_chunking_strategy.rbs @@ -8,12 +8,10 @@ module OpenAI attr_accessor max_chunk_size_tokens: Integer - def initialize: - (chunk_overlap_tokens: Integer, max_chunk_size_tokens: Integer) -> void - | ( - ?OpenAI::Models::static_file_chunking_strategy - | OpenAI::BaseModel data - ) -> void + def initialize: ( + chunk_overlap_tokens: Integer, + max_chunk_size_tokens: Integer + ) -> void def to_hash: -> OpenAI::Models::static_file_chunking_strategy end diff --git a/sig/openai/models/static_file_chunking_strategy_object.rbs b/sig/openai/models/static_file_chunking_strategy_object.rbs index f3b1f264..62e506a3 100644 --- a/sig/openai/models/static_file_chunking_strategy_object.rbs +++ b/sig/openai/models/static_file_chunking_strategy_object.rbs @@ -8,15 +8,10 @@ module OpenAI attr_accessor type: :static - def initialize: - ( - static: OpenAI::Models::StaticFileChunkingStrategy, - type: :static - ) -> void - | ( - ?OpenAI::Models::static_file_chunking_strategy_object - | OpenAI::BaseModel data - ) -> void + def initialize: ( + static: OpenAI::Models::StaticFileChunkingStrategy, + ?type: :static + ) -> void def to_hash: -> OpenAI::Models::static_file_chunking_strategy_object end diff --git a/sig/openai/models/static_file_chunking_strategy_object_param.rbs b/sig/openai/models/static_file_chunking_strategy_object_param.rbs index 9d6c4140..a86f96ab 100644 --- a/sig/openai/models/static_file_chunking_strategy_object_param.rbs +++ b/sig/openai/models/static_file_chunking_strategy_object_param.rbs @@ -8,15 +8,10 @@ module OpenAI attr_accessor type: :static - def initialize: - ( - static: OpenAI::Models::StaticFileChunkingStrategy, - type: :static - ) -> void - | ( - ?OpenAI::Models::static_file_chunking_strategy_object_param - | OpenAI::BaseModel data - ) -> void + def initialize: ( + static: OpenAI::Models::StaticFileChunkingStrategy, + ?type: :static + ) -> void def to_hash: -> OpenAI::Models::static_file_chunking_strategy_object_param end diff --git a/sig/openai/models/upload.rbs b/sig/openai/models/upload.rbs index e58a0c87..ff4fec3b 100644 --- a/sig/openai/models/upload.rbs +++ b/sig/openai/models/upload.rbs @@ -32,31 +32,31 @@ module OpenAI attr_accessor file: OpenAI::Models::FileObject? - def initialize: - ( - id: String, - bytes: Integer, - created_at: Integer, - expires_at: Integer, - filename: String, - purpose: String, - status: OpenAI::Models::Upload::status, - file: OpenAI::Models::FileObject?, - object: :upload - ) -> void - | (?OpenAI::Models::upload | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + bytes: Integer, + created_at: Integer, + expires_at: Integer, + filename: String, + purpose: String, + status: OpenAI::Models::Upload::status, + ?file: OpenAI::Models::FileObject?, + ?object: :upload + ) -> void def to_hash: -> OpenAI::Models::upload type status = :pending | :completed | :cancelled | :expired - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + PENDING: :pending COMPLETED: :completed CANCELLED: :cancelled EXPIRED: :expired - def self.values: -> ::Array[OpenAI::Models::Upload::status] + def self?.values: -> ::Array[OpenAI::Models::Upload::status] end end end diff --git a/sig/openai/models/upload_cancel_params.rbs b/sig/openai/models/upload_cancel_params.rbs index 4ddc9f7b..df6f7b0c 100644 --- a/sig/openai/models/upload_cancel_params.rbs +++ b/sig/openai/models/upload_cancel_params.rbs @@ -3,14 +3,10 @@ module OpenAI type upload_cancel_params = { } & OpenAI::request_parameters class UploadCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::upload_cancel_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::upload_cancel_params end diff --git a/sig/openai/models/upload_complete_params.rbs b/sig/openai/models/upload_complete_params.rbs index a22d1531..eb3cbcf1 100644 --- a/sig/openai/models/upload_complete_params.rbs +++ b/sig/openai/models/upload_complete_params.rbs @@ -4,7 +4,7 @@ module OpenAI { part_ids: ::Array[String], :md5 => String } & OpenAI::request_parameters class UploadCompleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor part_ids: ::Array[String] @@ -13,15 +13,11 @@ module OpenAI def md5=: (String) -> String - def initialize: - ( - part_ids: ::Array[String], - md5: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::upload_complete_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + part_ids: ::Array[String], + ?md5: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::upload_complete_params end diff --git a/sig/openai/models/upload_create_params.rbs b/sig/openai/models/upload_create_params.rbs index de006ed9..431fc356 100644 --- a/sig/openai/models/upload_create_params.rbs +++ b/sig/openai/models/upload_create_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class UploadCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor bytes: Integer @@ -21,17 +21,13 @@ module OpenAI attr_accessor purpose: OpenAI::Models::file_purpose - def initialize: - ( - bytes: Integer, - filename: String, - mime_type: String, - purpose: OpenAI::Models::file_purpose, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::upload_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + bytes: Integer, + filename: String, + mime_type: String, + purpose: OpenAI::Models::file_purpose, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::upload_create_params end diff --git a/sig/openai/models/uploads/part_create_params.rbs b/sig/openai/models/uploads/part_create_params.rbs index 0276fa19..cc960f1c 100644 --- a/sig/openai/models/uploads/part_create_params.rbs +++ b/sig/openai/models/uploads/part_create_params.rbs @@ -5,17 +5,15 @@ module OpenAI { data: (IO | StringIO) } & OpenAI::request_parameters class PartCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor data: IO | StringIO - def initialize: - (data: IO | StringIO, request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::Uploads::part_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + data: IO | StringIO, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::Uploads::part_create_params end diff --git a/sig/openai/models/uploads/upload_part.rbs b/sig/openai/models/uploads/upload_part.rbs index 18ff6f6e..2a1f9e38 100644 --- a/sig/openai/models/uploads/upload_part.rbs +++ b/sig/openai/models/uploads/upload_part.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class UploadPart = Uploads::UploadPart module Uploads @@ -21,16 +20,12 @@ module OpenAI attr_accessor upload_id: String - def initialize: - ( - id: String, - created_at: Integer, - upload_id: String, - object: :"upload.part" - ) -> void - | ( - ?OpenAI::Models::Uploads::upload_part | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + upload_id: String, + ?object: :"upload.part" + ) -> void def to_hash: -> OpenAI::Models::Uploads::upload_part end diff --git a/sig/openai/models/vector_store.rbs b/sig/openai/models/vector_store.rbs index de85bfdb..02c2f02f 100644 --- a/sig/openai/models/vector_store.rbs +++ b/sig/openai/models/vector_store.rbs @@ -42,21 +42,19 @@ module OpenAI attr_accessor expires_at: Integer? - def initialize: - ( - id: String, - created_at: Integer, - file_counts: OpenAI::Models::VectorStore::FileCounts, - last_active_at: Integer?, - metadata: OpenAI::Models::metadata?, - name: String, - status: OpenAI::Models::VectorStore::status, - usage_bytes: Integer, - expires_after: OpenAI::Models::VectorStore::ExpiresAfter, - expires_at: Integer?, - object: :vector_store - ) -> void - | (?OpenAI::Models::vector_store | OpenAI::BaseModel data) -> void + def initialize: ( + id: String, + created_at: Integer, + file_counts: OpenAI::Models::VectorStore::FileCounts, + last_active_at: Integer?, + metadata: OpenAI::Models::metadata?, + name: String, + status: OpenAI::Models::VectorStore::status, + usage_bytes: Integer, + ?expires_after: OpenAI::Models::VectorStore::ExpiresAfter, + ?expires_at: Integer?, + ?object: :vector_store + ) -> void def to_hash: -> OpenAI::Models::vector_store @@ -80,29 +78,27 @@ module OpenAI attr_accessor total: Integer - def initialize: - ( - cancelled: Integer, - completed: Integer, - failed: Integer, - in_progress: Integer, - total: Integer - ) -> void - | ( - ?OpenAI::Models::VectorStore::file_counts | OpenAI::BaseModel data - ) -> void + def initialize: ( + cancelled: Integer, + completed: Integer, + failed: Integer, + in_progress: Integer, + total: Integer + ) -> void def to_hash: -> OpenAI::Models::VectorStore::file_counts end type status = :expired | :in_progress | :completed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + EXPIRED: :expired IN_PROGRESS: :in_progress COMPLETED: :completed - def self.values: -> ::Array[OpenAI::Models::VectorStore::status] + def self?.values: -> ::Array[OpenAI::Models::VectorStore::status] end type expires_after = { anchor: :last_active_at, days: Integer } @@ -112,11 +108,7 @@ module OpenAI attr_accessor days: Integer - def initialize: - (days: Integer, anchor: :last_active_at) -> void - | ( - ?OpenAI::Models::VectorStore::expires_after | OpenAI::BaseModel data - ) -> void + def initialize: (days: Integer, ?anchor: :last_active_at) -> void def to_hash: -> OpenAI::Models::VectorStore::expires_after end diff --git a/sig/openai/models/vector_store_create_params.rbs b/sig/openai/models/vector_store_create_params.rbs index 93b49fe7..b0bdecc8 100644 --- a/sig/openai/models/vector_store_create_params.rbs +++ b/sig/openai/models/vector_store_create_params.rbs @@ -11,7 +11,7 @@ module OpenAI & OpenAI::request_parameters class VectorStoreCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader chunking_strategy: OpenAI::Models::file_chunking_strategy_param? @@ -36,18 +36,14 @@ module OpenAI def name=: (String) -> String - def initialize: - ( - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, - file_ids: ::Array[String], - metadata: OpenAI::Models::metadata?, - name: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::vector_store_create_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, + ?file_ids: ::Array[String], + ?metadata: OpenAI::Models::metadata?, + ?name: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::vector_store_create_params @@ -58,12 +54,7 @@ module OpenAI attr_accessor days: Integer - def initialize: - (days: Integer, anchor: :last_active_at) -> void - | ( - ?OpenAI::Models::VectorStoreCreateParams::expires_after - | OpenAI::BaseModel data - ) -> void + def initialize: (days: Integer, ?anchor: :last_active_at) -> void def to_hash: -> OpenAI::Models::VectorStoreCreateParams::expires_after end diff --git a/sig/openai/models/vector_store_delete_params.rbs b/sig/openai/models/vector_store_delete_params.rbs index 42f031e5..65b00bf3 100644 --- a/sig/openai/models/vector_store_delete_params.rbs +++ b/sig/openai/models/vector_store_delete_params.rbs @@ -3,14 +3,10 @@ module OpenAI type vector_store_delete_params = { } & OpenAI::request_parameters class VectorStoreDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::vector_store_delete_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::vector_store_delete_params end diff --git a/sig/openai/models/vector_store_deleted.rbs b/sig/openai/models/vector_store_deleted.rbs index 53fe34e4..3403e058 100644 --- a/sig/openai/models/vector_store_deleted.rbs +++ b/sig/openai/models/vector_store_deleted.rbs @@ -10,11 +10,11 @@ module OpenAI attr_accessor object: :"vector_store.deleted" - def initialize: - (id: String, deleted: bool, object: :"vector_store.deleted") -> void - | ( - ?OpenAI::Models::vector_store_deleted | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"vector_store.deleted" + ) -> void def to_hash: -> OpenAI::Models::vector_store_deleted end diff --git a/sig/openai/models/vector_store_list_params.rbs b/sig/openai/models/vector_store_list_params.rbs index 7ec8d50d..932f1b34 100644 --- a/sig/openai/models/vector_store_list_params.rbs +++ b/sig/openai/models/vector_store_list_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class VectorStoreListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -31,27 +31,25 @@ module OpenAI OpenAI::Models::VectorStoreListParams::order ) -> OpenAI::Models::VectorStoreListParams::order - def initialize: - ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::VectorStoreListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::vector_store_list_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::VectorStoreListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::vector_store_list_params type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::VectorStoreListParams::order] + def self?.values: -> ::Array[OpenAI::Models::VectorStoreListParams::order] end end end diff --git a/sig/openai/models/vector_store_retrieve_params.rbs b/sig/openai/models/vector_store_retrieve_params.rbs index a2603a79..39d412f5 100644 --- a/sig/openai/models/vector_store_retrieve_params.rbs +++ b/sig/openai/models/vector_store_retrieve_params.rbs @@ -3,14 +3,10 @@ module OpenAI type vector_store_retrieve_params = { } & OpenAI::request_parameters class VectorStoreRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters - def initialize: - (request_options: OpenAI::request_opts) -> void - | ( - ?OpenAI::Models::vector_store_retrieve_params | OpenAI::BaseModel data - ) -> void + def initialize: (?request_options: OpenAI::request_opts) -> void def to_hash: -> OpenAI::Models::vector_store_retrieve_params end diff --git a/sig/openai/models/vector_store_search_params.rbs b/sig/openai/models/vector_store_search_params.rbs index 2ac6032b..3c87c94f 100644 --- a/sig/openai/models/vector_store_search_params.rbs +++ b/sig/openai/models/vector_store_search_params.rbs @@ -11,7 +11,7 @@ module OpenAI & OpenAI::request_parameters class VectorStoreSearchParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor query: OpenAI::Models::VectorStoreSearchParams::query @@ -36,36 +36,36 @@ module OpenAI def rewrite_query=: (bool) -> bool - def initialize: - ( - query: OpenAI::Models::VectorStoreSearchParams::query, - filters: OpenAI::Models::VectorStoreSearchParams::filters, - max_num_results: Integer, - ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, - rewrite_query: bool, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::vector_store_search_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + query: OpenAI::Models::VectorStoreSearchParams::query, + ?filters: OpenAI::Models::VectorStoreSearchParams::filters, + ?max_num_results: Integer, + ?ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, + ?rewrite_query: bool, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::vector_store_search_params type query = String | ::Array[String] - class Query < OpenAI::Union + module Query + extend OpenAI::Union + + def self?.variants: -> [String, ::Array[String]] + type string_array = ::Array[String] StringArray: string_array - - def self.variants: -> [String, ::Array[String]] end type filters = OpenAI::Models::ComparisonFilter | OpenAI::Models::CompoundFilter - class Filters < OpenAI::Union - def self.variants: -> [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] + module Filters + extend OpenAI::Union + + def self?.variants: -> [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] end type ranking_options = @@ -85,25 +85,22 @@ module OpenAI def score_threshold=: (Float) -> Float - def initialize: - ( - ranker: OpenAI::Models::VectorStoreSearchParams::RankingOptions::ranker, - score_threshold: Float - ) -> void - | ( - ?OpenAI::Models::VectorStoreSearchParams::ranking_options - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?ranker: OpenAI::Models::VectorStoreSearchParams::RankingOptions::ranker, + ?score_threshold: Float + ) -> void def to_hash: -> OpenAI::Models::VectorStoreSearchParams::ranking_options type ranker = :auto | :"default-2024-11-15" - class Ranker < OpenAI::Enum + module Ranker + extend OpenAI::Enum + AUTO: :auto DEFAULT_2024_11_15: :"default-2024-11-15" - def self.values: -> ::Array[OpenAI::Models::VectorStoreSearchParams::RankingOptions::ranker] + def self?.values: -> ::Array[OpenAI::Models::VectorStoreSearchParams::RankingOptions::ranker] end end end diff --git a/sig/openai/models/vector_store_search_response.rbs b/sig/openai/models/vector_store_search_response.rbs index 9207fde5..a5ba79e3 100644 --- a/sig/openai/models/vector_store_search_response.rbs +++ b/sig/openai/models/vector_store_search_response.rbs @@ -20,24 +20,22 @@ module OpenAI attr_accessor score: Float - def initialize: - ( - attributes: ::Hash[Symbol, OpenAI::Models::VectorStoreSearchResponse::attribute]?, - content: ::Array[OpenAI::Models::VectorStoreSearchResponse::Content], - file_id: String, - filename: String, - score: Float - ) -> void - | ( - ?OpenAI::Models::vector_store_search_response | OpenAI::BaseModel data - ) -> void + def initialize: ( + attributes: ::Hash[Symbol, OpenAI::Models::VectorStoreSearchResponse::attribute]?, + content: ::Array[OpenAI::Models::VectorStoreSearchResponse::Content], + file_id: String, + filename: String, + score: Float + ) -> void def to_hash: -> OpenAI::Models::vector_store_search_response type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end type content = @@ -51,24 +49,21 @@ module OpenAI attr_accessor type: OpenAI::Models::VectorStoreSearchResponse::Content::type_ - def initialize: - ( - text: String, - type: OpenAI::Models::VectorStoreSearchResponse::Content::type_ - ) -> void - | ( - ?OpenAI::Models::VectorStoreSearchResponse::content - | OpenAI::BaseModel data - ) -> void + def initialize: ( + text: String, + type: OpenAI::Models::VectorStoreSearchResponse::Content::type_ + ) -> void def to_hash: -> OpenAI::Models::VectorStoreSearchResponse::content type type_ = :text - class Type < OpenAI::Enum + module Type + extend OpenAI::Enum + TEXT: :text - def self.values: -> ::Array[OpenAI::Models::VectorStoreSearchResponse::Content::type_] + def self?.values: -> ::Array[OpenAI::Models::VectorStoreSearchResponse::Content::type_] end end end diff --git a/sig/openai/models/vector_store_update_params.rbs b/sig/openai/models/vector_store_update_params.rbs index 33acab97..734ce7fd 100644 --- a/sig/openai/models/vector_store_update_params.rbs +++ b/sig/openai/models/vector_store_update_params.rbs @@ -9,7 +9,7 @@ module OpenAI & OpenAI::request_parameters class VectorStoreUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor expires_after: OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter? @@ -18,16 +18,12 @@ module OpenAI attr_accessor name: String? - def initialize: - ( - expires_after: OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter?, - metadata: OpenAI::Models::metadata?, - name: String?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::vector_store_update_params | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?expires_after: OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter?, + ?metadata: OpenAI::Models::metadata?, + ?name: String?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::vector_store_update_params @@ -38,12 +34,7 @@ module OpenAI attr_accessor days: Integer - def initialize: - (days: Integer, anchor: :last_active_at) -> void - | ( - ?OpenAI::Models::VectorStoreUpdateParams::expires_after - | OpenAI::BaseModel data - ) -> void + def initialize: (days: Integer, ?anchor: :last_active_at) -> void def to_hash: -> OpenAI::Models::VectorStoreUpdateParams::expires_after end diff --git a/sig/openai/models/vector_stores/file_batch_cancel_params.rbs b/sig/openai/models/vector_stores/file_batch_cancel_params.rbs index 42b68be5..7400302e 100644 --- a/sig/openai/models/vector_stores/file_batch_cancel_params.rbs +++ b/sig/openai/models/vector_stores/file_batch_cancel_params.rbs @@ -5,20 +5,15 @@ module OpenAI { vector_store_id: String } & OpenAI::request_parameters class FileBatchCancelParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String - def initialize: - ( - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_batch_cancel_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_batch_cancel_params end diff --git a/sig/openai/models/vector_stores/file_batch_create_params.rbs b/sig/openai/models/vector_stores/file_batch_create_params.rbs index 963a641f..ec58551e 100644 --- a/sig/openai/models/vector_stores/file_batch_create_params.rbs +++ b/sig/openai/models/vector_stores/file_batch_create_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class FileBatchCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor file_ids: ::Array[String] @@ -23,24 +23,21 @@ module OpenAI OpenAI::Models::file_chunking_strategy_param ) -> OpenAI::Models::file_chunking_strategy_param - def initialize: - ( - file_ids: ::Array[String], - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileBatchCreateParams::attribute]?, - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_batch_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_ids: ::Array[String], + ?attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileBatchCreateParams::attribute]?, + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_batch_create_params type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/vector_stores/file_batch_list_files_params.rbs b/sig/openai/models/vector_stores/file_batch_list_files_params.rbs index 21e09293..b19f61ad 100644 --- a/sig/openai/models/vector_stores/file_batch_list_files_params.rbs +++ b/sig/openai/models/vector_stores/file_batch_list_files_params.rbs @@ -13,7 +13,7 @@ module OpenAI & OpenAI::request_parameters class FileBatchListFilesParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String @@ -42,41 +42,40 @@ module OpenAI OpenAI::Models::VectorStores::FileBatchListFilesParams::order ) -> OpenAI::Models::VectorStores::FileBatchListFilesParams::order - def initialize: - ( - vector_store_id: String, - after: String, - before: String, - filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::filter, - limit: Integer, - order: OpenAI::Models::VectorStores::FileBatchListFilesParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_batch_list_files_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?after: String, + ?before: String, + ?filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::filter, + ?limit: Integer, + ?order: OpenAI::Models::VectorStores::FileBatchListFilesParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_batch_list_files_params type filter = :in_progress | :completed | :failed | :cancelled - class Filter < OpenAI::Enum + module Filter + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed FAILED: :failed CANCELLED: :cancelled - def self.values: -> ::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::filter] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::filter] end type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::order] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::FileBatchListFilesParams::order] end end end diff --git a/sig/openai/models/vector_stores/file_batch_retrieve_params.rbs b/sig/openai/models/vector_stores/file_batch_retrieve_params.rbs index 090286fa..2adbda41 100644 --- a/sig/openai/models/vector_stores/file_batch_retrieve_params.rbs +++ b/sig/openai/models/vector_stores/file_batch_retrieve_params.rbs @@ -5,20 +5,15 @@ module OpenAI { vector_store_id: String } & OpenAI::request_parameters class FileBatchRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String - def initialize: - ( - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_batch_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_batch_retrieve_params end diff --git a/sig/openai/models/vector_stores/file_content_params.rbs b/sig/openai/models/vector_stores/file_content_params.rbs index 751c410c..608c3d89 100644 --- a/sig/openai/models/vector_stores/file_content_params.rbs +++ b/sig/openai/models/vector_stores/file_content_params.rbs @@ -5,20 +5,15 @@ module OpenAI { vector_store_id: String } & OpenAI::request_parameters class FileContentParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String - def initialize: - ( - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_content_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_content_params end diff --git a/sig/openai/models/vector_stores/file_content_response.rbs b/sig/openai/models/vector_stores/file_content_response.rbs index 3153dccf..11f49799 100644 --- a/sig/openai/models/vector_stores/file_content_response.rbs +++ b/sig/openai/models/vector_stores/file_content_response.rbs @@ -12,12 +12,7 @@ module OpenAI def type=: (String) -> String - def initialize: - (text: String, type: String) -> void - | ( - ?OpenAI::Models::VectorStores::file_content_response - | OpenAI::BaseModel data - ) -> void + def initialize: (?text: String, ?type: String) -> void def to_hash: -> OpenAI::Models::VectorStores::file_content_response end diff --git a/sig/openai/models/vector_stores/file_create_params.rbs b/sig/openai/models/vector_stores/file_create_params.rbs index 471cc8a7..82145f08 100644 --- a/sig/openai/models/vector_stores/file_create_params.rbs +++ b/sig/openai/models/vector_stores/file_create_params.rbs @@ -10,7 +10,7 @@ module OpenAI & OpenAI::request_parameters class FileCreateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor file_id: String @@ -23,24 +23,21 @@ module OpenAI OpenAI::Models::file_chunking_strategy_param ) -> OpenAI::Models::file_chunking_strategy_param - def initialize: - ( - file_id: String, - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileCreateParams::attribute]?, - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_create_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + file_id: String, + ?attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileCreateParams::attribute]?, + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_create_params type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/vector_stores/file_delete_params.rbs b/sig/openai/models/vector_stores/file_delete_params.rbs index 212e1e30..c1b36f86 100644 --- a/sig/openai/models/vector_stores/file_delete_params.rbs +++ b/sig/openai/models/vector_stores/file_delete_params.rbs @@ -5,20 +5,15 @@ module OpenAI { vector_store_id: String } & OpenAI::request_parameters class FileDeleteParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String - def initialize: - ( - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_delete_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_delete_params end diff --git a/sig/openai/models/vector_stores/file_list_params.rbs b/sig/openai/models/vector_stores/file_list_params.rbs index 75b43fd1..88f6eb73 100644 --- a/sig/openai/models/vector_stores/file_list_params.rbs +++ b/sig/openai/models/vector_stores/file_list_params.rbs @@ -12,7 +12,7 @@ module OpenAI & OpenAI::request_parameters class FileListParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_reader after: String? @@ -39,40 +39,39 @@ module OpenAI OpenAI::Models::VectorStores::FileListParams::order ) -> OpenAI::Models::VectorStores::FileListParams::order - def initialize: - ( - after: String, - before: String, - filter: OpenAI::Models::VectorStores::FileListParams::filter, - limit: Integer, - order: OpenAI::Models::VectorStores::FileListParams::order, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_list_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + ?after: String, + ?before: String, + ?filter: OpenAI::Models::VectorStores::FileListParams::filter, + ?limit: Integer, + ?order: OpenAI::Models::VectorStores::FileListParams::order, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_list_params type filter = :in_progress | :completed | :failed | :cancelled - class Filter < OpenAI::Enum + module Filter + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed FAILED: :failed CANCELLED: :cancelled - def self.values: -> ::Array[OpenAI::Models::VectorStores::FileListParams::filter] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::FileListParams::filter] end type order = :asc | :desc - class Order < OpenAI::Enum + module Order + extend OpenAI::Enum + ASC: :asc DESC: :desc - def self.values: -> ::Array[OpenAI::Models::VectorStores::FileListParams::order] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::FileListParams::order] end end end diff --git a/sig/openai/models/vector_stores/file_retrieve_params.rbs b/sig/openai/models/vector_stores/file_retrieve_params.rbs index b490be00..dafdc50e 100644 --- a/sig/openai/models/vector_stores/file_retrieve_params.rbs +++ b/sig/openai/models/vector_stores/file_retrieve_params.rbs @@ -5,20 +5,15 @@ module OpenAI { vector_store_id: String } & OpenAI::request_parameters class FileRetrieveParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String - def initialize: - ( - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_retrieve_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_retrieve_params end diff --git a/sig/openai/models/vector_stores/file_update_params.rbs b/sig/openai/models/vector_stores/file_update_params.rbs index 946352ec..dfa006a4 100644 --- a/sig/openai/models/vector_stores/file_update_params.rbs +++ b/sig/openai/models/vector_stores/file_update_params.rbs @@ -9,30 +9,27 @@ module OpenAI & OpenAI::request_parameters class FileUpdateParams < OpenAI::BaseModel - extend OpenAI::RequestParameters::Converter + extend OpenAI::Type::RequestParameters::Converter include OpenAI::RequestParameters attr_accessor vector_store_id: String attr_accessor attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileUpdateParams::attribute]? - def initialize: - ( - vector_store_id: String, - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileUpdateParams::attribute]?, - request_options: OpenAI::request_opts - ) -> void - | ( - ?OpenAI::Models::VectorStores::file_update_params - | OpenAI::BaseModel data - ) -> void + def initialize: ( + vector_store_id: String, + attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileUpdateParams::attribute]?, + ?request_options: OpenAI::request_opts + ) -> void def to_hash: -> OpenAI::Models::VectorStores::file_update_params type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/vector_stores/vector_store_file.rbs b/sig/openai/models/vector_stores/vector_store_file.rbs index c25e3ea0..200981e8 100644 --- a/sig/openai/models/vector_stores/vector_store_file.rbs +++ b/sig/openai/models/vector_stores/vector_store_file.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class VectorStoreFile = VectorStores::VectorStoreFile module VectorStores @@ -40,22 +39,17 @@ module OpenAI OpenAI::Models::file_chunking_strategy ) -> OpenAI::Models::file_chunking_strategy - def initialize: - ( - id: String, - created_at: Integer, - last_error: OpenAI::Models::VectorStores::VectorStoreFile::LastError?, - status: OpenAI::Models::VectorStores::VectorStoreFile::status, - usage_bytes: Integer, - vector_store_id: String, - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::VectorStoreFile::attribute]?, - chunking_strategy: OpenAI::Models::file_chunking_strategy, - object: :"vector_store.file" - ) -> void - | ( - ?OpenAI::Models::VectorStores::vector_store_file - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + last_error: OpenAI::Models::VectorStores::VectorStoreFile::LastError?, + status: OpenAI::Models::VectorStores::VectorStoreFile::status, + usage_bytes: Integer, + vector_store_id: String, + ?attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::VectorStoreFile::attribute]?, + ?chunking_strategy: OpenAI::Models::file_chunking_strategy, + ?object: :"vector_store.file" + ) -> void def to_hash: -> OpenAI::Models::VectorStores::vector_store_file @@ -70,44 +64,45 @@ module OpenAI attr_accessor message: String - def initialize: - ( - code: OpenAI::Models::VectorStores::VectorStoreFile::LastError::code, - message: String - ) -> void - | ( - ?OpenAI::Models::VectorStores::VectorStoreFile::last_error - | OpenAI::BaseModel data - ) -> void + def initialize: ( + code: OpenAI::Models::VectorStores::VectorStoreFile::LastError::code, + message: String + ) -> void def to_hash: -> OpenAI::Models::VectorStores::VectorStoreFile::last_error type code = :server_error | :unsupported_file | :invalid_file - class Code < OpenAI::Enum + module Code + extend OpenAI::Enum + SERVER_ERROR: :server_error UNSUPPORTED_FILE: :unsupported_file INVALID_FILE: :invalid_file - def self.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFile::LastError::code] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFile::LastError::code] end end type status = :in_progress | :completed | :cancelled | :failed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed CANCELLED: :cancelled FAILED: :failed - def self.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFile::status] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFile::status] end type attribute = String | Float | bool - class Attribute < OpenAI::Union - def self.variants: -> [String, Float, bool] + module Attribute + extend OpenAI::Union + + def self?.variants: -> [String, Float, bool] end end end diff --git a/sig/openai/models/vector_stores/vector_store_file_batch.rbs b/sig/openai/models/vector_stores/vector_store_file_batch.rbs index 452a536f..d5ae501f 100644 --- a/sig/openai/models/vector_stores/vector_store_file_batch.rbs +++ b/sig/openai/models/vector_stores/vector_store_file_batch.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class VectorStoreFileBatch = VectorStores::VectorStoreFileBatch module VectorStores @@ -27,19 +26,14 @@ module OpenAI attr_accessor vector_store_id: String - def initialize: - ( - id: String, - created_at: Integer, - file_counts: OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, - status: OpenAI::Models::VectorStores::VectorStoreFileBatch::status, - vector_store_id: String, - object: :"vector_store.files_batch" - ) -> void - | ( - ?OpenAI::Models::VectorStores::vector_store_file_batch - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + created_at: Integer, + file_counts: OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts, + status: OpenAI::Models::VectorStores::VectorStoreFileBatch::status, + vector_store_id: String, + ?object: :"vector_store.files_batch" + ) -> void def to_hash: -> OpenAI::Models::VectorStores::vector_store_file_batch @@ -63,31 +57,28 @@ module OpenAI attr_accessor total: Integer - def initialize: - ( - cancelled: Integer, - completed: Integer, - failed: Integer, - in_progress: Integer, - total: Integer - ) -> void - | ( - ?OpenAI::Models::VectorStores::VectorStoreFileBatch::file_counts - | OpenAI::BaseModel data - ) -> void + def initialize: ( + cancelled: Integer, + completed: Integer, + failed: Integer, + in_progress: Integer, + total: Integer + ) -> void def to_hash: -> OpenAI::Models::VectorStores::VectorStoreFileBatch::file_counts end type status = :in_progress | :completed | :cancelled | :failed - class Status < OpenAI::Enum + module Status + extend OpenAI::Enum + IN_PROGRESS: :in_progress COMPLETED: :completed CANCELLED: :cancelled FAILED: :failed - def self.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFileBatch::status] + def self?.values: -> ::Array[OpenAI::Models::VectorStores::VectorStoreFileBatch::status] end end end diff --git a/sig/openai/models/vector_stores/vector_store_file_deleted.rbs b/sig/openai/models/vector_stores/vector_store_file_deleted.rbs index fe8437d3..19257a53 100644 --- a/sig/openai/models/vector_stores/vector_store_file_deleted.rbs +++ b/sig/openai/models/vector_stores/vector_store_file_deleted.rbs @@ -1,6 +1,5 @@ module OpenAI module Models - class VectorStoreFileDeleted = VectorStores::VectorStoreFileDeleted module VectorStores @@ -14,16 +13,11 @@ module OpenAI attr_accessor object: :"vector_store.file.deleted" - def initialize: - ( - id: String, - deleted: bool, - object: :"vector_store.file.deleted" - ) -> void - | ( - ?OpenAI::Models::VectorStores::vector_store_file_deleted - | OpenAI::BaseModel data - ) -> void + def initialize: ( + id: String, + deleted: bool, + ?object: :"vector_store.file.deleted" + ) -> void def to_hash: -> OpenAI::Models::VectorStores::vector_store_file_deleted end diff --git a/sig/openai/page.rbs b/sig/openai/page.rbs index 420e2716..48cd508b 100644 --- a/sig/openai/page.rbs +++ b/sig/openai/page.rbs @@ -1,9 +1,11 @@ module OpenAI class Page[Elem] - include OpenAI::BasePage[Elem] + include OpenAI::Type::BasePage[Elem] attr_accessor data: ::Array[Elem]? attr_accessor object: String + + def inspect: -> String end end diff --git a/sig/openai/pooled_net_requester.rbs b/sig/openai/pooled_net_requester.rbs deleted file mode 100644 index c9f6520d..00000000 --- a/sig/openai/pooled_net_requester.rbs +++ /dev/null @@ -1,35 +0,0 @@ -module OpenAI - class PooledNetRequester - type request = - { - method: Symbol, - url: URI::Generic, - headers: ::Hash[String, String], - body: top, - deadline: Float - } - - def self.connect: (URI::Generic url) -> top - - def self.calibrate_socket_timeout: (top conn, Float deadline) -> void - - def self.build_request: ( - OpenAI::PooledNetRequester::request request - ) { - (String arg0) -> void - } -> top - - private def with_pool: ( - URI::Generic url, - deadline: Float - ) { - (top arg0) -> void - } -> void - - def execute: ( - OpenAI::PooledNetRequester::request request - ) -> [Integer, top, Enumerable[String]] - - def initialize: (size: Integer) -> void - end -end diff --git a/sig/openai/request_options.rbs b/sig/openai/request_options.rbs index 97561491..51674ffe 100644 --- a/sig/openai/request_options.rbs +++ b/sig/openai/request_options.rbs @@ -2,22 +2,12 @@ module OpenAI type request_opts = OpenAI::RequestOptions | OpenAI::request_options | ::Hash[Symbol, top] - type request_parameters = { request_options: OpenAI::request_opts } - - module RequestParameters - attr_accessor request_options: OpenAI::request_opts - - module Converter - def dump_request: (top params) -> [top, ::Hash[Symbol, top]] - end - end - type request_options = { idempotency_key: String?, extra_query: ::Hash[String, (::Array[String] | String)?]?, extra_headers: ::Hash[String, String?]?, - extra_body: ::Hash[Symbol, top]?, + extra_body: top?, max_retries: Integer?, timeout: Float? } @@ -31,7 +21,7 @@ module OpenAI attr_accessor extra_headers: ::Hash[String, String?]? - attr_accessor extra_body: ::Hash[Symbol, top]? + attr_accessor extra_body: top? attr_accessor max_retries: Integer? diff --git a/sig/openai/resources/audio/speech.rbs b/sig/openai/resources/audio/speech.rbs index e537a18a..ad93110a 100644 --- a/sig/openai/resources/audio/speech.rbs +++ b/sig/openai/resources/audio/speech.rbs @@ -2,19 +2,15 @@ module OpenAI module Resources class Audio class Speech - def create: - ( - OpenAI::Models::Audio::SpeechCreateParams - | ::Hash[Symbol, top] params - ) -> top - | ( - input: String, - model: OpenAI::Models::Audio::SpeechCreateParams::model, - voice: OpenAI::Models::Audio::SpeechCreateParams::voice, - response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format, - speed: Float, - request_options: OpenAI::request_opts - ) -> top + def create: ( + input: String, + model: OpenAI::Models::Audio::SpeechCreateParams::model, + voice: OpenAI::Models::Audio::SpeechCreateParams::voice, + ?instructions: String, + ?response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format, + ?speed: Float, + ?request_options: OpenAI::request_opts + ) -> StringIO def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/audio/transcriptions.rbs b/sig/openai/resources/audio/transcriptions.rbs index d16f632f..b52531d0 100644 --- a/sig/openai/resources/audio/transcriptions.rbs +++ b/sig/openai/resources/audio/transcriptions.rbs @@ -2,21 +2,29 @@ module OpenAI module Resources class Audio class Transcriptions - def create: - ( - OpenAI::Models::Audio::TranscriptionCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Audio::transcription_create_response - | ( - file: IO | StringIO, - model: OpenAI::Models::Audio::TranscriptionCreateParams::model, - language: String, - prompt: String, - response_format: OpenAI::Models::audio_response_format, - temperature: Float, - timestamp_granularities: ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity], - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Audio::transcription_create_response + def create: ( + file: IO | StringIO, + model: OpenAI::Models::Audio::TranscriptionCreateParams::model, + ?include: ::Array[OpenAI::Models::Audio::transcription_include], + ?language: String, + ?prompt: String, + ?response_format: OpenAI::Models::audio_response_format, + ?temperature: Float, + ?timestamp_granularities: ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Audio::transcription_create_response + + def create_streaming: ( + file: IO | StringIO, + model: OpenAI::Models::Audio::TranscriptionCreateParams::model, + ?include: ::Array[OpenAI::Models::Audio::transcription_include], + ?language: String, + ?prompt: String, + ?response_format: OpenAI::Models::audio_response_format, + ?temperature: Float, + ?timestamp_granularities: ::Array[OpenAI::Models::Audio::TranscriptionCreateParams::timestamp_granularity], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Audio::transcription_stream_event] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/audio/translations.rbs b/sig/openai/resources/audio/translations.rbs index 540b8eaf..25ea82e3 100644 --- a/sig/openai/resources/audio/translations.rbs +++ b/sig/openai/resources/audio/translations.rbs @@ -2,19 +2,14 @@ module OpenAI module Resources class Audio class Translations - def create: - ( - OpenAI::Models::Audio::TranslationCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Audio::translation_create_response - | ( - file: IO | StringIO, - model: OpenAI::Models::Audio::TranslationCreateParams::model, - prompt: String, - response_format: OpenAI::Models::audio_response_format, - temperature: Float, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Audio::translation_create_response + def create: ( + file: IO | StringIO, + model: OpenAI::Models::Audio::TranslationCreateParams::model, + ?prompt: String, + ?response_format: OpenAI::Models::Audio::TranslationCreateParams::response_format, + ?temperature: Float, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Audio::translation_create_response def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/batches.rbs b/sig/openai/resources/batches.rbs index 8d004f2c..37dbb707 100644 --- a/sig/openai/resources/batches.rbs +++ b/sig/openai/resources/batches.rbs @@ -1,47 +1,29 @@ module OpenAI module Resources class Batches - def create: - ( - OpenAI::Models::BatchCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Batch - | ( - completion_window: OpenAI::Models::BatchCreateParams::completion_window, - endpoint: OpenAI::Models::BatchCreateParams::endpoint, - input_file_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Batch + def create: ( + completion_window: OpenAI::Models::BatchCreateParams::completion_window, + endpoint: OpenAI::Models::BatchCreateParams::endpoint, + input_file_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Batch - def retrieve: - ( - String batch_id, - ?OpenAI::Models::BatchRetrieveParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Batch - | ( - String batch_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Batch + def retrieve: ( + String batch_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Batch - def list: - ( - ?OpenAI::Models::BatchListParams | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Batch] - | ( - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Batch] + def list: ( + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Batch] - def cancel: - ( - String batch_id, - ?OpenAI::Models::BatchCancelParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Batch - | ( - String batch_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Batch + def cancel: ( + String batch_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Batch def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/beta/assistants.rbs b/sig/openai/resources/beta/assistants.rbs index 50acef87..84ea0af9 100644 --- a/sig/openai/resources/beta/assistants.rbs +++ b/sig/openai/resources/beta/assistants.rbs @@ -2,82 +2,54 @@ module OpenAI module Resources class Beta class Assistants - def create: - ( - OpenAI::Models::Beta::AssistantCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Assistant - | ( - model: OpenAI::Models::Beta::AssistantCreateParams::model, - description: String?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - name: String?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_resources: OpenAI::Models::Beta::AssistantCreateParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - top_p: Float?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Assistant + def create: ( + model: OpenAI::Models::Beta::AssistantCreateParams::model, + ?description: String?, + ?instructions: String?, + ?metadata: OpenAI::Models::metadata?, + ?name: String?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_resources: OpenAI::Models::Beta::AssistantCreateParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool], + ?top_p: Float?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Assistant - def retrieve: - ( - String assistant_id, - ?OpenAI::Models::Beta::AssistantRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Assistant - | ( - String assistant_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Assistant + def retrieve: ( + String assistant_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Assistant - def update: - ( - String assistant_id, - ?OpenAI::Models::Beta::AssistantUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Assistant - | ( - String assistant_id, - description: String?, - instructions: String?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::AssistantUpdateParams::model, - name: String?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_resources: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool], - top_p: Float?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Assistant + def update: ( + String assistant_id, + ?description: String?, + ?instructions: String?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::AssistantUpdateParams::model, + ?name: String?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_resources: OpenAI::Models::Beta::AssistantUpdateParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool], + ?top_p: Float?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Assistant - def list: - ( - ?OpenAI::Models::Beta::AssistantListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Assistant] - | ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::AssistantListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Assistant] + def list: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::AssistantListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Assistant] - def delete: - ( - String assistant_id, - ?OpenAI::Models::Beta::AssistantDeleteParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::AssistantDeleted - | ( - String assistant_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::AssistantDeleted + def delete: ( + String assistant_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::AssistantDeleted def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/beta/threads.rbs b/sig/openai/resources/beta/threads.rbs index b825e4a8..10e58839 100644 --- a/sig/openai/resources/beta/threads.rbs +++ b/sig/openai/resources/beta/threads.rbs @@ -6,100 +6,67 @@ module OpenAI attr_reader messages: OpenAI::Resources::Beta::Threads::Messages - def create: - ( - ?OpenAI::Models::Beta::ThreadCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Thread - | ( - messages: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::ThreadCreateParams::ToolResources?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Thread + def create: ( + ?messages: ::Array[OpenAI::Models::Beta::ThreadCreateParams::Message], + ?metadata: OpenAI::Models::metadata?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateParams::ToolResources?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Thread - def retrieve: - ( - String thread_id, - ?OpenAI::Models::Beta::ThreadRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Thread - | ( - String thread_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Thread + def retrieve: ( + String thread_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Thread - def update: - ( - String thread_id, - ?OpenAI::Models::Beta::ThreadUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Thread - | ( - String thread_id, - metadata: OpenAI::Models::metadata?, - tool_resources: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Thread + def update: ( + String thread_id, + ?metadata: OpenAI::Models::metadata?, + ?tool_resources: OpenAI::Models::Beta::ThreadUpdateParams::ToolResources?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Thread - def delete: - ( - String thread_id, - ?OpenAI::Models::Beta::ThreadDeleteParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::ThreadDeleted - | ( - String thread_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::ThreadDeleted + def delete: ( + String thread_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::ThreadDeleted - def create_and_run: - ( - OpenAI::Models::Beta::ThreadCreateAndRunParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - assistant_id: String, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, - parallel_tool_calls: bool, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def create_and_run: ( + assistant_id: String, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, + ?parallel_tool_calls: bool, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def create_and_run_streaming: - ( - OpenAI::Models::Beta::ThreadCreateAndRunParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] - | ( - assistant_id: String, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, - parallel_tool_calls: bool, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, - tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] + def create_and_run_streaming: ( + assistant_id: String, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::ThreadCreateAndRunParams::model?, + ?parallel_tool_calls: bool, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?thread: OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tool_resources: OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources?, + ?tools: ::Array[OpenAI::Models::Beta::ThreadCreateAndRunParams::tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/beta/threads/messages.rbs b/sig/openai/resources/beta/threads/messages.rbs index 3c37a9d8..f5421f58 100644 --- a/sig/openai/resources/beta/threads/messages.rbs +++ b/sig/openai/resources/beta/threads/messages.rbs @@ -3,73 +3,43 @@ module OpenAI class Beta class Threads class Messages - def create: - ( - String thread_id, - OpenAI::Models::Beta::Threads::MessageCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Message - | ( - String thread_id, - content: OpenAI::Models::Beta::Threads::MessageCreateParams::content, - role: OpenAI::Models::Beta::Threads::MessageCreateParams::role, - attachments: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]?, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Message + def create: ( + String thread_id, + content: OpenAI::Models::Beta::Threads::MessageCreateParams::content, + role: OpenAI::Models::Beta::Threads::MessageCreateParams::role, + ?attachments: ::Array[OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment]?, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Message - def retrieve: - ( - String message_id, - OpenAI::Models::Beta::Threads::MessageRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Message - | ( - String message_id, - thread_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Message + def retrieve: ( + String message_id, + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Message - def update: - ( - String message_id, - OpenAI::Models::Beta::Threads::MessageUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Message - | ( - String message_id, - thread_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Message + def update: ( + String message_id, + thread_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Message - def list: - ( - String thread_id, - ?OpenAI::Models::Beta::Threads::MessageListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Message] - | ( - String thread_id, - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::Threads::MessageListParams::order, - run_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Message] + def list: ( + String thread_id, + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::MessageListParams::order, + ?run_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Message] - def delete: - ( - String message_id, - OpenAI::Models::Beta::Threads::MessageDeleteParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::MessageDeleted - | ( - String message_id, - thread_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::MessageDeleted + def delete: ( + String message_id, + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::MessageDeleted def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/beta/threads/runs.rbs b/sig/openai/resources/beta/threads/runs.rbs index a0c45000..24c1f8c5 100644 --- a/sig/openai/resources/beta/threads/runs.rbs +++ b/sig/openai/resources/beta/threads/runs.rbs @@ -5,139 +5,91 @@ module OpenAI class Runs attr_reader steps: OpenAI::Resources::Beta::Threads::Runs::Steps - def create: - ( - String thread_id, - OpenAI::Models::Beta::Threads::RunCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - String thread_id, - assistant_id: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - additional_instructions: String?, - additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, - parallel_tool_calls: bool, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def create: ( + String thread_id, + assistant_id: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?additional_instructions: String?, + ?additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, + ?parallel_tool_calls: bool, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def create_streaming: - ( - String thread_id, - OpenAI::Models::Beta::Threads::RunCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] - | ( - String thread_id, - assistant_id: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - additional_instructions: String?, - additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, - instructions: String?, - max_completion_tokens: Integer?, - max_prompt_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, - parallel_tool_calls: bool, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Beta::assistant_response_format_option?, - temperature: Float?, - tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, - tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, - top_p: Float?, - truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] + def create_streaming: ( + String thread_id, + assistant_id: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?additional_instructions: String?, + ?additional_messages: ::Array[OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage]?, + ?instructions: String?, + ?max_completion_tokens: Integer?, + ?max_prompt_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?model: OpenAI::Models::Beta::Threads::RunCreateParams::model?, + ?parallel_tool_calls: bool, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Beta::assistant_response_format_option?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Beta::assistant_tool_choice_option?, + ?tools: ::Array[OpenAI::Models::Beta::assistant_tool]?, + ?top_p: Float?, + ?truncation_strategy: OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] - def retrieve: - ( - String run_id, - OpenAI::Models::Beta::Threads::RunRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - String run_id, - thread_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def retrieve: ( + String run_id, + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def update: - ( - String run_id, - OpenAI::Models::Beta::Threads::RunUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - String run_id, - thread_id: String, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def update: ( + String run_id, + thread_id: String, + ?metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def list: - ( - String thread_id, - ?OpenAI::Models::Beta::Threads::RunListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Run] - | ( - String thread_id, - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Beta::Threads::RunListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Run] + def list: ( + String thread_id, + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::RunListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Run] - def cancel: - ( - String run_id, - OpenAI::Models::Beta::Threads::RunCancelParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - String run_id, - thread_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def cancel: ( + String run_id, + thread_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def submit_tool_outputs: - ( - String run_id, - OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Run - | ( - String run_id, - thread_id: String, - tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Run + def submit_tool_outputs: ( + String run_id, + thread_id: String, + tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Run - def submit_tool_outputs_streaming: - ( - String run_id, - OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] - | ( - String run_id, - thread_id: String, - tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] + def submit_tool_outputs_streaming: ( + String run_id, + thread_id: String, + tool_outputs: ::Array[OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Beta::assistant_stream_event] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/beta/threads/runs/steps.rbs b/sig/openai/resources/beta/threads/runs/steps.rbs index d9c96cfa..262179eb 100644 --- a/sig/openai/resources/beta/threads/runs/steps.rbs +++ b/sig/openai/resources/beta/threads/runs/steps.rbs @@ -4,36 +4,24 @@ module OpenAI class Threads class Runs class Steps - def retrieve: - ( - String step_id, - OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Beta::Threads::Runs::RunStep - | ( - String step_id, - thread_id: String, - run_id: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Beta::Threads::Runs::RunStep + def retrieve: ( + String step_id, + thread_id: String, + run_id: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Beta::Threads::Runs::RunStep - def list: - ( - String run_id, - OpenAI::Models::Beta::Threads::Runs::StepListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Runs::RunStep] - | ( - String run_id, - thread_id: String, - after: String, - before: String, - include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], - limit: Integer, - order: OpenAI::Models::Beta::Threads::Runs::StepListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Runs::RunStep] + def list: ( + String run_id, + thread_id: String, + ?after: String, + ?before: String, + ?include: ::Array[OpenAI::Models::Beta::Threads::Runs::run_step_include], + ?limit: Integer, + ?order: OpenAI::Models::Beta::Threads::Runs::StepListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Beta::Threads::Runs::RunStep] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/chat/completions.rbs b/sig/openai/resources/chat/completions.rbs index c843c57c..5bd7a8db 100644 --- a/sig/openai/resources/chat/completions.rbs +++ b/sig/openai/resources/chat/completions.rbs @@ -4,131 +4,98 @@ module OpenAI class Completions attr_reader messages: OpenAI::Resources::Chat::Completions::Messages - def create: - ( - OpenAI::Models::Chat::CompletionCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Chat::ChatCompletion - | ( - messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], - model: OpenAI::Models::Chat::CompletionCreateParams::model, - audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, - frequency_penalty: Float?, - function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, - functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: bool?, - max_completion_tokens: Integer?, - max_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, - n: Integer?, - parallel_tool_calls: bool, - prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, - presence_penalty: Float?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, - seed: Integer?, - service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, - stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, - store: bool?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - temperature: Float?, - tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, - tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], - top_logprobs: Integer?, - top_p: Float?, - user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Chat::ChatCompletion + def create: ( + messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], + model: OpenAI::Models::Chat::CompletionCreateParams::model, + ?audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, + ?frequency_penalty: Float?, + ?function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, + ?functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: bool?, + ?max_completion_tokens: Integer?, + ?max_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, + ?n: Integer?, + ?parallel_tool_calls: bool, + ?prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, + ?presence_penalty: Float?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, + ?seed: Integer?, + ?service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, + ?stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, + ?store: bool?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, + ?tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], + ?top_logprobs: Integer?, + ?top_p: Float?, + ?user: String, + ?web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Chat::ChatCompletion - def create_streaming: - ( - OpenAI::Models::Chat::CompletionCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Chat::ChatCompletionChunk] - | ( - messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], - model: OpenAI::Models::Chat::CompletionCreateParams::model, - audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, - frequency_penalty: Float?, - function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, - functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: bool?, - max_completion_tokens: Integer?, - max_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, - n: Integer?, - parallel_tool_calls: bool, - prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, - presence_penalty: Float?, - reasoning_effort: OpenAI::Models::reasoning_effort?, - response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, - seed: Integer?, - service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, - stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, - store: bool?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - temperature: Float?, - tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, - tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], - top_logprobs: Integer?, - top_p: Float?, - user: String, - web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Chat::ChatCompletionChunk] + def create_streaming: ( + messages: ::Array[OpenAI::Models::Chat::chat_completion_message_param], + model: OpenAI::Models::Chat::CompletionCreateParams::model, + ?audio: OpenAI::Models::Chat::ChatCompletionAudioParam?, + ?frequency_penalty: Float?, + ?function_call: OpenAI::Models::Chat::CompletionCreateParams::function_call, + ?functions: ::Array[OpenAI::Models::Chat::CompletionCreateParams::Function], + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: bool?, + ?max_completion_tokens: Integer?, + ?max_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?modalities: ::Array[OpenAI::Models::Chat::CompletionCreateParams::modality]?, + ?n: Integer?, + ?parallel_tool_calls: bool, + ?prediction: OpenAI::Models::Chat::ChatCompletionPredictionContent?, + ?presence_penalty: Float?, + ?reasoning_effort: OpenAI::Models::reasoning_effort?, + ?response_format: OpenAI::Models::Chat::CompletionCreateParams::response_format, + ?seed: Integer?, + ?service_tier: OpenAI::Models::Chat::CompletionCreateParams::service_tier?, + ?stop: OpenAI::Models::Chat::CompletionCreateParams::stop?, + ?store: bool?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?temperature: Float?, + ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, + ?tools: ::Array[OpenAI::Models::Chat::ChatCompletionTool], + ?top_logprobs: Integer?, + ?top_p: Float?, + ?user: String, + ?web_search_options: OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Chat::ChatCompletionChunk] - def retrieve: - ( - String completion_id, - ?OpenAI::Models::Chat::CompletionRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Chat::ChatCompletion - | ( - String completion_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Chat::ChatCompletion + def retrieve: ( + String completion_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Chat::ChatCompletion - def update: - ( - String completion_id, - OpenAI::Models::Chat::CompletionUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Chat::ChatCompletion - | ( - String completion_id, - metadata: OpenAI::Models::metadata?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Chat::ChatCompletion + def update: ( + String completion_id, + metadata: OpenAI::Models::metadata?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Chat::ChatCompletion - def list: - ( - ?OpenAI::Models::Chat::CompletionListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletion] - | ( - after: String, - limit: Integer, - metadata: OpenAI::Models::metadata?, - model: String, - order: OpenAI::Models::Chat::CompletionListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletion] + def list: ( + ?after: String, + ?limit: Integer, + ?metadata: OpenAI::Models::metadata?, + ?model: String, + ?order: OpenAI::Models::Chat::CompletionListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletion] - def delete: - ( - String completion_id, - ?OpenAI::Models::Chat::CompletionDeleteParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Chat::ChatCompletionDeleted - | ( - String completion_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Chat::ChatCompletionDeleted + def delete: ( + String completion_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Chat::ChatCompletionDeleted def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/chat/completions/messages.rbs b/sig/openai/resources/chat/completions/messages.rbs index cd798db3..f2fc47a1 100644 --- a/sig/openai/resources/chat/completions/messages.rbs +++ b/sig/openai/resources/chat/completions/messages.rbs @@ -3,19 +3,13 @@ module OpenAI class Chat class Completions class Messages - def list: - ( - String completion_id, - ?OpenAI::Models::Chat::Completions::MessageListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletionStoreMessage] - | ( - String completion_id, - after: String, - limit: Integer, - order: OpenAI::Models::Chat::Completions::MessageListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletionStoreMessage] + def list: ( + String completion_id, + ?after: String, + ?limit: Integer, + ?order: OpenAI::Models::Chat::Completions::MessageListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Chat::ChatCompletionStoreMessage] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/completions.rbs b/sig/openai/resources/completions.rbs index c04b9ca0..42f91241 100644 --- a/sig/openai/resources/completions.rbs +++ b/sig/openai/resources/completions.rbs @@ -1,55 +1,47 @@ module OpenAI module Resources class Completions - def create: - ( - OpenAI::Models::CompletionCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Completion - | ( - model: OpenAI::Models::CompletionCreateParams::model, - prompt: OpenAI::Models::CompletionCreateParams::prompt?, - best_of: Integer?, - echo: bool?, - frequency_penalty: Float?, - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: Integer?, - max_tokens: Integer?, - n: Integer?, - presence_penalty: Float?, - seed: Integer?, - stop: OpenAI::Models::CompletionCreateParams::stop?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - suffix: String?, - temperature: Float?, - top_p: Float?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Completion + def create: ( + model: OpenAI::Models::CompletionCreateParams::model, + prompt: OpenAI::Models::CompletionCreateParams::prompt?, + ?best_of: Integer?, + ?echo: bool?, + ?frequency_penalty: Float?, + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: Integer?, + ?max_tokens: Integer?, + ?n: Integer?, + ?presence_penalty: Float?, + ?seed: Integer?, + ?stop: OpenAI::Models::CompletionCreateParams::stop?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?suffix: String?, + ?temperature: Float?, + ?top_p: Float?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Completion - def create_streaming: - ( - OpenAI::Models::CompletionCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Completion] - | ( - model: OpenAI::Models::CompletionCreateParams::model, - prompt: OpenAI::Models::CompletionCreateParams::prompt?, - best_of: Integer?, - echo: bool?, - frequency_penalty: Float?, - logit_bias: ::Hash[Symbol, Integer]?, - logprobs: Integer?, - max_tokens: Integer?, - n: Integer?, - presence_penalty: Float?, - seed: Integer?, - stop: OpenAI::Models::CompletionCreateParams::stop?, - stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, - suffix: String?, - temperature: Float?, - top_p: Float?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Completion] + def create_streaming: ( + model: OpenAI::Models::CompletionCreateParams::model, + prompt: OpenAI::Models::CompletionCreateParams::prompt?, + ?best_of: Integer?, + ?echo: bool?, + ?frequency_penalty: Float?, + ?logit_bias: ::Hash[Symbol, Integer]?, + ?logprobs: Integer?, + ?max_tokens: Integer?, + ?n: Integer?, + ?presence_penalty: Float?, + ?seed: Integer?, + ?stop: OpenAI::Models::CompletionCreateParams::stop?, + ?stream_options: OpenAI::Models::Chat::ChatCompletionStreamOptions?, + ?suffix: String?, + ?temperature: Float?, + ?top_p: Float?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Completion] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/embeddings.rbs b/sig/openai/resources/embeddings.rbs index 05dd3a2d..3babf508 100644 --- a/sig/openai/resources/embeddings.rbs +++ b/sig/openai/resources/embeddings.rbs @@ -1,18 +1,14 @@ module OpenAI module Resources class Embeddings - def create: - ( - OpenAI::Models::EmbeddingCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::CreateEmbeddingResponse - | ( - input: OpenAI::Models::EmbeddingCreateParams::input, - model: OpenAI::Models::EmbeddingCreateParams::model, - dimensions: Integer, - encoding_format: OpenAI::Models::EmbeddingCreateParams::encoding_format, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::CreateEmbeddingResponse + def create: ( + input: OpenAI::Models::EmbeddingCreateParams::input, + model: OpenAI::Models::EmbeddingCreateParams::model, + ?dimensions: Integer, + ?encoding_format: OpenAI::Models::EmbeddingCreateParams::encoding_format, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::CreateEmbeddingResponse def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/files.rbs b/sig/openai/resources/files.rbs index f8a6cae0..62988179 100644 --- a/sig/openai/resources/files.rbs +++ b/sig/openai/resources/files.rbs @@ -1,54 +1,34 @@ module OpenAI module Resources class Files - def create: - ( - OpenAI::Models::FileCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FileObject - | ( - file: IO | StringIO, - purpose: OpenAI::Models::file_purpose, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FileObject + def create: ( + file: IO | StringIO, + purpose: OpenAI::Models::file_purpose, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FileObject - def retrieve: - ( - String file_id, - ?OpenAI::Models::FileRetrieveParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FileObject - | ( - String file_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FileObject + def retrieve: ( + String file_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FileObject - def list: - ( - ?OpenAI::Models::FileListParams | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::FileObject] - | ( - after: String, - limit: Integer, - order: OpenAI::Models::FileListParams::order, - purpose: String, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::FileObject] + def list: ( + ?after: String, + ?limit: Integer, + ?order: OpenAI::Models::FileListParams::order, + ?purpose: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::FileObject] - def delete: - ( - String file_id, - ?OpenAI::Models::FileDeleteParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FileDeleted - | ( - String file_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FileDeleted + def delete: ( + String file_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FileDeleted - def content: - ( - String file_id, - ?OpenAI::Models::FileContentParams | ::Hash[Symbol, top] params - ) -> top - | (String file_id, request_options: OpenAI::request_opts) -> top + def content: ( + String file_id, + ?request_options: OpenAI::request_opts + ) -> StringIO def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/fine_tuning/jobs.rbs b/sig/openai/resources/fine_tuning/jobs.rbs index 8bd2b3c9..339d5f85 100644 --- a/sig/openai/resources/fine_tuning/jobs.rbs +++ b/sig/openai/resources/fine_tuning/jobs.rbs @@ -4,70 +4,42 @@ module OpenAI class Jobs attr_reader checkpoints: OpenAI::Resources::FineTuning::Jobs::Checkpoints - def create: - ( - OpenAI::Models::FineTuning::JobCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FineTuning::FineTuningJob - | ( - model: OpenAI::Models::FineTuning::JobCreateParams::model, - training_file: String, - hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, - integrations: ::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]?, - metadata: OpenAI::Models::metadata?, - method_: OpenAI::Models::FineTuning::JobCreateParams::Method, - seed: Integer?, - suffix: String?, - validation_file: String?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FineTuning::FineTuningJob + def create: ( + model: OpenAI::Models::FineTuning::JobCreateParams::model, + training_file: String, + ?hyperparameters: OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, + ?integrations: ::Array[OpenAI::Models::FineTuning::JobCreateParams::Integration]?, + ?metadata: OpenAI::Models::metadata?, + ?method_: OpenAI::Models::FineTuning::JobCreateParams::Method, + ?seed: Integer?, + ?suffix: String?, + ?validation_file: String?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FineTuning::FineTuningJob - def retrieve: - ( - String fine_tuning_job_id, - ?OpenAI::Models::FineTuning::JobRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FineTuning::FineTuningJob - | ( - String fine_tuning_job_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FineTuning::FineTuningJob + def retrieve: ( + String fine_tuning_job_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FineTuning::FineTuningJob - def list: - ( - ?OpenAI::Models::FineTuning::JobListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJob] - | ( - after: String, - limit: Integer, - metadata: ::Hash[Symbol, String]?, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJob] + def list: ( + ?after: String, + ?limit: Integer, + ?metadata: ::Hash[Symbol, String]?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJob] - def cancel: - ( - String fine_tuning_job_id, - ?OpenAI::Models::FineTuning::JobCancelParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::FineTuning::FineTuningJob - | ( - String fine_tuning_job_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::FineTuning::FineTuningJob + def cancel: ( + String fine_tuning_job_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::FineTuning::FineTuningJob - def list_events: - ( - String fine_tuning_job_id, - ?OpenAI::Models::FineTuning::JobListEventsParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJobEvent] - | ( - String fine_tuning_job_id, - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJobEvent] + def list_events: ( + String fine_tuning_job_id, + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::FineTuningJobEvent] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/fine_tuning/jobs/checkpoints.rbs b/sig/openai/resources/fine_tuning/jobs/checkpoints.rbs index 824d9aa0..9912513d 100644 --- a/sig/openai/resources/fine_tuning/jobs/checkpoints.rbs +++ b/sig/openai/resources/fine_tuning/jobs/checkpoints.rbs @@ -3,18 +3,12 @@ module OpenAI class FineTuning class Jobs class Checkpoints - def list: - ( - String fine_tuning_job_id, - ?OpenAI::Models::FineTuning::Jobs::CheckpointListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint] - | ( - String fine_tuning_job_id, - after: String, - limit: Integer, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint] + def list: ( + String fine_tuning_job_id, + ?after: String, + ?limit: Integer, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/images.rbs b/sig/openai/resources/images.rbs index ce35a4e6..b1d09b4d 100644 --- a/sig/openai/resources/images.rbs +++ b/sig/openai/resources/images.rbs @@ -1,52 +1,39 @@ module OpenAI module Resources class Images - def create_variation: - ( - OpenAI::Models::ImageCreateVariationParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::ImagesResponse - | ( - image: IO | StringIO, - model: OpenAI::Models::ImageCreateVariationParams::model?, - n: Integer?, - response_format: OpenAI::Models::ImageCreateVariationParams::response_format?, - size: OpenAI::Models::ImageCreateVariationParams::size?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::ImagesResponse + def create_variation: ( + image: IO | StringIO, + ?model: OpenAI::Models::ImageCreateVariationParams::model?, + ?n: Integer?, + ?response_format: OpenAI::Models::ImageCreateVariationParams::response_format?, + ?size: OpenAI::Models::ImageCreateVariationParams::size?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::ImagesResponse - def edit: - ( - OpenAI::Models::ImageEditParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::ImagesResponse - | ( - image: IO | StringIO, - prompt: String, - mask: IO | StringIO, - model: OpenAI::Models::ImageEditParams::model?, - n: Integer?, - response_format: OpenAI::Models::ImageEditParams::response_format?, - size: OpenAI::Models::ImageEditParams::size?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::ImagesResponse + def edit: ( + image: IO | StringIO, + prompt: String, + ?mask: IO | StringIO, + ?model: OpenAI::Models::ImageEditParams::model?, + ?n: Integer?, + ?response_format: OpenAI::Models::ImageEditParams::response_format?, + ?size: OpenAI::Models::ImageEditParams::size?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::ImagesResponse - def generate: - ( - OpenAI::Models::ImageGenerateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::ImagesResponse - | ( - prompt: String, - model: OpenAI::Models::ImageGenerateParams::model?, - n: Integer?, - quality: OpenAI::Models::ImageGenerateParams::quality, - response_format: OpenAI::Models::ImageGenerateParams::response_format?, - size: OpenAI::Models::ImageGenerateParams::size?, - style: OpenAI::Models::ImageGenerateParams::style?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::ImagesResponse + def generate: ( + prompt: String, + ?model: OpenAI::Models::ImageGenerateParams::model?, + ?n: Integer?, + ?quality: OpenAI::Models::ImageGenerateParams::quality, + ?response_format: OpenAI::Models::ImageGenerateParams::response_format?, + ?size: OpenAI::Models::ImageGenerateParams::size?, + ?style: OpenAI::Models::ImageGenerateParams::style?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::ImagesResponse def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/models.rbs b/sig/openai/resources/models.rbs index c1ed007f..cb91fa06 100644 --- a/sig/openai/resources/models.rbs +++ b/sig/openai/resources/models.rbs @@ -1,33 +1,19 @@ module OpenAI module Resources class Models - def retrieve: - ( - String model, - ?OpenAI::Models::ModelRetrieveParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Model - | ( - String model, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Model + def retrieve: ( + String model, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Model - def list: - ( - ?OpenAI::Models::ModelListParams | ::Hash[Symbol, top] params - ) -> OpenAI::Page[OpenAI::Models::Model] - | ( - request_options: OpenAI::request_opts - ) -> OpenAI::Page[OpenAI::Models::Model] + def list: ( + ?request_options: OpenAI::request_opts + ) -> OpenAI::Page[OpenAI::Models::Model] - def delete: - ( - String model, - ?OpenAI::Models::ModelDeleteParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::ModelDeleted - | ( - String model, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::ModelDeleted + def delete: ( + String model, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::ModelDeleted def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/moderations.rbs b/sig/openai/resources/moderations.rbs index a91a0487..1a10cff6 100644 --- a/sig/openai/resources/moderations.rbs +++ b/sig/openai/resources/moderations.rbs @@ -1,15 +1,11 @@ module OpenAI module Resources class Moderations - def create: - ( - OpenAI::Models::ModerationCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::ModerationCreateResponse - | ( - input: OpenAI::Models::ModerationCreateParams::input, - model: OpenAI::Models::ModerationCreateParams::model, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::ModerationCreateResponse + def create: ( + input: OpenAI::Models::ModerationCreateParams::input, + ?model: OpenAI::Models::ModerationCreateParams::model, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::ModerationCreateResponse def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/responses.rbs b/sig/openai/resources/responses.rbs index bf3ce99c..ba80da78 100644 --- a/sig/openai/resources/responses.rbs +++ b/sig/openai/resources/responses.rbs @@ -3,77 +3,58 @@ module OpenAI class Responses attr_reader input_items: OpenAI::Resources::Responses::InputItems - def create: - ( - OpenAI::Models::Responses::ResponseCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Responses::Response - | ( - input: OpenAI::Models::Responses::ResponseCreateParams::input, - model: OpenAI::Models::Responses::ResponseCreateParams::model, - include: ::Array[OpenAI::Models::Responses::response_includable]?, - instructions: String?, - max_output_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - parallel_tool_calls: bool?, - previous_response_id: String?, - reasoning: OpenAI::Models::Reasoning?, - store: bool?, - temperature: Float?, - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, - tools: ::Array[OpenAI::Models::Responses::tool], - top_p: Float?, - truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Responses::Response + def create: ( + input: OpenAI::Models::Responses::ResponseCreateParams::input, + model: OpenAI::Models::responses_model, + ?include: ::Array[OpenAI::Models::Responses::response_includable]?, + ?instructions: String?, + ?max_output_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?parallel_tool_calls: bool?, + ?previous_response_id: String?, + ?reasoning: OpenAI::Models::Reasoning?, + ?store: bool?, + ?temperature: Float?, + ?text: OpenAI::Models::Responses::ResponseTextConfig, + ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, + ?tools: ::Array[OpenAI::Models::Responses::tool], + ?top_p: Float?, + ?truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Responses::Response - def create_streaming: - ( - OpenAI::Models::Responses::ResponseCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Stream[OpenAI::Models::Responses::response_stream_event] - | ( - input: OpenAI::Models::Responses::ResponseCreateParams::input, - model: OpenAI::Models::Responses::ResponseCreateParams::model, - include: ::Array[OpenAI::Models::Responses::response_includable]?, - instructions: String?, - max_output_tokens: Integer?, - metadata: OpenAI::Models::metadata?, - parallel_tool_calls: bool?, - previous_response_id: String?, - reasoning: OpenAI::Models::Reasoning?, - store: bool?, - temperature: Float?, - text: OpenAI::Models::Responses::ResponseTextConfig, - tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, - tools: ::Array[OpenAI::Models::Responses::tool], - top_p: Float?, - truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, - user: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Stream[OpenAI::Models::Responses::response_stream_event] + def create_streaming: ( + input: OpenAI::Models::Responses::ResponseCreateParams::input, + model: OpenAI::Models::responses_model, + ?include: ::Array[OpenAI::Models::Responses::response_includable]?, + ?instructions: String?, + ?max_output_tokens: Integer?, + ?metadata: OpenAI::Models::metadata?, + ?parallel_tool_calls: bool?, + ?previous_response_id: String?, + ?reasoning: OpenAI::Models::Reasoning?, + ?store: bool?, + ?temperature: Float?, + ?text: OpenAI::Models::Responses::ResponseTextConfig, + ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, + ?tools: ::Array[OpenAI::Models::Responses::tool], + ?top_p: Float?, + ?truncation: OpenAI::Models::Responses::ResponseCreateParams::truncation?, + ?user: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Stream[OpenAI::Models::Responses::response_stream_event] - def retrieve: - ( - String response_id, - ?OpenAI::Models::Responses::ResponseRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Responses::Response - | ( - String response_id, - include: ::Array[OpenAI::Models::Responses::response_includable], - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Responses::Response + def retrieve: ( + String response_id, + ?include: ::Array[OpenAI::Models::Responses::response_includable], + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Responses::Response - def delete: - ( - String response_id, - ?OpenAI::Models::Responses::ResponseDeleteParams - | ::Hash[Symbol, top] params - ) -> nil - | (String response_id, request_options: OpenAI::request_opts) -> nil + def delete: ( + String response_id, + ?request_options: OpenAI::request_opts + ) -> nil def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/responses/input_items.rbs b/sig/openai/resources/responses/input_items.rbs index 34cc6a93..031857d2 100644 --- a/sig/openai/resources/responses/input_items.rbs +++ b/sig/openai/resources/responses/input_items.rbs @@ -2,20 +2,15 @@ module OpenAI module Resources class Responses class InputItems - def list: - ( - String response_id, - ?OpenAI::Models::Responses::InputItemListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::Responses::ResponseItemList::data] - | ( - String response_id, - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::Responses::InputItemListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::Responses::ResponseItemList::data] + def list: ( + String response_id, + ?after: String, + ?before: String, + ?include: ::Array[OpenAI::Models::Responses::response_includable], + ?limit: Integer, + ?order: OpenAI::Models::Responses::InputItemListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::Responses::response_item] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/uploads.rbs b/sig/openai/resources/uploads.rbs index 116d8e02..c60f0054 100644 --- a/sig/openai/resources/uploads.rbs +++ b/sig/openai/resources/uploads.rbs @@ -3,39 +3,25 @@ module OpenAI class Uploads attr_reader parts: OpenAI::Resources::Uploads::Parts - def create: - ( - OpenAI::Models::UploadCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Upload - | ( - bytes: Integer, - filename: String, - mime_type: String, - purpose: OpenAI::Models::file_purpose, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Upload + def create: ( + bytes: Integer, + filename: String, + mime_type: String, + purpose: OpenAI::Models::file_purpose, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Upload - def cancel: - ( - String upload_id, - ?OpenAI::Models::UploadCancelParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Upload - | ( - String upload_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Upload + def cancel: ( + String upload_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Upload - def complete: - ( - String upload_id, - OpenAI::Models::UploadCompleteParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Upload - | ( - String upload_id, - part_ids: ::Array[String], - md5: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Upload + def complete: ( + String upload_id, + part_ids: ::Array[String], + ?md5: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Upload def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/uploads/parts.rbs b/sig/openai/resources/uploads/parts.rbs index 40aa9015..e00684f2 100644 --- a/sig/openai/resources/uploads/parts.rbs +++ b/sig/openai/resources/uploads/parts.rbs @@ -2,17 +2,11 @@ module OpenAI module Resources class Uploads class Parts - def create: - ( - String upload_id, - OpenAI::Models::Uploads::PartCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::Uploads::UploadPart - | ( - String upload_id, - data: IO | StringIO, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::Uploads::UploadPart + def create: ( + String upload_id, + data: IO | StringIO, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::Uploads::UploadPart def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/vector_stores.rbs b/sig/openai/resources/vector_stores.rbs index 34a6d26a..707af947 100644 --- a/sig/openai/resources/vector_stores.rbs +++ b/sig/openai/resources/vector_stores.rbs @@ -5,79 +5,50 @@ module OpenAI attr_reader file_batches: OpenAI::Resources::VectorStores::FileBatches - def create: - ( - ?OpenAI::Models::VectorStoreCreateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStore - | ( - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, - file_ids: ::Array[String], - metadata: OpenAI::Models::metadata?, - name: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStore - - def retrieve: - ( - String vector_store_id, - ?OpenAI::Models::VectorStoreRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStore - | ( - String vector_store_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStore - - def update: - ( - String vector_store_id, - ?OpenAI::Models::VectorStoreUpdateParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStore - | ( - String vector_store_id, - expires_after: OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter?, - metadata: OpenAI::Models::metadata?, - name: String?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStore - - def list: - ( - ?OpenAI::Models::VectorStoreListParams | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStore] - | ( - after: String, - before: String, - limit: Integer, - order: OpenAI::Models::VectorStoreListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStore] - - def delete: - ( - String vector_store_id, - ?OpenAI::Models::VectorStoreDeleteParams | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStoreDeleted - | ( - String vector_store_id, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStoreDeleted - - def search: - ( - String vector_store_id, - OpenAI::Models::VectorStoreSearchParams | ::Hash[Symbol, top] params - ) -> OpenAI::Page[OpenAI::Models::VectorStoreSearchResponse] - | ( - String vector_store_id, - query: OpenAI::Models::VectorStoreSearchParams::query, - filters: OpenAI::Models::VectorStoreSearchParams::filters, - max_num_results: Integer, - ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, - rewrite_query: bool, - request_options: OpenAI::request_opts - ) -> OpenAI::Page[OpenAI::Models::VectorStoreSearchResponse] + def create: ( + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?expires_after: OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, + ?file_ids: ::Array[String], + ?metadata: OpenAI::Models::metadata?, + ?name: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStore + + def retrieve: ( + String vector_store_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStore + + def update: ( + String vector_store_id, + ?expires_after: OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter?, + ?metadata: OpenAI::Models::metadata?, + ?name: String?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStore + + def list: ( + ?after: String, + ?before: String, + ?limit: Integer, + ?order: OpenAI::Models::VectorStoreListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::VectorStore] + + def delete: ( + String vector_store_id, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStoreDeleted + + def search: ( + String vector_store_id, + query: OpenAI::Models::VectorStoreSearchParams::query, + ?filters: OpenAI::Models::VectorStoreSearchParams::filters, + ?max_num_results: Integer, + ?ranking_options: OpenAI::Models::VectorStoreSearchParams::RankingOptions, + ?rewrite_query: bool, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Page[OpenAI::Models::VectorStoreSearchResponse] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/vector_stores/file_batches.rbs b/sig/openai/resources/vector_stores/file_batches.rbs index 39a8abf0..5985e792 100644 --- a/sig/openai/resources/vector_stores/file_batches.rbs +++ b/sig/openai/resources/vector_stores/file_batches.rbs @@ -2,60 +2,36 @@ module OpenAI module Resources class VectorStores class FileBatches - def create: - ( - String vector_store_id, - OpenAI::Models::VectorStores::FileBatchCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - | ( - String vector_store_id, - file_ids: ::Array[String], - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileBatchCreateParams::attribute]?, - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch + def create: ( + String vector_store_id, + file_ids: ::Array[String], + ?attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileBatchCreateParams::attribute]?, + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - def retrieve: - ( - String batch_id, - OpenAI::Models::VectorStores::FileBatchRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - | ( - String batch_id, - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch + def retrieve: ( + String batch_id, + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - def cancel: - ( - String batch_id, - OpenAI::Models::VectorStores::FileBatchCancelParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - | ( - String batch_id, - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch + def cancel: ( + String batch_id, + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFileBatch - def list_files: - ( - String batch_id, - OpenAI::Models::VectorStores::FileBatchListFilesParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] - | ( - String batch_id, - vector_store_id: String, - after: String, - before: String, - filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::filter, - limit: Integer, - order: OpenAI::Models::VectorStores::FileBatchListFilesParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] + def list_files: ( + String batch_id, + vector_store_id: String, + ?after: String, + ?before: String, + ?filter: OpenAI::Models::VectorStores::FileBatchListFilesParams::filter, + ?limit: Integer, + ?order: OpenAI::Models::VectorStores::FileBatchListFilesParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/resources/vector_stores/files.rbs b/sig/openai/resources/vector_stores/files.rbs index 5abfd68c..b0e11ad0 100644 --- a/sig/openai/resources/vector_stores/files.rbs +++ b/sig/openai/resources/vector_stores/files.rbs @@ -2,84 +2,48 @@ module OpenAI module Resources class VectorStores class Files - def create: - ( - String vector_store_id, - OpenAI::Models::VectorStores::FileCreateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFile - | ( - String vector_store_id, - file_id: String, - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileCreateParams::attribute]?, - chunking_strategy: OpenAI::Models::file_chunking_strategy_param, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFile + def create: ( + String vector_store_id, + file_id: String, + ?attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileCreateParams::attribute]?, + ?chunking_strategy: OpenAI::Models::file_chunking_strategy_param, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFile - def retrieve: - ( - String file_id, - OpenAI::Models::VectorStores::FileRetrieveParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFile - | ( - String file_id, - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFile + def retrieve: ( + String file_id, + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFile - def update: - ( - String file_id, - OpenAI::Models::VectorStores::FileUpdateParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFile - | ( - String file_id, - vector_store_id: String, - attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileUpdateParams::attribute]?, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFile + def update: ( + String file_id, + vector_store_id: String, + attributes: ::Hash[Symbol, OpenAI::Models::VectorStores::FileUpdateParams::attribute]?, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFile - def list: - ( - String vector_store_id, - ?OpenAI::Models::VectorStores::FileListParams - | ::Hash[Symbol, top] params - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] - | ( - String vector_store_id, - after: String, - before: String, - filter: OpenAI::Models::VectorStores::FileListParams::filter, - limit: Integer, - order: OpenAI::Models::VectorStores::FileListParams::order, - request_options: OpenAI::request_opts - ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] + def list: ( + String vector_store_id, + ?after: String, + ?before: String, + ?filter: OpenAI::Models::VectorStores::FileListParams::filter, + ?limit: Integer, + ?order: OpenAI::Models::VectorStores::FileListParams::order, + ?request_options: OpenAI::request_opts + ) -> OpenAI::CursorPage[OpenAI::Models::VectorStores::VectorStoreFile] - def delete: - ( - String file_id, - OpenAI::Models::VectorStores::FileDeleteParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Models::VectorStores::VectorStoreFileDeleted - | ( - String file_id, - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Models::VectorStores::VectorStoreFileDeleted + def delete: ( + String file_id, + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Models::VectorStores::VectorStoreFileDeleted - def content: - ( - String file_id, - OpenAI::Models::VectorStores::FileContentParams - | ::Hash[Symbol, top] params - ) -> OpenAI::Page[OpenAI::Models::VectorStores::FileContentResponse] - | ( - String file_id, - vector_store_id: String, - request_options: OpenAI::request_opts - ) -> OpenAI::Page[OpenAI::Models::VectorStores::FileContentResponse] + def content: ( + String file_id, + vector_store_id: String, + ?request_options: OpenAI::request_opts + ) -> OpenAI::Page[OpenAI::Models::VectorStores::FileContentResponse] def initialize: (client: OpenAI::Client) -> void end diff --git a/sig/openai/stream.rbs b/sig/openai/stream.rbs index 7474463b..a566119e 100644 --- a/sig/openai/stream.rbs +++ b/sig/openai/stream.rbs @@ -1,6 +1,6 @@ module OpenAI class Stream[Elem] - include OpenAI::BaseStream[OpenAI::Util::server_sent_event, Elem] + include OpenAI::Type::BaseStream[OpenAI::Util::server_sent_event, Elem] private def iterator: -> Enumerable[Elem] end diff --git a/sig/openai/transport/base_client.rbs b/sig/openai/transport/base_client.rbs new file mode 100644 index 00000000..4ae59a76 --- /dev/null +++ b/sig/openai/transport/base_client.rbs @@ -0,0 +1,110 @@ +module OpenAI + module Transport + class BaseClient + type request_components = + { + method: Symbol, + path: String | ::Array[String], + query: ::Hash[String, (::Array[String] | String)?]?, + headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + body: top?, + unwrap: Symbol?, + page: Class?, + stream: Class?, + model: OpenAI::Type::Converter::input?, + options: OpenAI::request_opts? + } + + type request_input = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + max_retries: Integer, + timeout: Float + } + + MAX_REDIRECTS: 20 + + PLATFORM_HEADERS: ::Hash[String, String] + + def self.validate!: ( + OpenAI::Transport::BaseClient::request_components req + ) -> void + + def self.should_retry?: ( + Integer status, + headers: ::Hash[String, String] + ) -> bool + + def self.follow_redirect: ( + OpenAI::Transport::BaseClient::request_input request, + status: Integer, + response_headers: ::Hash[String, String] + ) -> OpenAI::Transport::BaseClient::request_input + + def self.reap_connection!: ( + Integer | OpenAI::APIConnectionError status, + stream: Enumerable[String]? + ) -> void + + # @api private + attr_accessor requester: OpenAI::Transport::PooledNetRequester + + def initialize: ( + base_url: String, + ?timeout: Float, + ?max_retries: Integer, + ?initial_retry_delay: Float, + ?max_retry_delay: Float, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?], + ?idempotency_header: String? + ) -> void + + private def auth_headers: -> ::Hash[String, String] + + private def generate_idempotency_key: -> String + + private def build_request: ( + OpenAI::Transport::BaseClient::request_components req, + OpenAI::request_options opts + ) -> OpenAI::Transport::BaseClient::request_input + + private def retry_delay: ( + ::Hash[String, String] headers, + retry_count: Integer + ) -> Float + + private def send_request: ( + OpenAI::Transport::BaseClient::request_input request, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: bool + ) -> [Integer, top, Enumerable[String]] + + def request: + ( + Symbol method, + String | ::Array[String] path, + ?query: ::Hash[String, (::Array[String] | String)?]?, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + ?body: top?, + ?unwrap: Symbol?, + ?page: Class?, + ?stream: Class?, + ?model: OpenAI::Type::Converter::input?, + ?options: OpenAI::request_opts? + ) -> top + | (OpenAI::Transport::BaseClient::request_components req) -> top + + def inspect: -> String + end + end +end diff --git a/sig/openai/transport/pooled_net_requester.rbs b/sig/openai/transport/pooled_net_requester.rbs new file mode 100644 index 00000000..d29e1f7e --- /dev/null +++ b/sig/openai/transport/pooled_net_requester.rbs @@ -0,0 +1,39 @@ +module OpenAI + module Transport + class PooledNetRequester + type request = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + deadline: Float + } + + KEEP_ALIVE_TIMEOUT: 30 + + def self.connect: (URI::Generic url) -> top + + def self.calibrate_socket_timeout: (top conn, Float deadline) -> void + + def self.build_request: ( + OpenAI::Transport::PooledNetRequester::request request + ) { + (String arg0) -> void + } -> top + + private def with_pool: ( + URI::Generic url, + deadline: Float + ) { + (top arg0) -> void + } -> void + + def execute: ( + OpenAI::Transport::PooledNetRequester::request request + ) -> [Integer, top, Enumerable[String]] + + def initialize: (?size: Integer) -> void + end + end +end diff --git a/sig/openai/type.rbs b/sig/openai/type.rbs new file mode 100644 index 00000000..61ed895e --- /dev/null +++ b/sig/openai/type.rbs @@ -0,0 +1,22 @@ +module OpenAI + class Unknown = OpenAI::Type::Unknown + + class BooleanModel = OpenAI::Type::BooleanModel + + module Enum = OpenAI::Type::Enum + + module Union = OpenAI::Type::Union + + class ArrayOf = OpenAI::Type::ArrayOf + + class HashOf = OpenAI::Type::HashOf + + class BaseModel = OpenAI::Type::BaseModel + + type request_parameters = OpenAI::Type::request_parameters + + module RequestParameters = OpenAI::Type::RequestParameters + + module Type + end +end diff --git a/sig/openai/type/array_of.rbs b/sig/openai/type/array_of.rbs new file mode 100644 index 00000000..7e8cb67c --- /dev/null +++ b/sig/openai/type/array_of.rbs @@ -0,0 +1,36 @@ +module OpenAI + module Type + class ArrayOf[Elem] + include OpenAI::Type::Converter + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def coerce: ( + Enumerable[Elem] | top value, + state: OpenAI::Type::Converter::state + ) -> (::Array[top] | top) + + def dump: (Enumerable[Elem] | top value) -> (::Array[top] | top) + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + end + end +end diff --git a/sig/openai/type/base_model.rbs b/sig/openai/type/base_model.rbs new file mode 100644 index 00000000..a929a421 --- /dev/null +++ b/sig/openai/type/base_model.rbs @@ -0,0 +1,73 @@ +module OpenAI + module Type + class BaseModel + extend OpenAI::Type::Converter + + type known_field = + { mode: (:coerce | :dump)?, required: bool, nilable: bool } + + def self.known_fields: -> ::Hash[Symbol, (OpenAI::BaseModel::known_field + & { type_fn: (^-> OpenAI::Type::Converter::input) })] + + def self.fields: -> ::Hash[Symbol, (OpenAI::BaseModel::known_field + & { type: OpenAI::Type::Converter::input })] + + private def self.add_field: ( + Symbol name_sym, + required: bool, + type_info: { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> OpenAI::Type::Converter::input?, + union: ^-> OpenAI::Type::Converter::input?, + api_name: Symbol + } + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input, + spec: ::Hash[Symbol, top] + ) -> void + + def self.required: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def self.optional: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + private def self.request_only: { -> void } -> void + + private def self.response_only: { -> void } -> void + + def self.==: (top other) -> bool + + def ==: (top other) -> bool + + def self.coerce: ( + OpenAI::BaseModel | ::Hash[top, top] | top value, + state: OpenAI::Type::Converter::state + ) -> (instance | top) + + def self.dump: (instance | top value) -> (::Hash[top, top] | top) + + def []: (Symbol key) -> top? + + def to_h: -> ::Hash[Symbol, top] + + alias to_hash to_h + + def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top] + + def initialize: (?::Hash[Symbol, top] | self data) -> void + + def inspect: -> String + end + end +end diff --git a/sig/openai/type/base_page.rbs b/sig/openai/type/base_page.rbs new file mode 100644 index 00000000..db9e8a49 --- /dev/null +++ b/sig/openai/type/base_page.rbs @@ -0,0 +1,22 @@ +module OpenAI + module Type + module BasePage[Elem] + def next_page?: -> bool + + def next_page: -> self + + def auto_paging_each: { (Elem arg0) -> void } -> void + + def to_enum: -> Enumerable[Elem] + + alias enum_for to_enum + + def initialize: ( + client: OpenAI::Transport::BaseClient, + req: OpenAI::Transport::BaseClient::request_components, + headers: ::Hash[String, String], + page_data: top + ) -> void + end + end +end diff --git a/sig/openai/type/base_stream.rbs b/sig/openai/type/base_stream.rbs new file mode 100644 index 00000000..de541575 --- /dev/null +++ b/sig/openai/type/base_stream.rbs @@ -0,0 +1,25 @@ +module OpenAI + module Type + module BaseStream[Message, Elem] + include Enumerable[Elem] + + def close: -> void + + private def iterator: -> Enumerable[Elem] + + def each: { (Elem arg0) -> void } -> void + + def to_enum: -> Enumerator[Elem] + + alias enum_for to_enum + + def initialize: ( + model: Class | OpenAI::Type::Converter, + url: URI::Generic, + status: Integer, + response: top, + stream: Enumerable[Message] + ) -> void + end + end +end diff --git a/sig/openai/type/boolean_model.rbs b/sig/openai/type/boolean_model.rbs new file mode 100644 index 00000000..00ed0300 --- /dev/null +++ b/sig/openai/type/boolean_model.rbs @@ -0,0 +1,18 @@ +module OpenAI + module Type + class BooleanModel + extend OpenAI::Type::Converter + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + bool | top value, + state: OpenAI::Type::Converter::state + ) -> (bool | top) + + def self.dump: (bool | top value) -> (bool | top) + end + end +end diff --git a/sig/openai/type/converter.rbs b/sig/openai/type/converter.rbs new file mode 100644 index 00000000..3785d489 --- /dev/null +++ b/sig/openai/type/converter.rbs @@ -0,0 +1,36 @@ +module OpenAI + module Type + module Converter + type input = OpenAI::Type::Converter | Class + + type state = + { + strictness: bool | :strong, + exactness: { yes: Integer, no: Integer, maybe: Integer }, + branched: Integer + } + + def coerce: (top value, state: OpenAI::Type::Converter::state) -> top + + def dump: (top value) -> top + + def self.type_info: ( + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> OpenAI::Type::Converter::input?, + union: ^-> OpenAI::Type::Converter::input? + } + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input spec + ) -> (^-> top) + + def self.coerce: ( + OpenAI::Type::Converter::input target, + top value, + ?state: OpenAI::Type::Converter::state + ) -> top + + def self.dump: (OpenAI::Type::Converter::input target, top value) -> top + end + end +end diff --git a/sig/openai/type/enum.rbs b/sig/openai/type/enum.rbs new file mode 100644 index 00000000..fb65841f --- /dev/null +++ b/sig/openai/type/enum.rbs @@ -0,0 +1,22 @@ +module OpenAI + module Type + module Enum + include OpenAI::Type::Converter + + def self.values: -> ::Array[(nil | bool | Integer | Float | Symbol)] + + private def self.finalize!: -> void + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def coerce: ( + String | Symbol | top value, + state: OpenAI::Type::Converter::state + ) -> (Symbol | top) + + def dump: (Symbol | top value) -> (Symbol | top) + end + end +end diff --git a/sig/openai/type/hash_of.rbs b/sig/openai/type/hash_of.rbs new file mode 100644 index 00000000..dea00a66 --- /dev/null +++ b/sig/openai/type/hash_of.rbs @@ -0,0 +1,36 @@ +module OpenAI + module Type + class HashOf[Elem] + include OpenAI::Type::Converter + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def coerce: ( + ::Hash[top, top] | top value, + state: OpenAI::Type::Converter::state + ) -> (::Hash[Symbol, top] | top) + + def dump: (::Hash[top, top] | top value) -> (::Hash[Symbol, top] | top) + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + end + end +end diff --git a/sig/openai/type/request_parameters.rbs b/sig/openai/type/request_parameters.rbs new file mode 100644 index 00000000..b92ee909 --- /dev/null +++ b/sig/openai/type/request_parameters.rbs @@ -0,0 +1,13 @@ +module OpenAI + module Type + type request_parameters = { request_options: OpenAI::request_opts } + + module RequestParameters + attr_accessor request_options: OpenAI::request_opts + + module Converter + def dump_request: (top params) -> [top, ::Hash[Symbol, top]] + end + end + end +end diff --git a/sig/openai/type/union.rbs b/sig/openai/type/union.rbs new file mode 100644 index 00000000..372932ce --- /dev/null +++ b/sig/openai/type/union.rbs @@ -0,0 +1,37 @@ +module OpenAI + module Type + module Union + include OpenAI::Type::Converter + + private def self.known_variants: -> ::Array[[Symbol?, (^-> OpenAI::Type::Converter::input)]] + + def self.derefed_variants: -> ::Array[[Symbol?, top]] + + def self.variants: -> ::Array[top] + + private def self.discriminator: (Symbol property) -> void + + private def self.variant: ( + Symbol + | ::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input key, + ?::Hash[Symbol, top] + | ^-> OpenAI::Type::Converter::input + | OpenAI::Type::Converter::input spec + ) -> void + + private def self.resolve_variant: ( + top value + ) -> OpenAI::Type::Converter::input? + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def coerce: (top value, state: OpenAI::Type::Converter::state) -> top + + def dump: (top value) -> top + end + end +end diff --git a/sig/openai/type/unknown.rbs b/sig/openai/type/unknown.rbs new file mode 100644 index 00000000..b3139352 --- /dev/null +++ b/sig/openai/type/unknown.rbs @@ -0,0 +1,15 @@ +module OpenAI + module Type + class Unknown + extend OpenAI::Type::Converter + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: (top value, state: OpenAI::Type::Converter::state) -> top + + def self.dump: (top value) -> top + end + end +end diff --git a/sig/openai/util.rbs b/sig/openai/util.rbs index 375f8324..97336cd4 100644 --- a/sig/openai/util.rbs +++ b/sig/openai/util.rbs @@ -20,12 +20,12 @@ module OpenAI OMIT: top - def self?.deep_merge_lr: (top lhs, top rhs, concat: bool) -> top + def self?.deep_merge_lr: (top lhs, top rhs, ?concat: bool) -> top def self?.deep_merge: ( *::Array[top] values, - sentinel: top?, - concat: bool + ?sentinel: top?, + ?concat: bool ) -> top def self?.dig: ( @@ -102,12 +102,12 @@ module OpenAI def self?.decode_content: ( ::Hash[String, String] headers, stream: Enumerable[String], - suppress_error: bool + ?suppress_error: bool ) -> top def self?.fused_enum: ( Enumerable[top] enum, - external: bool + ?external: bool ) { -> void } -> Enumerable[top] diff --git a/sig/openai/version.rbs b/sig/openai/version.rbs index e4f5239e..b4a8f46d 100644 --- a/sig/openai/version.rbs +++ b/sig/openai/version.rbs @@ -1,3 +1,3 @@ module OpenAI - VERSION: "0.1.0-alpha.1" + VERSION: "0.1.0-alpha.2" end diff --git a/sorbet/config b/sorbet/config new file mode 100644 index 00000000..538c1528 --- /dev/null +++ b/sorbet/config @@ -0,0 +1,2 @@ +--dir=rbi +--ignore=test/ diff --git a/test/openai/base_model_test.rb b/test/openai/base_model_test.rb index f6e598d0..7238cd06 100644 --- a/test/openai/base_model_test.rb +++ b/test/openai/base_model_test.rb @@ -2,354 +2,578 @@ require_relative "test_helper" -class OpenAI::Test::BaseModelTest < Minitest::Test - class E1 < OpenAI::Enum - A = :a - B = :b +class OpenAI::Test::PrimitiveModelTest < Minitest::Test + A = OpenAI::ArrayOf[-> { Integer }] + H = OpenAI::HashOf[-> { Integer }, nil?: true] + + module E + extend OpenAI::Enum end - A1 = OpenAI::ArrayOf[-> { Integer }] - A2 = OpenAI::ArrayOf[enum: -> { E1 }] + module U + extend OpenAI::Union + end - def test_basic - assert(E1.is_a?(OpenAI::Converter)) - assert(A1.is_a?(OpenAI::Converter)) + class B < OpenAI::BaseModel + optional :a, Integer + optional :b, B end - def test_basic_coerce - assert_pattern do - OpenAI::Converter.coerce(A1, [1.0, 2.0, 3.0]) => [1, 2, 3] - end + def test_typing + converters = [ + OpenAI::Unknown, + OpenAI::BooleanModel, + A, + H, + E, + U, + B + ] - assert_pattern do - OpenAI::Converter.coerce(A2, %w[a b c]) => [:a, :b, "c"] + converters.each do |conv| + assert_pattern do + conv => OpenAI::Type::Converter + end end end - def test_basic_dump - assert_pattern do - OpenAI::Converter.dump(A1, [1.0, 2.0, 3.0]) => [1, 2, 3] - end + def test_coerce + cases = { + [OpenAI::Unknown, :a] => [{yes: 1}, :a], + [NilClass, :a] => [{maybe: 1}, nil], + [NilClass, nil] => [{yes: 1}, nil], + [OpenAI::BooleanModel, true] => [{yes: 1}, true], + [OpenAI::BooleanModel, "true"] => [{no: 1}, "true"], + [Integer, 1] => [{yes: 1}, 1], + [Integer, 1.0] => [{maybe: 1}, 1], + [Integer, "1"] => [{maybe: 1}, 1], + [Integer, "one"] => [{no: 1}, "one"], + [Float, 1] => [{yes: 1}, 1.0], + [Float, "1"] => [{maybe: 1}, 1.0], + [Float, :one] => [{no: 1}, :one], + [String, :str] => [{yes: 1}, "str"], + [String, "str"] => [{yes: 1}, "str"], + [String, 1] => [{maybe: 1}, "1"], + [:a, "a"] => [{yes: 1}, :a], + [Date, "1990-09-19"] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, Date.new(1990, 9, 19)] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, "one"] => [{no: 1}, "one"], + [Time, "1990-09-19"] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, Time.new(1990, 9, 19)] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, "one"] => [{no: 1}, "one"] + } - assert_pattern do - OpenAI::Converter.dump(A2, %w[a b c]) => %w[a b c] + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + assert_pattern do + OpenAI::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end end end - def test_primitive_try_strict_coerce - d_now = Date.today - t_now = Time.now - + def test_dump cases = { - [NilClass, :a] => [true, nil, 0], - [NilClass, nil] => [true, nil, 1], - [Integer, 1.0] => [true, 1, 1], - [Float, 1] => [true, 1.0, 1], - [Date, d_now] => [true, d_now, 1], - [Time, t_now] => [true, t_now, 1] + [OpenAI::Unknown, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [A, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [H, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [E, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [U, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [B, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [String, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [:b, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [nil, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [OpenAI::BooleanModel, true] => true, + [OpenAI::BooleanModel, "true"] => "true", + [Integer, "1"] => "1", + [Float, 1] => 1, + [String, "one"] => "one", + [String, :one] => :one, + [:a, :b] => :b, + [:a, "a"] => "a" } - cases.each do |test, expect| - type, input = test + cases.each do + target, input = _1 + expect = _2 assert_pattern do - OpenAI::Converter.try_strict_coerce(type, input) => ^expect + OpenAI::Type::Converter.dump(target, input) => ^expect end end end - def test_basic_enum_try_strict_coerce + def test_coerce_errors cases = { - :a => [true, :a, 1], - "a" => [true, :a, 1], - :c => [false, true, 0], - 1 => [false, false, 0] + [Integer, "one"] => TypeError, + [Float, "one"] => TypeError, + [String, Time] => TypeError, + [:a, "one"] => ArgumentError, + [Date, "one"] => ArgumentError, + [Time, "one"] => ArgumentError } - cases.each do |input, expect| - assert_pattern do - OpenAI::Converter.try_strict_coerce(E1, input) => ^expect + cases.each do + target, input = _1 + state = {strictness: :strong, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + assert_raises(_2) do + OpenAI::Type::Converter.coerce(target, input, state: state) end end end +end + +class OpenAI::Test::EnumModelTest < Minitest::Test + module E1 + extend OpenAI::Enum + + TRUE = true + end + + module E2 + extend OpenAI::Enum + + ONE = 1 + TWO = 2 + end + + module E3 + extend OpenAI::Enum + + ONE = 1.0 + TWO = 2.0 + end + + module E4 + extend OpenAI::Enum + + ONE = :one + TWO = :two + end - def test_basic_array_try_strict_coerce + def test_coerce cases = { - [] => [true, [], 0], - nil => [false, false, 0], - [1, 2, 3] => [true, [1, 2, 3], 3], - [1.0, 2.0, 3.0] => [true, [1, 2, 3], 3], - [1, nil, 3] => [true, [1, nil, 3], 2], - [1, nil, nil] => [true, [1, nil, nil], 1], - [1, "two", 3] => [false, true, 2] + # rubocop:disable Style/BooleanSymbol + [E1, true] => [{yes: 1}, true], + [E1, false] => [{no: 1}, false], + [E1, :true] => [{no: 1}, :true], + # rubocop:enable Style/BooleanSymbol + + [E2, 1] => [{yes: 1}, 1], + [E2, 1.0] => [{yes: 1}, 1], + [E2, 1.2] => [{no: 1}, 1.2], + [E2, "1"] => [{no: 1}, "1"], + + [E3, 1.0] => [{yes: 1}, 1.0], + [E3, 1] => [{yes: 1}, 1.0], + [E3, "one"] => [{no: 1}, "one"], + + [E4, :one] => [{yes: 1}, :one], + [E4, "one"] => [{yes: 1}, :one], + [E4, "1"] => [{maybe: 1}, "1"], + [E4, :"1"] => [{maybe: 1}, :"1"], + [E4, 1] => [{no: 1}, 1] } - cases.each do |input, expect| + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} assert_pattern do - OpenAI::Converter.try_strict_coerce(A1, input) => ^expect + OpenAI::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness end end end - def test_nested_array_try_strict_coerce + def test_dump cases = { - %w[a b] => [true, [:a, :b], 2], - %w[a b c] => [false, true, 2] + [E1, true] => true, + [E1, "true"] => "true", + + [E2, 1.0] => 1.0, + [E2, 3] => 3, + [E2, "1.0"] => "1.0", + + [E3, 1.0] => 1.0, + [E3, 3] => 3, + [E3, "1.0"] => "1.0", + + [E4, :one] => :one, + [E4, "one"] => "one", + [E4, "1.0"] => "1.0" } - cases.each do |input, expect| + cases.each do + target, input = _1 + expect = _2 assert_pattern do - OpenAI::Converter.try_strict_coerce(A2, input) => ^expect + OpenAI::Type::Converter.dump(target, input) => ^expect end end end +end - class M1 < OpenAI::BaseModel - required :a, Time - optional :b, E1, api_name: :renamed - required :c, A1 +class OpenAI::Test::CollectionModelTest < Minitest::Test + A1 = OpenAI::ArrayOf[-> { Integer }] + H1 = OpenAI::HashOf[Integer] - request_only do - required :w, Integer - optional :x, String - end + A2 = OpenAI::ArrayOf[H1] + H2 = OpenAI::HashOf[-> { A1 }] - response_only do - required :y, Integer - optional :z, String + A3 = OpenAI::ArrayOf[Integer, nil?: true] + H3 = OpenAI::HashOf[Integer, nil?: true] + + def test_coerce + cases = { + [A1, []] => [{yes: 1}, []], + [A1, {}] => [{no: 1}, {}], + [A1, [1, 2.0]] => [{yes: 2, maybe: 1}, [1, 2]], + [A1, ["1", 2.0]] => [{yes: 1, maybe: 2}, [1, 2]], + [H1, {}] => [{yes: 1}, {}], + [H1, []] => [{no: 1}, []], + [H1, {a: 1, b: 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {"a" => 1, "b" => 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {[] => 1}] => [{yes: 2, no: 1}, {[] => 1}], + [H1, {a: 1.5}] => [{yes: 1, maybe: 1}, {a: 1}], + + [A2, [{}, {"a" => 1}]] => [{yes: 4}, [{}, {a: 1}]], + [A2, [{"a" => "1"}]] => [{yes: 2, maybe: 1}, [{a: 1}]], + [H2, {a: [1, 2]}] => [{yes: 4}, {a: [1, 2]}], + [H2, {"a" => ["1", 2]}] => [{yes: 3, maybe: 1}, {a: [1, 2]}], + [H2, {"a" => ["one", 2]}] => [{yes: 3, no: 1}, {a: ["one", 2]}], + + [A3, [nil, 1]] => [{yes: 3}, [nil, 1]], + [A3, [nil, "1"]] => [{yes: 2, maybe: 1}, [nil, 1]], + [H3, {a: nil, b: "1"}] => [{yes: 2, maybe: 1}, {a: nil, b: 1}], + [H3, {a: nil}] => [{yes: 2}, {a: nil}] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} + assert_pattern do + OpenAI::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end end end +end - class M2 < M1 - required :c, M1 +class OpenAI::Test::BaseModelTest < Minitest::Test + class M1 < OpenAI::BaseModel + required :a, Integer end - def test_model_accessors - now = Time.now.round(0) - model = M2.new(a: now.to_s, b: "b", renamed: "a", c: [1.0, 2.0, 3.0], w: 1, y: 1) + class M2 < M1 + required :a, Time + required :b, Integer, nil?: true + optional :c, String + end - cases = [ - [model.a, now], - [model.b, :a], - [model.c, [1, 2, 3]], - [model.w, 1], - [model.y, 1] - ] + class M3 < OpenAI::BaseModel + optional :c, const: :c + required :d, const: :d + end - cases.each do |input, expect| - assert_pattern do - input => ^expect - end + class M4 < M1 + request_only do + required :a, Integer + optional :b, String end - end - def test_model_conversion_accessor - model = M2.new(c: {}) - assert_pattern do - model.c => M1 + response_only do + required :c, Integer + optional :d, String end end - def test_model_equality - now = Time.now - model1 = M2.new(a: now, b: "b", renamed: "a", c: M1.new, w: 1, y: 1) - model2 = M2.new(a: now, b: "b", renamed: "a", c: M1.new, w: 1, y: 1) + class M5 < OpenAI::BaseModel + request_only do + required :c, const: :c + end - assert_pattern do - model2 => ^model1 + response_only do + required :d, const: :d end end - def test_basic_model_coerce + class M6 < M1 + required :a, OpenAI::ArrayOf[M6] + end + + def test_coerce cases = { - {} => M2.new, - {a: nil, b: :a, c: [1.0, 2.0, 3.0], w: 1} => M2.new(a: nil, b: :a, c: [1.0, 2.0, 3.0], w: 1) + [M1, {}] => [{yes: 1, no: 1}, {}], + [M1, :m1] => [{no: 1}, :m1], + + [M2, {}] => [{yes: 2, no: 1, maybe: 1}, {}], + [M2, {a: "1990-09-19", b: nil}] => [{yes: 4}, {a: "1990-09-19", b: nil}], + [M2, {a: "1990-09-19", b: "1"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19", b: "1"}], + [M2, {a: "1990-09-19"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19"}], + [M2, {a: "1990-09-19", c: nil}] => [{yes: 2, maybe: 2}, {a: "1990-09-19", c: nil}], + + [M3, {c: "c", d: "d"}] => [{yes: 3}, {c: :c, d: :d}], + [M3, {c: "d", d: "c"}] => [{yes: 1, no: 2}, {c: "d", d: "c"}], + + [M4, {c: 2}] => [{yes: 5}, {c: 2}], + [M4, {a: "1", c: 2}] => [{yes: 4, maybe: 1}, {a: "1", c: 2}], + [M4, {b: nil, c: 2}] => [{yes: 4, maybe: 1}, {b: nil, c: 2}], + + [M5, {}] => [{yes: 3}, {}], + [M5, {c: "c"}] => [{yes: 3}, {c: :c}], + [M5, {d: "d"}] => [{yes: 3}, {d: :d}], + [M5, {d: nil}] => [{yes: 2, no: 1}, {d: nil}], + + [M6, {a: [{a: []}]}] => [{yes: 4}, -> { _1 in {a: [M6]} }] } - cases.each do |input, expect| + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} assert_pattern do - OpenAI::Converter.coerce(M2, input) => ^expect + coerced = OpenAI::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(OpenAI::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness end end end - def test_basic_model_dump + def test_dump cases = { - nil => nil, - {} => {}, - {w: 1, x: "x", y: 1, z: "z"} => {w: 1, x: "x"}, - [1, 2, 3] => [1, 2, 3] + [M3, M3.new] => {d: :d}, + [M3, {}] => {d: :d}, + [M3, {d: 1}] => {d: 1}, + + [M4, M4.new(a: 1, b: "b", c: 2, d: "d")] => {a: 1, b: "b"}, + [M4, {a: 1, b: "b", c: 2, d: "d"}] => {a: 1, b: "b"}, + + [M5, M5.new] => {c: :c}, + [M5, {}] => {c: :c}, + [M5, {c: 1}] => {c: 1} } - cases.each do |input, expect| + cases.each do + target, input = _1 + expect = _2 assert_pattern do - OpenAI::Converter.dump(M2, input) => ^expect + OpenAI::Type::Converter.dump(target, input) => ^expect end end end - def test_basic_model_try_strict_coerce - raw = {a: Time.now, c: [2], y: 1} - addn = {x: "x", n: "n"} - expect_exact = M1.new(raw) - expect_addn = M1.new(**raw, **addn) - + def test_accessors cases = { - {} => [false, true, 0], - raw => [true, expect_exact, 3], - {**raw, **addn} => [true, expect_addn, 4] + M2.new({a: "1990-09-19", b: "1"}) => {a: Time.new(1990, 9, 19), b: TypeError}, + M2.new(a: "one", b: "one") => {a: ArgumentError, b: TypeError}, + M2.new(a: nil, b: 2.0) => {a: TypeError, b: TypeError}, + + M3.new => {d: :d}, + M3.new(d: 1) => {d: ArgumentError}, + + M5.new => {c: :c, d: :d} } - cases.each do |input, expect| - assert_pattern do - OpenAI::Converter.try_strict_coerce(M1, input) => ^expect + cases.each do + target = _1 + _2.each do |accessor, expect| + case expect + in Class if expect <= StandardError + tap do + target.public_send(accessor) + flunk + rescue OpenAI::ConversionError => e + assert_kind_of(expect, e.cause) + end + else + assert_pattern { target.public_send(accessor) => ^expect } + end end end end +end - def test_nested_model_dump - now = Time.now - models = [M1, M2] - inputs = [ - M1.new(a: now, b: "a", c: [1.0, 2.0, 3.0], y: 1), - {a: now, b: "a", c: [1.0, 2.0, 3.0], y: 1}, - {"a" => now, b: "", "b" => "a", "c" => [], :c => [1.0, 2.0, 3.0], "y" => 1} - ] +class OpenAI::Test::UnionTest < Minitest::Test + module U0 + extend OpenAI::Union + end - models.product(inputs).each do |model, input| - assert_pattern do - OpenAI::Converter.dump(model, input) => {a: now, renamed: "a", c: [1, 2, 3]} - end - end + module U1 + extend OpenAI::Union + variant const: :a + variant const: 2 end - A3 = OpenAI::ArrayOf[A1] + class M1 < OpenAI::BaseModel + required :t, const: :a, api_name: :type + optional :c, String + end - class M3 < M1 - optional :b, E1, api_name: :renamed_again + class M2 < OpenAI::BaseModel + required :type, const: :b + optional :c, String end - class U1 < OpenAI::Union + module U2 + extend OpenAI::Union discriminator :type + variant :a, M1 - variant :b, M3 + variant :b, M2 end - class U2 < OpenAI::Union - variant A1 - variant A3 + module U3 + extend OpenAI::Union + discriminator :type + + variant :a, M1 + variant String end - def test_basic_union - assert(U1.is_a?(OpenAI::Converter)) + module U4 + extend OpenAI::Union + discriminator :type - assert_pattern do - M1.new => U1 - M3.new => U1 - end + variant String + variant :a, M1 end - def test_basic_discriminated_union_coerce - common = {a: Time.now, c: [], w: 1} - cases = { - nil => nil, - {type: "a", **common} => M1.new(type: "a", **common), - {type: :b, **common} => M3.new(type: :b, **common), - {type: :c, xyz: 1} => {type: :c, xyz: 1} - } + class M3 < OpenAI::BaseModel + optional :recur, -> { U5 } + required :a, Integer + end - cases.each do |input, expect| - assert_pattern do - OpenAI::Converter.coerce(U1, input) => ^expect - end - end + class M4 < OpenAI::BaseModel + optional :recur, -> { U5 } + required :a, OpenAI::ArrayOf[-> { U5 }] end - def test_basic_discriminated_union_dump - now = Time.now - cases = { - nil => nil, - M1.new(a: now, b: :a, c: [1.0, 2.0, 3.0], y: 1) => {a: now, renamed: :a, c: [1, 2, 3]}, - M3.new(b: "a", y: 1) => {renamed_again: "a"}, - {type: :a, b: "a", y: 1} => {type: :a, renamed: "a"}, - {type: "b", b: "a", y: 1} => {type: "b", renamed_again: "a"}, - {type: :c, xyz: 1} => {type: :c, xyz: 1} - } + class M5 < OpenAI::BaseModel + optional :recur, -> { U5 } + required :b, OpenAI::ArrayOf[-> { U5 }] + end - cases.each do |input, expect| - assert_pattern do - OpenAI::Converter.dump(U1, input) => ^expect - end + module U5 + extend OpenAI::Union + + variant -> { M3 } + variant -> { M4 } + end + + module U6 + extend OpenAI::Union + + variant -> { M3 } + variant -> { M5 } + end + + def test_accessors + model = M3.new(recur: []) + tap do + model.recur + flunk + rescue OpenAI::ConversionError => e + assert_kind_of(ArgumentError, e.cause) end end - def test_basic_undifferentiated_union_try_strict_coerce + def test_coerce cases = { - [] => [true, [], 0], - [[]] => [true, [[]], 0], - # [nil] => [false, true, 0], - [1, 2, 3] => [true, [1, 2, 3], 3], - [[1, 2, 3], [4, 5, 6]] => [true, [[1, 2, 3], [4, 5, 6]], 6] + [U0, :""] => [{no: 1}, 0, :""], + + [U1, "a"] => [{yes: 1}, 1, :a], + [U1, "2"] => [{maybe: 1}, 2, 2], + [U1, :b] => [{no: 1}, 2, :b], + + [U2, {type: :a}] => [{yes: 3}, 0, {t: :a}], + [U2, {type: "b"}] => [{yes: 3}, 0, {type: :b}], + + [U3, "one"] => [{yes: 1}, 2, "one"], + [U4, "one"] => [{yes: 1}, 1, "one"], + + [U5, {a: []}] => [{yes: 3}, 2, {a: []}], + [U6, {b: []}] => [{yes: 3}, 2, {b: []}], + + [U5, {a: [{a: []}]}] => [{yes: 6}, 4, {a: [M4.new(a: [])]}], + [U5, {a: [{a: [{a: []}]}]}] => [{yes: 9}, 6, {a: [M4.new(a: [M4.new(a: [])])]}] } - cases.each do |input, expect| + cases.each do |lhs, rhs| + target, input = lhs + exactness, branched, expect = rhs + state = {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0} assert_pattern do - OpenAI::Converter.try_strict_coerce(U2, input) => ^expect + coerced = OpenAI::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(OpenAI::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + state => {branched: ^branched} end end end +end - class C1 < OpenAI::BaseModel - required :a, const: :a - required :b, const: :b, nil?: true - optional :c, const: :c - end +class OpenAI::Test::BaseModelQoLTest < Minitest::Test + module E1 + extend OpenAI::Enum - def test_basic_const - assert_pattern do - C1.dump(C1.new) => {a: :a} - C1.new => {a: :a} - C1.new(a: "a") => {a: :a} - C1.new(b: 2) => {b: 2} - C1.new.a => :a - C1.new.b => nil - C1.new.c => nil - end + A = 1 end - class E2 < OpenAI::Enum - A = :a - B = :b - end + module E2 + extend OpenAI::Enum - class U3 < OpenAI::Union - discriminator :type - variant :a, M1 - variant :b, M3 + A = 1 end - def test_basic_eql - assert_equal(OpenAI::Unknown, OpenAI::Unknown) - refute_equal(OpenAI::Unknown, OpenAI::BooleanModel) - assert_equal(OpenAI::BooleanModel, OpenAI::BooleanModel) + module E3 + extend OpenAI::Enum - assert_equal(E1, E2) - assert_equal(E1, E2) + A = 2 + B = 3 + end - refute_equal(U1, U2) - assert_equal(U1, U3) + class M1 < OpenAI::BaseModel + required :a, Integer + end + + class M2 < OpenAI::BaseModel + required :a, Integer, nil?: true end - class U4 < OpenAI::Union - variant :a, const: :a - variant :b, const: :b + class M3 < M2 + required :a, Integer end - def test_basic_const_union - assert_pattern do - U4.coerce(nil) => nil - U4.coerce("") => "" - U4.coerce(:a) => :a - U4.coerce("a") => :a + def test_equality + cases = { + [OpenAI::Unknown, OpenAI::Unknown] => true, + [OpenAI::BooleanModel, OpenAI::BooleanModel] => true, + [OpenAI::Unknown, OpenAI::BooleanModel] => false, + [E1, E2] => true, + [E1, E3] => false, + [M1, M2] => false, + [M1, M3] => true + } + + cases.each do + if _2 + assert_equal(*_1) + else + refute_equal(*_1) + end end end end diff --git a/test/openai/client_test.rb b/test/openai/client_test.rb index 9a3f400f..cbb0c21d 100644 --- a/test/openai/client_test.rb +++ b/test/openai/client_test.rb @@ -56,11 +56,7 @@ def test_client_default_request_default_retry_attempts openai.requester = requester assert_raises(OpenAI::InternalServerError) do - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") end assert_equal(3, requester.attempts.length) @@ -72,11 +68,7 @@ def test_client_given_request_default_retry_attempts openai.requester = requester assert_raises(OpenAI::InternalServerError) do - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") end assert_equal(4, requester.attempts.length) @@ -91,7 +83,6 @@ def test_client_default_request_given_retry_attempts openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {max_retries: 3} ) end @@ -108,7 +99,6 @@ def test_client_given_request_given_retry_attempts openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {max_retries: 4} ) end @@ -122,11 +112,7 @@ def test_client_retry_after_seconds openai.requester = requester assert_raises(OpenAI::InternalServerError) do - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") end assert_equal(2, requester.attempts.length) @@ -140,11 +126,7 @@ def test_client_retry_after_date assert_raises(OpenAI::InternalServerError) do Thread.current.thread_variable_set(:time_now, Time.now) - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") Thread.current.thread_variable_set(:time_now, nil) end @@ -158,11 +140,7 @@ def test_client_retry_after_ms openai.requester = requester assert_raises(OpenAI::InternalServerError) do - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") end assert_equal(2, requester.attempts.length) @@ -175,11 +153,7 @@ def test_retry_count_header openai.requester = requester assert_raises(OpenAI::InternalServerError) do - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") end retry_count_headers = requester.attempts.map { _1[:headers]["x-stainless-retry-count"] } @@ -195,7 +169,6 @@ def test_omit_retry_count_header openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {"x-stainless-retry-count" => nil}} ) end @@ -213,7 +186,6 @@ def test_overwrite_retry_count_header openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {"x-stainless-retry-count" => "42"}} ) end @@ -231,7 +203,6 @@ def test_client_redirect_307 openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {}} ) end @@ -254,7 +225,6 @@ def test_client_redirect_303 openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {}} ) end @@ -274,7 +244,6 @@ def test_client_redirect_auth_keep_same_origin openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {"Authorization" => "Bearer xyz"}} ) end @@ -294,7 +263,6 @@ def test_client_redirect_auth_strip_cross_origin openai.chat.completions.create( messages: [{content: "string", role: :developer}], model: :"o3-mini", - stream: true, request_options: {extra_headers: {"Authorization" => "Bearer xyz"}} ) end @@ -306,11 +274,7 @@ def test_default_headers openai = OpenAI::Client.new(base_url: "http://localhost:4010", api_key: "My API Key") requester = MockRequester.new(200, {}, {}) openai.requester = requester - openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") headers = requester.attempts.first[:headers] refute_empty(headers["accept"]) diff --git a/test/openai/resources/audio/speech_test.rb b/test/openai/resources/audio/speech_test.rb index 9718aa1a..e1588426 100644 --- a/test/openai/resources/audio/speech_test.rb +++ b/test/openai/resources/audio/speech_test.rb @@ -7,7 +7,7 @@ def test_create_required_params response = @openai.audio.speech.create(input: "input", model: :"tts-1", voice: :alloy) assert_pattern do - response => OpenAI::Unknown + response => StringIO end end end diff --git a/test/openai/resources/audio/transcriptions_test.rb b/test/openai/resources/audio/transcriptions_test.rb index ca797160..a8a6d471 100644 --- a/test/openai/resources/audio/transcriptions_test.rb +++ b/test/openai/resources/audio/transcriptions_test.rb @@ -4,10 +4,8 @@ class OpenAI::Test::Resources::Audio::TranscriptionsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.audio.transcriptions.create( - file: StringIO.new("some file contents"), - model: :"whisper-1" - ) + response = + @openai.audio.transcriptions.create(file: StringIO.new("some file contents"), model: :"whisper-1") assert_pattern do response => OpenAI::Models::Audio::TranscriptionCreateResponse diff --git a/test/openai/resources/audio/translations_test.rb b/test/openai/resources/audio/translations_test.rb index f0b69d4f..d42b8267 100644 --- a/test/openai/resources/audio/translations_test.rb +++ b/test/openai/resources/audio/translations_test.rb @@ -4,10 +4,8 @@ class OpenAI::Test::Resources::Audio::TranslationsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.audio.translations.create( - file: StringIO.new("some file contents"), - model: :"whisper-1" - ) + response = + @openai.audio.translations.create(file: StringIO.new("some file contents"), model: :"whisper-1") assert_pattern do response => OpenAI::Models::Audio::TranslationCreateResponse diff --git a/test/openai/resources/batches_test.rb b/test/openai/resources/batches_test.rb index 50ae1244..59e25d4f 100644 --- a/test/openai/resources/batches_test.rb +++ b/test/openai/resources/batches_test.rb @@ -4,11 +4,12 @@ class OpenAI::Test::Resources::BatchesTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.batches.create( - completion_window: :"24h", - endpoint: :"/v1/chat/completions", - input_file_id: "input_file_id" - ) + response = + @openai.batches.create( + completion_window: :"24h", + endpoint: :"/v1/responses", + input_file_id: "input_file_id" + ) assert_pattern do response => OpenAI::Models::Batch @@ -81,6 +82,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Batch end diff --git a/test/openai/resources/beta/assistants_test.rb b/test/openai/resources/beta/assistants_test.rb index e0ffb63a..f6363319 100644 --- a/test/openai/resources/beta/assistants_test.rb +++ b/test/openai/resources/beta/assistants_test.rb @@ -89,6 +89,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Beta::Assistant end diff --git a/test/openai/resources/beta/threads/messages_test.rb b/test/openai/resources/beta/threads/messages_test.rb index 42f89d03..bd430759 100644 --- a/test/openai/resources/beta/threads/messages_test.rb +++ b/test/openai/resources/beta/threads/messages_test.rb @@ -92,6 +92,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Beta::Threads::Message end diff --git a/test/openai/resources/beta/threads/runs/steps_test.rb b/test/openai/resources/beta/threads/runs/steps_test.rb index e18e9336..97fa3d2b 100644 --- a/test/openai/resources/beta/threads/runs/steps_test.rb +++ b/test/openai/resources/beta/threads/runs/steps_test.rb @@ -40,6 +40,8 @@ def test_list_required_params end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Beta::Threads::Runs::RunStep end diff --git a/test/openai/resources/beta/threads/runs_test.rb b/test/openai/resources/beta/threads/runs_test.rb index 98123435..919cb65f 100644 --- a/test/openai/resources/beta/threads/runs_test.rb +++ b/test/openai/resources/beta/threads/runs_test.rb @@ -4,7 +4,7 @@ class OpenAI::Test::Resources::Beta::Threads::RunsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.beta.threads.runs.create("thread_id", assistant_id: "assistant_id", stream: true) + response = @openai.beta.threads.runs.create("thread_id", assistant_id: "assistant_id") assert_pattern do response => OpenAI::Models::Beta::Threads::Run @@ -131,6 +131,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Beta::Threads::Run end @@ -209,12 +211,8 @@ def test_cancel_required_params end def test_submit_tool_outputs_required_params - response = @openai.beta.threads.runs.submit_tool_outputs( - "run_id", - thread_id: "thread_id", - stream: true, - tool_outputs: [{}] - ) + response = + @openai.beta.threads.runs.submit_tool_outputs("run_id", thread_id: "thread_id", tool_outputs: [{}]) assert_pattern do response => OpenAI::Models::Beta::Threads::Run diff --git a/test/openai/resources/beta/threads_test.rb b/test/openai/resources/beta/threads_test.rb index 4203a6f3..f7f1021f 100644 --- a/test/openai/resources/beta/threads_test.rb +++ b/test/openai/resources/beta/threads_test.rb @@ -74,7 +74,7 @@ def test_delete end def test_create_and_run_required_params - response = @openai.beta.threads.create_and_run(assistant_id: "assistant_id", stream: true) + response = @openai.beta.threads.create_and_run(assistant_id: "assistant_id") assert_pattern do response => OpenAI::Models::Beta::Threads::Run diff --git a/test/openai/resources/chat/completions/messages_test.rb b/test/openai/resources/chat/completions/messages_test.rb index 72c10f96..e9fac539 100644 --- a/test/openai/resources/chat/completions/messages_test.rb +++ b/test/openai/resources/chat/completions/messages_test.rb @@ -11,6 +11,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Chat::ChatCompletionStoreMessage end diff --git a/test/openai/resources/chat/completions_test.rb b/test/openai/resources/chat/completions_test.rb index 4b353ac2..f4d9b7f7 100644 --- a/test/openai/resources/chat/completions_test.rb +++ b/test/openai/resources/chat/completions_test.rb @@ -4,11 +4,8 @@ class OpenAI::Test::Resources::Chat::CompletionsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.chat.completions.create( - messages: [{content: "string", role: :developer}], - model: :"o3-mini", - stream: true - ) + response = + @openai.chat.completions.create(messages: [{content: "string", role: :developer}], model: :"o3-mini") assert_pattern do response => OpenAI::Models::Chat::ChatCompletion @@ -78,6 +75,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Chat::ChatCompletion end diff --git a/test/openai/resources/completions_test.rb b/test/openai/resources/completions_test.rb index 6fb99107..f7d94ab8 100644 --- a/test/openai/resources/completions_test.rb +++ b/test/openai/resources/completions_test.rb @@ -4,11 +4,7 @@ class OpenAI::Test::Resources::CompletionsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.completions.create( - model: :"gpt-3.5-turbo-instruct", - prompt: "This is a test.", - stream: true - ) + response = @openai.completions.create(model: :"gpt-3.5-turbo-instruct", prompt: "This is a test.") assert_pattern do response => OpenAI::Models::Completion diff --git a/test/openai/resources/embeddings_test.rb b/test/openai/resources/embeddings_test.rb index 244d5817..d9eb182b 100644 --- a/test/openai/resources/embeddings_test.rb +++ b/test/openai/resources/embeddings_test.rb @@ -4,10 +4,11 @@ class OpenAI::Test::Resources::EmbeddingsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.embeddings.create( - input: "The quick brown fox jumped over the lazy dog", - model: :"text-embedding-ada-002" - ) + response = + @openai.embeddings.create( + input: "The quick brown fox jumped over the lazy dog", + model: :"text-embedding-ada-002" + ) assert_pattern do response => OpenAI::Models::CreateEmbeddingResponse diff --git a/test/openai/resources/files_test.rb b/test/openai/resources/files_test.rb index c517f42f..58bcbf2b 100644 --- a/test/openai/resources/files_test.rb +++ b/test/openai/resources/files_test.rb @@ -55,6 +55,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::FileObject end @@ -96,7 +98,7 @@ def test_content response = @openai.files.content("file_id") assert_pattern do - response => OpenAI::Unknown + response => StringIO end end end diff --git a/test/openai/resources/fine_tuning/jobs/checkpoints_test.rb b/test/openai/resources/fine_tuning/jobs/checkpoints_test.rb index 96ee1164..feb9c651 100644 --- a/test/openai/resources/fine_tuning/jobs/checkpoints_test.rb +++ b/test/openai/resources/fine_tuning/jobs/checkpoints_test.rb @@ -11,6 +11,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint end diff --git a/test/openai/resources/fine_tuning/jobs_test.rb b/test/openai/resources/fine_tuning/jobs_test.rb index 2b35089a..7df07711 100644 --- a/test/openai/resources/fine_tuning/jobs_test.rb +++ b/test/openai/resources/fine_tuning/jobs_test.rb @@ -75,6 +75,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::FineTuning::FineTuningJob end @@ -144,6 +146,8 @@ def test_list_events end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::FineTuning::FineTuningJobEvent end diff --git a/test/openai/resources/images_test.rb b/test/openai/resources/images_test.rb index 82078e4d..c935d0c6 100644 --- a/test/openai/resources/images_test.rb +++ b/test/openai/resources/images_test.rb @@ -19,10 +19,11 @@ def test_create_variation_required_params end def test_edit_required_params - response = @openai.images.edit( - image: StringIO.new("some file contents"), - prompt: "A cute baby sea otter wearing a beret" - ) + response = + @openai.images.edit( + image: StringIO.new("some file contents"), + prompt: "A cute baby sea otter wearing a beret" + ) assert_pattern do response => OpenAI::Models::ImagesResponse diff --git a/test/openai/resources/models_test.rb b/test/openai/resources/models_test.rb index d91063a2..33384138 100644 --- a/test/openai/resources/models_test.rb +++ b/test/openai/resources/models_test.rb @@ -28,6 +28,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::Model end diff --git a/test/openai/resources/responses/input_items_test.rb b/test/openai/resources/responses/input_items_test.rb index c00355a7..1250f3bd 100644 --- a/test/openai/resources/responses/input_items_test.rb +++ b/test/openai/resources/responses/input_items_test.rb @@ -11,20 +11,22 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do - row => OpenAI::Models::Responses::ResponseItemList::Data + row => OpenAI::Models::Responses::ResponseItem end assert_pattern do case row - in OpenAI::Models::Responses::ResponseItemList::Data::Message + in OpenAI::Models::Responses::ResponseInputMessageItem in OpenAI::Models::Responses::ResponseOutputMessage in OpenAI::Models::Responses::ResponseFileSearchToolCall in OpenAI::Models::Responses::ResponseComputerToolCall - in OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput + in OpenAI::Models::Responses::ResponseComputerToolCallOutputItem in OpenAI::Models::Responses::ResponseFunctionWebSearch - in OpenAI::Models::Responses::ResponseFunctionToolCall - in OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput + in OpenAI::Models::Responses::ResponseFunctionToolCallItem + in OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem end end @@ -34,8 +36,8 @@ def test_list type: :message, id: String, content: ^(OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseInputContent]), - role: OpenAI::Models::Responses::ResponseItemList::Data::Message::Role, - status: OpenAI::Models::Responses::ResponseItemList::Data::Message::Status | nil + role: OpenAI::Models::Responses::ResponseInputMessageItem::Role, + status: OpenAI::Models::Responses::ResponseInputMessageItem::Status | nil } in { type: :message, @@ -63,25 +65,17 @@ def test_list type: :computer_call_output, id: String, call_id: String, - output: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Output, - acknowledged_safety_checks: ^(OpenAI::ArrayOf[OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::AcknowledgedSafetyCheck]) | nil, - status: OpenAI::Models::Responses::ResponseItemList::Data::ComputerCallOutput::Status | nil + output: OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot, + acknowledged_safety_checks: ^(OpenAI::ArrayOf[OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck]) | nil, + status: OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status | nil } in {type: :web_search_call, id: String, status: OpenAI::Models::Responses::ResponseFunctionWebSearch::Status} - in { - type: :function_call, - id: String, - arguments: String, - call_id: String, - name: String, - status: OpenAI::Models::Responses::ResponseFunctionToolCall::Status | nil - } in { type: :function_call_output, id: String, call_id: String, output: String, - status: OpenAI::Models::Responses::ResponseItemList::Data::FunctionCallOutput::Status | nil + status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status | nil } end end diff --git a/test/openai/resources/responses_test.rb b/test/openai/resources/responses_test.rb index 6ecd70a3..d0e0157e 100644 --- a/test/openai/resources/responses_test.rb +++ b/test/openai/resources/responses_test.rb @@ -4,7 +4,7 @@ class OpenAI::Test::Resources::ResponsesTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.responses.create(input: "string", model: :"o3-mini", stream: true) + response = @openai.responses.create(input: "string", model: :"gpt-4o") assert_pattern do response => OpenAI::Models::Responses::Response @@ -18,7 +18,7 @@ def test_create_required_params incomplete_details: OpenAI::Models::Responses::Response::IncompleteDetails | nil, instructions: String | nil, metadata: ^(OpenAI::HashOf[String]) | nil, - model: OpenAI::Models::Responses::Response::Model, + model: OpenAI::Models::ResponsesModel, object: Symbol, output: ^(OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseOutputItem]), parallel_tool_calls: OpenAI::BooleanModel, @@ -53,7 +53,7 @@ def test_retrieve incomplete_details: OpenAI::Models::Responses::Response::IncompleteDetails | nil, instructions: String | nil, metadata: ^(OpenAI::HashOf[String]) | nil, - model: OpenAI::Models::Responses::Response::Model, + model: OpenAI::Models::ResponsesModel, object: Symbol, output: ^(OpenAI::ArrayOf[union: OpenAI::Models::Responses::ResponseOutputItem]), parallel_tool_calls: OpenAI::BooleanModel, diff --git a/test/openai/resources/uploads_test.rb b/test/openai/resources/uploads_test.rb index 88af217d..3b3e356c 100644 --- a/test/openai/resources/uploads_test.rb +++ b/test/openai/resources/uploads_test.rb @@ -4,12 +4,8 @@ class OpenAI::Test::Resources::UploadsTest < OpenAI::Test::ResourceTest def test_create_required_params - response = @openai.uploads.create( - bytes: 0, - filename: "filename", - mime_type: "mime_type", - purpose: :assistants - ) + response = + @openai.uploads.create(bytes: 0, filename: "filename", mime_type: "mime_type", purpose: :assistants) assert_pattern do response => OpenAI::Models::Upload diff --git a/test/openai/resources/vector_stores/file_batches_test.rb b/test/openai/resources/vector_stores/file_batches_test.rb index d9d66e4d..f4bcecf5 100644 --- a/test/openai/resources/vector_stores/file_batches_test.rb +++ b/test/openai/resources/vector_stores/file_batches_test.rb @@ -68,6 +68,8 @@ def test_list_files_required_params end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::VectorStores::VectorStoreFile end diff --git a/test/openai/resources/vector_stores/files_test.rb b/test/openai/resources/vector_stores/files_test.rb index a8c36003..2b789caa 100644 --- a/test/openai/resources/vector_stores/files_test.rb +++ b/test/openai/resources/vector_stores/files_test.rb @@ -48,11 +48,12 @@ def test_retrieve_required_params end def test_update_required_params - response = @openai.vector_stores.files.update( - "file-abc123", - vector_store_id: "vs_abc123", - attributes: {foo: "string"} - ) + response = + @openai.vector_stores.files.update( + "file-abc123", + vector_store_id: "vs_abc123", + attributes: {foo: "string"} + ) assert_pattern do response => OpenAI::Models::VectorStores::VectorStoreFile @@ -81,6 +82,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::VectorStores::VectorStoreFile end @@ -124,6 +127,8 @@ def test_content_required_params end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::VectorStores::FileContentResponse end diff --git a/test/openai/resources/vector_stores_test.rb b/test/openai/resources/vector_stores_test.rb index 2296e034..c7ae05cb 100644 --- a/test/openai/resources/vector_stores_test.rb +++ b/test/openai/resources/vector_stores_test.rb @@ -83,6 +83,8 @@ def test_list end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::VectorStore end @@ -128,6 +130,8 @@ def test_search_required_params end row = response.to_enum.first + return if row.nil? + assert_pattern do row => OpenAI::Models::VectorStoreSearchResponse end