Availability
For how response filters run, refer to Response Filters.
Write a script that blocks an LLM response with forbidden content. Then attach it to an LLM or a chat room.
Create a Response Filter
- Create a script filter, and select Is this a Response Filter?.
- In the script, read the response text. For streaming, use
input.current_buffer, the accumulated text. Otherwise, useinput.raw_input. For all fields, refer to Response Filter Input. - For streaming, evaluate only when
len(input.current_buffer)reaches enough context. The script runs on every chunk, so keep its logic lightweight. - Set
output.blockandoutput.message. The user sees the message, so make it clear. A response filter cannot change the response, so AI Studio ignorespayloadandmessages. - Attach the filter to an LLM or a chat room.