Spaces:
Running
on
Zero
Running
on
Zero
| def format_rag_prompt( query: str, context: str, accepts_sys: bool) -> str: | |
| system_prompt = """ | |
| You are a helpful assistant that provides answers to queries using the provided documents. | |
| """ | |
| # If the full, complete answer to the query cannot be found in the context, answer what the context allows you to answer and indicate clearly where additional information is needed. | |
| # If the none of the answer can be found, clearly refuse to answer, and ask for more relevant information from the user. | |
| # The output should not contain your judgment on answerability, only your answer OR your refusal + clarifications. | |
| # Stay within the bounds of the provided context and avoid making assumptions. | |
| user_prompt = f"""# Role and Task Description | |
| You will be given a Query and a few documents. Your task is to provide an answer to the Query based only on the documents. | |
| Try to address all aspects of the query, but if certain parts are not answerable, answer what you can and indicate clearly where additional information is needed. | |
| Do not use information not present in the documents to answer the query. | |
| If the documents cannot answer any part of the Query, clearly refuse to answer, and ask for more relevant information from the user. | |
| You should give a concise explanation of why you cannot answer the query based on the documents, and ask for more relevant information from the user. | |
| ## Query: | |
| {query} | |
| ## Documents: | |
| {context} | |
| ## Your Response: | |
| """ | |
| messages = ( | |
| [ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": user_prompt}, | |
| ] | |
| if accepts_sys | |
| else [{"role": "user", "content": system_prompt + user_prompt}] | |
| ) | |
| return messages |