natural-python
Gitlab repository | Github mirror | Blog post
This is a wrapper around the Python REPL which uses LLMs to search for code that matches your natural language specification and Python constraints.
Naturally, from a safety perspective the output of an LLM can only be assumed to be adversarial. Indeed, executing the output of an LLM is an inherently dangerous approach to implementing a REPL. Use at your own peril.
Example
Hello world session: given this input
>>> # Create a list with the days of the week, call it 'days'
>>> # finally:
+++ assert days[0] == 'Sunday'
+++
the interpreter will write the following code:
>>> days = [
>>> 'Sunday',
>>> 'Monday',
>>> 'Tuesday',
>>> 'Wednesday',
>>> 'Thursday',
>>> 'Friday',
>>> 'Saturday',
>>> ]
>>> assert days[0] == 'Sunday'
Installation
pip install --user --upgrade git+https://gitlab.com/da_doomer/natural-python.git
(You can remove --upgrade if your pip is reasonably updated)
Then simply execute natural-python --output my_script.py in your shell (--output is an optional parameter).
The first time the interpreter is executed, it will ask for an API key. Currently, the interpreter supports GooseAI and OpenAI endpoints.
Usage
Run natural-python --help to get the following:
usage: natural-python [-h] [--engine-id ENGINE_ID] [--sample-n SAMPLE_N] [--sample-temperature SAMPLE_TEMPERATURE] [--max-sample-tokens MAX_SAMPLE_TOKENS]
[--python-shell PYTHON_SHELL] [--show-engines] [--output OUTPUT]
Natural Python interpreter.
options:
-h, --help show this help message and exit
--engine-id ENGINE_ID
Language model engine used for sampling.
--sample-n SAMPLE_N Number of samples drawn from the language model when executing an instruction.
--sample-temperature SAMPLE_TEMPERATURE
Sampling temperature.
--max-sample-tokens MAX_SAMPLE_TOKENS
Maximum number of tokens in each sample.
--python-shell PYTHON_SHELL
Engine used for sampling.
--show-engines Display available language model engines.
--output OUTPUT Write the source code to a file at the end of the session.
Metadata
Release files for natural-python 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| natural-python-0.1.8.tar.gz | 9.0 kB | Without provenance | Details for natural-python-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| natural_python-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for natural_python-0.1.8-py3-none-any.whl |
Total release size: 18.7 kB
Release files / natural-python-0.1.8.tar.gz
| Download URL | natural-python-0.1.8.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6907ba4efde94adbdb737fc759df709b319b1cadf24b16a5a7e5d06caba5395d
|
|
BLAKE2b-256 checksum How to use checksums |
1aa27d8124ca3cabd70f240ec4e939d182a45c7c2def31477d5a680097a4171e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.4 Linux/6.0.12-76060006-generic
|
Release files / natural_python-0.1.8-py3-none-any.whl
| Download URL | natural_python-0.1.8-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dce55cda8f9fc8218ad86dcebc0e06ed61ffb054fa403319dc22e8a54a0d68cc
|
|
BLAKE2b-256 checksum How to use checksums |
0e8492c6fefbc2eb2007794f1691c36dfc54bef9b6ec107f0a08861b21ffd002
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.4 Linux/6.0.12-76060006-generic
|
Security for natural-python 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.