MCPcopy
hub / github.com/wavetermdev/waveterm / UpdateToolUseData

Function UpdateToolUseData

pkg/aiusechat/gemini/gemini-convertmessage.go:423–459  ·  view source on GitHub ↗

UpdateToolUseData updates the tool use data for a specific tool call in the chat

(chatId string, toolCallId string, toolUseData uctypes.UIMessageDataToolUse)

Source from the content-addressed store, hash-verified

421
422// UpdateToolUseData updates the tool use data for a specific tool call in the chat
423func UpdateToolUseData(chatId string, toolCallId string, toolUseData uctypes.UIMessageDataToolUse) error {
424 chat := chatstore.DefaultChatStore.Get(chatId)
425 if chat == nil {
426 return fmt.Errorf("chat not found: %s", chatId)
427 }
428
429 for _, genMsg := range chat.NativeMessages {
430 chatMsg, ok := genMsg.(*GeminiChatMessage)
431 if !ok {
432 continue
433 }
434
435 for i, part := range chatMsg.Parts {
436 if part.FunctionCall != nil && part.ToolUseData != nil && part.ToolUseData.ToolCallId == toolCallId {
437 // Update the message with new tool use data
438 updatedMsg := &GeminiChatMessage{
439 MessageId: chatMsg.MessageId,
440 Role: chatMsg.Role,
441 Parts: make([]GeminiMessagePart, len(chatMsg.Parts)),
442 Usage: chatMsg.Usage,
443 }
444 copy(updatedMsg.Parts, chatMsg.Parts)
445 updatedMsg.Parts[i].ToolUseData = &toolUseData
446
447 aiOpts := &uctypes.AIOptsType{
448 APIType: chat.APIType,
449 Model: chat.Model,
450 APIVersion: chat.APIVersion,
451 }
452
453 return chatstore.DefaultChatStore.PostMessage(chatId, aiOpts, updatedMsg)
454 }
455 }
456 }
457
458 return fmt.Errorf("tool call with ID %s not found in chat %s", toolCallId, chatId)
459}
460
461func RemoveToolUseCall(chatId string, toolCallId string) error {
462 chat := chatstore.DefaultChatStore.Get(chatId)

Callers 1

UpdateToolUseDataMethod · 0.92

Calls 2

PostMessageMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected