---------- Public entrypoint ----------
(chatId string, callId string, newToolUseData uctypes.UIMessageDataToolUse)
| 409 | // ---------- Public entrypoint ---------- |
| 410 | |
| 411 | func 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 | |
| 442 | func RemoveToolUseCall(chatId string, callId string) error { |
| 443 | chat := chatstore.DefaultChatStore.Get(chatId) |
no test coverage detected