I think LangChain should improve its tool definition structure, like the Vercel AI SDK. This structure is cleaner and JavaScript-friendly.
example:
```const weatherTool = tool({
name: “get weather”,
description: ‘Get the weather in a location’,
inputSchema: z.object({
location: z.string().describe('The location to get the weather for'),
}),
execute: async ({ location }) => {
// Your implementation
return { temperature: 72, conditions: ‘sunny’ };
},
});````
Hey, @SheikhAriful! I find them to be quite similar. Here are the two side by side:
Vercel AI SDK
import { tool } from "ai";
import { z } from "zod";
const weatherTool = tool({
description: "Get the weather in a location",
inputSchema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
execute: async ({ location }) => ({ temperature: 72, conditions: "sunny" }),
});
LangChain JS / LangGraph JS
import { tool } from "langchain";
import { z } from "zod";
const weatherTool = tool(
async ({ location }) => ({ temperature: 72, conditions: "sunny" }),
{
name: "get_weather",
description: "Get the weather in a location",
schema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
}
);
Is there a feature of the AI SDK you feel is currently missing in LangChain?
The actual difference is in how we handle JavaScript conventions. In JavaScript, we mostly work with objects, so Vercel designed everything around a single object parameter. LangChain, on the other hand, accepts two separate parameters instead. I think Vercel’s approach is cleaner — and it’s not just Vercel; I’ve noticed most AI SDKs follow a Vercel-like syntax
I see. That is a fair, stylistic observation.