PromptingTools.jl: Getting Started


PromptingTools.jl is your gateway to buying back valuable time. Just a few cents can now liberate you from the tedium of repetitive tasks, leaving you free to focus on what truly matters.


Installing PromptingTools.jl is a breeze. Ensure Julia is installed on your system, and add the package via the Julia REPL with ]add This package is designed to be user-friendly, catering to both beginners and seasoned programmers.

Setting Up OpenAI API Key

To use PromptingTools.jl, obtain an OpenAI API key by signing up at OpenAI. Then, set it as an environment variable in Julia: ENV["OPENAI_API_KEY"] = "your-api-key".

For detailed guidance on setting persistent environment variables, refer to these links for Windows (see "Windows Set-up") and Unix/Linux.

Usage Examples

  1. String Manipulation:

using PromptingTools
   msg = aigenerate("Rewrite this sentence in a formal tone: {{sentence}}"; sentence="Hey, what's up?")
  1. Data Extraction:

# Define a custom return type
   "Individual hashtag"
   struct HashTag
   struct HashTags
   msg = aiextract("Extract individual hashtags from this tweet: 'I love #JuliaLang and #GenerativeAI!'"; return_type = HashTags)
  1. Image OCR:

# gpt4v is an alias for GPT-4 Vision
   msg = aiscan("Transcribe the text in the provided image.", image_path="path_to_image.jpg", model="gpt4v")
  1. Asking Questions:

# alias gpt4t is optional. It will forward the query to the most powerful GPT-4 Turbo model
   ai"In Julia, what's the use case for a Channel?"gpt4t
  1. Prompt Templates:


Available Functions

PromptingTools.jl offers a variety of functions including aigenerate, aiextract, aiclassify, and aiscan. Each is tailored for specific tasks, ranging from generating content to working with images. Moreover, there are pre-defined prompt templates for common tasks - find the best one with aitemplates. Explore the documentation to learn more about these functions and how they can transform your workflow.

Start your AI-powered journey in Julia with PromptingTools.jl and discover a new realm of possibilities!

CC BY-SA 4.0 Jan Siml. Last modified: April 30, 2024. Website built with Franklin.jl and the Julia programming language. See the Privacy Policy