From eec826dd486440e2210c18fcde0445a4ed45e0bd Mon Sep 17 00:00:00 2001 From: J S <49557684+svilupp@users.noreply.github.com> Date: Sat, 18 May 2024 19:52:24 +0100 Subject: [PATCH] upsampling prompt --- CHANGELOG.md | 1 + app.jl | 5 ++++- src/view_builder.jl | 9 ++++++--- templates/PromptGeneratorUpsampler.json | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 templates/PromptGeneratorUpsampler.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a703c4..0ba2fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Chat tab Prompt Builder tab - Added a "Detailed view" button to toggle between a compact view and a detailed view +- Added an alternative template `:PromptGeneratorUpsampler` that generates a prompt template for chat without extensive examples (zero-shot prompt) Configuration - Changed default OpenAI model to GPT-4 Omni diff --git a/app.jl b/app.jl index 474ae6b..bf54336 100644 --- a/app.jl +++ b/app.jl @@ -116,6 +116,9 @@ const HISTORY_SAVE = get(ENV, "PROTO_HISTORY_SAVE", true) @in builder_detailed_view = false @in builder_model = isempty(PT.GROQ_API_KEY) ? "gpt4o" : "gllama370" @in builder_samples = 3 + @in builder_template = "PromptGeneratorBasic" + @out builder_tpl_options = filter( + x -> occursin("PromptGenerator", string(x)), keys(PT.TEMPLATE_STORE)) # Template browser @in template_filter = "" @in template_submit = false @@ -335,7 +338,7 @@ const HISTORY_SAVE = get(ENV, "PROTO_HISTORY_SAVE", true) if first_run ## Generate the first version conv_current = send_to_model( - :PromptGeneratorBasic; task = builder_question, model = builder_model) + Symbol(builder_template); task = builder_question, model = builder_model) instructions, inputs = parse_builder(PT.last_message(conv_current)) new_sample = Dict(:name => "tab$(i)", :label => "Sample $(i)", diff --git a/src/view_builder.jl b/src/view_builder.jl index 4e2adcd..1509cf9 100644 --- a/src/view_builder.jl +++ b/src/view_builder.jl @@ -9,13 +9,16 @@ function tab_builder_settings() class = "py-5", headerstyle = "bg-blue-1", [ row(p("Prompt Builder Settings", class = "text-lg text-weight-bold pt-4")), - row([select(:builder_model, options = :model_options, label = "Model")]), + row(cell([select(:builder_model, options = :model_options, label = "Model")])), row(class = "pt-4", - [p("Number of Samples"), + cell([ + p("Number of Samples"), slider( 1:1:10, :builder_samples, labelalways = true, snap = true, class = "ml-4, my-5", - markers = 1)]) + markers = 1)])), + row(cell([select(:builder_template, options = :builder_tpl_options, + label = "Builder Template")])) ]) ]) end diff --git a/templates/PromptGeneratorUpsampler.json b/templates/PromptGeneratorUpsampler.json new file mode 100644 index 0000000..a9f9399 --- /dev/null +++ b/templates/PromptGeneratorUpsampler.json @@ -0,0 +1 @@ +[{"content":"Template Metadata","description":"Given a user task it generates the enhanced system (instructions) and user prompt (inputs). It contains no examples (zero-shot prompt). Placeholders: `task`","version":"1.0","source":"","_type":"metadatamessage"},{"content":"You are an expert in writing clear, comprehensive instructions for unworldly AI assistants to accomplish tasks. Your goal is to take an existing task prompt that is often succint and generic and rewrite it to be clearer, more detailed, and better aligned with best practices for instructing AI.\n\nThe existing task prompt will be provided in the tags. Carefully read through this prompt and identify areas that could be improved. \n\nThen, write a new and improved version of the task prompt. The structure should be:\n\n Provide your thinking process and the plan you aim to follow when necessary. \n\n- Plan out where to include each variable.\n- Variables are formatted in double handlebars like this `{{variable_name}}` and are always single word or two words in lowercase with an underscore. You may refer to this variable later in the template, but do so without the double brackets.\n- Any information that the AI requires to know before it can complete the task MUST be included in the tags. But there can be only 2-3 variables. Everything else must be provided in the tags as suggestions to fill in the details.\n- Inputs section MUST preface each variable placeholder with its name, eg, `Milk Carton: {{milk_carton}}`, `Milk Curd: {{milk_curd}}`. You may refer to this variable later in the template by using its name, avoid using the curly braces in any references.\n\n\n- Specify the AI's role using superlatives to enhance performance \n- Give step-by-step instructions for the AI to follow, including:\n-- Detailed explanation of the task goal and desired output format\n-- Examples of input the AI will receive and desired output\n-- Guidance to \"think through\" the task and show its reasoning before responding\n-- Encouragement to ask clarifying questions if needed\n- Define any key terms that may be ambiguous\n- Use simple language and short sentences\n- Encourage the AI assistant to \"think step by step\" before responding. Use tags like or to indicate thinking process BEFORE RESPONDING. \n- Repeat the most important instructions\n\n\nA list of input variables the AI will receive, enclosed in double curly braces like {{variable_name}}. Use descriptive names and keep the number of variables to a minimum.\n\n\n\n\nBefore drafting the improved prompt, take time to analyze the original and brainstorm ideas for enhancement. Think step by step inside of tags. \nYou should use apply thinking process yourself before you write any of the instructions.Aim to make the new version substantially better than the original while preserving the core task. Let your first response be your improved prompt draft, formatted as specified above.\n\n ","variables":["variable_name","milk_carton","milk_curd","variable_name"],"_type":"systemmessage"},{"content":" \n {{task}}\n \n\nTo write your instructions, follow THESE instructions first:\n1. Apply thinking process in tags.\n2. In tags, plan out how you will structure your instructions.\n3. In tags, write the instructions for the AI assistant to follow.\n4. Finally, in tags, write down the barebones, minimal, nonoverlapping set of text input variable(s) the instructions will make reference to. They should be formatted as double handlebars (eg, `{{variable_name}}`).\n\n\nNote: This is probably obvious to you already, but you are not *completing* the task here. You are writing instructions for an AI to complete the task.\nNote: If the task is particularly complicated, you may wish to instruct the AI to think things out beforehand in scratchpad or inner monologue XML tags before it gives its final answer. For simple tasks, omit this.\nNote: If you want the AI to output its entire response or parts of its response inside certain tags, specify the name of these tags (e.g. \"write your answer inside tags\") but do not include closing tags or unnecessary open-and-close tag sections.\n ","variables":["task","variable_name"],"_type":"usermessage"}] \ No newline at end of file