Package: plunkylib
plunkylib - Python LLM User Navigation Kit via YAMLYour Buddy for OpenAI/GPT4/ChatGPT and moreplunkylibaims to be an experimenter's best friend when working with modern text generation engines. It stores prompts in reusable text files and supports nested prompt expansion.There's a simple CLI interface, but usually after you get going, you'll do most of your query tweaking in text and yaml files that you can version-control separately from your app (or save/restore for research usage).Installation(Coming soon)pipinstallplunkylibConfigure the API keys and other settingsCopy.env.templateto.envand add your API keys there:OPENAI_API_KEY = "ADD_YOUR_OPENAI_KEY"
AI21_API_KEY = "ADD_YOUR_AI21_API_KEY"
PINECONE_API_KEY = "ADD_YOUR_PINECONE_API_KEY"
PINECONE_PROJ_ENVIRONMENT = "ADD_YOUR_PINECONE_PROJECT_ENVIRONMENT"CLI InterfaceFor the most part, the expected workflow withplunkylibis to create some objects, modify the generated files on disk to do what you want, and then submit a namedpetitionobject to the LLM engine of choice to get it to generate the text you want.The CLI uses thetyperlibrary for its help/commands. So you can see the commands by running:>python-mplunkylib--helpand get an output like:Usage: cli.py [OPTIONS] COMMAND [ARGS]...
  --help                          Show this message and exit.

Commands:
  complete    (commands to complete texts from prompts)
  interact    (interactive petition usage)
  params      (records for settings for engine, temperature, etc)
  pet         (records for petititions, reusable combined prompt/params)
  prompt      (records for text used for completions)
  promptvars  (records for replacing text in prompts)Each command shows more of its help by providing its name with no parameters.You'll typically need a couple of things with easy setup before you begin, theparams(i.e.CompletionParams), theprompt, and apet(i.e.petition) to wrap those. Then you can usecompleteto generate aCompletion.1. CreateCompletionParamsfor your engine of choiceThere's some samples of a few engines indatafiles/plunkylib/params/Example*.yml, let's use GPT3 to start:>python-mplunkylibparamscopyfromExampleGPT3MyFirstEngineCopied CompletionParams ExampleGPT3 to MyFirstEngine:
CompletionParams(name='MyFirstEngine', engine='text-davinci-002', n=1, best_of=1, max_tokens=300, stop=['\n\n', '----\n'], temperature=0.3, top_p=1.0, frequency_penalty=0.0, presence_penalty=0.0)This createsdatafiles/plunkylib/params/MyFirstEngine.ymlwhich you can edit to customize your parameters.2. Create aPromptto useLet's use a simple sample first:>python-mplunkylibpromptcopyfromExampleSimpleMyFirstPromptCopied Prompt ExampleSimple to MyFirstPrompt:
Prompt(name='MyFirstPrompt', text='Describe the color of of the sky in flowery language.\n----\n')3. Create aPetitionto usePetitions just combine params and prompts into a reusable form since they often pair together.>python-mplunkylibpetcreateMyFirstPetitionMyFirstPromptMyFirstEngineCreated Petition MyFirstPetition, Petition(name='MyFirstPetition', prompt_name='MyFirstPrompt', params_name='MyFirstEngine', promptvars_name=None)4. Get a completion output!It'll pay off later for reusability and convenience, but finally we can now execute (and re-execute) the query we wanted to use.>python-mplunkylibcompleteuse-petMyFirstPetitionOutput:The sky is a deep, rich blue, like the petals of a flower. The blue is so deep that it seems to go on forever. The sky is dotted with white clouds, like cotton balls, which add to the beauty of the sky.You should now see the following files (in ./datafiles/plunkylib) directory, and they can be helpful for a file-based workflow.prompts/MyFirstPrompt.txtparams/MyFirstParams.ymlpetition/MyFirstPetition.ymlAs well ascompletions/MyFirstPetition-NNNN.ymlAll of these are files you can edit it in your favorite text editor and then rerun thecomplete use-petcommand on the petition you made. This makes it very easy to iterate on prompts and parameter combinations until you get what you want. Then you can reuse that again and again to generate the relevant text.The completions output is a log of the outputAdvanced Prompt Query NestingTODO: Describe the general{prompt.name}way to inject other text as well as{pet.name}to run another petition expansion recursively inside a prompt you're trying to complete. This makes it very easy to chain prompts together for complex cases.