Conversion properties
List of controllers to convert to LangChain tools.
typia.llm.controller<Class>(), converts all
methods of the class to toolsHttpLlm.controller(), converts all
operations from OpenAPI document to toolsOptionalprefix?: booleanWhether to add controller name as prefix to tool names.
If true, tool names become {controllerName}_{methodName}. If false,
tool names are just {methodName}.
Array of LangChain DynamicStructuredTool
import { initChatModel } from "langchain/chat_models/universal";
import typia from "typia";
import { toLangChainTools } from "@typia/langchain";
class Calculator {
add(input: { a: number; b: number }): { value: number } {
return { value: input.a + input.b };
}
}
const tools = toLangChainTools({
controllers: [
typia.llm.controller<Calculator>("calculator", new Calculator()),
],
});
const llm = await initChatModel();
const modelWithTools = llm.bindTools(tools);
const result = await modelWithTools.invoke("What is 10 + 5?");
Convert typia controllers to LangChain tools.
Converts TypeScript class methods via
typia.llm.controller<Class>()or OpenAPI operations viaHttpLlm.controller()to LangChain tools.Every tool call is validated by typia. If LLM provides invalid arguments, returns validation error formatted by LlmJson.stringify so that LLM can correct them automatically.