Skip to content

Tindell/ScriptPack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScriptPack

This project is a collection of scripts generated using GPT-4 and 3.5. Approximately 95% of the code was generated by these AI models. The goal of this project is to explore the capabilities of GPT-4 and 3.5 by creating useful tools for various tasks. The scripts include tools for generating commit messages, modifying clipboard text, searching man pages, and generating regular expressions.

Installation and configuration

Clone the repo.

In config.ini, change the saved_prompts_location to your project's memory folder.

Make sure your openai API key is saved in the environment variable OPENAI_API_KEY, or provided as an argument when you run the scripts.

Running in terminal

> cd .../src/utils
> ./LinkScripts.sh

Then you can run each script by name anywhere. For example,

> commitmeant

Running with mac automator

You can automate running the command line scripts using Mac Automator. Here's how to set it up:

  1. Open Automator from the Applications folder on your Mac.
  2. Create a new Quick Action by selecting "Quick Action" in the list of document types and clicking "Choose".
  3. In the Quick Action template, change the "Workflow receives" dropdown to "no input".
  4. Search for "Run Shell Script" and drag it into the workflow.
  5. Add the command python3 <...>/src/utils/openterm.py cliptweak replacing <...> with your project path and adding changing cliptweak script you want to automate.
  6. Save the workflow and give it a name.
  7. Open the "Keyboard" settings on your Mac.
  8. Click on the "Shortcuts" tab, then select "Services" from the list on the left.
  9. Scroll down to the "Text" section and find your workflow under "General".
  10. Click on your workflow to select it, then click on the "Add Shortcut" button and enter a keyboard shortcut.
  11. You may need to restart your computer for the keyboard shortcut to take effect.

Optional command line args for any of these scripts

  • --model: specifies the OpenAI model to use for generating responses. Format: string.
  • --printResponse: specifies whether to print the OpenAI response to the console. Format: boolean (True or False).
  • --operation: specifies the OpenAI operation to perform (e.g., generate_response or generate_message_response). Format: string.
  • --api_key: specifies the OpenAI API key to use for authentication. Format: string.
  • --saved_prompts_location: specifies the directory to save or load prompts from. Format: string.
  • --load_prompts: specifies whether to load prompts from a file. Format: boolean (True or False).
  • --save_prompts: specifies whether to save prompts to a file. Format: boolean (True or False).
  • --stream: specifies whether to stream the response from OpenAI. Format: boolean (True or False).

Running from Mac Automation Commands

See this link

  • TODO

Scripts:

This script prompts the user to enter a system prompt, a user prompt, and the maximum number of response tokens, and generates a response, printing it to the console as it is generated.

This script uses the ClipTweak class, a subclass of OpenAIInteraction, to modify text copied to the clipboard. The user selects a system prompt and the maximum number of response tokens, and the GPT-3 model generates a modified response. The modified text is then copied back to the clipboard and printed to the console. The script includes two system prompts to choose from.

This script defines a ManSearch class, a subclass of OpenAIInteraction, which can search a man page for a specified command and return information about that command. The script prompts the user to enter a command and then retrieves the corresponding man page. It then prompts the user to enter a query and calls the generate_response method to generate a response using the GPT-3 model. If the man page is too long, it prints an error message.

This script defines a mayberegex class that uses the OpenAI API to generate a regular expression pattern based on a user prompt. It validates the response and tests the generated regex on sample inputs and user inputs. The script prompts the user to input their own strings and checks if they match the generated regex pattern.

This script defines a Commitmeant class that uses GPT's API to generate a concise commit message for Git repositories. It checks if the script is being run inside a Git repository, stages changes, gets a Git diff, and commits the changes with a GPT-generated commit message. The user is prompted to accept or reject the generated commit message. The script exits if the token length of the Git diff is too large or if there are no changes detected to commit.

promptprompt is designed to assist users in creating comprehensive prompts for ChatGPT to respond to user requests. The class ensures that prompts are clear, concise, and contain all necessary information for ChatGPT to understand the user's request and provide an appropriate response. It also takes into account potential errors or misunderstandings and provides suggestions for correcting them.

This is much better as a few-shot problem, so there are the configuration options save_prompts and load_prompts for keeping track of good responses.

Base files:

This script defines a class called OpenAIInteraction that interacts with OpenAI's GPT-3 language model to generate responses to user prompts. The class reads parameters such as the API key and model to be used from a configuration file. It provides two main methods, generate_message_response and generate_response, which take in user prompts and generate responses using the GPT-3 model. The class also includes methods to count the number of tokens used by a list of messages or a string. These methods can be used for debugging or to ensure that responses do not exceed the token limits imposed by OpenAI.

This script opens a new terminal window and runs a specified command (only on macOS). It can be used to automate running these scripts outside of the terminal, for example binding cliptweak to a key binding.

About

Public scripts experimenting with some LLM APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published