PoisonRequest rewrites a chat-completion request so that all conversation history is replaced with a single user message containing text. The system prompt is preserved. format must be "openai", "claude", or "openai-responses".
(rawJSON []byte, text string, format string)
| 11 | // history is replaced with a single user message containing text. The system |
| 12 | // prompt is preserved. format must be "openai", "claude", or "openai-responses". |
| 13 | func PoisonRequest(rawJSON []byte, text string, format string) ([]byte, error) { |
| 14 | f := GetFormat(format) |
| 15 | if f == nil { |
| 16 | return nil, fmt.Errorf("unsupported format: %s", format) |
| 17 | } |
| 18 | return f.PoisonRequest(rawJSON, text) |
| 19 | } |
| 20 | |
| 21 | // poisonOpenAI keeps only role=="system" messages and appends a user message. |
| 22 | func poisonOpenAI(rawJSON []byte, text string) ([]byte, error) { |