Skip to main content

hi, a human interpreter

A truly natural scripting language

hi runs your natural language

Install humanscript

hi script is provided in python-hi pip package

pip install -U python-hi

you can also clone this repository and run "poetry install"

Be careful The converted bash can contain weird things. you can run hi script initially with HI_EXECUTE=false to check the resulting code before executing.

Example

hi could you list current dir

since ? is special character in shell, if you want to use ?, just add quotation mark around it,like this

hi "could you list current dir?"

hi can also be used as shellbang interpreter create a file: progressbar.hi

#!/usr/bin/env hi
could you display a progress bar from 1 to 100?

and chmod +x ./progressbar.hi then ./progressbar.hi It can be executed like any other script.

$ ./progressbar.hi
#!/usr/bin/env bash

echo "Progress:"

for ((i=1; i<=100; i++))
do
    echo -ne "$i%\r"
    sleep 0.1
done

echo "Complete!"%  

The code is sent to LLM and then convert to bash and then execute, while also cache for next time fast reexecute(then it doesn't need to query the LLM again)

Usage

Config hi

We need to add it to ~/.hi

HI_API_KEY: sk-xxx
HI_MODEL: gpt-4
#HI_API: if you have a different base to forward other than https://api.openai.com/v1, it's set using openai.openai_api_base=this value

Now you can run hi script either from command line or as an shellbang interpreter(check out samples/*.hi)

Cache invalidation

after you first run the script, the converted bash code will be cached in ~/.hicache/ , you can run

hi cache clear

to completely clear the cache.

Configuration that can change runtime behavior

you can set the following variables in ~/.hi(in yaml format) or use in command line like

$ HI_API_KEY="sk-xxx" hi ...

HI_EXECUTE

you can use HI_EXECUTE to control the execution of the hi script

$ HI_EXECUTE="false" hi ...

HI_API

Default: https://api.openai.com/v1

A server following OpenAI's Chat Completion API.

Many local proxies exist that implement this API in front of locally running LLMs like Llama 2. LM Studio is a good option.

HI_API="http://localhost:1234/v1"

HI_API_KEY

Default: unset

The API key to be sent to the LLM backend. Only needed when using OpenAI.

HI_API_KEY="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

HI_MODEL

Default: gpt-4

The model to use for inference.

HI_MODEL="gpt-3.5"

HI_EXECUTE

Default: true

Whether or not the hi interpreter should automatically execute the generated code on the fly.

If false the generated code will not be executed and instead be streamed to stdout.

HI_EXECUTE="false"

HI_REGENERATE

Default: false

Whether or not the hi interpreter should regenerate a cached hiscript.

If true the hiscript will be reinterpreted and the cache entry will be replaced with the newly generated code. Due to the nondeterministic nature of LLMs each time you reinferpret a hiscript you will get a similar but slightly different output.

HI_REGENERATE="true"

Inspiration

This project is highly inspired by humanscript project(https://github.com/lukechilds/humanscript), but I think hi is a better name, also hi can be interpreted as short for human input, human inteprete,human interface, human inferenceinterpreter etc, and just for fun. Also using python is easier for plugin architecture, the way I think is in different project/workspace, maybe there will be different 'hi' implementations, so .hi in that directory with plugin_type="metagpt" will run some metagpt command at that directory.

License

MIT © femto Zheng

Metadata

Release files for python-hi 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-hi 0.1.3
File Size Uploaded
python_hi-0.1.3.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-hi 0.1.3
File Interpreter ABI Platform
python_hi-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / python_hi-0.1.3.tar.gz

Download URL python_hi-0.1.3.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9827b9daa3f9e52a0736c9b0d25cb5300e2b1e0805a3b7e653350a201e74f123
BLAKE2b-256 checksum
How to use checksums
9d2327cced5692c0056204f06b649f138961984dda375337da1d4d8db16d91d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/21.5.0

Release files / python_hi-0.1.3-py3-none-any.whl

Download URL python_hi-0.1.3-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f50704312091ccb678d0adbeb633dae7f36a6ca886c37684b71a30948ef68145
BLAKE2b-256 checksum
How to use checksums
9e18986f2629dba3163821222dbd9a5c9ac2ade751cffbdfd1037da0efbf88de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/21.5.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page