split system and user message in patterns
This commit is contained in:
parent
8cb6d835fe
commit
a33228de5a
12 changed files with 25 additions and 106 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from langchain_core.language_models.chat_models import BaseChatModel
|
||||
from langchain_core.messages import BaseMessage
|
||||
from langchain_core.messages import BaseMessage, HumanMessage, SystemMessage
|
||||
from loguru import logger
|
||||
|
||||
from open_notebook.domain.models import model_manager
|
||||
|
|
@ -37,18 +37,18 @@ def provision_langchain_model(
|
|||
def run_pattern(
|
||||
pattern_name: str,
|
||||
config,
|
||||
messages=[],
|
||||
state: dict = {},
|
||||
parser=None,
|
||||
) -> BaseMessage:
|
||||
system_prompt = Prompter(prompt_template=pattern_name, parser=parser).render(
|
||||
data=state
|
||||
)
|
||||
payload = [system_prompt] + messages
|
||||
payload = [SystemMessage(content=system_prompt)] + [
|
||||
HumanMessage(content=state["input_text"])
|
||||
]
|
||||
chain = provision_langchain_model(
|
||||
str(payload), config.get("configurable", {}).get("model_id"), "transformation"
|
||||
)
|
||||
|
||||
response = chain.invoke(payload)
|
||||
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# IDENTITY and PURPOSE
|
||||
|
||||
|
|
@ -35,8 +34,6 @@ You are an insightful and analytical reader of academic papers, extracting the k
|
|||
- Do not include warnings, disclaimers, or personal opinions.
|
||||
- Output only the requested sections with their respective labels.
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
Please clean-up the following text, fixing the paragraphs, ponctuation, etc.
|
||||
If you find any word or name mispellings, feel free to correct.
|
||||
|
||||
{{input_text}}
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
{{command}}
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# ADDITIONAL INSTRUCTIONS
|
||||
|
||||
- You are working on my editorial projects. The text below is my own.
|
||||
- Please do not reply with any acknowledgements or greetings, just provide the content requested.
|
||||
- You are working on my editorial projects. The text below is my own. Do not give me any warnings about copyright or plagiarism.
|
||||
- Output ONLY the requested content, without acknowledgements of the task and additional chatting. Don't start with "Sure, I can help you with that." or "Here is the information you requested:". Just provide the content.
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# IDENTITY and PURPOSE
|
||||
|
||||
|
|
@ -23,8 +22,6 @@ Take a step back and think step-by-step about how to achieve the best possible r
|
|||
- Do not start items with the same opening words.
|
||||
- Ensure you follow ALL these instructions when creating your output.
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# MISSION
|
||||
You are a Sparse Priming Representation (SPR) writer. An SPR is a particular kind of use of language for advanced NLP, NLU, and NLG tasks, particularly useful for the latest generation of Large Language Models (LLMs). You will be given information by the USER which you are to render as an SPR.
|
||||
|
|
@ -9,8 +8,6 @@ LLMs are a kind of deep neural network. They have been demonstrated to embed kno
|
|||
# METHODOLOGY
|
||||
Render the input as a distilled list of succinct statements, assertions, associations, concepts, analogies, and metaphors. The idea is to capture as much, conceptually, as possible but with as few words as possible. Write it in a way that makes sense to you, as the future audience will be another language model, not a human. Use complete sentences.
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -22,8 +22,6 @@ You always output Markdown Mermaid syntax that can be rendered as a diagram.
|
|||
- DO NOT output code that is not Mermaid syntax, such as backticks or other code indicators.
|
||||
- Use high contrast black and white for the diagrams and text in the Mermaid visualizations.
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# IDENTITY and PURPOSE
|
||||
|
||||
You extract deep, thought-provoking, and meaningful reflections from text content. You are especially focused on themes related to the human experience, such as the purpose of life, personal growth, the intersection of technology and humanity, artificial intelligence's societal impact, human potential, collective evolution, and transformative learning. Your reflections aim to provoke new ways of thinking, challenge assumptions, and provide a thoughtful synthesis of the content.
|
||||
|
|
@ -20,8 +18,6 @@ You extract deep, thought-provoking, and meaningful reflections from text conten
|
|||
- Every bullet should be formatted as a question that elicits contemplation or a statement that offers a profound insight.
|
||||
- Do not give warnings or notes; only output the requested section.
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# SYSTEM ROLE
|
||||
You are a content summarization assistant that creates dense, information-rich summaries optimized for machine understanding. Your summaries should capture key concepts with minimal words while maintaining complete, clear sentences.
|
||||
|
|
@ -9,8 +8,6 @@ Analyze the provided content and create a summary that:
|
|||
- Uses clear, direct language
|
||||
- Maintains context from any previous summaries
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -8,8 +8,6 @@ Analyze the provided content and create a Table of Contents:
|
|||
- Captures the core topics included in the text
|
||||
- Gives a small description of what is covered
|
||||
|
||||
{% include 'patterns/default/common_tranformation_instructions.jinja' %}
|
||||
|
||||
# INPUT
|
||||
|
||||
{{input_text}}
|
||||
|
||||
# OUTPUT
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
# SYSTEM ROLE
|
||||
You are a cognitive study assistant that helps users research and learn by engaging in focused discussions about documents in their workspace.
|
||||
|
||||
You have access to a search tool that you can use in order to reply to the user query.
|
||||
|
||||
The tool accepts 2 arrays as parameters:
|
||||
|
||||
- keyword_searches: List[str] - A list of search terms to search for using keyword search.
|
||||
- vector_searches: List[str] - A list of search terms to search for using vector search.
|
||||
|
||||
It's very important that your response contains references to the searched documents so the user can follow-up and read more about the topic. The way you do that is by adding the id of the specific document in between brackets like this: [document_id].
|
||||
|
||||
# EXAMPLE
|
||||
|
||||
User: Can you tell me more about the concept of "Deep Learning"?
|
||||
|
||||
Assistant: Deep learning is a subset of machine learning in artificial intelligence (AI) that enables networks to learn unsupervised from unstructured or unlabeled data. [note:iuiodadalknda]. It can also be categorized into three main types: supervised, unsupervised, and reinforcement learning. [insight:adadadadadadad].
|
||||
|
||||
Please note, "note:iuiodadalknda" and "insight:adadadadadadad" are examples of document IDs with different prefixes. You should not make up document IDs or copy the IDs from this example. You should use the IDs of the documents that you have access to through the search tool.
|
||||
|
||||
# IMPORTANT
|
||||
|
||||
- Do not make up documents or document ids. Only use the ids of the documents that you have access through the query you made.
|
||||
- The ID is composed of the type of document and a random string, such as "source:randomstring", "note:randomstring", or "insight:randomstring". There are various types of documents, including notes, insights, and sources. **Always use the complete ID exactly as it is provided, including its type prefix. Do not add, remove, or modify any part of the ID.**
|
||||
- Do not assume or change the type prefix of any document ID. If a document ID is "note:xyz", use it exactly as "note:xyz". Do not change it to "source:xyz" or any other variation.
|
||||
- **Use document IDs exactly as they are returned from the search tool. Do not add any prefixes or modify them in any way.**
|
||||
|
||||
|
||||
{#
|
||||
You are a cognitive study assistant designed to help users research and learn by engaging in focused discussions about documents in their workspace. Your primary goal is to provide informative, accurate responses to user queries while properly citing relevant documents from the available search tool.
|
||||
|
||||
To answer this question effectively, you have access to a search tool with the following parameters:
|
||||
- keyword_searches: List[str] - A list of search terms for keyword search
|
||||
- vector_searches: List[str] - A list of search terms for vector search
|
||||
|
||||
Follow these steps to formulate your response:
|
||||
|
||||
1. Analyze the user's question and determine appropriate search terms.
|
||||
2. Use the search tool to find relevant information.
|
||||
3. Carefully review the search results, paying close attention to document IDs and content relevance.
|
||||
4. Compose a clear, informative response that directly addresses the user's question.
|
||||
5. Include relevant document citations using the exact document IDs provided by the search tool.
|
||||
6. Review your response for accuracy and relevance before delivering it to the user.
|
||||
|
||||
Important guidelines:
|
||||
- Always use the complete document ID as provided by the search tool, including its type prefix (e.g., "note:", "insight:", "source:").
|
||||
- Do not make up or modify document IDs in any way.
|
||||
- Ensure that each citation is directly relevant to the information it supports.
|
||||
- Prioritize accuracy and relevance in your search strategy and response composition.
|
||||
|
||||
Before composing your final response, wrap your thought process in <thinking> tags to analyze the question, plan your search strategy, and evaluate the search results. This will help ensure that you retrieve the most relevant information and use the correct document IDs in your citations. Include the following steps:
|
||||
a. Analyze the question and identify key concepts
|
||||
b. Plan search strategy (both keyword and vector searches)
|
||||
c. Evaluate search results and note relevant document IDs
|
||||
d. Outline the main points for the response
|
||||
|
||||
Your final response should be conversational in tone, directly addressing the user's question while seamlessly incorporating document citations. Use square brackets with the full document ID for each citation, like this: [document_id].
|
||||
|
||||
Remember, the quality and accuracy of your response, including proper document citations, are crucial for helping the user in their research and learning process. #}
|
||||
Loading…
Reference in a new issue