MCPcopy Create free account
hub / github.com/53AI/53AIHub / mergeProcessRecordsWithToolCalls

Function mergeProcessRecordsWithToolCalls

api/controller/message.go:209–251  ·  view source on GitHub ↗
(processRecordMap map[int64][]*model.MessageProcessStep, toolCallMap map[int64][]*model.MessageToolCall)

Source from the content-addressed store, hash-verified

207}
208
209func mergeProcessRecordsWithToolCalls(processRecordMap map[int64][]*model.MessageProcessStep, toolCallMap map[int64][]*model.MessageToolCall) map[int64][]*model.MessageProcessStep {
210 merged := make(map[int64][]*model.MessageProcessStep, len(processRecordMap)+len(toolCallMap))
211 for messageID, records := range processRecordMap {
212 if len(records) == 0 {
213 continue
214 }
215 merged[messageID] = append(merged[messageID], records...)
216 }
217
218 for messageID, toolCalls := range toolCallMap {
219 for _, toolCall := range toolCalls {
220 record := convertToolCallToProcessRecord(toolCall)
221 if record == nil {
222 continue
223 }
224 merged[messageID] = append(merged[messageID], record)
225 }
226 }
227
228 for messageID := range merged {
229 records := merged[messageID]
230 sort.SliceStable(records, func(i, j int) bool {
231 left := records[i]
232 right := records[j]
233 if left == nil {
234 return false
235 }
236 if right == nil {
237 return true
238 }
239 if left.StepTimestamp != right.StepTimestamp {
240 return left.StepTimestamp < right.StepTimestamp
241 }
242 if left.CreatedTime != right.CreatedTime {
243 return left.CreatedTime < right.CreatedTime
244 }
245 return left.ID < right.ID
246 })
247 merged[messageID] = records
248 }
249
250 return merged
251}
252
253func parseConversationIDParam(rawID string) (int64, error) {
254 return hashids.TryParseID(rawID)

Callers 2

GetMessagesListFunction · 0.85

Calls 1

Tested by

no test coverage detected