Spaces:
Runtime error
Runtime error
Download api/llama_cpp_routes/utils.py from gordonchan/embedding-m3e-large: direct link, hf CLI and curl.
- Browser
- Download file 672 Bytes
-
https://huggingface.co/spaces/gordonchan/embedding-m3e-large/resolve/main/api/llama_cpp_routes/utils.py
- Command line
-
hf download hf://spaces/gordonchan/embedding-m3e-large/api/llama_cpp_routes/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/gordonchan/embedding-m3e-large/resolve/main/api/llama_cpp_routes/utils.py
672 Bytes
| from api.models import GENERATE_ENGINE | |
| from api.utils.request import llama_outer_lock, llama_inner_lock | |
| def get_llama_cpp_engine(): | |
| # NOTE: This double lock allows the currently streaming model to | |
| # check if any other requests are pending in the same thread and cancel | |
| # the stream if so. | |
| llama_outer_lock.acquire() | |
| release_outer_lock = True | |
| try: | |
| llama_inner_lock.acquire() | |
| try: | |
| llama_outer_lock.release() | |
| release_outer_lock = False | |
| yield GENERATE_ENGINE | |
| finally: | |
| llama_inner_lock.release() | |
| finally: | |
| if release_outer_lock: | |
| llama_outer_lock.release() | |