stuartleeks / aoai-simulated-api

An exploration into creating a simulated API implementation for Azure OpenAI (AOAI)
MIT License
11 stars 4 forks source link

Added tiktoken cache support, added script to load encoding file #12

Closed aerjenn closed 4 months ago

aerjenn commented 5 months ago

This pull request primarily focuses on enabling the simulated API to operate in environments with restricted network access. It introduces a caching mechanism for the TikToken encoding file, which was previously retrieved from a public blob storage account. The changes also include the addition of a new Python script to handle the setup of the TikToken cache and updates to the README to provide instructions on using the simulator with restricted network access.

Key changes include:

README Updates:

Codebase Updates:

stuartleeks commented 5 months ago

Thanks for this @aerjenn - this would be a great addition!

The flow in the PR as I understand it is:

  1. run setup_tiktoken.py to download the content into the src/aoai-simulated-api/src/aoai_simulated_api folder
  2. set the USE_TIKTOKEN_CACHE env var when running the simulator to pick up the downloaded file

I'm not keen on downloading the content into the source folder (although I'm not really sure why!), so was thinking maybe we could tweak the flow

  1. run setup_tiktoken.py to download the content into a cache folder
  2. set TIKTOKEN_CACHE_DIR env var to point to the cache location when running the simulator. I think we then don't need the config.py changes?

For running via Docker, we could consider add an additional Dockerfile that runs setup_tiktoken.py and to save the content into the image, and also sets the TIKTOKEN_CACHE_DIR so that the resulting image has the cached content and is ready to run.

What do you think?

stuartleeks commented 5 months ago

(Either way, ensuring that we .gitignore the downloaded content would be good 😄 )