OpenClaw技能开发入门:为Phi-3-mini-128k-instruct定制周报生成模块

张开发
2026/6/9 12:00:23 15 分钟阅读
OpenClaw技能开发入门:为Phi-3-mini-128k-instruct定制周报生成模块
OpenClaw技能开发入门为Phi-3-mini-128k-instruct定制周报生成模块1. 为什么需要定制周报生成技能上周五下午6点我又一次对着空白的周报文档发呆。作为技术团队负责人每周都要汇总项目进展、问题复盘和下周计划这个重复性工作消耗了我大量时间。直到我发现OpenClaw可以通过技能扩展实现自动化周报生成才意识到这个痛点完全可以用技术解决。与通用AI写作工具不同定制化周报技能有三个独特优势领域适配能理解我们团队特有的项目术语和汇报结构流程集成可以直接读取JIRA任务列表和Git提交记录作为数据源风格统一生成的周报符合公司规定的Markdown模板格式2. 开发环境准备与项目初始化2.1 基础环境配置我选择在本地MacBook ProM1芯片上开发这个技能主要工具链如下# 确认基础环境 node -v # v18.16.0 npm -v # 9.5.1 openclaw --version # 2.3.1 # 创建技能项目目录 mkdir weekly-report-skill cd weekly-report-skill clawhub init --templateskill-typescript这里特别选择了TypeScript模板因为周报生成涉及复杂的数据结构类型系统能帮助减少运行时错误。2.2 连接Phi-3-mini模型服务我们的Phi-3-mini-128k-instruct模型通过vllm部署在内网服务器需要在OpenClaw配置文件中添加模型端点// ~/.openclaw/openclaw.json { models: { providers: { phi3-mini: { baseUrl: http://192.168.1.100:8000/v1, apiKey: our_team_key, api: openai-completions, models: [ { id: phi-3-mini-128k-instruct, name: Phi-3 Mini Instruct, contextWindow: 128000 } ] } } } }配置完成后用以下命令测试模型连通性openclaw models list openclaw chat --model phi-3-mini-128k-instruct3. 技能核心逻辑开发3.1 定义技能元数据每个OpenClaw技能都需要在package.json中声明元数据{ name: team/weekly-report, version: 0.1.0, claw: { displayName: 智能周报生成器, description: 自动生成技术团队周报支持JIRA和Git数据源, icon: , tags: [productivity, report], permissions: [read:files, exec:command] } }特别注意permissions字段我们的技能需要读取本地文件和执行Git命令获取提交记录。3.2 实现自然语言指令解析在src/interpreter.ts中我们定义如何将用户自然语言转换为结构化参数interface ReportParams { timeframe: week | sprint; members?: string[]; projects?: string[]; template?: standard | detailed; } export function interpret(input: string): ReportParams { // 示例指令生成前端组上周周报包含A项目和B项目 const timeframe input.includes(上周) ? week : sprint; const members input.match(/[前后端]端组/) ? [frontend] : undefined; const projects [...input.matchAll(/(A|B)项目/g)].map(m m[1].toLowerCase()); return { timeframe, members, projects, template: input.includes(详细) ? detailed : standard }; }这个解析器可以处理我们团队80%以上的周报请求句式。3.3 集成Phi-3-mini的生成能力核心生成逻辑在src/generator.ts中实现async function generateWithPhi3(prompt: string): Promisestring { const response await fetch(${config.modelBaseUrl}/chat/completions, { method: POST, headers: { Content-Type: application/json, Authorization: Bearer ${config.apiKey} }, body: JSON.stringify({ model: phi-3-mini-128k-instruct, messages: [{ role: user, content: prompt }], temperature: 0.7 }) }); const data await response.json(); return data.choices[0].message.content; }我们为Phi-3-mini设计了特定的提示词模板你是一位技术团队负责人需要根据以下信息生成周报 [项目进展] {projects} [代码变更] {commits} [待办事项] {tickets} 请用Markdown格式输出包含本周成果、问题与解决、下周计划三个章节。 保持专业简洁的风格重要事项用**加粗**标注。4. 数据源集成实践4.1 从JIRA获取任务数据我们使用node-jira客户端获取任务列表import JiraApi from jira-client; const jira new JiraApi({ protocol: https, host: jira.our-company.com, username: process.env.JIRA_USER, password: process.env.JIRA_TOKEN }); async function getJiraTickets(sprintId: string): PromiseJiraTicket[] { const result await jira.searchJira( sprint ${sprintId} AND assignee in (currentUser()), { fields: [summary, status, priority] } ); return result.issues.map(issue ({ key: issue.key, summary: issue.fields.summary, status: issue.fields.status.name, priority: issue.fields.priority.name })); }4.2 从Git仓库提取提交记录通过执行Git命令获取代码变更数据import { execSync } from child_process; function getGitCommits(since: string): GitCommit[] { const format --prettyformat:%h|%an|%ad|%s; const cmd git log --since${since} --no-merges ${format}; const output execSync(cmd, { cwd: config.projectDir }).toString(); return output.split(\n).map(line { const [hash, author, date, message] line.split(|); return { hash, author, date, message }; }); }5. 调试与优化技巧5.1 本地测试方法OpenClaw提供了便捷的本地测试命令# 在技能目录下运行 clawhub dev # 模拟用户输入测试 curl -X POST http://localhost:3000/execute \ -H Content-Type: application/json \ -d {input:生成前端组本周周报}开发过程中我经常遇到的两个典型问题权限不足需要在openclaw.json中显式声明技能权限模型响应不稳定通过调整temperature参数和优化提示词解决5.2 性能优化记录初始版本生成周报需要15-20秒经过以下优化降到5秒内缓存机制对JIRA和Git数据做内存缓存批量请求并行获取多个项目的数据提示词精简去掉不必要的上下文说明6. 发布到ClawHub共享6.1 打包发布流程# 构建生产版本 npm run build # 发布到ClawHub clawhub publish \ --name team-weekly-report \ --desc 技术团队周报自动生成器 \ --category productivity发布时需要准备清晰的README文档示例用法截图兼容性说明OpenClaw版本要求等6.2 版本更新策略我们采用语义化版本控制补丁版本0.1.x修复bug次要版本0.x.0新增功能主版本x.0.0不兼容变更每次更新都通过CHANGELOG.md详细记录变更内容。7. 实际使用效果与改进方向部署两周后这个技能已经生成23份周报节省了约15小时人工时间。最让我惊喜的是Phi-3-mini对技术术语的理解非常准确生成的复盘分析常常能抓住关键点。目前发现的局限性包括对跨多个Sprint的任务跟踪能力不足生成的下周计划有时过于泛泛无法自动识别高风险事项下一步计划引入团队知识库作为额外上下文并开发周报质量评估子模块。不过即使当前版本也已经显著提升了我们团队的周报效率。获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。

更多文章