AddRefusal appends a terminal chunk carrying finish_reason "refusal", the way the Anthropic adapter surfaces a safety-classifier refusal (HTTP 200, no content).
()
| 41 | // way the Anthropic adapter surfaces a safety-classifier refusal (HTTP 200, |
| 42 | // no content). |
| 43 | func (b *streamBuilder) AddRefusal() *streamBuilder { |
| 44 | b.responses = append(b.responses, chat.MessageStreamResponse{ |
| 45 | Choices: []chat.MessageStreamChoice{{ |
| 46 | Index: 0, |
| 47 | FinishReason: chat.FinishReasonRefusal, |
| 48 | }}, |
| 49 | Usage: &chat.Usage{InputTokens: 1}, |
| 50 | }) |
| 51 | return b |
| 52 | } |
| 53 | |
| 54 | // TestHandleStream_Refusal verifies that a refusal terminates the stream with |
| 55 | // the refusal finish reason and stops the loop instead of being mistaken for a |
no outgoing calls
no test coverage detected