anthropic.ts 953 B

12345678910111213141516171819202122232425
  1. import { Effect } from "effect"
  2. import { PluginV2 } from "../../plugin"
  3. export const AnthropicPlugin = PluginV2.define({
  4. id: PluginV2.ID.make("anthropic"),
  5. effect: Effect.gen(function* () {
  6. return {
  7. "catalog.transform": Effect.fn(function* (evt) {
  8. for (const item of evt.provider.list()) {
  9. if (item.provider.endpoint.type !== "aisdk") continue
  10. if (item.provider.endpoint.package !== "@ai-sdk/anthropic") continue
  11. evt.provider.update(item.provider.id, (provider) => {
  12. provider.options.headers["anthropic-beta"] =
  13. "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
  14. })
  15. }
  16. }),
  17. "aisdk.sdk": Effect.fn(function* (evt) {
  18. if (evt.package !== "@ai-sdk/anthropic") return
  19. const mod = yield* Effect.promise(() => import("@ai-sdk/anthropic"))
  20. evt.sdk = mod.createAnthropic(evt.options)
  21. }),
  22. }
  23. }),
  24. })