LlamaIndex Llms Integration: Langchain
Installation
-
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)
| File | Size | Uploaded | |
|---|---|---|---|
| llama_index_llms_langchain-0.9.0.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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}
|