diff --git a/README.md b/README.md index ff557c2d..2c5d6001 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,8 @@ 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. diff --git a/lib/openai.rb b/lib/openai.rb index 3a9e6cd2..64c67b2f 100644 --- a/lib/openai.rb +++ b/lib/openai.rb @@ -1,5 +1,20 @@ # frozen_string_literal: true +# 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 defined?(:Tapioca) && caller_locations.any? { _1.path.end_with?("tapioca/cli.rb") } + 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 + # Standard libraries. require "cgi" require "date"