Code Monkey home page Code Monkey logo

prooompt-engineer's Introduction

prooompt-engineer

We can do variable templating like in Jinja2...

{% message system %}
You are a genius
{% endmessage %}

{% message user %}
My name is {{name}}. What is my name?
{% endmessage %}
[
  {
    "type": "message",
    "role": "system",
    "template": [
      {
        "type": "text",
        "content": "You are a genius"
      }
    ]
  },
  {
    "type": "message",
    "role": "user",
    "template": [
      {
        "type": "text",
        "content": "My name is "
      },
      {
        "type": "eval",
        "value": "name"
      },
      {
        "type": "text",
        "content": ". What is my name?"
      }
    ]
  }
]

We can evaluate python expressions...

{% message user %}
Alpha is {{alpha}}. Beta plus one is {{beta+1}}. Express {{alpha + 2 * beta}} in terms of alpha and beta.
{% endmessage %}
[
  {
    "type": "message",
    "role": "user",
    "template": [
      {
        "type": "text",
        "content": "Alpha is "
      },
      {
        "type": "eval",
        "value": "alpha"
      },
      {
        "type": "text",
        "content": ". Beta plus one is "
      },
      {
        "type": "eval",
        "value": "beta+1"
      },
      {
        "type": "text",
        "content": ". Express "
      },
      {
        "type": "eval",
        "value": "alpha + 2 * beta"
      },
      {
        "type": "text",
        "content": " in terms of alpha and beta."
      }
    ]
  }
]

We can define loops within our prompts...

{% message user %}
I have three friends:

{% for friend in friends %}
- {{friend.name}} aged {{friend.age}}
{% endfor %}

Who is the oldest?
{% endmessage %}
  [
    {
      "type": "message",
      "role": "user",
      "template": [
        {
          "type": "text",
          "content": "I have three friends:\n"
        },
        {
          "type": "loop",
          "content": "name",
          "iterator": "friend",
          "iterable": "friends",
          "template": [
            {
              "type": "text",
              "content": "\n- "
            },
            {
              "type": "eval",
              "value": "friend['name']"
            },
            {
              "type": "text",
              "content": " aged "
            },
            {
              "type": "eval",
              "value": "friend['age']"
            }
          ]
        },
        {
          "type": "text",
          "content": "\n\nWho is the oldest?"
        }
      ]
    }
  ]

We can define loops outside our prompts (to get few shot templates ๐Ÿ™€)...

{% for example in few_shot_examples %}

    {% message user %}
    What is {{example.alpha}} + {{example.beta}}?
    {% endmessage %}

    {% message assistant %}
    {{example.alpha + example.beta}}
    {% endmessage %}

{% endfor %}

{% message user %}
What is {{gamma}} + {{delta}}?
{% endmessage %}
[{
    "type": "loop",
    "content": "example",
    "iterator": "example",
    "iterable": "few_shot_examples",
    "template": [{
        "type": "message",
        "role": "user",
        "template": [{
            "type": "text",
            "content": "What is "
        }, {
            "type": "eval",
            "value": "example.alpha"
        }, {
            "type": "text",
            "content": " + "
        }, {
            "type": "eval",
            "value": "example.beta"
        }, {
            "type": "text",
            "content": "?"
        }]
    }, {
        "type": "message",
        "role": "assistant",
        "template": [{
            "type": "eval",
            "value": "example.alpha + example.beta"
        }]
    }]
}, {
    "type": "message",
    "role": "user",
    "template": [{
        "type": "text",
        "content": "What is "
    }, {
        "type": "eval",
        "value": "gamma"
    }, {
        "type": "text",
        "content": " + "
    }, {
        "type": "eval",
        "value": "delta"
    }, {
        "type": "text",
        "content": "?"
    }]
}]

prooompt-engineer's People

Contributors

wantpinow avatar

Stargazers

Diana Muse avatar  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.