A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/v0.1/docs/expression_language/primitives/ below:

Primitives | 🦜️🔗 LangChain

This is documentation for LangChain v0.1, which is no longer actively maintained. Check out the docs for the

latest version here

.

This is documentation for LangChain v0.1, which is no longer actively maintained.

Primitives

In addition to various components that are usable with LCEL, LangChain also includes various primitives that help pass around and format data, bind arguments, invoke custom logic, and more.

This section goes into greater depth on where and how some of these components are useful.

📄️ Sequences: Chaining runnables

One key advantage of the Runnable interface is that any two runnables can be "chained" together into sequences. The output of the previous runnable's .invoke() call is passed as input to the next runnable. This can be done using the pipe operator (|), or the more explicit .pipe() method, which does the same thing. The resulting RunnableSequence is itself a runnable, which means it can be invoked, streamed, or piped just like any other runnable.

📄️ Parallel: Format data

The RunnableParallel primitive is essentially a dict whose values are runnables (or things that can be coerced to runnables, like functions). It runs all of its values in parallel, and each value is called with the overall input of the RunnableParallel. The final return value is a dict with the results of each value under its appropriate key.

📄️ Binding: Attach runtime args

Sometimes we want to invoke a Runnable within a Runnable sequence with constant arguments that are not part of the output of the preceding Runnable in the sequence, and which are not part of the user input. We can use Runnable.bind() to pass these arguments in.

📄️ Lambda: Run custom functions

You can use arbitrary functions in the pipeline.

📄️ Passthrough: Pass through inputs

RunnablePassthrough on its own allows you to pass inputs unchanged. This typically is used in conjuction with RunnableParallel to pass data through to a new key in the map.

📄️ Assign: Add values to state

The RunnablePassthrough.assign(...) static method takes an input value and adds the extra arguments passed to the assign function.

📄️ Configure runtime chain internals

Oftentimes you may want to experiment with, or even expose to the end user, multiple different ways of doing things.

📄️ Primitives

In addition to various components that are usable with LCEL, LangChain also includes various primitives

Help us out by providing feedback on this documentation page:

Previous

Runnable interface

Next

Sequences: Chaining runnables


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4