devve1's picture
Update prompts.py
518aa51 verified
raw
history blame
No virus
4.74 kB
import outlines
def transform_query(query: str) -> str:
""" For retrieval, add the prompt for query (not for documents)."""
return f'Represent this sentence for searching relevant passages: {query}'
def build_prompt_conv(user_input: str):
return [
{
'role': 'system',
'content': """Assume the role of an innovator who thrives on creativity and resourcefulness. Your responses should encourage new approaches and challenge conventional thinking.
Behavior: Focus on brainstorming and ideation, offering unconventional solutions to problems.
Mannerisms: Use energetic, enthusiastic language that reflects your innovative spirit. Frequently propose ideas that are bold and forward-looking."""
},
{
'role': 'user',
'content': f"""Generate a short, single-sentence summary, in 10 tokens maximum, of the user's intent or topic based on their question, capturing the main focus of what they want to discuss. Do NOT cite the user.
Question : {user_input}
"""
}
]
@outlines.prompt
def question_type_prompt(query: str):
"""Determine whether the following query is a 'Domain-Specific Question' or a 'General Question.'
A 'Domain-Specific Question' requires knowledge or familiarity with a particular field, niche, or specialized area of interest, including specific video games, movies, books, academic disciplines, or professional fields.
A 'General Question' is broad, open-ended, and can be answered by almost anyone without needing specific context or prior knowledge about any particular domain.
A Domain-Specific Question can also just contain a word related to a particular field, niche, or specialized area of interet. For example: the word 'aggro' is related to specific video games.
Examples :
1. Query: "What are the symptoms of Type 2 diabetes?"
Choose one: Domain-Specific Question
2. Query: "What is your favorite color?"
Choose one: General Question
3. Query: "Who is the main character in Dark Souls?"
Choose one: Domain-Specific Question
4. Query: "How do you bake a cake?"
Choose one: General Question
5. Query: "Explain the difference between RAM and ROM."
Choose one: Domain-Specific Question
6. Query: "Tell me more about your weekend."
Choose one: General Question
7. Query: "Explain me more"
Choose one: General Question
8. Query: "What is god mode ?"
Choose one: Domain-Specific Question
9. Query: "Give me the meaning of aggro"
Choose one: Domain-Specific Question
10. Query: "Give me a description of an aimbot"
Choose one: Domain-Specific Question
Now, determine the following query : {{ query }}
Choose one: 'Domain-Specific Question' or 'General Question'
"""
@outlines.prompt
def open_query_prompt(past_messages: str, query: str):
"""{{ past_messages }}
user: {{ query }}
assistant:
"""
@outlines.prompt
def route_llm(context: str, query: str):
"""Based on the following context, determine if the context contains specific and direct information needed to answer the question. Only respond with 'Yes' if the context explicitly provides the exact information required to answer the question fully and accurately. Respond with 'No' if the context does not explicitly provide the required information, or if it is missing, vague, indirect, or implied.
Question: {{ query }}
Context: {{ context }}
Answer (Yes/No):
"""
@outlines.prompt
def answer_with_context(context: str, query: str):
"""You are an assistant helping user by following directives and answering question.
Generate your response by following the steps below:
1. Recursively break-down the question into smaller questions/directives.
2. For each atomic question/directive:
2a. Select the most relevant informations from the context.
3. Generate a draft answer using the selected informations. Use three sentences maximum and keep the answer concise.
4. Remove duplicate content from the draft answer.
5. Generate your final answer after adjusting it to increase accuracy and relevance.
Question: {{query}}
Context: {{context}}
Answer:
"""
@outlines.prompt
def idk(query: str):
"Just express that you don't find the knowledge required in the vector database to answer the question. Be creative and original."
@outlines.prompt
def self_knowledge(query: str):
"""Answer the following question by using your own knowledge about the topic.
Question: {{ query }}
"""