Package: tulp
TULP: TULP Understands Language PromptlyA command line tool, in the best essence of POSIX tooling, that will help you toprocess,filter, andcreatedata in this new Artificial Intelligence world, backed by chatGPT.TULP allows you to harness the power of chatGPT by piping standard input content directly to chatGPT, getting the answer back on the shell.Installation:pipinstalltulpUsage:TULP has 3 main operation modes:request:Process the user request:tulp[Awrittenrequestorquestion]stdin processing:Process or filter all the stdin input according to the user instructions, writing the processed output to stdout.cat[MYFILE]|tulp[Processinginstructionswritteninnaturallanguage]Code Interpretation:Add a -x to any of the previous operations, and Tulp will try tocreate, debug, and executea program that gets the request done!.cat examples/titanics.csv | tulp -x how many persons survivedIn both cases, TULP will write to the standard output the answers and will write any other information to the standard error. You can safely pipe the output to your file or next piping command and will still get all the information and errors on stderr.It isimportantto note that if your input is larger than 5000 characters, the input will be split into multiple chunks and processed by chatGPT in multiple requests. In this case, the result quality will really depend on the task (e.g., will work fine for translations or grammatical corrections, it will work terribly for summarizing). Anyway,tulp works great when the input is less than 5000 chars.By default, tulp usesgpt-3.5-turbo, because it is cheaper andfaster, but for complex tasks, it is always agood idea to force the gpt-4 model: tulp --model gpt-4 {a complex task}Options:usage: tulp [-h] [-x] [-w W] [--model {gpt-3.5-turbo,gpt-4}] [--max-chars MAX_CHARS] [-v] [-q] ...

TULP Understands Language Promptly: A command line tool, in the best essence of POSIX tooling, that will help you to **process**, **filter**, and **create** data in this new Artificial Intelligence world, backed by chatGPT.

positional arguments:
  request               User request, instructions written in natural language

optional arguments:
  -h, --help            show this help message and exit
  -x                    Allow tulp to create a program and execute it to fulfill the task (code interpret)
  -w W                  Write the output (or the created program for execution) to the file. If the file exists, a backup will be created before overwriting it.
  --model {gpt-3.5-turbo,gpt-4}
                        Select the LLM model to use, currently gpt-3.5-turbo or gpt-4
  --max-chars MAX_CHARS
                        Number of chars per message chunk per request
  -v                    Be verbose!
  -q                    Be quiet! Only print the answer and errors.ConfigurationThe configuration file is located at ~/.tulp.conf.The following are the parameters that can be configured:LOG_LEVEL: The log level of Tulp. Valid options are DEBUG, INFO, WARNING, ERROR, and CRITICAL. The default value is INFO.OPENAI_API_KEY: The API key for OpenAI. The default value is an empty string.MAX_CHARS: The maximum number of characters processed in one chunk. The default value is 5000.MODEL: The OpenAI model to be used by Tulp. The default value is gpt-3.5-turbo, but gpt-4 is also available.All these settings could be overridden by an environment variable using the prefix TULP_ or by the different command line arguments described above.
As environment variables, they will become: TULP_LOG_LEVEL, TULP_OPENAI_API_KEY, TULP_MAX_CHARS, or TULP_MODEL.
Command line arguments will override environmental variables and the configuration file.Here is an example configuration file with the default values:[DEFAULT]LOG_LEVEL=INFOOPENAI_API_KEY=<<<YOUR API KEY >>>>MAX_CHARS=10000MODEL=gpt-3.5-turboExamples:The usage is endless, but anyway, here you have some ideas as inspiration:RandomCreate a plot directly from raw memory output printed by gdb:Command:cat<<EOF | tulp convert this to a python list of 2 element tuples |  tulp write a python function to scatter plot these points using matplotlib | python(gdb) p *polygon._points._M_ptr._M_impl._M_start@4$21 = {{x = 0.441429973, y = -0.176619753}, {x = 0.476210177, y = -0.104575738}, {x = 0.674865067, y = -0.0814191923}, {x = 0.640084863, y = -0.199776307}}EOFResult:Typical Unix tooling replacement:SedcatREADME.md|tulpreplacealltheoccurrencesofTULPfor**TULP**AwkcatREADME.md|tulpprintthesecondwordofeachlinegrep, but advancedcattulp.py|tulpprintthenameofthefunctionsandalsothereturnlineGrammatical and syntax corrections:catREADME.md|tulpfixallthetypos,syntaxandgrammaticalerrors>README.fix.mdOr even better:catREADME.md|TULP_MAX_CHARS=10000TULP_MODEL=gpt-4tulpfixallthetypos,syntaxandgrammaticalerrors>README.fix.mdTranslationscatREADME.md|tulptranslatetoSpanish>README.es.mdData filtering from formatted inputcsvcatlist.csv|tulpprintonlythesecondcolumn
Count312csvcatpersons.json|tulp'list the names and ages of each person in a csv table, using ; as separator'Data creation and extraction from unstructured data (a story of oranges and friends):fede@liebre:~/repos/tulp$tulpwriteapoemthatnames3persons\(giveneachaname\)andlisthowtheyshared10oranges|teeexamples/oranges_poem.txt
Rosesarered,
Violetsareblue,
Here's a poem,About sharing oranges too.There were three friends,Whose names were Ann, Ben, and Sue,They had 10 oranges,And didn'tknowwhattodo.

Annsuggestedtheysplitthem,
Equally,threeeach,
ButBensaidthatwasn't fair,As Sue was too weak.So they decided to give Sue,An extra orange or two,And split the rest evenly,So everyone had a fair view.And that'showAnn,Ben,andSue,
Sharedtheir10oranges,
Withkindnessandfairness,
Andnoonehadanygrudges.

fede@liebre:~/repos/tulp$catexamples/oranges_poem.txt|python3./tulp.pywritealistofpersonsandthenumberoforangesthattheyhaveascsv
Ann,3
Ben,3
Sue,4Origin of the nameI usedtulp.pyto create "TULP". In some way, everything is recursive in "TULP", so it makes sense to use a recursive acronym.Therefore, after several iterations withtulp.py, "TULP" and I decided that the best name would be "TULP", and this is how we decided what "TULP" stands for:fede@liebre:~/repos/openai/tulp$python3./tulp.py"TULP is a recursive acronym naming an opensource posix tool that processes stdin input according to natural language instructions, processing the input by instructing an artificial intelligence. Write some options of what TULP could stand for as recursive acronym"TULPcouldstandfor:
-TULPUnderstandsLanguagePerfectly
-TULPUsesLanguagetoProcess
-TULPUnderstandsLanguagePromptly
-TULPUtilizesLanguageforProcessing
-TULPUnravelsLanguagePreciselyWhy?I am a heavy user of Unix tooling (e.g: awk, jq, sed, grep, and so on), I have been using them since my early days and I used to think that I couldn't survive without them. But then, ChatGPT appeared, and I started to use more and more GPT for things that I used to use Unix tooling for. Somehow I feel the pain of cut & paste, and I was missing a way to do it faster and from within the terminal itself, so I came up withtulp.Changelogv1.0 | 2024-02-14Changed to use gpt-4-0125-preview model by defaultUpdated to use openapi v1.0Changes default max-chars to 40000v07  | 2023-05-23Adds Code Interpretation, -x optionv0.6 | 2023-05-11Adds all the settings as command line arguments