ai icon indicating copy to clipboard operation
ai copied to clipboard

Leftover '@ai-sdk/[email protected]' after installing @ai-sdk/anthropic@latest in certain environments

Open jb-dev1 opened this issue 1 year ago • 0 comments

Description

I get a leftover stale dependency @ai-sdk/[email protected] in pnpm-lock.yaml when setting up vercel/ai-chatbot with the new pnpm 9.6.0. After installing @ai-sdk/anthropic@latest after a fresh clone of ai-chatbot and attempting to use experimental_createProviderRegistry with anthropic, it fails on build due to the stale [email protected].

This happens with the base ai-chatbot (commit b38c49d, 1 Aug) with no modifications and running pnpm install on the latest code without installing anthropic, then running pnpm add @ai-sdk/anthropic@latest. However, by initially upgrading @ai-sdk/openai@latest right after a fresh clone of ai-chatbot, it clears the stale [email protected].

I assume this would happen to any other code with the same dependency state as ai-chatbot.

Code example

import { anthropic } from '@ai-sdk/anthropic';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_createProviderRegistry as createProviderRegistry } from 'ai';

export const registry = createProviderRegistry({

  // issue shows here
  anthropic,

  openai: createOpenAI({
    apiKey: process.env.OPENAI_API_KEY,
  }),
});

Example workaround until solved (using pnpm 9.6.0)

  1. clone ai-chatbot
  2. delete pnpm-lock.yaml
  3. pnpm install
  4. pnpm update @ai-sdk/openai@latest (clears the stale [email protected])
  5. and then if you want it: pnpm add @ai-sdk/anthropic@latest

The stale [email protected] will be removed from pnpm-lock.yaml, and anthropic will not throw a provider error.

jb-dev1 avatar Aug 03 '24 07:08 jb-dev1