Skip to main content

llama-index llms langchain integration

Project description

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_llms_langchain-0.5.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file llama_index_llms_langchain-0.5.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_llms_langchain-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7781510ff6179ad7ba5969d8803290e12ae55e6944ecd2d4b325caec270fb531
MD5 d6577cfc62849e5978e758626ccd17ae
BLAKE2b-256 5a5759d54fa492e5361b7521d248e4eee0cd252f47d4cb6ad391a285fe1e6f77

See more details on using hashes here.

File details

Details for the file llama_index_llms_langchain-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_llms_langchain-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93e2d643f716eb840752a04a2b4e216627bb6b3a54fbae9e80db0b4b017e2c08
MD5 923de5b9139f6a1be9b092a6b9ddddde
BLAKE2b-256 660e7b4ad3dd0879417765daa4e52563a8da53c9b197b4e9ea6d6144d5a9e2a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page