Method 1: use time.time() and do calculations Method 2: Create a Timer class that stores the start time and last time recorded
All posts in python
Chunking text
These are basic chunking utilities for quickly getting large text blocks into smaller chunks. Starts with Character based, then Word base, then Sentence based chunking.
async openai calls with python
In the previous post we explored asyncio (link), here we build on that to create async openai calls The uses the standard python “asyncio” library and the function asyncio.gather to concurrently call openai 3 times (you can add as many calls as you like).
Async python with asyncio
You have two options for concurrent python Traditionally, we used threads with python for concurrency, but the release of the asyncio library (version 3.4) and the release of async/await syntax (version 3.5) created support for native coroutines that are familiar to users of the many languages that support it. (history of asyncio) asyncio (docs) The…
Django and pgvector for semantic search
Goal: Semantic Search Setup pgvector You have a model with a field you want to make semantically searchable. Installation comes from: https://github.com/pgvector/pgvector-python Step: install pgvector on your machine Step: create a migration to activate Step: add a VectorField to your model Step: make migrations and migrate Setup sentence transformers for embeddings We will use the…
How to use OpenAI whisper with python
OpenAI open sourced their speech recognition model: https://github.com/openai/whisper There are 5 sizes: tiny, base, small, medium, large Note: you need to pip install openai-whisper (pypi link) Here is code to transcribe an audio file
UserWarning: FP16 is not supported on CPU; using FP32 instead
warnings.warn(“FP16 is not supported on CPU; using FP32 instead”)
Q: Are you trying to use whisper on your Mac instead of a Google Colab? Short answer: Example: Source: https://github.com/openai/whisper/discussions/301
Create Django Project with scaffolding from Django Cookiecutter
I use Django Cookiecutter (link) 🍪 because its awesome! Find your python version Hit the github page to see what python version it supports, you should match whichever provider support you have. Create project: use pyenv to set python version Note: if your pyenv install –list is not listing the newest versions, you’ll need to…
Python: Print all items in a directory
pytest (error): Requested setting ROOT_URLCONF, but settings are not configured
Trying to run pytest or coverage run -m pytest to test your Django code? The error is telling us that the code no longer knows how to find our settings module. Note that we are no longer using the manage.py command to deal with Django code and if you look at this file, one of…