(toolCall *model.MessageToolCall)
| 149 | } |
| 150 | |
| 151 | func convertToolCallToProcessRecord(toolCall *model.MessageToolCall) *model.MessageProcessStep { |
| 152 | if toolCall == nil { |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | status := toolCall.Status |
| 157 | if status == "" { |
| 158 | status = model.ToolCallStatusPending |
| 159 | } |
| 160 | |
| 161 | stepTimestamp := toolCall.CreatedTime / 1000 |
| 162 | if stepTimestamp <= 0 { |
| 163 | stepTimestamp = toolCall.UpdatedTime / 1000 |
| 164 | } |
| 165 | if stepTimestamp <= 0 { |
| 166 | stepTimestamp = time.Now().Unix() |
| 167 | } |
| 168 | |
| 169 | stepMessage := fmt.Sprintf("工具 %s 执行状态: %s", toolCall.FunctionName, status) |
| 170 | if toolCall.FunctionName == "" { |
| 171 | stepMessage = fmt.Sprintf("工具调用状态: %s", status) |
| 172 | } |
| 173 | |
| 174 | record := &model.MessageProcessStep{ |
| 175 | Eid: toolCall.Eid, |
| 176 | MessageID: toolCall.MessageID, |
| 177 | StepCode: "tool_call", |
| 178 | Name: "工具调用", |
| 179 | Status: status, |
| 180 | Message: stepMessage, |
| 181 | StepTimestamp: stepTimestamp, |
| 182 | BaseModel: model.BaseModel{ |
| 183 | CreatedTime: toolCall.CreatedTime, |
| 184 | UpdatedTime: toolCall.UpdatedTime, |
| 185 | }, |
| 186 | } |
| 187 | |
| 188 | toolData := map[string]interface{}{ |
| 189 | "message_tool_call_id": toolCall.ID, |
| 190 | "tool_name": toolCall.ToolName, |
| 191 | "tool_call_id": toolCall.ToolCallID, |
| 192 | "function_name": toolCall.FunctionName, |
| 193 | "arguments": toolCall.Arguments, |
| 194 | "status": toolCall.Status, |
| 195 | "result": toolCall.Result, |
| 196 | "error_msg": toolCall.ErrorMsg, |
| 197 | "duration_ms": toolCall.DurationMs, |
| 198 | "skill_name": toolCall.SkillName, |
| 199 | "turn_number": toolCall.TurnNumber, |
| 200 | "channel_id": toolCall.ChannelID, |
| 201 | "model_name": toolCall.ModelName, |
| 202 | } |
| 203 | if err := record.SetDataMap(toolData); err != nil { |
| 204 | record.Data = "" |
| 205 | } |
| 206 | return record |
| 207 | } |
| 208 |
no test coverage detected