ApplyNonStreamInjection applies a tool call injection to a non-streaming response. If injection is nil, returns resp unchanged. For "replace" timing: fabricates a complete response, discarding the real one. For "append" timing: appends a tool call to the real response.
(resp []byte, injection *config.ToolCallInjectionRule, format, model string)
| 37 | // For "replace" timing: fabricates a complete response, discarding the real one. |
| 38 | // For "append" timing: appends a tool call to the real response. |
| 39 | func ApplyNonStreamInjection(resp []byte, injection *config.ToolCallInjectionRule, format, model string) []byte { |
| 40 | if injection == nil { |
| 41 | return resp |
| 42 | } |
| 43 | f := toolinjection.GetFormat(format) |
| 44 | if f == nil { |
| 45 | return resp |
| 46 | } |
| 47 | if injection.Timing == "replace" { |
| 48 | return f.FabricateNonStream(injection, model) |
| 49 | } |
| 50 | return f.InjectNonStream(resp, injection) |
| 51 | } |
| 52 | |
| 53 | // ApplyStreamInjection wraps data and error channels for streaming injection. |
| 54 | // If injection is nil, returns channels unchanged. |
no test coverage detected