Skip to main content
Version: v2.x

LangChain LangServe Adapter

LangChain is a new and popular framework for building services powered by Large Language Models. It enables applications that are context-aware. It also provides a library called LangServe to create standardized APIs that can be used to interact with LangChain runnables.

This example illustrates how to use NLUX to connect to a LangChain runnable made available through LangServe.

import { AiChat } from '@nlux/react';
import { useChatAdapter } from '@nlux/langchain-react';
import '@nlux/themes/nova.css';

import { personasOptions } from './personas';

export default () => {
  // LangServe adapter that connects to a demo LangChain Runnable API
  // It fetches data in streaming mode
  const adapter = useChatAdapter({
    url: 'https://pynlux.api.nlkit.com/pirate-speak',
    dataTransferMode: 'stream'
  });

  return (
    <AiChat
      adapter={ adapter }
      personaOptions={ personasOptions }
      displayOptions={{ colorScheme: 'dark' }}
    />
  );
};

This example focuses on the frontend integration between LangServe and NLUX. If you are interested in seeing the backend code that enabled this demo, you can check this repository, which contains Python LangServe API code.


Learn More About NLUX LangChain Adapter