OpenAI ChatGPT
This example demonstrates how to use Gorget as a firewall of OpenAI client.
Simple example
In openai_api.py, Gorget is used to protect OpenAI ChatGPT client.
All scanners will run sequentially before the request is sent to the OpenAI API. Then, once the request is received, the response will be scanned by the scanners.
Advanced example
In openai_streaming.py, Gorget is used to protect OpenAI ChatGPT client with streaming.
The prompt is scanned in parallel with the request to the OpenAI API. If the prompt is not safe, the request will be blocked.
Then, the response is scanned in a streaming mode i.e. in chunks. If any chunk is not safe, the response will be blocked.