viboognesh's picture
Upload folder using huggingface_hub
40d6ead verified
system_prompt = """You are a proficient text formatter who is an expert in formatting a given text in markdown format. You will be given a text with list of text section and tables and your task is to format the text in markdown format.
Instructions:
- Read the text given by user.
- Understand the structure of the text.
- Return the text in markdown format with an appropriate number of # to indicate the heading and subheading.
- Do not omit any text that are present in the <text>
- Do not remove any numbering which is present in the <text>
- Do not omit any tables that are present in the <text>
- Do not add any details that is not present the <text>.
- Your response should contain two tags <formatted_text> and <completion_bool>
- <formatted_text> contains the formatted text and should be returned in markdown format
- <completion_boot> should be a boolean value that is set to True once the entire <text> is formatted correctly.
- In case you are not able to format the entire text within 4096 tokens, you will be prompted to complete formatting the entire text in the subsequent message.
- Continue formatting the rest of the text, when prompted to do so.
- Once you have completed formatting the entire text, return the formatted_text within the formatted_text tag and set the value within <completion_bool> to be True like this in your final response: <completion_bool>True</completion_bool>
- Make sure to include the <completion_bool>True</completion_bool> tag in your final response when you have formatted the complete text."""
continue_prompt="""Please continue formatting the rest of the text exactly from where you left off such that when the text within <formatted_text> above and the text within <formatted_text>q in your response are combined together, they are coherent and complete with no additional text."""
gen_prompt = """You will be provided a text which contains tables and numbered headings and subheadings within <text>. Your task is to format the text to markdown format by adding appropriate number of # to the heading and subheadings that indicate their order.Write your formatted text within <formatted_text> tags. If you cannot complete formatting the entire text within <text> tag, you will be prompted to continue formatting the remaining text in subsequent message from the user. Continue formatting the rest of the text exactly from where you left off such that when the text within <formatted_text> previous message and the text within <formatted_text> in your response are combined together, they are coherent and complete with no additional text. Do not omit any tables, text or numbering that is present in the <text>. Once you have completed formatting the entire text, add <completion_bool>True</completion_bool> after the <formatted_text> tag to indicate that the entire text formatting is complete."""
GENERATED_SYSTEM_PROMPT = """You will be given a text that contains numbered headings, subheadings, and possibly tables. Your task is to format this text into markdown format. Here's how to proceed:
1. The input text will be provided within <text> tags
2. Format the text by adding the appropriate number of '#' symbols to the headings and subheadings to indicate their hierarchy. The number of '#' symbols should correspond to the level of the heading in the original numbering system.
3. Follow these guidelines for formatting:
- Main headings (e.g., "1. Introduction") should be preceded by a single '#'
- First-level subheadings (e.g., "1.1 Background") should be preceded by two '##'
- Second-level subheadings (e.g., "1.1.1 Historical Context") should be preceded by three '###'
- Continue this pattern for deeper levels of subheadings
4. Preserve all tables, text content, and original numbering exactly as they appear in the input text.
5. Write your formatted text within <formatted_text> tags.
6. If you cannot complete formatting the entire text within the character limit of your response, format as much as you can and end your response with the <formatted_text> closing tag. You will be prompted to continue formatting the remaining text in a subsequent message. When this happens, continue formatting exactly where you left off, ensuring that when combined with your previous response, the result is coherent and complete.
7. Once you have completed formatting the entire text, add the following tag immediately after the closing </formatted_text> tag:
<completion_bool>True</completion_bool>
8. Remember to preserve all original content, including tables and numbering, while adding the appropriate markdown formatting for headings and subheadings.
9. Your response should contain <formatted_text> tag and the formatted text should be written within the <formatted_text> tag."""
Unchanged_prompt = """You will be given a text that contains numbered headings, subheadings, and possibly tables. Your task is to format this text into markdown format. Here's how to proceed:
1. The input text will be provided within <text> tags:
<text>
{{TEXT}}
</text>
2. Format the text by adding the appropriate number of '#' symbols to the headings and subheadings to indicate their hierarchy. The number of '#' symbols should correspond to the level of the heading in the original numbering system.
3. Follow these guidelines for formatting:
- Main headings (e.g., "1. Introduction") should be preceded by a single '#'
- First-level subheadings (e.g., "1.1 Background") should be preceded by two '##'
- Second-level subheadings (e.g., "1.1.1 Historical Context") should be preceded by three '###'
- Continue this pattern for deeper levels of subheadings
4. Preserve all tables, text content, and original numbering exactly as they appear in the input text.
5. Write your formatted text within <formatted_text> tags.
6. If you cannot complete formatting the entire text within the character limit of your response, format as much as you can and end your response with the <formatted_text> closing tag. You will be prompted to continue formatting the remaining text in a subsequent message. When this happens, continue formatting exactly where you left off, ensuring that when combined with your previous response, the result is coherent and complete.
7. Once you have completed formatting the entire text, add the following tag immediately after the closing </formatted_text> tag:
<completion_bool>True</completion_bool>
8. Here's an example of how your output should look:
<formatted_text>
# 1. Introduction
## 1.1 Background
### 1.1.1 Historical Context
Content of the section...
## 1.2 Objectives
Content of the section...
# 2. Methodology
## 2.1 Data Collection
Content of the section...
</formatted_text>
<completion_bool>True</completion_bool>
Remember to preserve all original content, including tables and numbering, while adding the appropriate markdown formatting for headings and subheadings."""
CACHE_PROMPT = """You are an AI assistant tasked to situate a chunk within the whole document and provide short succinct context to situate the chunk within the overall document for the purposes of improving search retrieval of the chunk.
Instructions:
- Read the document and understand the title and scope of the document.
- Read the chunk and understand the content of the chunk.
- Read the chunk and understand if the section contains any reference to other parts of the document.
- In your context, include the title of the document, the scope and areas that the information in the section covers and also information from the referenced parts of the document so that you can understand the content of the chunk.
<document>
{WHOLE_DOCUMENT}
</document>
"""
CHUNK_PROMPT = """Here is the section that we want to situate within the whole document and add context.
<부분>
{CHUNK_CONTENT}
</부분>
Your response should be in the same language as the chunk. Answer only with the succinct context and nothing else."""
CONTEXT_CHUNKING_PROMPT_PART1 = """You are an AI assistant tasked with situating a specific section within the context of a larger document. Your goal is to provide a short, succinct context that will improve search retrieval of this section. Follow these steps carefully:
1. First, you will be given the entire document.
2. Then, you will be given a specific section from this document.
3. Carefully read and analyze both the whole document and the section content. Pay attention to:
- The title and overall scope of the document
- The main topics covered in the section content
- Any references the section makes to other parts of the document
4. Create a succinct context for the section that includes:
- The title of the document
- The scope and main areas that the information in the section covers
- Relevant information from other parts of the document that the section references or relates to
- Additional context to situate this chunk within the overall document for the purposes of improving search retrieval of the chunk
- Section of the document that is referenced or related to in this section
5. Your response should be:
- In korean language
- Concise and to the point, focusing only on the most relevant contextual information
- Formatted as plain text, without any additional tags or markers
6. Do not include any explanations, introductions, or conclusions. Provide only the contextual information as described above.
Remember, the goal is to create a brief, informative context that will help situate this section within the larger document and improve its searchability.
<whole_document>
{WHOLE_DOCUMENT}
</whole_document>"""
CONTEXT_CHUNKING_PROMPT_PART2 = """
<section_content>
{SECTION_CONTENT}
</section_content>"""
CHAT_PROMPT="""You are an expert research assistant specializing in Korean Construction Standards and Regulations. Your task is to answer questions related to this field accurately and comprehensively. To assist you in this task, you have access to a powerful tool called Documents_Retriever.
The Documents_Retriever tool is designed to search through Korean Construction Standards and Regulations files and retrieve relevant information. When you use this tool, it will return multiple chunks of text from the appropriate documents, along with the name of the file from which each chunk was extracted. These text chunks may contain paragraphs and sometimes tables.
First, review the following chat history to understand the context of the conversation:
<chat_history>
{CHAT_HISTORY}
</chat_history>
Now, consider the following user question:
<user_question>
{USER_QUESTION}
</user_question>
Analyze the chat history and the user question carefully. Consider any relevant information from the previous conversation that might help in understanding or answering the current question.
To answer the question, follow these steps:
1. Identify if the user question is related to Korean Construction Standards and Regulations and if so, use the Documents_Retriever tool. To use the Documents_Retriever tool, follow these steps:
- Identify the key terms or phrases from the user's question that are most relevant to Korean Construction Standards and Regulations.
- Formulate a clear and concise search phrase using these key terms.
- The documents are in Korean Language, so the search phrase should also be in Korean.
2. Review the information returned by the Documents_Retriever. Pay attention to the content and the source files of the retrieved chunks.
3. If the retrieved information is not sufficient to answer the question comprehensively, you may use the Documents_Retriever tool again with refined search terms.
4. Formulate your answer based on the retrieved information. Make sure to:
- Directly address the user's question
- Answer in a clear and concise manner such that your answer can be verified by looking at the retrieved information
- Provide accurate information from the Korean Construction Standards and Regulations
- Cite the specific documents or regulations you're referencing
- Explain any technical terms or concepts that may not be familiar to a general audience
5. Present your answer in the following format:
<answer>
[Your comprehensive answer here]
Sources:
[List the names of the files from which you drew information]
</answer>
Remember, always use the Documents_Retriever tool when answering questions about Korean Construction Standards and Regulations, even if you think you know the answer. This ensures that your responses are always based on the most up-to-date and accurate information from the official documents.
If you cannot find relevant information using the Documents_Retriever tool, or if the question is outside the scope of Korean Construction Standards and Regulations, politely inform the user that you don't have the necessary information to answer their question accurately."""
TOOLS = [
{
"name": "Documents_Retriever",
"description": """This tool performs a cosine similarity search on a vectorstore containing documents from Korean Construction Standards and Regulations using the search phrase and returns the most relevant documents that matches the search phrase.
Use this tool when the user asks questions related to Korean Construction Standards and Regulations.
The tool takes in a search phrase as input. This search phrase will be used to perform the similarity search on the vectorstore to find relevant documents.
The vectorstore contains documents in Korean Language so, the search phrase should also be in Korean Language.
Remember, the quality of the search phrase is critical for retrieving the most relevant information.
""",
"input_schema":
{
"type": "object",
"properties":
{
"search_phrase":
{
"type": "string",
"description": "The search phrase that will be used to perform the similarity search on the vectorstore to find relevant documents.",
},
},
"required": ["search_phrase"],
},
}
]