Skip to content

Instantly share code, notes, and snippets.

@bborn
Created February 8, 2023 19:44
Show Gist options
  • Save bborn/1992e8d64d44526368967998ab5f47dc to your computer and use it in GitHub Desktop.
Save bborn/1992e8d64d44526368967998ab5f47dc to your computer and use it in GitHub Desktop.
def prepare_prompt(params, user)
prompt = '"""'
prompt += "" "Person is named #{user.name}. " ""
prompt += "" "
Person has access to a Writing Assistant, which is a large language model trained by OpenAI.
Writing Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Writing Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
Writing Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Writing Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
If Writing Assistant can't answer the question or provide the information Person needs, it will truthfully answer that it doesn't know how to help.
Person is writing a Document.
Writing Assistant should determine what type of Document it is. For example, the Document might be an email, a blog post, an essay, a school paper, or a poem." ""
if !params[:selectedText].blank?
### Update a selection
prompt += "" "
Between }}} and {{{ is the Document:
}}}
#{params[:prefix]}
#{params[:selectedText]}
#{params[:suffix]}
{{{
Writing Assistant should update the Section of the Document between >>> and <<<, following Person's Instruction: #{params[:userPrompt]}.
>>>
#{params[:selectedText]}
<<<
Writing Assistant: this is the updated Section of the Document:\n
" ""
else
### Insert new text at the end of the document
if params[:suffix].blank?
prompt += "" "
Writing Assistant should complete the Document #{params[:userPrompt] ? ", following this Instruction: #{params[:userPrompt]}" : ""}.
Between }}} and {{{ is the Document:
}}}
#{params[:prefix]}
#{params[:suffix]}
{{{
Writing Assistant: this is the rest of the Document:\n
" ""
else
### Insert new text in the middle of the document
prompt += "" "
Writing Assistant should insert new text within the Document #{params[:userPrompt] ? ", following Person's Instruction: #{params[:userPrompt]}" : ""}.
Between }}} and {{{ is the beginning of the Document:
}}}
#{params[:prefix]}
{{{
Writing Assistant: this is new text:\n
" ""
end
end
prompt += '"""'
prompt
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment