From c63936e348c7c50e92634c2ccf07d234d2fcfe2b Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Mon, 10 Mar 2025 16:15:27 -0700 Subject: [PATCH] cr --- README.md | 16 ++++++++++++---- examples/coding.py | 8 ++++---- examples/llm_as_a_judge.py | 10 +++++----- pyproject.toml | 3 --- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 84c49e8..2c256a6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ This prebuilt graph is an agent that uses a reflection-style architecture to check and improve an initial agent's output. +## Installation + +``` +pip install langgraph-reflection +``` + +## Details + This reflection agent uses two subagents: - A "main" agent, which is the agent attempting to solve the users task - A "critique" agent, which checks the main agents work and offers any critiques @@ -56,8 +64,8 @@ judge_graph = StateGraph(MessagesState).add_node(judge_response)... # Create reflection graph that combines assistant and judge -reflexion_app = create_reflection_graph(assistant_graph, judge_graph) -result = reflexion_app.invoke({"messages": example_query}) +reflection_app = create_reflection_graph(assistant_graph, judge_graph) +result = reflection_app.invoke({"messages": example_query}) ``` ### Code Validation ([examples/coding.py](examples/coding.py)) @@ -100,8 +108,8 @@ def try_running(state: dict) -> dict | None: judge_graph = StateGraph(MessagesState).add_node(try_running)... # Create reflection system that combines code generation and validation -reflexion_app = create_reflection_graph(assistant_graph, judge_graph) -result = reflexion_app.invoke({"messages": example_query}) +reflection_app = create_reflection_graph(assistant_graph, judge_graph) +result = reflection_app.invoke({"messages": example_query}) ``` The code validation example ensures that generated code is not only syntactically correct but also type-safe and follows best practices through static analysis. diff --git a/examples/coding.py b/examples/coding.py index 3427b8d..f6f754f 100644 --- a/examples/coding.py +++ b/examples/coding.py @@ -141,7 +141,7 @@ def create_graphs(): if __name__ == "__main__": - """Run an example query through the reflexion system.""" + """Run an example query through the reflection system.""" example_query = [ { "role": "user", @@ -149,7 +149,7 @@ if __name__ == "__main__": } ] - print("Running example with reflexion...") - reflexion_app = create_graphs() - result = reflexion_app.invoke({"messages": example_query}) + print("Running example with reflection...") + reflection_app = create_graphs() + result = reflection_app.invoke({"messages": example_query}) print("Result:", result) \ No newline at end of file diff --git a/examples/llm_as_a_judge.py b/examples/llm_as_a_judge.py index be5c939..2259f9d 100644 --- a/examples/llm_as_a_judge.py +++ b/examples/llm_as_a_judge.py @@ -80,8 +80,8 @@ judge_graph = ( # Create the complete reflection graph -reflexion_app = create_reflection_graph(assistant_graph, judge_graph) -reflexion_app = reflexion_app.compile() +reflection_app = create_reflection_graph(assistant_graph, judge_graph) +reflection_app = reflection_app.compile() # Example usage @@ -94,6 +94,6 @@ if __name__ == "__main__": } ] - # Process the query through the reflexion system - print("Running example with reflexion...") - result = reflexion_app.invoke({"messages": example_query}) + # Process the query through the reflection system + print("Running example with reflection...") + result = reflection_app.invoke({"messages": example_query}) diff --git a/pyproject.toml b/pyproject.toml index ef7113c..4658a5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,9 +14,6 @@ authors = [{name = "Harrison Chase"}] [tool.setuptools.packages.find] where = ["src"] -[tool.uv.sources] -langgraph-reflexion = { workspace = true } - [dependency-groups] dev = [ "langgraph-reflection",