diff --git a/.changeset/lovely-stingrays-fail.md b/.changeset/lovely-stingrays-fail.md new file mode 100644 index 000000000000..933d9f01ebfc --- /dev/null +++ b/.changeset/lovely-stingrays-fail.md @@ -0,0 +1,5 @@ +--- +'ai': patch +--- + +feat (ai/streams): add LangChainAdapter.toAIStream() diff --git a/content/providers/04-adapters/index.mdx b/content/providers/04-adapters/index.mdx new file mode 100644 index 000000000000..50650059461c --- /dev/null +++ b/content/providers/04-adapters/index.mdx @@ -0,0 +1,14 @@ +--- +title: Adapters +description: Learn how to use AI SDK Adapters. +--- + +# Adapters + +Adapters are lightweight integrations that enable you to use +the Vercel AI SDK UI functions (`useChat` and `useCompletion`) +with 3rd party libraries. + +The following adapters are currently available: + +- [LangChain](./langchain) diff --git a/content/providers/04-adapters/langchain.mdx b/content/providers/04-adapters/langchain.mdx new file mode 100644 index 000000000000..0b3bdd0b017d --- /dev/null +++ b/content/providers/04-adapters/langchain.mdx @@ -0,0 +1,66 @@ +--- +title: LangChain +description: Learn how to use LangChain with the Vercel AI SDK. +--- + +# LangChain + +[LangChain](https://js.langchain.com/docs/) is a framework for developing applications powered by language models. +It provides tools and abstractions for working with AI models, agents, vector stores, and other data sources for retrieval augmented generation (RAG). +However, LangChain does not provide a way to easily build UIs or a standard way to stream data to the client. + +## Example: Completion + +Here is a basic example that uses both Vercel AI SDK and LangChain together with the [Next.js](https://nextjs.org/docs) App Router. + +The AI SDK `LangChainAdapter` uses the result from [LangChain ExpressionLanguage streaming](https://js.langchain.com/docs/expression_language/streaming) to pipe text to the client. +`LangChainAdapter.toAIStream()` is compatible with the LangChain Expression Language `.stream()` function response. + +```tsx filename="app/api/completion/route.ts" highlight={"17"} +import { ChatOpenAI } from '@langchain/openai'; +import { LangChainAdapter, StreamingTextResponse } from 'ai'; + +export const dynamic = 'force-dynamic'; +export const maxDuration = 60; + +export async function POST(req: Request) { + const { prompt } = await req.json(); + + const model = new ChatOpenAI({ + model: 'gpt-3.5-turbo-0125', + temperature: 0, + }); + + const stream = await model.stream(prompt); + + const aiStream = LangChainAdapter.toAIStream(stream); + + return new StreamingTextResponse(aiStream); +} +``` + +Then, we use the Vercel AI SDK's [`useCompletion`](/docs/ai-sdk-ui/completion) method in the page component to handle the completion: + +```tsx filename="app/page.tsx" +'use client'; + +import { useCompletion } from 'ai/react'; + +export default function Chat() { + const { completion, input, handleInputChange, handleSubmit } = + useCompletion(); + + return ( +
+ {completion} +
+ +
+
+ ); +} +``` + +## More Examples + +You can find additional examples in the Vercel AI SDK [examples/next-langchain](https://github.com/vercel/ai/tree/main/examples/next-langchain) folder. diff --git a/content/providers/04-legacy-providers/langchain.mdx b/content/providers/04-legacy-providers/langchain.mdx deleted file mode 100644 index 9b9ea49c4631..000000000000 --- a/content/providers/04-legacy-providers/langchain.mdx +++ /dev/null @@ -1,134 +0,0 @@ ---- -title: LangChain -description: Learn how to use LangChain with the Vercel AI SDK. ---- - -# LangChain - -[LangChain](https://js.langchain.com/docs/) is a framework for developing applications powered by language models. -It provides tools and abstractions for working with AI models, agents, vector stores, and other data sources for retrieval augmented generation (RAG). -However, LangChain does not provide a way to easily build UIs or a standard way to stream data to the client. - -## Example - -Here is an example implementation of a chat application that uses both Vercel AI SDK and a composed LangChain chain together with the -[Next.js](https://nextjs.org/docs) App Router. It includes a LangChain [`PromptTemplate`](https://js.langchain.com/docs/modules/model_io/prompts/quick_start/) -to pass input into a [`ChatOpenAI`](https://js.langchain.com/docs/modules/model_io/models/chat/integrations/openai) model wrapper, -then streams the result through an encoding output parser. - -It takes this stream and uses Vercel AI SDK's [`StreamingTextResponse`](/docs/reference/stream-helpers/streaming-text-response) -to pipe text to the client and then Vercel AI SDK's `useChat` to handle the chat UI. - -```tsx filename="app/api/chat/route.ts" -import { NextRequest } from 'next/server'; -import { Message as VercelChatMessage, StreamingTextResponse } from 'ai'; - -import { ChatOpenAI } from 'langchain/chat_models/openai'; -import { BytesOutputParser } from 'langchain/schema/output_parser'; -import { PromptTemplate } from 'langchain/prompts'; - -/** - * Basic memory formatter that stringifies and passes - * message history directly into the model. - */ -const formatMessage = (message: VercelChatMessage) => { - return `${message.role}: ${message.content}`; -}; - -const TEMPLATE = `You are a pirate named Patchy. All responses must be extremely verbose and in pirate dialect. - -Current conversation: -{chat_history} - -User: {input} -AI:`; - -/* - * This handler initializes and calls a simple chain with a prompt, - * chat model, and output parser. See the docs for more information: - * - * https://js.langchain.com/docs/guides/expression_language/cookbook#prompttemplate--llm--outputparser - */ -export async function POST(req: NextRequest) { - const body = await req.json(); - const messages = body.messages ?? []; - const formattedPreviousMessages = messages.slice(0, -1).map(formatMessage); - const currentMessageContent = messages[messages.length - 1].content; - - const prompt = PromptTemplate.fromTemplate(TEMPLATE); - /** - * See a full list of supported models at: - * https://js.langchain.com/docs/modules/model_io/models/ - */ - const model = new ChatOpenAI({ - temperature: 0.8, - }); - - /** - * Chat models stream message chunks rather than bytes, so this - * output parser handles serialization and encoding. - */ - const outputParser = new BytesOutputParser(); - - /* - * Can also initialize as: - * - * import { RunnableSequence } from "langchain/schema/runnable"; - * const chain = RunnableSequence.from([prompt, model, outputParser]); - */ - const chain = prompt.pipe(model).pipe(outputParser); - - const stream = await chain.stream({ - chat_history: formattedPreviousMessages.join('\n'), - input: currentMessageContent, - }); - - return new StreamingTextResponse(stream); -} -``` - -Then, we use the Vercel AI SDK's [`useChat`](/docs/reference/ai-sdk-ui/use-chat) method: - -```tsx filename="app/page.tsx" -'use client'; - -import { useChat } from 'ai/react'; - -export default function Chat() { - const { messages, input, handleInputChange, handleSubmit } = useChat(); - - return ( -
- {messages.map(m => ( -
- {m.role === 'user' ? 'User: ' : 'AI: '} - {m.content} -
- ))} - -
- - -
-
- ); -} -``` - -For more usage examples, including agents and retrieval, you can check out the [official LangChain starter template](https://github.com/langchain-ai/langchain-nextjs-template). - -# Advanced - -For streaming with legacy or more complex chains or agents that don't support streaming out of the box, you can use the `LangChainStream` class to handle certain -[callbacks](https://js.langchain.com/docs/modules/callbacks/) provided by LangChain on your behalf. -Under the hood it is a wrapper over LangChain's [`callbacks`](https://js.langchain.com/docs/production/callbacks/). -We wrap over these methods to provide which then write to the `stream` which can then be passed directly to [`StreamingTextResponse`](/docs/reference/stream-helpers/streaming-text-response). - -You can see an example of how this looks from the [`LangChainStream` docs page](/docs/reference/stream-helpers/lang-chain-stream). diff --git a/content/providers/04-legacy-providers/anthropic.mdx b/content/providers/05-legacy-providers/anthropic.mdx similarity index 100% rename from content/providers/04-legacy-providers/anthropic.mdx rename to content/providers/05-legacy-providers/anthropic.mdx diff --git a/content/providers/04-legacy-providers/aws-bedrock.mdx b/content/providers/05-legacy-providers/aws-bedrock.mdx similarity index 100% rename from content/providers/04-legacy-providers/aws-bedrock.mdx rename to content/providers/05-legacy-providers/aws-bedrock.mdx diff --git a/content/providers/04-legacy-providers/azure-openai.mdx b/content/providers/05-legacy-providers/azure-openai.mdx similarity index 100% rename from content/providers/04-legacy-providers/azure-openai.mdx rename to content/providers/05-legacy-providers/azure-openai.mdx diff --git a/content/providers/04-legacy-providers/cohere.mdx b/content/providers/05-legacy-providers/cohere.mdx similarity index 100% rename from content/providers/04-legacy-providers/cohere.mdx rename to content/providers/05-legacy-providers/cohere.mdx diff --git a/content/providers/04-legacy-providers/fireworks-ai.mdx b/content/providers/05-legacy-providers/fireworks-ai.mdx similarity index 100% rename from content/providers/04-legacy-providers/fireworks-ai.mdx rename to content/providers/05-legacy-providers/fireworks-ai.mdx diff --git a/content/providers/04-legacy-providers/google.mdx b/content/providers/05-legacy-providers/google.mdx similarity index 100% rename from content/providers/04-legacy-providers/google.mdx rename to content/providers/05-legacy-providers/google.mdx diff --git a/content/providers/04-legacy-providers/hugging-face.mdx b/content/providers/05-legacy-providers/hugging-face.mdx similarity index 100% rename from content/providers/04-legacy-providers/hugging-face.mdx rename to content/providers/05-legacy-providers/hugging-face.mdx diff --git a/content/providers/04-legacy-providers/index.mdx b/content/providers/05-legacy-providers/index.mdx similarity index 100% rename from content/providers/04-legacy-providers/index.mdx rename to content/providers/05-legacy-providers/index.mdx diff --git a/content/providers/04-legacy-providers/inkeep.mdx b/content/providers/05-legacy-providers/inkeep.mdx similarity index 100% rename from content/providers/04-legacy-providers/inkeep.mdx rename to content/providers/05-legacy-providers/inkeep.mdx diff --git a/content/providers/04-legacy-providers/mistral.mdx b/content/providers/05-legacy-providers/mistral.mdx similarity index 100% rename from content/providers/04-legacy-providers/mistral.mdx rename to content/providers/05-legacy-providers/mistral.mdx diff --git a/content/providers/04-legacy-providers/openai-functions.mdx b/content/providers/05-legacy-providers/openai-functions.mdx similarity index 100% rename from content/providers/04-legacy-providers/openai-functions.mdx rename to content/providers/05-legacy-providers/openai-functions.mdx diff --git a/content/providers/04-legacy-providers/openai.mdx b/content/providers/05-legacy-providers/openai.mdx similarity index 100% rename from content/providers/04-legacy-providers/openai.mdx rename to content/providers/05-legacy-providers/openai.mdx diff --git a/content/providers/04-legacy-providers/perplexity.mdx b/content/providers/05-legacy-providers/perplexity.mdx similarity index 100% rename from content/providers/04-legacy-providers/perplexity.mdx rename to content/providers/05-legacy-providers/perplexity.mdx diff --git a/content/providers/04-legacy-providers/replicate.mdx b/content/providers/05-legacy-providers/replicate.mdx similarity index 100% rename from content/providers/04-legacy-providers/replicate.mdx rename to content/providers/05-legacy-providers/replicate.mdx diff --git a/examples/next-langchain/app/api/chat/route.ts b/examples/next-langchain/app/api/chat/route.ts index 99e3658ab80c..a0d9be49f1f0 100644 --- a/examples/next-langchain/app/api/chat/route.ts +++ b/examples/next-langchain/app/api/chat/route.ts @@ -1,29 +1,29 @@ -import { StreamingTextResponse, LangChainStream, Message } from 'ai'; -import { ChatOpenAI } from 'langchain/chat_models/openai'; +import { ChatOpenAI } from '@langchain/openai'; +import { LangChainAdapter, Message, StreamingTextResponse } from 'ai'; import { AIMessage, HumanMessage } from 'langchain/schema'; export const dynamic = 'force-dynamic'; +export const maxDuration = 60; export async function POST(req: Request) { - const { messages } = await req.json(); + const { + messages, + }: { + messages: Message[]; + } = await req.json(); - const { stream, handlers } = LangChainStream(); - - const llm = new ChatOpenAI({ - streaming: true, + const model = new ChatOpenAI({ + model: 'gpt-3.5-turbo-0125', + temperature: 0, }); - llm - .call( - (messages as Message[]).map(m => - m.role == 'user' - ? new HumanMessage(m.content) - : new AIMessage(m.content), - ), - {}, - [handlers], - ) - .catch(console.error); + const stream = await model.stream( + messages.map(message => + message.role == 'user' + ? new HumanMessage(message.content) + : new AIMessage(message.content), + ), + ); - return new StreamingTextResponse(stream); + return new StreamingTextResponse(LangChainAdapter.toAIStream(stream)); } diff --git a/examples/next-langchain/app/api/completion-stream-data/route.ts b/examples/next-langchain/app/api/completion-stream-data/route.ts new file mode 100644 index 000000000000..66025cd638f3 --- /dev/null +++ b/examples/next-langchain/app/api/completion-stream-data/route.ts @@ -0,0 +1,28 @@ +import { ChatOpenAI } from '@langchain/openai'; +import { LangChainAdapter, StreamData, StreamingTextResponse } from 'ai'; + +export const dynamic = 'force-dynamic'; +export const maxDuration = 60; + +export async function POST(req: Request) { + const { prompt } = await req.json(); + + const model = new ChatOpenAI({ + model: 'gpt-3.5-turbo-0125', + temperature: 0, + }); + + const stream = await model.stream(prompt); + + const data = new StreamData(); + + data.append({ test: 'value' }); + + const aiStream = LangChainAdapter.toAIStream(stream, { + onFinal() { + data.close(); + }, + }); + + return new StreamingTextResponse(aiStream, {}, data); +} diff --git a/examples/next-langchain/app/api/completion/route.ts b/examples/next-langchain/app/api/completion/route.ts new file mode 100644 index 000000000000..223501c304ac --- /dev/null +++ b/examples/next-langchain/app/api/completion/route.ts @@ -0,0 +1,18 @@ +import { ChatOpenAI } from '@langchain/openai'; +import { LangChainAdapter, StreamingTextResponse } from 'ai'; + +export const dynamic = 'force-dynamic'; +export const maxDuration = 60; + +export async function POST(req: Request) { + const { prompt } = await req.json(); + + const model = new ChatOpenAI({ + model: 'gpt-3.5-turbo-0125', + temperature: 0, + }); + + const stream = await model.stream(prompt); + + return new StreamingTextResponse(LangChainAdapter.toAIStream(stream)); +} diff --git a/examples/next-langchain/app/api/docs/route.ts b/examples/next-langchain/app/api/docs/route.ts deleted file mode 100644 index a16db568c8c0..000000000000 --- a/examples/next-langchain/app/api/docs/route.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { NextRequest } from 'next/server'; -import { Message as VercelChatMessage, StreamingTextResponse } from 'ai'; - -import { ChatOpenAI } from 'langchain/chat_models/openai'; -import { BytesOutputParser } from 'langchain/schema/output_parser'; -import { PromptTemplate } from 'langchain/prompts'; - -export const dynamic = 'force-dynamic'; - -/** - * Basic memory formatter that stringifies and passes - * message history directly into the model. - */ -const formatMessage = (message: VercelChatMessage) => { - return `${message.role}: ${message.content}`; -}; - -const TEMPLATE = `You are a pirate named Patchy. All responses must be extremely verbose and in pirate dialect. - -Current conversation: -{chat_history} - -User: {input} -AI:`; - -/* - * This handler initializes and calls a simple chain with a prompt, - * chat model, and output parser. See the docs for more information: - * - * https://js.langchain.com/docs/guides/expression_language/cookbook#prompttemplate--llm--outputparser - */ -export async function POST(req: NextRequest) { - const body = await req.json(); - const messages = body.messages ?? []; - const formattedPreviousMessages = messages.slice(0, -1).map(formatMessage); - const currentMessageContent = messages[messages.length - 1].content; - - const prompt = PromptTemplate.fromTemplate(TEMPLATE); - /** - * See a full list of supported models at: - * https://js.langchain.com/docs/modules/model_io/models/ - */ - const model = new ChatOpenAI({ - temperature: 0.8, - }); - - /** - * Chat models stream message chunks rather than bytes, so this - * output parser handles serialization and encoding. - */ - const outputParser = new BytesOutputParser(); - - /* - * Can also initialize as: - * - * import { RunnableSequence } from "langchain/schema/runnable"; - * const chain = RunnableSequence.from([prompt, model, outputParser]); - */ - const chain = prompt.pipe(model).pipe(outputParser); - - const stream = await chain.stream({ - chat_history: formattedPreviousMessages.join('\n'), - input: currentMessageContent, - }); - - return new StreamingTextResponse(stream); -} diff --git a/examples/next-langchain/app/api/stream-data-basic/route.ts b/examples/next-langchain/app/api/stream-data-basic/route.ts deleted file mode 100644 index a0a806c0fc98..000000000000 --- a/examples/next-langchain/app/api/stream-data-basic/route.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { - StreamingTextResponse, - LangChainStream, - Message, - StreamData, -} from 'ai'; -import { ChatOpenAI } from 'langchain/chat_models/openai'; -import { AIMessage, HumanMessage } from 'langchain/schema'; - -export const dynamic = 'force-dynamic'; - -export async function POST(req: Request) { - const { messages } = await req.json(); - - const data = new StreamData(); - - // important: use LangChainStream from the AI SDK: - const { stream, handlers } = LangChainStream({ - onFinal: () => { - data.append(JSON.stringify({ key: 'value' })); // example - data.close(); - }, - }); - - const llm = new ChatOpenAI({ - streaming: true, - }); - - llm - .call( - (messages as Message[]).map(m => - m.role == 'user' - ? new HumanMessage(m.content) - : new AIMessage(m.content), - ), - {}, - [handlers], - ) - .catch(console.error); - - return new StreamingTextResponse(stream, {}, data); -} diff --git a/examples/next-langchain/app/api/stream-data-chain/route.ts b/examples/next-langchain/app/api/stream-data-chain/route.ts deleted file mode 100644 index eecb2782647c..000000000000 --- a/examples/next-langchain/app/api/stream-data-chain/route.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { LangChainStream, StreamingTextResponse, StreamData } from 'ai'; -import { LLMChain } from 'langchain/chains'; -import { OpenAI } from 'langchain/llms/openai'; -import { PromptTemplate } from 'langchain/prompts'; - -export const dynamic = 'force-dynamic'; - -export async function POST(req: Request) { - const { prompt: value } = await req.json(); - - 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 }); - - const data = new StreamData(); - - // important: use LangChainStream from the AI SDK: - const { stream, handlers } = LangChainStream({ - onFinal: () => { - data.append(JSON.stringify({ key: 'value' })); // example - data.close(); - }, - }); - - await chain.stream({ product: value }, { callbacks: [handlers] }); - - return new StreamingTextResponse(stream, {}, data); -} diff --git a/examples/next-langchain/app/completion-stream-data/page.tsx b/examples/next-langchain/app/completion-stream-data/page.tsx new file mode 100644 index 000000000000..d9c779a1089a --- /dev/null +++ b/examples/next-langchain/app/completion-stream-data/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import { useCompletion } from 'ai/react'; + +export default function Completion() { + const { completion, input, handleInputChange, handleSubmit, error, data } = + useCompletion({ api: '/api/completion-stream-data' }); + + return ( +
+

+ useCompletion Example +

+ {data && ( +
+          {JSON.stringify(data, null, 2)}
+        
+ )} + {error && ( +
+ {error.message} +
+ )} + {completion} +
+ +
+
+ ); +} diff --git a/examples/next-langchain/app/stream-data-chain/page.tsx b/examples/next-langchain/app/completion/page.tsx similarity index 73% rename from examples/next-langchain/app/stream-data-chain/page.tsx rename to examples/next-langchain/app/completion/page.tsx index 7b6f195ab0e1..5683e64d158b 100644 --- a/examples/next-langchain/app/stream-data-chain/page.tsx +++ b/examples/next-langchain/app/completion/page.tsx @@ -4,15 +4,15 @@ import { useCompletion } from 'ai/react'; export default function Chat() { const { completion, input, handleInputChange, handleSubmit, error } = - useCompletion({ api: '/api/stream-data-chain' }); + useCompletion(); return (
-

- useCompletion / stream-data-chain Example +

+ useCompletion Example

{error && ( -
+
{error.message}
)} @@ -21,7 +21,7 @@ export default function Chat() { diff --git a/examples/next-langchain/app/docs/page.tsx b/examples/next-langchain/app/docs/page.tsx deleted file mode 100644 index 4549037e59e6..000000000000 --- a/examples/next-langchain/app/docs/page.tsx +++ /dev/null @@ -1,32 +0,0 @@ -'use client'; - -import { useChat } from 'ai/react'; - -export default function Chat() { - const { messages, input, handleInputChange, handleSubmit } = useChat({ - api: '/api/docs', - }); - - return ( -
- {messages.map(m => ( -
- {m.role === 'user' ? 'User: ' : 'AI: '} - {m.content} -
- ))} - -
- - -
-
- ); -} diff --git a/examples/next-langchain/app/page.tsx b/examples/next-langchain/app/page.tsx index 2ee7ead43db2..2e13bc84e609 100644 --- a/examples/next-langchain/app/page.tsx +++ b/examples/next-langchain/app/page.tsx @@ -6,7 +6,7 @@ export default function Chat() { const { messages, input, handleInputChange, handleSubmit } = useChat(); return ( -
+
{messages.length > 0 ? messages.map(m => (
@@ -18,7 +18,7 @@ export default function Chat() {
- {messages.length > 0 - ? messages.map(m => ( -
- {m.role === 'user' ? 'User: ' : 'AI: '} - {m.content} -
- )) - : null} - - - -
-
- ); -} diff --git a/examples/next-langchain/package.json b/examples/next-langchain/package.json index dfb3107e4961..2a7267b26a64 100644 --- a/examples/next-langchain/package.json +++ b/examples/next-langchain/package.json @@ -9,8 +9,9 @@ "lint": "next lint" }, "dependencies": { + "@langchain/openai": "0.0.28", "ai": "latest", - "langchain": "^0.0.196", + "langchain": "0.1.36", "next": "latest", "react": "18.2.0", "react-dom": "^18.2.0" diff --git a/packages/core/streams/index.ts b/packages/core/streams/index.ts index 6178fb215547..153e9231a6d5 100644 --- a/packages/core/streams/index.ts +++ b/packages/core/streams/index.ts @@ -9,6 +9,7 @@ export * from './cohere-stream'; export * from './google-generative-ai-stream'; export * from './huggingface-stream'; export * from './inkeep-stream'; +export * as LangChainAdapter from './langchain-adapter'; export * from './langchain-stream'; export * from './mistral-stream'; export * from './openai-stream'; diff --git a/packages/core/streams/langchain-adapter.ts b/packages/core/streams/langchain-adapter.ts new file mode 100644 index 000000000000..5c0b3b0f24f9 --- /dev/null +++ b/packages/core/streams/langchain-adapter.ts @@ -0,0 +1,66 @@ +import { + AIStreamCallbacksAndOptions, + createCallbacksTransformer, +} from './ai-stream'; +import { createStreamDataTransformer } from './stream-data'; + +type LangChainImageDetail = 'auto' | 'low' | 'high'; + +type LangChainMessageContentText = { + type: 'text'; + text: string; +}; + +type LangChainMessageContentImageUrl = { + type: 'image_url'; + image_url: + | string + | { + url: string; + detail?: LangChainImageDetail; + }; +}; + +type LangChainMessageContentComplex = + | LangChainMessageContentText + | LangChainMessageContentImageUrl + | (Record & { + type?: 'text' | 'image_url' | string; + }) + | (Record & { + type?: never; + }); + +type LangChainMessageContent = string | LangChainMessageContentComplex[]; + +type LangChainAIMessageChunk = { + content: LangChainMessageContent; +}; + +/** +Converts the result of a LangChain Expression Language stream invocation to an AIStream. + */ +export function toAIStream( + stream: ReadableStream, + callbacks?: AIStreamCallbacksAndOptions, +) { + return stream + .pipeThrough( + new TransformStream({ + transform: async (chunk, controller) => { + if (typeof chunk.content === 'string') { + controller.enqueue(chunk.content); + } else { + const content: LangChainMessageContentComplex[] = chunk.content; + for (const item of content) { + if (item.type === 'text') { + controller.enqueue(item.text); + } + } + } + }, + }), + ) + .pipeThrough(createCallbacksTransformer(callbacks)) + .pipeThrough(createStreamDataTransformer()); +} diff --git a/packages/core/streams/langchain-stream.ts b/packages/core/streams/langchain-stream.ts index 1fec69374579..7bb73ee2c90d 100644 --- a/packages/core/streams/langchain-stream.ts +++ b/packages/core/streams/langchain-stream.ts @@ -4,6 +4,9 @@ import { } from './ai-stream'; import { createStreamDataTransformer } from './stream-data'; +/** +@deprecated Use LangChainAdapter.toAIStream() instead. + */ export function LangChainStream(callbacks?: AIStreamCallbacksAndOptions) { const stream = new TransformStream(); const writer = stream.writable.getWriter(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ec45bfd982b..df13d0622e9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -561,12 +561,15 @@ importers: examples/next-langchain: dependencies: + '@langchain/openai': + specifier: 0.0.28 + version: 0.0.28 ai: specifier: latest version: link:../../packages/core langchain: - specifier: ^0.0.196 - version: 0.0.196 + specifier: 0.1.36 + version: 0.1.36 next: specifier: latest version: 14.2.3(react-dom@18.2.0)(react@18.2.0) @@ -4384,6 +4387,344 @@ packages: resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} dev: true + /@langchain/community@0.0.55: + resolution: {integrity: sha512-JMlmzsOtdexQavFWPRZHAnlTnEKnYqlqFXo7YSVOGclW0pAaePT6oH+BNLhX9uCb2wZYBFUgdKm5eN2CpHb3eg==} + engines: {node: '>=18'} + peerDependencies: + '@aws-crypto/sha256-js': ^5.0.0 + '@aws-sdk/client-bedrock-agent-runtime': ^3.485.0 + '@aws-sdk/client-bedrock-runtime': ^3.422.0 + '@aws-sdk/client-dynamodb': ^3.310.0 + '@aws-sdk/client-kendra': ^3.352.0 + '@aws-sdk/client-lambda': ^3.310.0 + '@aws-sdk/client-sagemaker-runtime': ^3.310.0 + '@aws-sdk/client-sfn': ^3.310.0 + '@aws-sdk/credential-provider-node': ^3.388.0 + '@azure/search-documents': ^12.0.0 + '@clickhouse/client': ^0.2.5 + '@cloudflare/ai': '*' + '@datastax/astra-db-ts': ^1.0.0 + '@elastic/elasticsearch': ^8.4.0 + '@getmetal/metal-sdk': '*' + '@getzep/zep-js': ^0.9.0 + '@gomomento/sdk': ^1.51.1 + '@gomomento/sdk-core': ^1.51.1 + '@google-ai/generativelanguage': ^0.2.1 + '@gradientai/nodejs-sdk': ^1.2.0 + '@huggingface/inference': ^2.6.4 + '@mozilla/readability': '*' + '@neondatabase/serverless': '*' + '@opensearch-project/opensearch': '*' + '@pinecone-database/pinecone': '*' + '@planetscale/database': ^1.8.0 + '@premai/prem-sdk': ^0.3.25 + '@qdrant/js-client-rest': ^1.8.2 + '@raycast/api': ^1.55.2 + '@rockset/client': ^0.9.1 + '@smithy/eventstream-codec': ^2.0.5 + '@smithy/protocol-http': ^3.0.6 + '@smithy/signature-v4': ^2.0.10 + '@smithy/util-utf8': ^2.0.0 + '@supabase/postgrest-js': ^1.1.1 + '@supabase/supabase-js': ^2.10.0 + '@tensorflow-models/universal-sentence-encoder': '*' + '@tensorflow/tfjs-converter': '*' + '@tensorflow/tfjs-core': '*' + '@upstash/redis': ^1.20.6 + '@upstash/vector': ^1.0.7 + '@vercel/kv': ^0.2.3 + '@vercel/postgres': ^0.5.0 + '@writerai/writer-sdk': ^0.40.2 + '@xata.io/client': ^0.28.0 + '@xenova/transformers': ^2.5.4 + '@zilliz/milvus2-sdk-node': '>=2.2.7' + better-sqlite3: ^9.4.0 + cassandra-driver: ^4.7.2 + cborg: ^4.1.1 + chromadb: '*' + closevector-common: 0.1.3 + closevector-node: 0.1.6 + closevector-web: 0.1.6 + cohere-ai: '*' + convex: ^1.3.1 + couchbase: ^4.3.0 + discord.js: ^14.14.1 + dria: ^0.0.3 + duck-duck-scrape: ^2.2.5 + faiss-node: ^0.5.1 + firebase-admin: ^11.9.0 || ^12.0.0 + google-auth-library: ^8.9.0 + googleapis: ^126.0.1 + hnswlib-node: ^3.0.0 + html-to-text: ^9.0.5 + interface-datastore: ^8.2.11 + ioredis: ^5.3.2 + it-all: ^3.0.4 + jsdom: '*' + jsonwebtoken: ^9.0.2 + llmonitor: ^0.5.9 + lodash: ^4.17.21 + lunary: ^0.6.11 + mongodb: '>=5.2.0' + mysql2: ^3.3.3 + neo4j-driver: '*' + node-llama-cpp: '*' + pg: ^8.11.0 + pg-copy-streams: ^6.0.5 + pickleparser: ^0.2.1 + portkey-ai: ^0.1.11 + redis: '*' + replicate: ^0.18.0 + typeorm: ^0.3.12 + typesense: ^1.5.3 + usearch: ^1.1.1 + vectordb: ^0.1.4 + voy-search: 0.6.2 + weaviate-ts-client: '*' + web-auth-library: ^1.0.3 + ws: ^8.14.2 + peerDependenciesMeta: + '@aws-crypto/sha256-js': + optional: true + '@aws-sdk/client-bedrock-agent-runtime': + optional: true + '@aws-sdk/client-bedrock-runtime': + optional: true + '@aws-sdk/client-dynamodb': + optional: true + '@aws-sdk/client-kendra': + optional: true + '@aws-sdk/client-lambda': + optional: true + '@aws-sdk/client-sagemaker-runtime': + optional: true + '@aws-sdk/client-sfn': + optional: true + '@aws-sdk/credential-provider-node': + optional: true + '@azure/search-documents': + optional: true + '@clickhouse/client': + optional: true + '@cloudflare/ai': + optional: true + '@datastax/astra-db-ts': + optional: true + '@elastic/elasticsearch': + optional: true + '@getmetal/metal-sdk': + optional: true + '@getzep/zep-js': + optional: true + '@gomomento/sdk': + optional: true + '@gomomento/sdk-core': + optional: true + '@google-ai/generativelanguage': + optional: true + '@gradientai/nodejs-sdk': + optional: true + '@huggingface/inference': + optional: true + '@mozilla/readability': + optional: true + '@neondatabase/serverless': + optional: true + '@opensearch-project/opensearch': + optional: true + '@pinecone-database/pinecone': + optional: true + '@planetscale/database': + optional: true + '@premai/prem-sdk': + optional: true + '@qdrant/js-client-rest': + optional: true + '@raycast/api': + optional: true + '@rockset/client': + optional: true + '@smithy/eventstream-codec': + optional: true + '@smithy/protocol-http': + optional: true + '@smithy/signature-v4': + optional: true + '@smithy/util-utf8': + optional: true + '@supabase/postgrest-js': + optional: true + '@supabase/supabase-js': + optional: true + '@tensorflow-models/universal-sentence-encoder': + optional: true + '@tensorflow/tfjs-converter': + optional: true + '@tensorflow/tfjs-core': + optional: true + '@upstash/redis': + optional: true + '@upstash/vector': + optional: true + '@vercel/kv': + optional: true + '@vercel/postgres': + optional: true + '@writerai/writer-sdk': + optional: true + '@xata.io/client': + optional: true + '@xenova/transformers': + optional: true + '@zilliz/milvus2-sdk-node': + optional: true + better-sqlite3: + optional: true + cassandra-driver: + optional: true + cborg: + optional: true + chromadb: + optional: true + closevector-common: + optional: true + closevector-node: + optional: true + closevector-web: + optional: true + cohere-ai: + optional: true + convex: + optional: true + couchbase: + optional: true + discord.js: + optional: true + dria: + optional: true + duck-duck-scrape: + optional: true + faiss-node: + optional: true + firebase-admin: + optional: true + google-auth-library: + optional: true + googleapis: + optional: true + hnswlib-node: + optional: true + html-to-text: + optional: true + interface-datastore: + optional: true + ioredis: + optional: true + it-all: + optional: true + jsdom: + optional: true + jsonwebtoken: + optional: true + llmonitor: + optional: true + lodash: + optional: true + lunary: + optional: true + mongodb: + optional: true + mysql2: + optional: true + neo4j-driver: + optional: true + node-llama-cpp: + optional: true + pg: + optional: true + pg-copy-streams: + optional: true + pickleparser: + optional: true + portkey-ai: + optional: true + redis: + optional: true + replicate: + optional: true + typeorm: + optional: true + typesense: + optional: true + usearch: + optional: true + vectordb: + optional: true + voy-search: + optional: true + weaviate-ts-client: + optional: true + web-auth-library: + optional: true + ws: + optional: true + dependencies: + '@langchain/core': 0.1.62(openai@4.44.0) + '@langchain/openai': 0.0.28 + expr-eval: 2.0.2 + flat: 5.0.2 + langsmith: 0.1.23(openai@4.44.0) + uuid: 9.0.1 + zod: 3.23.4 + zod-to-json-schema: 3.22.5(zod@3.23.4) + transitivePeerDependencies: + - encoding + - openai + dev: false + + /@langchain/core@0.1.62(openai@4.44.0): + resolution: {integrity: sha512-PsBM/x0wxVvVPawKak2MFjxEneogipf212yO+rLf+2M3RDepCpYCdn1NBWgfmC+AWpmBYx/8zM7Y4QW7Kg2Wjw==} + engines: {node: '>=18'} + dependencies: + ansi-styles: 5.2.0 + camelcase: 6.3.0 + decamelize: 1.2.0 + js-tiktoken: 1.0.11 + langsmith: 0.1.23(openai@4.44.0) + ml-distance: 4.0.1 + mustache: 4.2.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + zod: 3.23.4 + zod-to-json-schema: 3.22.5(zod@3.23.4) + transitivePeerDependencies: + - openai + dev: false + + /@langchain/openai@0.0.28: + resolution: {integrity: sha512-2s1RA3/eAnz4ahdzsMPBna9hfAqpFNlWdHiPxVGZ5yrhXsbLWWoPcF+22LCk9t0HJKtazi2GCIWc0HVXH9Abig==} + engines: {node: '>=18'} + dependencies: + '@langchain/core': 0.1.62(openai@4.44.0) + js-tiktoken: 1.0.11 + openai: 4.44.0 + zod: 3.23.4 + zod-to-json-schema: 3.22.5(zod@3.23.4) + transitivePeerDependencies: + - encoding + dev: false + + /@langchain/textsplitters@0.0.0: + resolution: {integrity: sha512-3hPesWomnmVeYMppEGYbyv0v/sRUugUdlFBNn9m1ueJYHAIKbvCErkWxNUH3guyKKYgJVrkvZoQxcd9faucSaw==} + engines: {node: '>=18'} + dependencies: + '@langchain/core': 0.1.62(openai@4.44.0) + js-tiktoken: 1.0.11 + transitivePeerDependencies: + - openai + dev: false + /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} dependencies: @@ -11689,6 +12030,12 @@ packages: engines: {node: '>=0.10.0'} dev: true + /js-tiktoken@1.0.11: + resolution: {integrity: sha512-PajXFLq2vx7/8jllQZ43vzNpAai/0MOVdJjW/UrNyJorNQRTjHrqdGJG/mjHVy7h9M6dW6CaG43eNLMYFkTh6w==} + dependencies: + base64-js: 1.5.1 + dev: false + /js-tiktoken@1.0.7: resolution: {integrity: sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==} dependencies: @@ -11958,6 +12305,7 @@ packages: p-queue: 6.6.2 p-retry: 4.6.2 uuid: 9.0.1 + dev: true /langchain@0.0.129(@mozilla/readability@0.4.4)(jsdom@23.0.0): resolution: {integrity: sha512-KHJANXuwaq4CJ23HbLfp4c23S75UsI4Mh5yXIZT5bdsivLN4YmMphIudPMf27Y+5gZbiJzjlZFeM116M0RQ52Q==} @@ -12199,7 +12547,7 @@ packages: - encoding dev: false - /langchain@0.0.196: + /langchain@0.0.196(@aws-sdk/client-bedrock-runtime@3.451.0)(@huggingface/inference@2.6.4)(cohere-ai@7.6.2)(jsdom@23.0.0): resolution: {integrity: sha512-kt17GGTDFWHNv3jJOIXymsQxfa+h9UQ6hrHbhur+V2pV6RBKO5E+RRCvnCqBzbnOPtrlkENF6Wl3Ezmsfo21dg==} engines: {node: '>=18'} peerDependencies: @@ -12500,140 +12848,88 @@ packages: optional: true dependencies: '@anthropic-ai/sdk': 0.9.1 + '@aws-sdk/client-bedrock-runtime': 3.451.0 + '@huggingface/inference': 2.6.4 binary-extensions: 2.2.0 + cohere-ai: 7.6.2 expr-eval: 2.0.2 flat: 5.0.2 js-tiktoken: 1.0.7 js-yaml: 4.1.0 + jsdom: 23.0.0 jsonpointer: 5.0.1 langchain-core: 0.0.1 langchainhub: 0.0.6 langsmith: 0.0.48 ml-distance: 4.0.1 - openai: 4.28.4 + openai: 4.42.0 openapi-types: 12.1.3 p-retry: 4.6.2 uuid: 9.0.1 yaml: 2.3.4 - zod: 3.22.4 - zod-to-json-schema: 3.20.3(zod@3.22.4) + zod: 3.23.4 + zod-to-json-schema: 3.20.3(zod@3.23.4) transitivePeerDependencies: - encoding - dev: false + dev: true - /langchain@0.0.196(@aws-sdk/client-bedrock-runtime@3.451.0)(@huggingface/inference@2.6.4)(cohere-ai@7.6.2)(jsdom@23.0.0): - resolution: {integrity: sha512-kt17GGTDFWHNv3jJOIXymsQxfa+h9UQ6hrHbhur+V2pV6RBKO5E+RRCvnCqBzbnOPtrlkENF6Wl3Ezmsfo21dg==} + /langchain@0.1.36: + resolution: {integrity: sha512-NTbnCL/jKWIeEI//Nm1oG8nhW3vkYWvEMr1MPotmTThTfeKfO87eV/OAzAyh6Ruy6GFs/qofRgQZGIe6XvXTNQ==} engines: {node: '>=18'} peerDependencies: - '@aws-crypto/sha256-js': ^5.0.0 - '@aws-sdk/client-bedrock-runtime': ^3.422.0 - '@aws-sdk/client-dynamodb': ^3.310.0 - '@aws-sdk/client-kendra': ^3.352.0 - '@aws-sdk/client-lambda': ^3.310.0 '@aws-sdk/client-s3': ^3.310.0 '@aws-sdk/client-sagemaker-runtime': ^3.310.0 '@aws-sdk/client-sfn': ^3.310.0 '@aws-sdk/credential-provider-node': ^3.388.0 '@azure/storage-blob': ^12.15.0 - '@clickhouse/client': ^0.0.14 - '@cloudflare/ai': ^1.0.12 - '@elastic/elasticsearch': ^8.4.0 - '@getmetal/metal-sdk': '*' - '@getzep/zep-js': ^0.9.0 - '@gomomento/sdk': ^1.47.1 - '@gomomento/sdk-core': ^1.47.1 - '@gomomento/sdk-web': ^1.47.1 + '@gomomento/sdk': ^1.51.1 + '@gomomento/sdk-core': ^1.51.1 + '@gomomento/sdk-web': ^1.51.1 '@google-ai/generativelanguage': ^0.2.1 - '@google-cloud/storage': ^6.10.1 - '@huggingface/inference': ^2.6.4 - '@mozilla/readability': '*' + '@google-cloud/storage': ^6.10.1 || ^7.7.0 + '@mendable/firecrawl-js': ^0.0.13 '@notionhq/client': ^2.2.10 - '@opensearch-project/opensearch': '*' - '@pinecone-database/pinecone': ^1.1.0 - '@planetscale/database': ^1.8.0 - '@qdrant/js-client-rest': ^1.2.0 - '@raycast/api': ^1.55.2 - '@rockset/client': ^0.9.1 - '@smithy/eventstream-codec': ^2.0.5 - '@smithy/protocol-http': ^3.0.6 - '@smithy/signature-v4': ^2.0.10 - '@smithy/util-utf8': ^2.0.0 - '@supabase/postgrest-js': ^1.1.1 + '@pinecone-database/pinecone': '*' '@supabase/supabase-js': ^2.10.0 - '@tensorflow-models/universal-sentence-encoder': '*' - '@tensorflow/tfjs-converter': '*' - '@tensorflow/tfjs-core': '*' - '@upstash/redis': ^1.20.6 '@vercel/kv': ^0.2.3 - '@vercel/postgres': ^0.5.0 - '@writerai/writer-sdk': ^0.40.2 - '@xata.io/client': ^0.25.1 - '@xenova/transformers': ^2.5.4 - '@zilliz/milvus2-sdk-node': '>=2.2.7' + '@xata.io/client': ^0.28.0 apify-client: ^2.7.1 - assemblyai: ^2.0.2 + assemblyai: ^4.0.0 axios: '*' - cassandra-driver: ^4.7.2 cheerio: ^1.0.0-rc.12 chromadb: '*' - closevector-common: 0.1.0-alpha.1 - closevector-node: 0.1.0-alpha.10 - closevector-web: 0.1.0-alpha.16 - cohere-ai: '>=6.0.0' convex: ^1.3.1 + couchbase: ^4.3.0 d3-dsv: ^2.0.0 epub2: ^3.0.1 - faiss-node: ^0.5.1 - fast-xml-parser: ^4.2.7 - firebase-admin: ^11.9.0 + faiss-node: '*' + fast-xml-parser: '*' google-auth-library: ^8.9.0 - googleapis: ^126.0.1 - hnswlib-node: ^1.4.2 + handlebars: ^4.7.8 html-to-text: ^9.0.5 ignore: ^5.2.0 ioredis: ^5.3.2 jsdom: '*' - llmonitor: ^0.5.9 - lodash: ^4.17.21 - mammoth: '*' - mongodb: ^5.2.0 - mysql2: ^3.3.3 - neo4j-driver: '*' + mammoth: ^1.6.0 + mongodb: '>=5.2.0' node-llama-cpp: '*' notion-to-md: ^3.1.0 + officeparser: ^4.0.4 pdf-parse: 1.1.1 peggy: ^3.0.2 - pg: ^8.11.0 - pg-copy-streams: ^6.0.5 - pickleparser: ^0.2.1 playwright: ^1.32.1 - portkey-ai: ^0.1.11 puppeteer: ^19.7.2 + pyodide: ^0.24.1 redis: ^4.6.4 - replicate: ^0.18.0 sonix-speech-recognition: ^2.1.1 - srt-parser-2: ^1.2.2 + srt-parser-2: ^1.2.3 typeorm: ^0.3.12 - typesense: ^1.5.3 - usearch: ^1.1.1 - vectordb: ^0.1.4 - voy-search: 0.6.2 - weaviate-ts-client: ^1.4.0 + weaviate-ts-client: '*' web-auth-library: ^1.0.3 ws: ^8.14.2 youtube-transcript: ^1.0.6 - youtubei.js: ^5.8.0 + youtubei.js: ^9.1.0 peerDependenciesMeta: - '@aws-crypto/sha256-js': - optional: true - '@aws-sdk/client-bedrock-runtime': - optional: true - '@aws-sdk/client-dynamodb': - optional: true - '@aws-sdk/client-kendra': - optional: true - '@aws-sdk/client-lambda': - optional: true '@aws-sdk/client-s3': optional: true '@aws-sdk/client-sagemaker-runtime': @@ -12644,16 +12940,6 @@ packages: optional: true '@azure/storage-blob': optional: true - '@clickhouse/client': - optional: true - '@cloudflare/ai': - optional: true - '@elastic/elasticsearch': - optional: true - '@getmetal/metal-sdk': - optional: true - '@getzep/zep-js': - optional: true '@gomomento/sdk': optional: true '@gomomento/sdk-core': @@ -12664,78 +12950,32 @@ packages: optional: true '@google-cloud/storage': optional: true - '@huggingface/inference': - optional: true - '@mozilla/readability': + '@mendable/firecrawl-js': optional: true '@notionhq/client': optional: true - '@opensearch-project/opensearch': - optional: true '@pinecone-database/pinecone': optional: true - '@planetscale/database': - optional: true - '@qdrant/js-client-rest': - optional: true - '@raycast/api': - optional: true - '@rockset/client': - optional: true - '@smithy/eventstream-codec': - optional: true - '@smithy/protocol-http': - optional: true - '@smithy/signature-v4': - optional: true - '@smithy/util-utf8': - optional: true - '@supabase/postgrest-js': - optional: true '@supabase/supabase-js': optional: true - '@tensorflow-models/universal-sentence-encoder': - optional: true - '@tensorflow/tfjs-converter': - optional: true - '@tensorflow/tfjs-core': - optional: true - '@upstash/redis': - optional: true '@vercel/kv': optional: true - '@vercel/postgres': - optional: true - '@writerai/writer-sdk': - optional: true '@xata.io/client': optional: true - '@xenova/transformers': - optional: true - '@zilliz/milvus2-sdk-node': - optional: true apify-client: optional: true assemblyai: optional: true axios: optional: true - cassandra-driver: - optional: true cheerio: optional: true chromadb: optional: true - closevector-common: - optional: true - closevector-node: - optional: true - closevector-web: - optional: true - cohere-ai: - optional: true convex: optional: true + couchbase: + optional: true d3-dsv: optional: true epub2: @@ -12744,13 +12984,9 @@ packages: optional: true fast-xml-parser: optional: true - firebase-admin: - optional: true google-auth-library: optional: true - googleapis: - optional: true - hnswlib-node: + handlebars: optional: true html-to-text: optional: true @@ -12760,41 +12996,27 @@ packages: optional: true jsdom: optional: true - llmonitor: - optional: true - lodash: - optional: true mammoth: optional: true mongodb: optional: true - mysql2: - optional: true - neo4j-driver: - optional: true node-llama-cpp: optional: true notion-to-md: optional: true + officeparser: + optional: true pdf-parse: optional: true peggy: optional: true - pg: - optional: true - pg-copy-streams: - optional: true - pickleparser: - optional: true playwright: optional: true - portkey-ai: - optional: true puppeteer: optional: true - redis: + pyodide: optional: true - replicate: + redis: optional: true sonix-speech-recognition: optional: true @@ -12802,14 +13024,6 @@ packages: optional: true typeorm: optional: true - typesense: - optional: true - usearch: - optional: true - vectordb: - optional: true - voy-search: - optional: true weaviate-ts-client: optional: true web-auth-library: @@ -12822,33 +13036,102 @@ packages: optional: true dependencies: '@anthropic-ai/sdk': 0.9.1 - '@aws-sdk/client-bedrock-runtime': 3.451.0 - '@huggingface/inference': 2.6.4 + '@langchain/community': 0.0.55 + '@langchain/core': 0.1.62(openai@4.44.0) + '@langchain/openai': 0.0.28 + '@langchain/textsplitters': 0.0.0 binary-extensions: 2.2.0 - cohere-ai: 7.6.2 - expr-eval: 2.0.2 - flat: 5.0.2 js-tiktoken: 1.0.7 js-yaml: 4.1.0 - jsdom: 23.0.0 jsonpointer: 5.0.1 - langchain-core: 0.0.1 - langchainhub: 0.0.6 - langsmith: 0.0.48 + langchainhub: 0.0.10 + langsmith: 0.1.23(openai@4.44.0) ml-distance: 4.0.1 - openai: 4.42.0 openapi-types: 12.1.3 p-retry: 4.6.2 uuid: 9.0.1 yaml: 2.3.4 zod: 3.23.4 - zod-to-json-schema: 3.20.3(zod@3.23.4) + zod-to-json-schema: 3.22.5(zod@3.23.4) transitivePeerDependencies: + - '@aws-crypto/sha256-js' + - '@aws-sdk/client-bedrock-agent-runtime' + - '@aws-sdk/client-bedrock-runtime' + - '@aws-sdk/client-dynamodb' + - '@aws-sdk/client-kendra' + - '@aws-sdk/client-lambda' + - '@azure/search-documents' + - '@clickhouse/client' + - '@cloudflare/ai' + - '@datastax/astra-db-ts' + - '@elastic/elasticsearch' + - '@getmetal/metal-sdk' + - '@getzep/zep-js' + - '@gradientai/nodejs-sdk' + - '@huggingface/inference' + - '@mozilla/readability' + - '@neondatabase/serverless' + - '@opensearch-project/opensearch' + - '@planetscale/database' + - '@premai/prem-sdk' + - '@qdrant/js-client-rest' + - '@raycast/api' + - '@rockset/client' + - '@smithy/eventstream-codec' + - '@smithy/protocol-http' + - '@smithy/signature-v4' + - '@smithy/util-utf8' + - '@supabase/postgrest-js' + - '@tensorflow-models/universal-sentence-encoder' + - '@tensorflow/tfjs-converter' + - '@tensorflow/tfjs-core' + - '@upstash/redis' + - '@upstash/vector' + - '@vercel/postgres' + - '@writerai/writer-sdk' + - '@xenova/transformers' + - '@zilliz/milvus2-sdk-node' + - better-sqlite3 + - cassandra-driver + - cborg + - closevector-common + - closevector-node + - closevector-web + - cohere-ai + - discord.js + - dria + - duck-duck-scrape - encoding - dev: true + - firebase-admin + - googleapis + - hnswlib-node + - interface-datastore + - it-all + - jsonwebtoken + - llmonitor + - lodash + - lunary + - mysql2 + - neo4j-driver + - openai + - pg + - pg-copy-streams + - pickleparser + - portkey-ai + - replicate + - typesense + - usearch + - vectordb + - voy-search + dev: false + + /langchainhub@0.0.10: + resolution: {integrity: sha512-mOVso7TGTMSlvTTUR1b4zUIMtu8zgie/pcwRm1SeooWwuHYMQovoNXjT6gEjvWEZ6cjt4gVH+1lu2tp1/phyIQ==} + dev: false /langchainhub@0.0.6: resolution: {integrity: sha512-SW6105T+YP1cTe0yMf//7kyshCgvCTyFBMTgH2H3s9rTAR4e+78DA/BBrUL/Mt4Q5eMWui7iGuAYb3pgGsdQ9w==} + dev: true /langsmith@0.0.48: resolution: {integrity: sha512-s0hW8iZ90Q9XLTnDK0Pgee245URV3b1cXQjPDj5OKm1+KN7iSK1pKx+4CO7RcFLz58Ixe7Mt+mVcomYqUuryxQ==} @@ -12860,6 +13143,22 @@ packages: p-retry: 4.6.2 uuid: 9.0.1 + /langsmith@0.1.23(openai@4.44.0): + resolution: {integrity: sha512-lc6BpC82zpHNDW5qNO/+eQrN9YNK7ElZIU0GIHZrdKTclaqAXYkJB2C3hM2sxdkdp0HbFYOLa0PxxZLzNkMloQ==} + peerDependencies: + openai: '*' + peerDependenciesMeta: + openai: + optional: true + dependencies: + '@types/uuid': 9.0.7 + commander: 10.0.1 + openai: 4.44.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + /language-subtag-registry@0.3.22: resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==} @@ -13585,6 +13884,11 @@ packages: yargs: 17.7.2 dev: true + /mustache@4.2.0: + resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} + hasBin: true + dev: false + /mute-stream@0.0.8: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} dev: true @@ -14415,6 +14719,22 @@ packages: transitivePeerDependencies: - encoding + /openai@4.44.0: + resolution: {integrity: sha512-jVpDIJsBAR83rVbIHPuWRr9UkFc5DaH9ev2kt2IQAhKCs73DBRoFOa5SwtqfN7/CcBdIGBdygpmpc0gsFaV+Ow==} + hasBin: true + dependencies: + '@types/node': 18.18.9 + '@types/node-fetch': 2.6.9 + abort-controller: 3.0.0 + agentkeepalive: 4.5.0 + form-data-encoder: 1.7.2 + formdata-node: 4.4.1 + node-fetch: 2.7.0 + web-streams-polyfill: 3.2.1 + transitivePeerDependencies: + - encoding + dev: false + /openapi-types@12.1.3: resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==} @@ -18853,14 +19173,6 @@ packages: readable-stream: 3.6.2 dev: true - /zod-to-json-schema@3.20.3(zod@3.22.4): - resolution: {integrity: sha512-/Q3wnyxAfCt94ZcrGiXXoiAfRqasxl9CX64LZ9fj+4dKH68zulUtU0uk1WMxQPfAxQ0ZI70dKzcoW7hHj+DwSQ==} - peerDependencies: - zod: ^3.20.0 - dependencies: - zod: 3.22.4 - dev: false - /zod-to-json-schema@3.20.3(zod@3.23.4): resolution: {integrity: sha512-/Q3wnyxAfCt94ZcrGiXXoiAfRqasxl9CX64LZ9fj+4dKH68zulUtU0uk1WMxQPfAxQ0ZI70dKzcoW7hHj+DwSQ==} peerDependencies: