Skip to main content

LlamaIndex Llms Integration: Langchain

Installation

  1. Install the required Python packages:

    %pip install llama-index-llms-langchain
    

Usage

Import Required Libraries

from langchain.llms import OpenAI
from llama_index.llms.langchain import LangChainLLM

Initialize LangChain LLM

To create an instance of LangChainLLM with OpenAI:

llm = LangChainLLM(llm=OpenAI())

Generate Streaming Response

To generate a streaming response, use the following code:

response_gen = llm.stream_complete("Hi this is")
for delta in response_gen:
    print(delta.delta, end="")

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/langchain/

Release files for llama-index-llms-langchain 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-llms-langchain 0.9.0
File Size Uploaded
llama_index_llms_langchain-0.9.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-llms-langchain 0.9.0
File Interpreter ABI Platform
llama_index_llms_langchain-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / llama_index_llms_langchain-0.9.0.tar.gz

Download URL llama_index_llms_langchain-0.9.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3fd0cb671f28d1efef7617f0fffec7bbe20304ce66cdf34cd646b56b7b8f7d01
BLAKE2b-256 checksum
How to use checksums
a2d0f0940aabe16295be31073ca9896de01ac22a99f347748739cb605cb27397
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_llms_langchain-0.9.0-py3-none-any.whl

Download URL llama_index_llms_langchain-0.9.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7f966cea0a6d15f8cf5f52c4cfe59c5795ac6c06a99c3cc075003213b26c11b
BLAKE2b-256 checksum
How to use checksums
326f57b6b0a435c3691839967227b20557836ae719911685a3587a5fc08a328d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page