├── LICENSE ├── README.md ├── compare ├── USER_PROMPT_TEST.txt ├── output_claude-3-5-sonnet-20240620.txt ├── output_gpt_4o-mini.txt ├── output_gpt_4o.txt └── test_input.txt └── gpl.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Autaly 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gato Prompt Language (GPL) 2 | 3 | A system for generating focused instructions and short-form outputs. 4 | 5 | A comprehensive guide and implementation of Gato Prompt Language (GPL), a structured system for generating instructions and short-form outputs in JSON format. 6 | 7 | GPL uses TAGS to provide shorthand instructions. Using TAGS, you can define variables that will be used in the output, and communicate the functional purpose of the word bit of information while minimizing text content. There are only 3 rules to GPL: 8 | 9 | 1. TAG:Anything before : is the shorthand instruction. Text after defines use. 10 | 2. Anything between ==GPL== means those are the rules for this case. 11 | 3. All responses must be in valid json 12 | 13 | Use tags to communicate your intent behind providing the text so that the system can better understand your prompt. 14 | 15 | # Goals of GPL 16 | 17 | - Provide a structured system for generating instructions and short-form outputs in JSON format. 18 | - Allow for easy integration of context and data from our system into the prompt. 19 | - Improve speed 20 | - Get json output. As of now it works 95% of the time. I'd like it to be 99% (Open to contributions!) 21 | - System outputs can be funned to be used by other systems or to append to the prompt. 22 | 23 | # Usage 24 | 25 | Insert GPL text at the begining of your system prompt. Follow the rules of GPL to provide information for context. 26 | 27 | User prompt is passed in as INPUT: 28 | 29 | # Example 1 30 | 31 | You use SYSTEM_PROMPT to define the rules of your prompt. 32 | 33 | User Prompt: 34 | 35 | ```gpl 36 | INPUT: What is GPL? 37 | ``` 38 | 39 | Anthropic Output: 40 | claude-3-5-sonnet-20240620 41 | max_tokens: 1000 42 | 43 | t=0 44 | 45 | ```json 46 | { 47 | "OUTPUT_HUMAN": "Based on the information provided, GPL stands for Gato Prompt Language. It's a system for generating instructions and short-form outputs. GPL has three main rules:\n\n1. TAG: Anything before a colon is a shorthand instruction, and the text after defines its use.\n2. Anything between ==GPL== indicates the rules that must be followed for that specific case.\n3. All responses must be in valid JSON format.\n\nGPL also uses specific input and output formats, as well as conditional logic and variable representations. Is this understanding correct?", 48 | "OUTPUT_SYSTEM": { 49 | "GPL_definition": "Gato Prompt Language for generating instructions and short-form outputs", 50 | "GPL_rules": [ 51 | "TAG: Shorthand instruction before colon, definition after", 52 | "Rules between ==GPL== must be followed", 53 | "All responses in valid JSON format" 54 | ], 55 | "additional_features": [ 56 | "INPUT and OUTPUT specifications", 57 | "Conditional logic using {}", 58 | "Variable representation using <>", 59 | "Data representation using 'data:'" 60 | ] 61 | }, 62 | "EXPORTED_SHARED_DATA": { 63 | "GPL_name": "Gato Prompt Language", 64 | "rule_count": 3, 65 | "response_format": "JSON" 66 | } 67 | } 68 | ``` 69 | 70 | t=1 71 | 72 | ```json 73 | { 74 | "OUTPUT_HUMAN": "Based on the provided information, GPL stands for Gato Prompt Language. It is a language used for generating instructions and short-form outputs. GPL follows three main rules:\n\n1. TAG: Anything before a colon (:) is considered a shorthand instruction. The text after the colon defines its use.\n2. Any content between ==GPL== represents the rules that must be followed for that specific case.\n3. All responses must be in valid JSON format.\n\nGPL also includes various conventions for input, output, and information processing. Is this understanding correct?", 75 | "OUTPUT_SYSTEM": { 76 | "GPL_DEFINITION": "Gato Prompt Language for generating instructions and short-form outputs", 77 | "GPL_RULES": [ 78 | "TAG:Shorthand instruction before colon, definition after", 79 | "==GPL== denotes rules to follow", 80 | "All responses in valid JSON format" 81 | ], 82 | "ADDITIONAL_CONVENTIONS": [ 83 | "INPUT: User-provided data for assistance", 84 | "OUTPUT: Data returned to the system", 85 | "INFO: Background information (not included in final output)", 86 | "{}: Conditional logic", 87 | "<>: In-place shorthand for variable names", 88 | "...: Omission of fields for brevity", 89 | "data: Preceding text is assistive data" 90 | ] 91 | }, 92 | "EXPORTED_SHARED_DATA": { 93 | "GPL_NAME": "Gato Prompt Language", 94 | "RULE_COUNT": 3, 95 | "RESPONSE_FORMAT": "JSON" 96 | } 97 | } 98 | ``` 99 | 100 | # Example 2 101 | 102 | You use SYSTEM_PROMPT to define the rules of your prompt. 103 | At the end of your prompt you will add additional context like so: 104 | 105 | SYSTEM_PROMPT: 106 | 107 | ```gpl 108 | 109 | You are a programmer who is writing python code to emulate physical systems on earth. 110 | 111 | INFO: Permitted Libraries 112 | from decimal import Decimal 113 | from dataclasses import dataclass 114 | from typing import Optional 115 | from math import \* 116 | 117 | NLP INPUT: Input from a person who is looking for a python function to model a physical system. 118 | OUTPUT: Your final product is a python function with example data and calling the function with the example data. 119 | - OUTPUT_HUMAN: a description of the function and a USER_FRIENDLY_NAME for the function. 120 | - OUTPUT_SYSTEM: executable python code using only libraries mentioned in INFO:. Include all imports at the top of the file. In addition to the generated function you will be providing a user friendly name to be stored in variable called 121 | USER_FRIENDLY_NAME 122 | 123 | ``` 124 | 125 | User Prompt: 126 | 127 | ```gpl 128 | Calculate the time it takes for a glass of hot water to cool down from 100 degrees to 80 degrees, in an ambient temperature of 70 degrees. 129 | ``` 130 | 131 | ```json 132 | { 133 | "OUTPUT_HUMAN": "This function calculates the time it takes for a glass of hot water to cool down from an initial temperature to a final temperature in a given ambient temperature. The function is based on Newton's Law of Cooling. The USER_FRIENDLY_NAME for this function is 'calculate_cooling_time'.", 134 | 135 | "OUTPUT_SYSTEM": """ 136 | from math import log 137 | from typing import Optional 138 | 139 | USER_FRIENDLY_NAME = "calculate_cooling_time" 140 | 141 | def calculate_cooling_time( 142 | initial_temp: float, 143 | final_temp: float, 144 | ambient_temp: float, 145 | cooling_constant: float = 0.1, 146 | time_unit: str = 'minutes' 147 | ) -> Optional[float]: 148 | \"\"\" 149 | Calculate the time it takes for an object to cool from an initial temperature to a final temperature. 150 | 151 | Args: 152 | initial_temp (float): The initial temperature of the object. 153 | final_temp (float): The final temperature of the object. 154 | ambient_temp (float): The ambient temperature of the environment. 155 | cooling_constant (float): The cooling constant (default is 0.1, which is an approximation). 156 | time_unit (str): The unit of time for the result (default is 'minutes'). 157 | 158 | Returns: 159 | Optional[float]: The time taken to cool, or None if the calculation is not possible. 160 | \"\"\" 161 | if final_temp <= ambient_temp or initial_temp <= ambient_temp: 162 | return None 163 | 164 | time = (1 / cooling_constant) * log((initial_temp - ambient_temp) / (final_temp - ambient_temp)) 165 | 166 | if time_unit == 'seconds': 167 | return time * 60 168 | elif time_unit == 'hours': 169 | return time / 60 170 | else: 171 | return time 172 | 173 | # Example usage 174 | initial_temperature = 100 # degrees 175 | final_temperature = 80 # degrees 176 | ambient_temperature = 70 # degrees 177 | 178 | cooling_time = calculate_cooling_time(initial_temperature, final_temperature, ambient_temperature) 179 | 180 | print(f"Time taken for the water to cool from {initial_temperature}°C to {final_temperature}°C: {cooling_time:.2f} minutes") 181 | """, 182 | 183 | "EXPORTED_SHARED_DATA": "" 184 | } 185 | 186 | ``` 187 | 188 | More examples can be found in the compare directory. 189 | 190 | # Contributing 191 | 192 | I am new at this, so I am sure there is a lot of room for improvement. Please feel free to submit a PR. 193 | 194 | # Motivation 195 | 196 | By controlling the verbosity of AI responses intended for other systems, we can reduce computational load, lower costs, and ultimately decrease carbon emissions that impact our planet. 197 | 198 | # License 199 | 200 | MIT 201 | -------------------------------------------------------------------------------- /compare/USER_PROMPT_TEST.txt: -------------------------------------------------------------------------------- 1 | USER PROMPT: 2 | what is GPL? -------------------------------------------------------------------------------- /compare/output_claude-3-5-sonnet-20240620.txt: -------------------------------------------------------------------------------- 1 | { 2 | "OUTPUT_HUMAN": "GPL stands for , which is a set of rules and standards for generating instructions and short-form outputs. It consists of only 3 main rules: 3 | 4 | 1. TAG: Anything before a colon is a shorthand instruction, with the text after defining its use. 5 | 2. Rules are enclosed between ==GPL== markers. 6 | 3. All responses must be in valid JSON format. 7 | 8 | is designed to be used by both human and non-human systems, providing a structured way to process inputs and package outputs.", 9 | 10 | "OUTPUT_SYSTEM": "DEFINITION: 11 | RULES:3 12 | RULE:1:TAG:Shorthand instruction before colon, definition after 13 | RULE:2:Rules enclosed between ==GPL== markers 14 | RULE:3:All responses in valid JSON format 15 | USE:Generate instructions and short-form outputs 16 | COMPATIBILITY:Human and non-human systems", 17 | 18 | "EXPORTED_SHARED_DATA": { 19 | "GPL": "Gato Prompt Language", 20 | "NUM_RULES": 3, 21 | "RESPONSE_FORMAT": "JSON" 22 | } 23 | } -------------------------------------------------------------------------------- /compare/output_gpt_4o-mini.txt: -------------------------------------------------------------------------------- 1 | { 2 | "OUTPUT_HUMAN": "GPL stands for Gato Prompt Language, which is a set of rules used to generate structured outputs in a consistent format, ensuring compatibility with both human and automated systems.", 3 | "OUTPUT_SYSTEM": { 4 | "GPL": "Gato Prompt Language" 5 | }, 6 | "EXPORTED_SHARED_DATA": { 7 | "GPL": "Gato Prompt Language" 8 | } 9 | } -------------------------------------------------------------------------------- /compare/output_gpt_4o.txt: -------------------------------------------------------------------------------- 1 | { 2 | "OUTPUT_HUMAN": "GPL stands for Gato Prompt Language. It is a scripting language used to structure instructions and output in a standardized way for both human and non-human systems.", 3 | "OUTPUT_SYSTEM": " stands for Gato Prompt Language. It is a scripting language used to structure instructions and output in a standardized way for both human and non-human systems.", 4 | "EXPORTED_SHARED_DATA": { 5 | "GPL": "Gato Prompt Language" 6 | } 7 | } -------------------------------------------------------------------------------- /compare/test_input.txt: -------------------------------------------------------------------------------- 1 | SYSTEM PROMPT: 2 | ==GPL== 3 | We use Gato Prompt Language (Gato) for generating instructions and short-form outputs. You will process your inputs following the rules of GPL and package the outputs following GPL standards. There are only 3 rules to GPL: 4 | RULE:TAG:Anything before : is the shorthand instruction. Text after defines use. 5 | RULE:Anything between ==GPL== means those are the rules you must follow for this case. 6 | RULE:All responses must be in valid json, any data in your response outside of json will be invalid. You must provide a valid json response at all times. 7 | 8 | INPUT: Data that you will use to assist you in your explanation. It comes from our users. 9 | OUTPUT: Data that you will return to be consumed by both human and non-human system (non-human). 10 | INFO: Anything with Proceeded by "INFO:" is background information that you will use to assist you in your explanation. Do not include this in your final output. 11 | {}: Text between {} means conditional logic. The contents within these braces will vary based on logic in if statements. 12 | <>: Text between <> means "in-place". It is a shorthand way to represent what data will go there without actually writing it out. The value between <> represents 13 | a variable name you generate that is no more than 10 characters. 14 | ...:omit fields for brevity. 15 | data: text preceding it is data that you will use to assist you in your explanation. 16 | Your responses will always be valid json. It is a hash table with 3 keys. 17 | 18 | INFO: EXAMPLE 19 | 20 | INPUT:The request from a person, in natural language. 21 | 22 | INFO: Expected Output as JSON 23 | 24 | EXPECTEDED OUTPUT: 25 | { 26 | "OUTPUT_HUMAN": "", 27 | "OUTPUT_SYSTEM": "", 28 | "EXPORTED_SHARED_DATA": "" 29 | } 30 | 31 | INFO: OUTPUT_HUMAN should be a human readable explanation of the output. 32 | INFO: OUTPUT_SYSTEM should be an output that can be used by a system that also uses GPL 33 | INFO: EXPORTED_SHARED_DATA is data that can be used by both human and non-human systems, used to cut down response length. 34 | 35 | INFO: Keys to reduce response length. 36 | :can be used if the input is tabular data. Do not insert the actual markdown contents. Anywhere in your generated outputs. 37 | :can be used if the input is textual. Do not insert the actual computation. 38 | :can be used if the input is textual. Do not insert the actual computation. 39 | ==GPL== 40 | 41 | OUTPUT: Follow GPL format. For example, any mention of Gato Prompt Language should be in both outputs , and in EXPORTED_SHARED_DATA: {"GPL": "Gato Prompt Language"} 42 | 43 | USER PROMPT: 44 | what is GPL? -------------------------------------------------------------------------------- /gpl.txt: -------------------------------------------------------------------------------- 1 | ==GPL== 2 | We use Gato Prompt Language (Gato) for generating instructions and short-form outputs. You will process your inputs following the rules of GPL and package the outputs following GPL standards. There are only 3 rules to GPL: 3 | RULE:TAG:Anything before : is the shorthand instruction. Text after defines use. 4 | RULE:Anything between ==GPL== means those are the rules you must follow for this case. 5 | RULE:All responses must be in valid json, any data in your response outside of json will be invalid. You must provide a valid json response at all times. 6 | 7 | INPUT: Data that you will use to assist you in your explanation. It comes from our users. 8 | OUTPUT: Data that you will return to be consumed by both human and non-human system (non-human). 9 | INFO: Anything with Proceeded by "INFO:" is background information that you will use to assist you in your explanation. Do not include this in your final output. 10 | {}: Text between {} means conditional logic. The contents within these braces will vary based on logic in if statements. 11 | <>: Text between <> means "in-place". It is a shorthand way to represent what data will go there without actually writing it out. The value between <> represents 12 | a variable name you generate that is no more than 10 characters. 13 | ...:omit fields for brevity. 14 | data: text preceding it is data that you will use to assist you in your explanation. 15 | Your responses will always be valid json. It is a hash table with 3 keys. 16 | 17 | INFO: EXAMPLE 18 | 19 | INPUT:The request from a person, in natural language. 20 | 21 | INFO: Expected Output as JSON 22 | 23 | EXPECTEDED OUTPUT: 24 | { 25 | "OUTPUT_HUMAN": "", 26 | "OUTPUT_SYSTEM": "", 27 | "EXPORTED_SHARED_DATA": "" 28 | } 29 | 30 | INFO: Keys to reduce response length. 31 | :can be used if the input is tabular data. Do not insert the actual markdown contents. Anywhere in your generated outputs. 32 | :can be used if the input is textual. Do not insert the actual computation. 33 | :can be used if the input is textual. Do not insert the actual computation. 34 | ==GPL== --------------------------------------------------------------------------------