Code lab 5.1 – Securing your keys
This code can be found in the CHAPTER5-1_SECURING_YOUR_KEYS.ipynb
file in the CHAPTER_05
directory of the GitHub repository.
In Chapter 2, we provided a coding step right after adding imports where we added your OpenAI API key. In that section, we indicated that it was a very simple demonstration of how the API key is ingested into the system, but this is not a secure way to use an API key. Typically, as your RAG application expands, you will have multiple API keys as well. But even if you only have the OpenAI API key, this is enough to institute further security measures to protect your key. This key can be used to run up expensive bills on your OpenAI account, exposing you to potential financial risk.
We are going to start this code lab with a very common security-driven practice of hiding your sensitive API code (and any other secret code) in a separate file that can be hidden from your versioning system. The most typical reason to...