jawadsadiq01-langchain-email-agent
基于 LangChain 与 OpenAI GPT 的 AI 邮件撰写与发送代理,内置人工审核中间件,在发送前需经批准、编辑或拒绝。支持自定义主题、正文与撰写指令。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~jawadsadiq01-langchain-email-agentcURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~jawadsadiq01-langchain-email-agent/file -o jawadsadiq01-langchain-email-agent.md## 概述(中文)
基于 LangChain 与 OpenAI GPT 的 AI 邮件撰写与发送代理,内置人工审核中间件,在发送前需经批准、编辑或拒绝。支持自定义主题、正文与撰写指令。
## 技能正文
# EmailAgent README
## 概述
`EmailAgent` 类提供基于 LangChain 与 OpenAI GPT 模型的 AI 邮件撰写与发送能力,并包含人工介入(human-in-the-loop)中间件,在邮件发送前需要审批。
## 配置
### 环境变量
| 变量 | 默认值 | 描述 |
|----------|---------|-------------|
| `OPENAI_MODEL` | `gpt-4o-mini` | 使用的 OpenAI 模型 |
## 用法
```typescript
import { EmailAgent } from './email.agent';
import { SendEmailDto } from '../dto/send-email.dto';
const agent = new EmailAgent();
const dto: SendEmailDto = {
email: 'recipient@example.com',
name: 'John Doe',
subject: 'Meeting Request', // optional
body: 'Initial email content', // optional
instructions: 'Keep it formal' // optional
};
const result = await agent.sendEmail(dto);
```
## 人工介入中间件
代理使用 `humanInTheLoopMiddleware`,在 `EmailTool` 发送邮件前中断执行,支持:
- **approve** - 按当前内容发送邮件
- **edit** - 发送前修改邮件内容
- **reject** - 取消邮件操作
`readEmailTool` 被排除在中断之外(`false`),读取操作无需审批即可继续。
## 参数
| 参数 | 类型 | 必填 | 描述 |
|-----------|------|----------|-------------|
| `email` | string | 是 | 收件人邮箱地址 |
| `name` | string | 是 | 收件人姓名 |
| `subject` | string | 否 | 邮件主题 |
| `body` | string | 否 | 初始邮件正文 |
| `instructions` | string | 否 | AI 撰写邮件的指令 |
## 返回值
返回代理最终消息内容的字符串。