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.4.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

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