handleRemoveFromCart handles remove from cart tool calls
(arguments string, sessionID string, toolCallID string)
| 154 | |
| 155 | // handleRemoveFromCart handles remove from cart tool calls |
| 156 | func (te *ToolExecutor) handleRemoveFromCart(arguments string, sessionID string, toolCallID string) models.ToolCallResult { |
| 157 | var args struct { |
| 158 | ProductName string `json:"product_name"` |
| 159 | } |
| 160 | |
| 161 | if err := json.Unmarshal([]byte(arguments), &args); err != nil { |
| 162 | return models.ToolCallResult{ |
| 163 | CallID: toolCallID, |
| 164 | ToolName: "remove_from_cart", |
| 165 | Success: false, |
| 166 | Error: "Invalid arguments", |
| 167 | Arguments: arguments, |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | cartSummary, err := te.cartService.RemoveFromCart(sessionID, args.ProductName) |
| 172 | if err != nil { |
| 173 | return models.ToolCallResult{ |
| 174 | CallID: toolCallID, |
| 175 | ToolName: "remove_from_cart", |
| 176 | Success: false, |
| 177 | Error: err.Error(), |
| 178 | Arguments: arguments, |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | return models.ToolCallResult{ |
| 183 | CallID: toolCallID, |
| 184 | ToolName: "remove_from_cart", |
| 185 | Success: true, |
| 186 | Result: cartSummary, |
| 187 | Arguments: arguments, |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // handleViewCart handles view cart tool calls |
| 192 | func (te *ToolExecutor) handleViewCart(sessionID string, toolCallID string) models.ToolCallResult { |
no test coverage detected