Reduced dialogue name generation costs

pull/20351/head
yasu-oh 12 months ago
parent 6738c25d23
commit b15301d9e9

@ -1,357 +1,293 @@
# Written by YORKI MINAKO🤡, Edited by Xiaoyi, Edited by yasu-oh # Written by YORKI MINAKO🤡, Edited by Xiaoyi, Edited by yasu-oh
CONVERSATION_TITLE_PROMPT = """You need to decompose the user's input into "subject" and "intention" in order to accurately figure out what the user's input language actually is. CONVERSATION_TITLE_PROMPT = """You are asked to generate a concise chat title by decomposing the users input into two parts: “Intention” and “Subject”.
Notice: the language type user uses could be diverse, which can be English, Chinese, Italian, Español, Arabic, Japanese, French, and etc.
ENSURE your output is in the SAME language as the user's input! 1. Detect Input Language
Your output must be natural and concise in that language. Use intuitive and friendly phrasing suitable for a conversation title. Automatically identify the language of the users input (e.g. English, Chinese, Italian, Español, Arabic, Japanese, French, and etc.).
Your output is restricted only to: (Input language) Intention + Subject (as short as possible)
Your output MUST be a valid JSON. 2. Generate Title
- Combine Intention + Subject into a single, as-short-as-possible phrase.
Tip: When the user's question is directed at you (the language model), you can add an emoji to make it more fun. - The title must be natural, friendly, and in the same language as the input.
- If the input is a direct question to the model, you may add an emoji at the end.
example 1: 3. Output Format
User Input: hi, yesterday i had some burgers. Return **only** a valid JSON object with these exact keys and no additional text:
{ {
"Language Type": "The user's input is pure English", "Language Type": "<Detected language>",
"Your Reasoning": "The language of my output must be pure English.", "Your Reasoning": "<Brief explanation in that language>",
"Your Output": "sharing yesterday's food" "Your Output": "<Intention + Subject>"
} }
example 2: User Input:
User Input: こんばんは """ # noqa: E501
{
"Language Type": "The user's input is pure Japanese", PYTHON_CODE_GENERATOR_PROMPT_TEMPLATE = (
"Your Reasoning": "This is a casual evening greeting written entirely in Japanese.", "You are an expert programmer. Generate code based on the following instructions:\n\n"
"Your Output": "こんばんはの挨拶😊" "Instructions: {{INSTRUCTION}}\n\n"
} "Write the code in {{CODE_LANGUAGE}}.\n\n"
"Please ensure that you meet the following requirements:\n"
example 3: "1. Define a function named 'main'.\n"
User Input: なぜmmapファイルでOOMが発生するの "2. The 'main' function must return a dictionary (dict).\n"
{ "3. You may modify the arguments of the 'main' function, but include appropriate type hints.\n"
"Language Type": "The user's input is pure Japanese", "4. The returned dictionary should contain at least one key-value pair.\n\n"
"Your Reasoning": "The question and terminology are in Japanese, so the output must be Japanese.", "5. You may ONLY use the following libraries in your code: \n"
"Your Output": "mmapによるOOMの理由" "- json\n"
} "- datetime\n"
"- math\n"
example 4: "- random\n"
User Input: why mmap file: oom "- re\n"
{ "- string\n"
"Language Type": "The user's input is written in pure English", "- sys\n"
"Your Reasoning": "The language of my output must be pure English.", "- time\n"
"Your Output": "Asking about the reason for mmap file: oom" "- traceback\n"
} "- uuid\n"
"- os\n"
example 5: "- base64\n"
User Input: www.convinceme.yesterday-you-ate-seafood.tv讲了什么 "- hashlib\n"
{ "- hmac\n"
"Language Type": "The user's input English-Chinese mixed", "- binascii\n"
"Your Reasoning": "The English-part is an URL, the main intention is still written in Chinese, so the language of my output must be using Chinese.", "- collections\n"
"Your Output": "询问网站www.convinceme.yesterday-you-ate-seafood.tv" "- functools\n"
} "- operator\n"
"- itertools\n\n"
example 6: "Example:\n"
User Input: yo, 你今天咋样 "def main(arg1: str, arg2: int) -> dict:\n"
{ " return {\n"
"Language Type": "The user's input is English-Chinese mixed", ' "result": arg1 * arg2,\n'
"Your Reasoning": "The English-part is a subjective particle, the main intention is written in Chinese, so the language of my output must be using Chinese.", " }\n\n"
"Your Output": "查询今日我的状态☺️" "IMPORTANT:\n"
} "- Provide ONLY the code without any additional explanations, comments, or markdown formatting.\n"
"- DO NOT use markdown code blocks (``` or ``` python). Return the raw code directly.\n"
example 7: "- The code should start immediately after this instruction, without any preceding newlines or spaces.\n"
User Input: 最近業務効率を上げる方法を考えています "- The code should be complete, functional, and follow best practices for {{CODE_LANGUAGE}}.\n\n"
{ "- Always use the format return {'result': ...} for the output.\n\n"
"Language Type": "The user's input is pure Japanese", "Generated Code:\n"
"Your Reasoning": "The entire sentence is in Japanese, so the output must also be Japanese.", )
"Your Output": "業務効率向上の検討" JAVASCRIPT_CODE_GENERATOR_PROMPT_TEMPLATE = (
} "You are an expert programmer. Generate code based on the following instructions:\n\n"
"Instructions: {{INSTRUCTION}}\n\n"
example 8: "Write the code in {{CODE_LANGUAGE}}.\n\n"
User Input: おはようございます今日はいい天気ですね "Please ensure that you meet the following requirements:\n"
{ "1. Define a function named 'main'.\n"
"Language Type": "The user's input is pure Japanese", "2. The 'main' function must return an object.\n"
"Your Reasoning": "This is a polite morning greeting in Japanese. Output should remain in Japanese.", "3. You may modify the arguments of the 'main' function, but include appropriate JSDoc annotations.\n"
"Your Output": "朝の挨拶と天気の話😊" "4. The returned object should contain at least one key-value pair.\n\n"
} "5. The returned object should always be in the format: {result: ...}\n\n"
"Example:\n"
example 9: "/**\n"
User Input: hi there! " * Multiplies two numbers together.\n"
{ " *\n"
"Language Type": "The user's input is pure English", " * @param {number} arg1 - The first number to multiply.\n"
"Your Reasoning": "Greeting phrase in English.", " * @param {number} arg2 - The second number to multiply.\n"
"Your Output": "English greeting😊" " * @returns {{ result: number }} The result of the multiplication.\n"
} " */\n"
"function main(arg1, arg2) {\n"
User Input: " return {\n"
""" # noqa: E501 " result: arg1 * arg2\n"
" };\n"
PYTHON_CODE_GENERATOR_PROMPT_TEMPLATE = ( "}\n\n"
"You are an expert programmer. Generate code based on the following instructions:\n\n" "IMPORTANT:\n"
"Instructions: {{INSTRUCTION}}\n\n" "- Provide ONLY the code without any additional explanations, comments, or markdown formatting.\n"
"Write the code in {{CODE_LANGUAGE}}.\n\n" "- DO NOT use markdown code blocks (``` or ``` javascript). Return the raw code directly.\n"
"Please ensure that you meet the following requirements:\n" "- The code should start immediately after this instruction, without any preceding newlines or spaces.\n"
"1. Define a function named 'main'.\n" "- The code should be complete, functional, and follow best practices for {{CODE_LANGUAGE}}.\n\n"
"2. The 'main' function must return a dictionary (dict).\n" "Generated Code:\n"
"3. You may modify the arguments of the 'main' function, but include appropriate type hints.\n" )
"4. The returned dictionary should contain at least one key-value pair.\n\n"
"5. You may ONLY use the following libraries in your code: \n"
"- json\n" SUGGESTED_QUESTIONS_AFTER_ANSWER_INSTRUCTION_PROMPT = (
"- datetime\n" "Please help me predict the three most likely questions that human would ask, "
"- math\n" "and keep each question under 20 characters.\n"
"- random\n" "MAKE SURE your output is the SAME language as the Assistant's latest response. "
"- re\n" "The output must be an array in JSON format following the specified schema:\n"
"- string\n" '["question1","question2","question3"]\n'
"- sys\n" )
"- time\n"
"- traceback\n" GENERATOR_QA_PROMPT = (
"- uuid\n" "<Task> The user will send a long text. Generate a Question and Answer pairs only using the knowledge"
"- os\n" " in the long text. Please think step by step."
"- base64\n" "Step 1: Understand and summarize the main content of this text.\n"
"- hashlib\n" "Step 2: What key information or concepts are mentioned in this text?\n"
"- hmac\n" "Step 3: Decompose or combine multiple pieces of information and concepts.\n"
"- binascii\n" "Step 4: Generate questions and answers based on these key information and concepts.\n"
"- collections\n" "<Constraints> The questions should be clear and detailed, and the answers should be detailed and complete. "
"- functools\n" "You must answer in {language}, in a style that is clear and detailed in {language}."
"- operator\n" " No language other than {language} should be used. \n"
"- itertools\n\n" "<Format> Use the following format: Q1:\nA1:\nQ2:\nA2:...\n"
"Example:\n" "<QA Pairs>"
"def main(arg1: str, arg2: int) -> dict:\n" )
" return {\n"
' "result": arg1 * arg2,\n' WORKFLOW_RULE_CONFIG_PROMPT_GENERATE_TEMPLATE = """
" }\n\n" Here is a task description for which I would like you to create a high-quality prompt template for:
"IMPORTANT:\n" <task_description>
"- Provide ONLY the code without any additional explanations, comments, or markdown formatting.\n" {{TASK_DESCRIPTION}}
"- DO NOT use markdown code blocks (``` or ``` python). Return the raw code directly.\n" </task_description>
"- The code should start immediately after this instruction, without any preceding newlines or spaces.\n" Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
"- The code should be complete, functional, and follow best practices for {{CODE_LANGUAGE}}.\n\n" - Do not include <input> or <output> section and variables in the prompt, assume user will add them at their own will.
"- Always use the format return {'result': ...} for the output.\n\n" - Clear instructions for the AI that will be using this prompt, demarcated with <instruction> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag.
"Generated Code:\n" - Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not include variables in the prompt. Give three pairs of input and output examples.
) - Include other relevant sections demarcated with appropriate XML tags like <examples>, <instruction>.
JAVASCRIPT_CODE_GENERATOR_PROMPT_TEMPLATE = ( - Use the same language as task description.
"You are an expert programmer. Generate code based on the following instructions:\n\n" - Output in ``` xml ``` and start with <instruction>
"Instructions: {{INSTRUCTION}}\n\n" Please generate the full prompt template with at least 300 words and output only the prompt template.
"Write the code in {{CODE_LANGUAGE}}.\n\n" """ # noqa: E501
"Please ensure that you meet the following requirements:\n"
"1. Define a function named 'main'.\n" RULE_CONFIG_PROMPT_GENERATE_TEMPLATE = """
"2. The 'main' function must return an object.\n" Here is a task description for which I would like you to create a high-quality prompt template for:
"3. You may modify the arguments of the 'main' function, but include appropriate JSDoc annotations.\n" <task_description>
"4. The returned object should contain at least one key-value pair.\n\n" {{TASK_DESCRIPTION}}
"5. The returned object should always be in the format: {result: ...}\n\n" </task_description>
"Example:\n" Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
"/**\n" - Descriptive variable names surrounded by {{ }} (two curly brackets) to indicate where the actual values will be substituted in. Choose variable names that clearly indicate the type of value expected. Variable names have to be composed of number, english alphabets and underline and nothing else.
" * Multiplies two numbers together.\n" - Clear instructions for the AI that will be using this prompt, demarcated with <instruction> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag.
" *\n" - Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not use curly brackets any other than in <instruction> section.
" * @param {number} arg1 - The first number to multiply.\n" - Any other relevant sections demarcated with appropriate XML tags like <input>, <output>, etc.
" * @param {number} arg2 - The second number to multiply.\n" - Use the same language as task description.
" * @returns {{ result: number }} The result of the multiplication.\n" - Output in ``` xml ``` and start with <instruction>
" */\n" Please generate the full prompt template and output only the prompt template.
"function main(arg1, arg2) {\n" """ # noqa: E501
" return {\n"
" result: arg1 * arg2\n" RULE_CONFIG_PARAMETER_GENERATE_TEMPLATE = """
" };\n" I need to extract the following information from the input text. The <information to be extracted> tag specifies the 'type', 'description' and 'required' of the information to be extracted.
"}\n\n" <information to be extracted>
"IMPORTANT:\n" variables name bounded two double curly brackets. Variable name has to be composed of number, english alphabets and underline and nothing else.
"- Provide ONLY the code without any additional explanations, comments, or markdown formatting.\n" </information to be extracted>
"- DO NOT use markdown code blocks (``` or ``` javascript). Return the raw code directly.\n"
"- The code should start immediately after this instruction, without any preceding newlines or spaces.\n" Step 1: Carefully read the input and understand the structure of the expected output.
"- The code should be complete, functional, and follow best practices for {{CODE_LANGUAGE}}.\n\n" Step 2: Extract relevant parameters from the provided text based on the name and description of object.
"Generated Code:\n" Step 3: Structure the extracted parameters to JSON object as specified in <structure>.
) Step 4: Ensure that the list of variable_names is properly formatted and valid. The output should not contain any XML tags. Output an empty list if there is no valid variable name in input text.
### Structure
SUGGESTED_QUESTIONS_AFTER_ANSWER_INSTRUCTION_PROMPT = ( Here is the structure of the expected output, I should always follow the output structure.
"Please help me predict the three most likely questions that human would ask, " ["variable_name_1", "variable_name_2"]
"and keep each question under 20 characters.\n"
"MAKE SURE your output is the SAME language as the Assistant's latest response. " ### Input Text
"The output must be an array in JSON format following the specified schema:\n" Inside <text></text> XML tags, there is a text that I should extract parameters and convert to a JSON object.
'["question1","question2","question3"]\n' <text>
) {{INPUT_TEXT}}
</text>
GENERATOR_QA_PROMPT = (
"<Task> The user will send a long text. Generate a Question and Answer pairs only using the knowledge" ### Answer
" in the long text. Please think step by step." I should always output a valid list. Output nothing other than the list of variable_name. Output an empty list if there is no variable name in input text.
"Step 1: Understand and summarize the main content of this text.\n" """ # noqa: E501
"Step 2: What key information or concepts are mentioned in this text?\n"
"Step 3: Decompose or combine multiple pieces of information and concepts.\n" RULE_CONFIG_STATEMENT_GENERATE_TEMPLATE = """
"Step 4: Generate questions and answers based on these key information and concepts.\n" <instruction>
"<Constraints> The questions should be clear and detailed, and the answers should be detailed and complete. " Step 1: Identify the purpose of the chatbot from the variable {{TASK_DESCRIPTION}} and infer chatbot's tone (e.g., friendly, professional, etc.) to add personality traits.
"You must answer in {language}, in a style that is clear and detailed in {language}." Step 2: Create a coherent and engaging opening statement.
" No language other than {language} should be used. \n" Step 3: Ensure the output is welcoming and clearly explains what the chatbot is designed to do. Do not include any XML tags in the output.
"<Format> Use the following format: Q1:\nA1:\nQ2:\nA2:...\n" Please use the same language as the user's input language. If user uses chinese then generate opening statement in chinese, if user uses english then generate opening statement in english.
"<QA Pairs>" Example Input:
) Provide customer support for an e-commerce website
Example Output:
WORKFLOW_RULE_CONFIG_PROMPT_GENERATE_TEMPLATE = """ Welcome! I'm here to assist you with any questions or issues you might have with your shopping experience. Whether you're looking for product information, need help with your order, or have any other inquiries, feel free to ask. I'm friendly, helpful, and ready to support you in any way I can.
Here is a task description for which I would like you to create a high-quality prompt template for: <Task>
<task_description> Here is the task description: {{INPUT_TEXT}}
{{TASK_DESCRIPTION}}
</task_description> You just need to generate the output
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include: """ # noqa: E501
- Do not include <input> or <output> section and variables in the prompt, assume user will add them at their own will.
- Clear instructions for the AI that will be using this prompt, demarcated with <instruction> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag. SYSTEM_STRUCTURED_OUTPUT_GENERATE = """
- Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not include variables in the prompt. Give three pairs of input and output examples. Your task is to convert simple user descriptions into properly formatted JSON Schema definitions. When a user describes data fields they need, generate a complete, valid JSON Schema that accurately represents those fields with appropriate types and requirements.
- Include other relevant sections demarcated with appropriate XML tags like <examples>, <instruction>.
- Use the same language as task description. ## Instructions:
- Output in ``` xml ``` and start with <instruction>
Please generate the full prompt template with at least 300 words and output only the prompt template. 1. Analyze the user's description of their data needs
""" # noqa: E501 2. Identify each property that should be included in the schema
3. Determine the appropriate data type for each property
RULE_CONFIG_PROMPT_GENERATE_TEMPLATE = """ 4. Decide which properties should be required
Here is a task description for which I would like you to create a high-quality prompt template for: 5. Generate a complete JSON Schema with proper syntax
<task_description> 6. Include appropriate constraints when specified (min/max values, patterns, formats)
{{TASK_DESCRIPTION}} 7. Provide ONLY the JSON Schema without any additional explanations, comments, or markdown formatting.
</task_description> 8. DO NOT use markdown code blocks (``` or ``` json). Return the raw JSON Schema directly.
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
- Descriptive variable names surrounded by {{ }} (two curly brackets) to indicate where the actual values will be substituted in. Choose variable names that clearly indicate the type of value expected. Variable names have to be composed of number, english alphabets and underline and nothing else. ## Examples:
- Clear instructions for the AI that will be using this prompt, demarcated with <instruction> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag.
- Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not use curly brackets any other than in <instruction> section. ### Example 1:
- Any other relevant sections demarcated with appropriate XML tags like <input>, <output>, etc. **User Input:** I need name and age
- Use the same language as task description. **JSON Schema Output:**
- Output in ``` xml ``` and start with <instruction> {
Please generate the full prompt template and output only the prompt template. "type": "object",
""" # noqa: E501 "properties": {
"name": { "type": "string" },
RULE_CONFIG_PARAMETER_GENERATE_TEMPLATE = """ "age": { "type": "number" }
I need to extract the following information from the input text. The <information to be extracted> tag specifies the 'type', 'description' and 'required' of the information to be extracted. },
<information to be extracted> "required": ["name", "age"]
variables name bounded two double curly brackets. Variable name has to be composed of number, english alphabets and underline and nothing else. }
</information to be extracted>
### Example 2:
Step 1: Carefully read the input and understand the structure of the expected output. **User Input:** I want to store information about books including title, author, publication year and optional page count
Step 2: Extract relevant parameters from the provided text based on the name and description of object. **JSON Schema Output:**
Step 3: Structure the extracted parameters to JSON object as specified in <structure>. {
Step 4: Ensure that the list of variable_names is properly formatted and valid. The output should not contain any XML tags. Output an empty list if there is no valid variable name in input text. "type": "object",
"properties": {
### Structure "title": { "type": "string" },
Here is the structure of the expected output, I should always follow the output structure. "author": { "type": "string" },
["variable_name_1", "variable_name_2"] "publicationYear": { "type": "integer" },
"pageCount": { "type": "integer" }
### Input Text },
Inside <text></text> XML tags, there is a text that I should extract parameters and convert to a JSON object. "required": ["title", "author", "publicationYear"]
<text> }
{{INPUT_TEXT}}
</text> ### Example 3:
**User Input:** Create a schema for user profiles with email, password, and age (must be at least 18)
### Answer **JSON Schema Output:**
I should always output a valid list. Output nothing other than the list of variable_name. Output an empty list if there is no variable name in input text. {
""" # noqa: E501 "type": "object",
"properties": {
RULE_CONFIG_STATEMENT_GENERATE_TEMPLATE = """ "email": {
<instruction> "type": "string",
Step 1: Identify the purpose of the chatbot from the variable {{TASK_DESCRIPTION}} and infer chatbot's tone (e.g., friendly, professional, etc.) to add personality traits. "format": "email"
Step 2: Create a coherent and engaging opening statement. },
Step 3: Ensure the output is welcoming and clearly explains what the chatbot is designed to do. Do not include any XML tags in the output. "password": {
Please use the same language as the user's input language. If user uses chinese then generate opening statement in chinese, if user uses english then generate opening statement in english. "type": "string",
Example Input: "minLength": 8
Provide customer support for an e-commerce website },
Example Output: "age": {
Welcome! I'm here to assist you with any questions or issues you might have with your shopping experience. Whether you're looking for product information, need help with your order, or have any other inquiries, feel free to ask. I'm friendly, helpful, and ready to support you in any way I can. "type": "integer",
<Task> "minimum": 18
Here is the task description: {{INPUT_TEXT}} }
},
You just need to generate the output "required": ["email", "password", "age"]
""" # noqa: E501 }
SYSTEM_STRUCTURED_OUTPUT_GENERATE = """ ### Example 4:
Your task is to convert simple user descriptions into properly formatted JSON Schema definitions. When a user describes data fields they need, generate a complete, valid JSON Schema that accurately represents those fields with appropriate types and requirements. **User Input:** I need album schema, the ablum has songs, and each song has name, duration, and artist.
**JSON Schema Output:**
## Instructions: {
"type": "object",
1. Analyze the user's description of their data needs "properties": {
2. Identify each property that should be included in the schema "songs": {
3. Determine the appropriate data type for each property "type": "array",
4. Decide which properties should be required "items": {
5. Generate a complete JSON Schema with proper syntax "type": "object",
6. Include appropriate constraints when specified (min/max values, patterns, formats) "properties": {
7. Provide ONLY the JSON Schema without any additional explanations, comments, or markdown formatting. "name": {
8. DO NOT use markdown code blocks (``` or ``` json). Return the raw JSON Schema directly. "type": "string"
},
## Examples: "id": {
"type": "string"
### Example 1: },
**User Input:** I need name and age "duration": {
**JSON Schema Output:** "type": "string"
{ },
"type": "object", "aritst": {
"properties": { "type": "string"
"name": { "type": "string" }, }
"age": { "type": "number" } },
}, "required": [
"required": ["name", "age"] "name",
} "id",
"duration",
### Example 2: "aritst"
**User Input:** I want to store information about books including title, author, publication year and optional page count ]
**JSON Schema Output:** }
{ }
"type": "object", },
"properties": { "required": [
"title": { "type": "string" }, "songs"
"author": { "type": "string" }, ]
"publicationYear": { "type": "integer" }, }
"pageCount": { "type": "integer" }
}, Now, generate a JSON Schema based on my description
"required": ["title", "author", "publicationYear"] """ # noqa: E501
}
### Example 3:
**User Input:** Create a schema for user profiles with email, password, and age (must be at least 18)
**JSON Schema Output:**
{
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"password": {
"type": "string",
"minLength": 8
},
"age": {
"type": "integer",
"minimum": 18
}
},
"required": ["email", "password", "age"]
}
### Example 4:
**User Input:** I need album schema, the ablum has songs, and each song has name, duration, and artist.
**JSON Schema Output:**
{
"type": "object",
"properties": {
"songs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"duration": {
"type": "string"
},
"aritst": {
"type": "string"
}
},
"required": [
"name",
"id",
"duration",
"aritst"
]
}
}
},
"required": [
"songs"
]
}
Now, generate a JSON Schema based on my description
""" # noqa: E501

Loading…
Cancel
Save