资讯动态

基于Function Calling的智能工作项自动打标与工时估算

发布时间:2026/9/17 11:48:53 来源:尧图企业网站定制
基于Function Calling的智能工作项自动打标与工时估算在很多项目管理和敏捷看板系统中工程师提交完周报后往往还需要在系统里手动填写每个任务的“所属模块、技术标签、难度等级以及实际耗费工时Story Points / Man-Hours”。这种重复的表单录入是典型的“行政性负担”工程师为了应付差事往往随手乱填工时全部填 8 小时导致管理层拿到的工时统计数据严重失真无法真实评估项目的研发成本。如果让传统大模型输出纯文本然后再用脆弱的正则表达式去解析工时和标签极易因为大模型多吐了一个换行或少了一个逗号导致解析崩溃。为了实现100% 确定性、强类型 Schema 约束的自动化工作项结构化提取利用现代大模型的Function Calling工具调用 / 结构化输出 Tool Calls机制是工业级落地的标准解法。Function Calling 结构化提取架构[ 用户输入的非结构化 Commit 日志与工作随笔 ] │ ▼ (传入带有强类型 JSON Schema 的 Function 定义) ┌─────────────────────────────────────────────────────────────┐ │ 大模型 Function Calling 引擎 (gpt-4o-mini / DeepSeek) │ ├──────────────────────────────┬──────────────────────────────┤ │ 函数名: record_work_items │ 强制按 Schema 返回参数对象 │ └──────────────────────────────┬──────────────────────────────┘ │ ▼ (100% 保证合法的强类型 JSON 树) ┌─────────────────────────────────────────────────────────────┐ │ items: [ │ │ { name: 微信 Native 支付, tags: [全栈, 安全], │ │ difficulty: HIGH, estimatedHours: 12 }, │ │ { name: 修复 TabBar 样式, tags: [前端, UI], │ │ difficulty: LOW, estimatedHours: 2 } │ │ ] │ └─────────────────────────────────────────────────────────────┘ │ ▼ [ 自动入库 SQLite 关联表一秒生成敏捷工时度量看板 ]核心实现定义标准的 Function Calling 规范契约// src/services/workItemsExtractor.ts export const WORK_ITEMS_TOOL_DEFINITION { type: function as const, function: { name: record_structured_work_items, description: 从用户的原始工作日志中提取结构化的任务项、专业技术标签与预估实际工时, parameters: { type: object, properties: { items: { type: array, items: { type: object, properties: { taskTitle: { type: string, description: 任务简要标题不超过 20 字 }, category: { type: string, enum: [frontend, backend, devops, architecture, bugfix], description: 任务所属工程领域 }, technicalTags: { type: array, items: { type: string }, description: 提取的 1~3 个核心技术名词如 React, Docker, Redis }, difficulty: { type: string, enum: [LOW, MEDIUM, HIGH], description: 技术攻坚难度评级 }, estimatedHours: { type: number, description: 根据提交复杂度客观估算的人工实际耗时小时支持 0.5 的倍数 } }, required: [taskTitle, category, technicalTags, difficulty, estimatedHours] } }, weeklyTotalHours: { type: number, description: 全周累计有效研发工时总和 } }, required: [items, weeklyTotalHours] } } };服务端调度与入库处理Node.js OpenAI SDK// src/services/autoTaggingService.ts import OpenAI from openai; import { WORK_ITEMS_TOOL_DEFINITION } from ./workItemsExtractor; const openai new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); export async function extractWorkItemsWithFunctionCalling(rawLogs: string) { const response await openai.chat.completions.create({ model: gpt-4o-mini, temperature: 0.1, // 极低温度保持提取的严谨客观性 messages: [ { role: system, content: 你是一位资深研发效能度量专家。请客观分析用户的 Git 提交记录与工作随笔提取结构化任务清单与合理工时。 }, { role: user, content: rawLogs } ], tools: [WORK_ITEMS_TOOL_DEFINITION], // 强制模型必须调用该结构化函数 tool_choice: { type: function, function: { name: record_structured_work_items } } }); const toolCall response.choices[0]?.message?.tool_calls?.[0]; if (!toolCall) { throw new Error(模型未返回结构化工具调用); } // 100% 结构合法的 JSON 字符串 const extractedData JSON.parse(toolCall.function.arguments); console.log(✓ [FunctionCalling] 成功提取 ${extractedData.items.length} 个结构化任务预估总工时: ${extractedData.weeklyTotalHours}h); return extractedData; }前端敏捷工时看板可视化展示// 结构化任务与工时明细组件 export const StructuredWorkItemsTable: React.FC{ data: { items: any[]; weeklyTotalHours: number }; } ({ data }) { return ( div classNamep-6 bg-white border border-slate-200 rounded-2xl shadow-sm space-y-4 div classNameflex justify-between items-center div h4 classNamefont-bold text-slate-800 text-sm工时与技术标签自动提炼/h4 p classNametext-xs text-slate-500基于提交记录复杂度自动化度量/p /div span classNamepx-3 py-1 bg-indigo-50 text-indigo-700 text-xs font-bold rounded-lg 本周总工时: {data.weeklyTotalHours} 小时 /span /div div classNameoverflow-x-auto table classNamew-full text-left text-xs thead classNamebg-slate-50 text-slate-500 border-b tr th classNamepy-2.5 px-3任务项/th th classNamepy-2.5 px-3技术标签/th th classNamepy-2.5 px-3难度/th th classNamepy-2.5 px-3 text-right预估耗时/th /tr /thead tbody classNamedivide-y divide-slate-100 {data.items.map((item, idx) ( tr key{idx} classNamehover:bg-slate-50/60 td classNamepy-2.5 px-3 font-medium text-slate-800{item.taskTitle}/td td classNamepy-2.5 px-3 div classNameflex space-x-1 {item.technicalTags.map((tag: string) ( span key{tag} classNamepx-1.5 py-0.5 bg-slate-100 text-slate-600 rounded text-[10px] {tag} /span ))} /div /td td classNamepy-2.5 px-3 span className{px-1.5 py-0.5 rounded text-[10px] font-bold ${ item.difficulty HIGH ? bg-rose-50 text-rose-600 : bg-blue-50 text-blue-600 }} {item.difficulty} /span /td td classNamepy-2.5 px-3 text-right font-mono font-bold text-slate-700 {item.estimatedHours} h /td /tr ))} /tbody /table /div /div ); };落地收益彻底终结正则解析崩溃Function Calling 机制保证输出 100% 严格遵循 JSON Schema类型安全直接拉满消灭工程师手动填工时的痛点全自动分析 Git 提交行数与逻辑深度估算出的工时客观真实极大地提升了研发团队敏捷度量的数据质量。

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价