main.py activate_terminal.scpt
All posts in python
openai embeddings in python with asyncio and gather
Async version: Sources
Django jupyter notebook in vscode
Django jupyter notebook in browser
How do you start a jupyter notebook with all the django settings working? Step 1: Install shell_plus from django-extensions Step 2: start shell_plus with –lab Note: old documentation may suggest “–notebook” Also:
Removing stopwords with NLTK
Code with explanations: Just the code
How to write files and read files in python
In short How would you optimize saving expensive API calls? Explanation Say you have a function with output you want to save. It could be from: Step: Create the directory you are saving to. I usually write to the system tmp directory or a project tmp tmp directory and put “tmp” in my gitignore so…
How to time a function in python (bonus: intervals ⏱️)
Method 1: use time.time() and do calculations Method 2: Create a Timer class that stores the start time and last time recorded
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…