Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing from "langchain/llms/openai" is deprecated. #1469

Closed
oliviermills opened this issue Apr 30, 2024 · 3 comments
Closed

Importing from "langchain/llms/openai" is deprecated. #1469

oliviermills opened this issue Apr 30, 2024 · 3 comments

Comments

@oliviermills
Copy link

Description

In your example you use the old method for LangChain :

https://github.com/vercel/ai/tree/main/examples/next-langchain/app/api/stream-data-chain/route.ts

You should no long user LLMChain and update to using invoke() and, here stream()

e.g.:

const chatPrompt = ChatPromptTemplate.fromMessages([...])
const chain = chatPrompt.pipe(chatModel)
response = await chain.pipe(outputParser).stream({...},{ callbacks: [handlers]})

Code example

const model = new OpenAI({ temperature: 0, streaming: true });
  const prompt = PromptTemplate.fromTemplate(
    'What is a good name for a company that makes {product}?',
  );
  const chain = new LLMChain({ llm: model, prompt });

Additional context

Should update the LangChainStream() to work with:

import { OpenAI } from '@langchain/openai'
@beeirl
Copy link

beeirl commented Apr 30, 2024

@oliviermills have u been able to get it working using chain.stream() and Vercel's LangChainStream()? If so, mind sharing a gist?

@oliviermills
Copy link
Author

@oliviermills have u been able to get it working using chain.stream() and Vercel's LangChainStream()? If so, mind sharing a gist?

Not with the Vercel version of LangChainStream.. I implemented my own (https://dev.to/omills/vercel-ai-sdk-langchain-3edf) but this could be improved using AIStream I believe. You essentially need to pipe the right stream transformers. This uses the latest Vercel Ai sdk and latest Langchain.

@lgrammel
Copy link
Collaborator

I've updated the langchain integration: https://sdk.vercel.ai/providers/adapters/langchain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants