openai-compatible.ts 596 B

1234567891011121314151617
  1. import { Effect } from "effect"
  2. import { define } from "../internal"
  3. export const OpenAICompatiblePlugin = define({
  4. id: "openai-compatible",
  5. effect: Effect.fn(function* (ctx) {
  6. yield* ctx.aisdk.sdk(
  7. Effect.fn(function* (evt) {
  8. if (evt.sdk) return
  9. if (!evt.package.includes("@ai-sdk/openai-compatible")) return
  10. if (evt.options.includeUsage !== false) evt.options.includeUsage = true
  11. const mod = yield* Effect.promise(() => import("@ai-sdk/openai-compatible"))
  12. evt.sdk = mod.createOpenAICompatible(evt.options as any)
  13. }),
  14. )
  15. }),
  16. })