prompts.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. from llama_index import QueryKeywordExtractPrompt
  2. CONVERSATION_TITLE_PROMPT = (
  3. "Human:{query}\n-----\n"
  4. "Help me summarize the intent of what the human said and provide a title, the title should not exceed 20 words.\n"
  5. "If the human said is conducted in Chinese, you should return a Chinese title.\n"
  6. "If the human said is conducted in English, you should return an English title.\n"
  7. "title:"
  8. )
  9. CONVERSATION_SUMMARY_PROMPT = (
  10. "Please generate a short summary of the following conversation.\n"
  11. "If the conversation communicating in Chinese, you should return a Chinese summary.\n"
  12. "If the conversation communicating in English, you should return an English summary.\n"
  13. "[Conversation Start]\n"
  14. "{context}\n"
  15. "[Conversation End]\n\n"
  16. "summary:"
  17. )
  18. INTRODUCTION_GENERATE_PROMPT = (
  19. "I am designing a product for users to interact with an AI through dialogue. "
  20. "The Prompt given to the AI before the conversation is:\n\n"
  21. "```\n{prompt}\n```\n\n"
  22. "Please generate a brief introduction of no more than 50 words that greets the user, based on this Prompt. "
  23. "Do not reveal the developer's motivation or deep logic behind the Prompt, "
  24. "but focus on building a relationship with the user:\n"
  25. )
  26. MORE_LIKE_THIS_GENERATE_PROMPT = (
  27. "-----\n"
  28. "{original_completion}\n"
  29. "-----\n\n"
  30. "Please use the above content as a sample for generating the result, "
  31. "and include key information points related to the original sample in the result. "
  32. "Try to rephrase this information in different ways and predict according to the rules below.\n\n"
  33. "-----\n"
  34. "{prompt}\n"
  35. )
  36. SUGGESTED_QUESTIONS_AFTER_ANSWER_INSTRUCTION_PROMPT = (
  37. "Please help me predict the three most likely questions that human would ask, "
  38. "and keeping each question under 20 characters.\n"
  39. "The output must be in JSON format following the specified schema:\n"
  40. "[\"question1\",\"question2\",\"question3\"]\n"
  41. )
  42. QUERY_KEYWORD_EXTRACT_TEMPLATE_TMPL = (
  43. "A question is provided below. Given the question, extract up to {max_keywords} "
  44. "keywords from the text. Focus on extracting the keywords that we can use "
  45. "to best lookup answers to the question. Avoid stopwords."
  46. "I am not sure which language the following question is in. "
  47. "If the user asked the question in Chinese, please return the keywords in Chinese. "
  48. "If the user asked the question in English, please return the keywords in English.\n"
  49. "---------------------\n"
  50. "{question}\n"
  51. "---------------------\n"
  52. "Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'\n"
  53. )
  54. QUERY_KEYWORD_EXTRACT_TEMPLATE = QueryKeywordExtractPrompt(
  55. QUERY_KEYWORD_EXTRACT_TEMPLATE_TMPL
  56. )
  57. RULE_CONFIG_GENERATE_TEMPLATE = """Given MY INTENDED AUDIENCES and HOPING TO SOLVE using a language model, please select \
  58. the model prompt that best suits the input.
  59. You will be provided with the prompt, variables, and an opening statement.
  60. Only the content enclosed in double curly braces, such as {{variable}}, in the prompt can be considered as a variable; \
  61. otherwise, it cannot exist as a variable in the variables.
  62. If you believe revising the original input will result in a better response from the language model, you may \
  63. suggest revisions.
  64. << FORMATTING >>
  65. Return a markdown code snippet with a JSON object formatted to look like, \
  66. no any other string out of markdown code snippet:
  67. ```json
  68. {{{{
  69. "prompt": string \\ generated prompt
  70. "variables": list of string \\ variables
  71. "opening_statement": string \\ an opening statement to guide users on how to ask questions with generated prompt \
  72. and fill in variables, with a welcome sentence, and keep TLDR.
  73. }}}}
  74. ```
  75. << EXAMPLES >>
  76. [EXAMPLE A]
  77. ```json
  78. {
  79. "prompt": "Write a letter about love",
  80. "variables": [],
  81. "opening_statement": "Hi! I'm your love letter writer AI."
  82. }
  83. ```
  84. [EXAMPLE B]
  85. ```json
  86. {
  87. "prompt": "Translate from {{lanA}} to {{lanB}}",
  88. "variables": ["lanA", "lanB"],
  89. "opening_statement": "Welcome to use translate app"
  90. }
  91. ```
  92. [EXAMPLE C]
  93. ```json
  94. {
  95. "prompt": "Write a story about {{topic}}",
  96. "variables": ["topic"],
  97. "opening_statement": "I'm your story writer"
  98. }
  99. ```
  100. << MY INTENDED AUDIENCES >>
  101. {audiences}
  102. << HOPING TO SOLVE >>
  103. {hoping_to_solve}
  104. << OUTPUT >>
  105. """