LangChain.js

Wrap LangChain.js agents for use with the Reminix runtime

The LangChain.js adapter provides functions to wrap LangChain agents and chat models for deployment with the Reminix runtime.

Installation

npm install @reminix/runtime @reminix/adapters @langchain/openai @langchain/core
# or
pnpm add @reminix/runtime @reminix/adapters @langchain/openai @langchain/core

Available Adapters

Wrap a modern LangChain agent created with createAgent():

import { createAgent } from 'langchain';
import { fromLangChainAgent } from '@reminix/adapters/langchain';
import { serve } from '@reminix/runtime';

const lcAgent = createAgent({
  model: 'openai:gpt-4o',
  tools: [searchTool, calculatorTool],
});

const agent = fromLangChainAgent(lcAgent, { name: 'smart-agent' });
serve(agent);

fromAgentExecutor (Legacy)

Wrap a LangChain AgentExecutor for compatibility with older code:

import { AgentExecutor, createReactAgent } from 'langchain/agents';
import { ChatOpenAI } from '@langchain/openai';
import { fromAgentExecutor } from '@reminix/adapters/langchain';
import { serve } from '@reminix/runtime';

const llm = new ChatOpenAI({ model: 'gpt-4o' });
const agent = createReactAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });

const reminixAgent = fromAgentExecutor(executor, { name: 'my-agent' });
serve(reminixAgent);

fromLangChainChatModel

Wrap a simple chat model for quick deployment:

import { ChatOpenAI } from '@langchain/openai';
import { fromLangChainChatModel } from '@reminix/adapters/langchain';
import { serve } from '@reminix/runtime';

const llm = new ChatOpenAI({ model: 'gpt-4o' });
const agent = fromLangChainChatModel(llm, {
  name: 'gpt4-chat',
  system: 'You are a helpful assistant.',
});

serve(agent);

Handler Mapping

All LangChain.js adapters implement:

Reminix HandlerLangChain Method
onInvokeagent.invoke()
onInvokeStreamagent.stream()
onChatagent.invoke() with messages
onChatStreamagent.stream() with messages

On this page