Add example and documentation for custom tool
**Is your feature request related to a problem? Please describe.**
The [langchainjs docs](https://js.langchain.com/docs/how_to/custom_tools/) do a good job of showing how to turn a function (just a regular JS function) into a tool. The example is simple enough that it is easy to understand how to create your own tool.
**Describe the solution you'd like**
Create an the example for the adder tool but in langchain_rust. Add it to examples and README.md
```javascript
import { z } from "zod";
import { tool } from "@langchain/core/tools";
const adderSchema = z.object({
a: z.number(),
b: z.number(),
});
const adderTool = tool(
async (input): Promise<string> => {
const sum = input.a + input.b;
return `The sum of ${input.a} and ${input.b} is ${sum}`;
},
{
name: "adder",
description: "Adds two numbers together",
schema: adderSchema,
}
);
await adderTool.invoke({ a: 1, b: 2 });
```
**Describe alternatives you've considered**
**Additional context**
The example should focus on the langchain-rust boilerplate necessary for any tool with any explanations which are specific to rust version of langchain.
0 条评论