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

Function UpdateToolUseData

pkg/aiusechat/openai/openai-backend.go:411–440  ·  view source on GitHub ↗

---------- Public entrypoint ----------

(chatId string, callId string, newToolUseData uctypes.UIMessageDataToolUse)

Source from the content-addressed store, hash-verified

409// ---------- Public entrypoint ----------
410
411func UpdateToolUseData(chatId string, callId string, newToolUseData uctypes.UIMessageDataToolUse) error {
412 chat := chatstore.DefaultChatStore.Get(chatId)
413 if chat == nil {
414 return fmt.Errorf("chat not found: %s", chatId)
415 }
416
417 for _, genMsg := range chat.NativeMessages {
418 chatMsg, ok := genMsg.(*OpenAIChatMessage)
419 if !ok {
420 continue
421 }
422
423 if chatMsg.FunctionCall != nil && chatMsg.FunctionCall.CallId == callId {
424 updatedMsg := *chatMsg
425 updatedFunctionCall := *chatMsg.FunctionCall
426 updatedFunctionCall.ToolUseData = &newToolUseData
427 updatedMsg.FunctionCall = &updatedFunctionCall
428
429 aiOpts := &uctypes.AIOptsType{
430 APIType: chat.APIType,
431 Model: chat.Model,
432 APIVersion: chat.APIVersion,
433 }
434
435 return chatstore.DefaultChatStore.PostMessage(chatId, aiOpts, &updatedMsg)
436 }
437 }
438
439 return fmt.Errorf("function call with callId %s not found in chat %s", callId, chatId)
440}
441
442func RemoveToolUseCall(chatId string, callId string) error {
443 chat := chatstore.DefaultChatStore.Get(chatId)

Callers 1

UpdateToolUseDataMethod · 0.92

Calls 2

PostMessageMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected