2023-06 ¶
2023-06-24 Gossipping in June, is spilling the LGBTea by Jesper Dramsch ¶
The Latest Fashion
-
Turns out OpenAI lobbied the EU to water down AI regulation
-
Check out this great explainer for BatchNorm
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 ¶
-
https://til.simonwillison.net/gpt3/picking-python-project-name-chatgpt
-
https://fedi.simonwillison.net/@simon/110567557236834749 (The hardest part of this project was picking a name for it!I ended up using ChatGPT Browse, since it could both read the README)
-
https://fedi.simonwillison.net/@simon/110567525624161968 ( just released symbex, a tiny Python CLI tool for recursively searching for functions and classes)
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 ¶
-
https://fedi.simonwillison.net/@simon/110567547149384789 (Being able to pipe code to an LLM in the terminal is really fun)
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.