Skip to content

Latest commit

 

History

History
88 lines (59 loc) · 1.92 KB

File metadata and controls

88 lines (59 loc) · 1.92 KB

jsonfirst-langchain

npm version

LangChain agents break on ambiguous input.

JSONFIRST adds a structured JSON intent layer to your LangChain pipeline so agents execute reliably.

Parse → Govern → Execute.

JSONFIRST helps build reliable AI agents by converting natural language into structured JSON intent.

User input
    ↓
JSONFIRST (structured JDON)
    ↓
LangChain router
    ↓
Tool / Chain execution

Quick Example

const { asLangChainTool } = require('jsonfirst-langchain');

// Drop JSONFIRST as a LangChain tool
const tools = [
  asLangChainTool(process.env.JSONFIRST_API_KEY),
  // ... your other tools
];

// Your agent now gets structured JDON before acting
const agent = await initializeAgentExecutorWithOptions(tools, llm, {
  agentType: 'zero-shot-react-description'
});

Or use it directly in a chain:

const { parseIntent } = require('jsonfirst-langchain');

const jdon = await parseIntent("book a meeting with Alice tomorrow", process.env.JSONFIRST_API_KEY);
// { action: { normalized: "book" }, object: { type: "meeting" }, confidence: 0.96 }

// Route to the right LangChain chain based on jdon.action.normalized

Installation

npm install jsonfirst-langchain

Get your API key at jsonfirst.com → Dashboard → API Console.


API

const { parseIntent, asLangChainTool } = require('jsonfirst-langchain');
Function Description
parseIntent(text, apiKey, opts) Returns structured JDON for any input
asLangChainTool(apiKey, opts) Returns a LangChain-compatible tool definition

Links


License

MIT © JSONFIRST