2023-06

2023-06-24 Gossipping in June, is spilling the LGBTea by Jesper Dramsch

The Latest Fashion

2023-06-17 How inclusive is generative AI on chatLGBT ? by Jesper Dramsch

2023-06-18 symbex: search Python code for functions and classes, then pipe them into a LLM

I just released a new Python CLI tool called symbex.

It’s a search tool, loosely inspired by ripgrep, which lets you search Python code for functions and classes by name or wildcard, then see just the source code of those matching entities.

I partly built this to have fun learning Python’s ast module, but it’s mainly designed to complement my LLM CLI tool for running large language model prompts.

Searching for functions and classes

Here’s an example of what it can do. Running in my datasette/ folder:

symbex inspect_hash

Code explanations with a large language model

Check this out:

symbex inspect_hash | llm --system 'explain succinctly'

Output:

This function calculates the hash of a database file efficiently by
reading the file in blocks and updating the hash object using SHA256
algorithm from the hashlib module.

The resulting hash value is returned as a hexadecimal string.

Refactoring code

Let’s try something a whole lot more useful:

symbex Request | llm --system 'add type hints to this'

This locates the Request class in Datasette—this one here, and starts adding Python type hints to it.

The output started out like this (that code has no type hints at all at the moment):

Picking a name for the tool

The most time-consuming part of this project ended up being picking the name!

Originally I planned to call it py-grep. I checked https://pypi.org/project/py-grep/ and it was available, so I spun up the first version of the tool and attempted to upload it to PyPI.

2023-06-18 strip-tags 0.4 is now out, with a set of features to make it easier to turn large HTML pages into content suitable for feeding to a LLM

strip-tags 0.4 is now out, with a set of features to make it easier to turn large HTML pages into content suitable for feeding to a LLM

I wrote more about strip-tags here: https://simonwillison.net/2023/May/18/cli-tools-for-llms/