Giter Club home page Giter Club logo

llm-prompt-optimizer's Introduction

๐Ÿš€ LLMPromptOptimizer: a simple tool for Optimizing Prompts! ๐Ÿค–

LLMPromptOptimizer helps you optimize your prompts to get the best possible responses from AI models like ChatOpenAI! ๐Ÿ’ป

๐ŸŽ‰ How does it work? To use the tool out-of-the box, simply configure your desired input and settings values in the config.js file. Using the Langchain library, you can choose which AI model to use and its settings, which input files to fetch, and how to print the results.

If you want to use the tool out of the box, start out by setting an environment variable OPENAI_API_KEY to an OpenAI API key. You can set it in your PATH and it will be accessed automatically.

Here is how to use the tool when you have configured the config.js file:

  1. First, run node createOutputs.js to generate the outputs for each prompt pair.

  2. Then, run node resultAnalyser.js to see each result from the prompts in turn. You can say y/n to each result and see the score for each prompt pair at the end! ๐Ÿ“Š

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ (index) โ”‚ prompt โ”‚ files                   โ”‚ yes โ”‚ no โ”‚ percentageYes โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚ 0       โ”‚ 1      โ”‚ 'system1.txt,user1.txt' โ”‚ 3   โ”‚ 0  โ”‚ '100.00%'     โ”‚
    โ”‚ 1       โ”‚ 2      โ”‚ 'system2.txt,user2.txt' โ”‚ 1   โ”‚ 2  โ”‚ '33.33%'      โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค Some key features of LLMPromptOptimizer include:

  1. Multiple prompt pairs: Configure multiple prompt pairs in a single file, each with its own set of system and user messages, and prompt template inputs

    //config.js
    export const promptPairs = [
    ['system1.txt', 'user1.txt', promptInput1, aiModel],
    ['system2.txt', 'user2.txt', promptInput2, aiModel],
    ]
  2. Customizable AI model: Choose from a variety of AI models available through Langchain, including ChatOpenAI, and customize the configuration for each prompt pair. You can test the same prompt with two different models and evaluate the result.

    //config.js
    const aiModel= new ChatOpenAI({
    // modelName: "gpt-4",
    // temperature: 0,
    });
  3. Result printing: LLMPromptOptimizer lets you configure how to print the results of the prompt pairs.

    โžค  ๐Ÿ”ฅ Please evaluate the following result:
    
    
    โžค  "NASA is a space agency that sends people and robots into space. They explore planets, study stars, and learn about the universe. It's like a big adventure in space!"
    
    
    โ™ฅ  Do you approve (y/n)?:
    
  4. Adaptive structure: LLMPromptOptimizer allows you to adapt the result structure to suit your needs. In config.js you can extract individual items from array outputs if you want to evaluate them individually.

๐Ÿ’ป And of course, if you need to adapt the tool even more, you can go beyond the config.js file and edit the other code to suit your needs.

llm-prompt-optimizer's People

Contributors

eli6 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.