Langchain provides components and abstraction that is useful to for quick prototypes/POCs, while also allowing vendor agnostic way to work with LLMs.

  • By being vendor agnostic, users can interact with provider APIs in a consistent way.
  • Provided convenient components include:
    • A text splitter function.
    • A PDF loader etc.
    • A lightweight InMemoryVectorStore implementation.

Langchain has many resources which makes it easy to get started.

Specifically, I suggest the following:

Methods:

Invoking:

Runnable methods that result in the execution of the Runnable (e.g., invoke, batch, stream, astream_events) work with these input and output types.

  • invoke: Accepts an input and returns an output.
  • batch: Accepts a list of inputs and returns a list of outputs.
  • stream: Accepts an input and returns a generator that yields outputs.

The input type and output type vary by component:

ComponentInput TypeOutput Type
PromptdictionaryPromptValue
ChatModela string, list of chat messages or a PromptValueChatMessage
LLMa string, list of chat messages or a PromptValueString
OutputParserthe output of an LLM or ChatModelDepends on the parser
Retrievera stringList of Documents
Toola string or dictionary, depending on the toolDepends on the tool
(Documentation link)