rename to patterns
This commit is contained in:
parent
3e11d9ba68
commit
796012f716
5 changed files with 18 additions and 22 deletions
|
|
@ -13,7 +13,7 @@ from open_notebook.graphs.utils import run_pattern
|
|||
|
||||
class PatternChainState(TypedDict):
|
||||
content_stack: Annotated[Sequence[str], operator.add]
|
||||
transformations: List[str]
|
||||
patterns: List[str]
|
||||
output: str
|
||||
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ def call_model(state: dict, config: RunnableConfig) -> dict:
|
|||
model_id = config.get("configurable", {}).get(
|
||||
"model_id", DEFAULT_MODELS.default_transformation_model
|
||||
)
|
||||
transformations = state["transformations"]
|
||||
current_transformation = transformations.pop(0)
|
||||
patterns = state["patterns"]
|
||||
current_transformation = patterns.pop(0)
|
||||
if current_transformation.startswith("patterns/"):
|
||||
input_args = {"input_text": state["content_stack"][-1]}
|
||||
else:
|
||||
|
|
@ -40,7 +40,7 @@ def call_model(state: dict, config: RunnableConfig) -> dict:
|
|||
return {
|
||||
"content_stack": [transformation_result.content],
|
||||
"output": transformation_result.content,
|
||||
"transformations": state["transformations"],
|
||||
"patterns": state["patterns"],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def transform_condition(state: PatternChainState) -> Literal["agent", END]: # t
|
|||
"""
|
||||
Checks whether there are more chunks to process.
|
||||
"""
|
||||
if len(state["transformations"]) > 0:
|
||||
if len(state["patterns"]) > 0:
|
||||
return "agent"
|
||||
return END
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ def call_model(state: TocState, config: RunnableConfig) -> dict:
|
|||
)
|
||||
return {
|
||||
"toc": run_pattern(
|
||||
pattern_name="default/recursive_toc",
|
||||
pattern_name="recursive_toc",
|
||||
model_id=model_id,
|
||||
state=state,
|
||||
).content
|
||||
|
|
|
|||
|
|
@ -52,12 +52,10 @@ def note_panel(session_id=None, note_id=None):
|
|||
|
||||
def make_note_from_chat(content, notebook_id=None):
|
||||
# todo: make this more efficient
|
||||
transformations = [
|
||||
patterns = [
|
||||
"Based on the Note below, please provide a Title for this content, with max 15 words"
|
||||
]
|
||||
output = pattern_graph.invoke(
|
||||
dict(content_stack=[content], transformations=transformations)
|
||||
)
|
||||
output = pattern_graph.invoke(dict(content_stack=[content], patterns=patterns))
|
||||
title = surreal_clean(output["output"])
|
||||
|
||||
note = Note(
|
||||
|
|
|
|||
|
|
@ -17,10 +17,8 @@ from open_notebook.utils import surreal_clean
|
|||
from .consts import context_icons
|
||||
|
||||
|
||||
def run_transformations(input_text, transformations):
|
||||
output = transform_graph.invoke(
|
||||
dict(content_stack=[input_text], transformations=transformations)
|
||||
)
|
||||
def run_patterns(input_text, patterns):
|
||||
output = transform_graph.invoke(dict(content_stack=[input_text], patterns=patterns))
|
||||
return output["output"]
|
||||
|
||||
|
||||
|
|
@ -66,8 +64,8 @@ def source_panel(source_id):
|
|||
if st.button(
|
||||
transformation["name"], help=transformation["description"]
|
||||
):
|
||||
result = run_transformations(
|
||||
source.full_text, transformation["transformations"]
|
||||
result = run_patterns(
|
||||
source.full_text, transformation["patterns"]
|
||||
)
|
||||
source.add_insight(
|
||||
transformation["insight_type"], surreal_clean(result)
|
||||
|
|
|
|||
|
|
@ -3,33 +3,33 @@ source_insights:
|
|||
- name: "Summarize"
|
||||
insight_type: "Content Summary"
|
||||
description: "Summarize the content"
|
||||
transformations:
|
||||
patterns:
|
||||
- patterns/default/makeitdense
|
||||
- patterns/default/summarize
|
||||
- name: "Key Insights"
|
||||
insight_type: "Key Insights"
|
||||
description: "Extracts a list of the Key Insights of the content"
|
||||
transformations:
|
||||
patterns:
|
||||
- patterns/default/keyinsights
|
||||
- name: "Make it Dense"
|
||||
insight_type: "Dense Representation"
|
||||
description: "Create a dense representation of the content"
|
||||
transformations:
|
||||
patterns:
|
||||
- patterns/default/makeitdense
|
||||
- name: "Analyze Paper"
|
||||
insight_type: "Paper Analysis"
|
||||
description: "Analyze the paper and provide a quick summary"
|
||||
transformations:
|
||||
patterns:
|
||||
- patterns/default/analyze_paper
|
||||
- name: "Reflection"
|
||||
insight_type: "Reflection Questions"
|
||||
description: "Generates a list of insightful questions to provoke reflection"
|
||||
transformations:
|
||||
patterns:
|
||||
- patterns/default/reflection_questions
|
||||
# - name: "Reflection [PT]"
|
||||
# insight_type: "Reflection Questions [PT]"
|
||||
# description: "Generates a list of insightful questions to provoke reflection"
|
||||
# transformations:
|
||||
# patterns:
|
||||
# - patterns/default/reflection_questions
|
||||
# - patterns/default/translate
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue