Abraxas-365 / Abraxas-365/langchain-rust
Add example and documentation for custom tool
- Lenguaje dominante
- Rust
- Estrellas
- 1.3k
- Forks
- 177
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**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 => {
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.
[Example code](https://github.com/dfberry/rust/pull/18)
I can submit a PR.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.