LangChain Structured Tool (TS & Python)
Plug BaZi calculations into LangChain Agents and AgentExecutors.
AI Agents & LLM Tools
Integrate BaZi chart calculations as a structured tool into LangChain JS/TS DynamicStructuredTool or LangChain Python @tool.
Installation
Bash
npm install @langchain/core @baziapi/ai-tools @baziapi/sdkQuick Start
LangChain TS DynamicStructuredTool
TypeScript
import { DynamicStructuredTool } from '@langchain/core/tools';
import { BaziClient } from '@baziapi/sdk';
import { createBaziLangChainConfig } from '@baziapi/ai-tools';
const client = new BaziClient({ apiKey: process.env.BAZI_API_KEY! });
const baziTool = new DynamicStructuredTool(createBaziLangChainConfig(client));More Examples
LangChain Python @tool Decorator
LangChain Python @tool Decorator
Python
from langchain.tools import tool
from bazi import BaziClient
client = BaziClient(api_key="bazi_live_xxxx")
@tool
def calculate_bazi(birth_date: str, birth_time: str, gender: str, timezone: str = "Asia/Shanghai") -> dict:
"""Calculates Chinese Four Pillars of Destiny (BaZi) chart."""
return client.calculate(birth_date=birth_date, birth_time=birth_time, gender=gender, timezone=timezone).to_dict()Something unclear? Contact developer support.