Skip to content

LangChain Hub

The LangChain Hub component lets you pull a ready‑made prompt from the LangChain Hub library and use it in your automation flow. It’s a quick way to add powerful, pre‑built prompts to your tasks without writing them from scratch.

How it Works

When you add this component to your dashboard, you first pick a prompt from the LangChain Hub list. The component then sends that prompt to the Langsmith & Langchain API, which stores and manages prompts. The API returns the prompt text, and the component outputs it as a Message that can be fed into any language‑model component (like an LLM or a text‑generation step).

Because the component talks to the Langsmith & Langchain API, you need to have a credential set up in Nappai. The credential holds your Langsmith API key, so the component can securely access the prompt library.

Inputs

Before you can use the component, make sure you have done the following:

  1. Set up a credential called Langsmith & Langchain API in the Nappai credentials section.
    The credential must contain your Langsmith API Key (e.g., <LANGSMITH_API_KEY>).

  2. Select that credential in the component’s Credential field.
    This field is not listed in the Input Fields section because it is a special credential selector.

Input Fields

  • LangChain Hub Prompt: The name of the prompt you want to use from the LangChain Hub library.
    This field is always visible.

Outputs

  • Build Prompt: A Message that contains the full prompt text retrieved from LangChain Hub.
    You can connect this output to any component that accepts a prompt, such as an LLM or a text‑generation block.

Usage Example

  1. Add the LangChain Hub component to your workflow.
  2. Configure the credential as described above.
  3. Choose a prompt from the LangChain Hub list (e.g., “Summarize a paragraph”).
  4. Connect the “Build Prompt” output to the input of an LLM component.
  5. Run the workflow – the LLM will receive the prompt and generate a response.
  • LLM – Uses the prompt produced by LangChain Hub to generate text.
  • Prompt Builder – Allows you to create custom prompts that can also be stored in LangChain Hub.
  • Text Splitter – Can split large texts before feeding them into the LLM after the prompt is applied.

Tips and Best Practices

  • Keep your Langsmith API key secret; never share it in public workflows.
  • Use descriptive prompt names in LangChain Hub so you can find them quickly later.
  • Test prompts in isolation before adding them to a larger workflow to ensure they produce the expected output.

Security Considerations

  • The component relies on a credential that stores your Langsmith API key.
  • Make sure only trusted users have access to the credential in Nappai.
  • Regularly rotate your API key and update the credential in Nappai to maintain security.