Skip to content

Files

Latest commit

jacoblee93bracesproulefriis
Sep 13, 2024
6c47c59 · Sep 13, 2024

History

History

cookbook

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 1, 2023
Apr 10, 2024
Apr 10, 2024
Apr 10, 2024
Sep 13, 2024
Oct 27, 2023
Nov 1, 2023

LangChain.js cookbook

Example code for building applications with LangChain.js, with an emphasis on more applied and end-to-end examples than contained in the main documentation.

Setup

These cookbooks are in Jupyter notebook form and use the Deno runtime and the experimental Deno Jupyter Kernel (requires >= Deno v1.37).

Full installation instructions are available here: https://docs.deno.com/runtime/manual/tools/jupyter

Note that you will also need to install the Python jupyter package, and that the syntax for imports and environment variables are slightly different from Node and the web. In particular, we use Deno.env.get() to retrieve environment variables, and e.g. import { PromptTemplate } from "https://esm.sh/langchain/prompts"; to import from a URL to match Deno conventions.

Notebook Description
rewrite.ipynb Handle real-world questions that contain extraneous, distracting information in your RAG chains by first rewriting them before performing retrieval.
rag_fusion.ipynb Turn user queries into more search friendly queries, then query a vector store and use reciprocal rank fusion to rank the results.
basic_critique_revise.ipynb Basic example of correcting an LLM's output using a pattern called critique-revise, where we highlight what part of the output is wrong and re-query the LLM for a correction.
step_back.ipynb Example of a step back prompting technique, where we ask the LLM to take a step back and rephrase the original query for a more search friendly question.