Package: python-hi
hi, a human interpreterA truly natural scripting languagehi runs your natural languageInstall humanscripthi script is provided in python-hi pip packagepipinstall-Upython-hiyou 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.Examplehi could you list current dirsince ? is special character in shell, if you want to use ?, just add quotation mark around it,like thishi "could you list current dir?"hi can also be used as shellbang interpreter
create a file: progressbar.hi#!/usr/bin/env hicouldyoudisplayaprogressbarfrom1to100?and chmod +x ./progressbar.hi
then ./progressbar.hi
It can be executed like any other script.$./progressbar.hi#!/usr/bin/env bashecho"Progress:"for((i=1;i<=100;i++))doecho-ne"$i%\r"sleep0.1doneecho"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)UsageConfig hiWe need to add it to~/.hiHI_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 valueNow you can run hi script either from command line or as an shellbang interpreter(check out samples/*.hi)Cache invalidationafter you first run the script, the converted bash code will be cached in ~/.hicache/ , you can runhicacheclearto completely clear the cache.Configuration that can change runtime behavioryou can set the following variables in ~/.hi(in yaml format) or use in command line like$HI_API_KEY="sk-xxx"hi...HI_EXECUTEyou can use HI_EXECUTE to control the execution of the hi script$HI_EXECUTE="false"hi...HI_APIDefault:https://api.openai.com/v1A 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 Studiois a good option.HI_API="http://localhost:1234/v1"HI_API_KEYDefault:unsetThe API key to be sent to the LLM backend. Only needed when using OpenAI.HI_API_KEY="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"HI_MODELDefault:gpt-4The model to use for inference.HI_MODEL="gpt-3.5"HI_EXECUTEDefault:trueWhether 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_REGENERATEDefault:falseWhether 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"InspirationThis 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.LicenseMIT © femto Zheng