Abraxas-365 / Abraxas-365/langchain-rust
Add example and documentation for custom tool
- 主要语言
- Rust
- 星标
- 1.3k
- 派生
- 177
- PR 合并指标
- 30 天内没有已合并 PR
描述
**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.
贡献指南
调研方向
Look at the existing examples directory in the repository to understand the structure. The task is to create a Rust equivalent of the provided JavaScript adder tool example. Start by examining how other tools are defined in langchain-rust, likely in a tools module. The example should be placed in the examples folder and referenced in README.md. Test the example by running it with cargo run --example adder_tool (or similar) to ensure it works.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 75/100