__ ______ ____ _ UPG CLI / / / / __ \/ __ `/ Public Beta / /_/ / /_/ / /_/ / \__,_/ .___/\__, / 🇺🇸 Built by GPT Labs /_/ /____/ Now officially a CIA front company! (c) 2022 MIT License
This is an initial public release. It will be ugly. Please send feedback to
@gptlabs on Twitter.
What is UPG?
UPG is a tool for creating and editing programs given a target (language) and a description.
You can put anything you want in those fields, but some targets are supported
out of the box for execution (TypeScript using
tsmodule, Python using
python3, and OS-specific shell commands
cmd). You can
still execute non-supported targets by telling the CLI what command to run to
execute the output file.
yarn global add @gptlabs/upg
npm i -g @gptlabs/upg
After installing, you can update with
To create a new program, run
upg. You will be prompted to enter a language and
a description of what the program will do.
When you have a program loaded, either by creating a new one or using
upg load <file>, you can edit it by describing the changes that need to be made.
When you have a program loaded, you can ask UPG to explain it using the Explain command. We attempt to generate the most useful, detailed explanation possible.
By default, the language is set to an OS-specific shell:
zsh for Mac,
for Linux, and
cmd for Windows.
Converting files with
ffmpegspaghetti to convert all
.movfiles in the current directory to
Converting screen recordings of these demos to
.giffor use in this README:
Example: Other programs
You can generate programs for any language.
Plotting the Mandelbrot set with Python
An oldie but a goodie.
Generating and demonstrating the Y combinator function
Also adds a demo, and executes using TS Module¹.
¹ Similar to
ts-node, but won't throw on account of type errors. You'll need to install
@tsmodule/tsmodulefor now to run TS.
Solving nontrivial problems using an edit loop
UPG did not generate a solution to the minimum edit distance problem immediately. It initially contained errors and would not run.
First, errors were fixed using Edit to tell it:
fix errors: [pasted errors]. If you are able to identify the error logically and say it
conversationally rather than paste an error, that is better. (The person
who generated this solution was flying completely blind, could not solve
this problem if they wanted to, and had never written C.)
Then, failed cases were fixed using the following Edit pattern:
functionName(input) should equal A, got B. This was sufficient through
trial and error to fix the output for certain cases, until it passed for
Finally, once it converged on a working solution, it was asked to optimize
performance using the Edit command:
refactor: make it faster. (For
some reason, that spell works very well for performance optimization.)
Converting to other languages
You can translate programs to other languages using the edit feature. The
language context will not automatically change yet - in the meantime, use
Save to write to
yc.py and then
upg load yc.py to run it as Python.
Translating from TypeScript to Python
Translates the Y combinator output above.
UPG can translate comments and languages extremely reliably, for basically any language you could name. It speaks English, Chinese, and Japanese very fluently. See examples below for even harder language targets.
Translates the comments in the generated minimum edit distance solution to English.
Translates the comments in the same solution to Latin.
Something interesting actually happens in this translation, where
GPT-3 chooses a Romanian (Latin-descended) word
over the most likely best choice
begin", "to initiate"), due to it looking closer to English
initialize. But it
remains a reliable transation more or less.
Translates the comments in the same solution to Māori, an Eastern Polynesian language with approximately 180,000 native speakers.
It seems to drop the macrons (e.g. ā) due to code comments almost always being ASCII only.
Use the Explain command after loading a program to generate a detailed explanation of what it does.
Explaining the UPG-generated solution to the minimum edit distance problem
The following explanation was generated:
The program is a solution to the Levenshtein Distance problem, which is the minimum number of edits (insertions, deletions, or substitutions) needed to transform one string into another. The program uses a dynamic programming approach to solving the problem.
It is not possible yet to switch the language context for a translation, i.e. the CLI cannot know the above example was translated to Python, and if you select Run, it will attempt to execute it as TS.
This will be solved in future versions, but for now, use Copy or Save to get it out of the CLI and execute it manually, or load it with
upg load [new-file]and then Run.
See the Convert to other languages section above.