Crimson Langgraph Reflection
A modular implementation of LangChain's Reflexion example, designed to make agent development more accessible, extensible, and reusable.
Overview
This project transforms the original LangChain Reflexion tutorial into a fully modular package. The Reflexion pattern enables LLM agents to:
- Answer questions
- Reflect on and critique their own answers
- Generate search queries to gather more information
- Revise answers based on new information
By modularizing this pattern, this package aims to:
- Make Reflexion-style agents easier to implement in your projects
- Provide a solid foundation for further customization and extension
- Encourage reusability of core Reflexion components
Installation
pip install crimson-langgraph-reflection
Key Components
The package is organized into several main modules:
- graph.py: Defines the LangGraph state machine that orchestrates the reflection process
- responder/: Contains components for generating answers, reflections, and search queries
- base.py: Core classes for response generation and validation
- prebuilt.py: Ready-to-use responder implementations
- tool.py: Search tool integration for information gathering
- ui.py: Simple interface for running the Reflexion agent
- llm.py: LLM configuration (defaulting to Claude 3.5 Sonnet)
Quick Start
from crimson.langchain_reflexion.ui import stream_shortcut
# Run with default settings (5 iterations)
stream_shortcut(question="What is LangChain?")
# Or customize the number of iterations
stream_shortcut(
question="What is LangChain?",
max_iterations=3
)
# Use a custom LLM
from langchain_anthropic import ChatAnthropic
custom_llm = ChatAnthropic(model="claude-3-opus-20240229")
stream_shortcut(
question="What is LangChain?",
llm=custom_llm
)
Examples
For complete examples, check out:
Extension and Customization
This package is designed to be extensible. You can:
- Create custom responder implementations by extending the base classes
- Modify the graph structure to add additional steps
- Integrate different search or reasoning tools
- Adjust the system prompts and reflection criteria
Requirements
- Python ≥ 3.9
- LangChain
- LangGraph
- Anthropic API access (for default LLM)
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgements
This project is based on LangChain's Reflexion tutorial. Special thanks to the LangChain team for their innovative work on LLM agent frameworks.
Metadata
Release files for crimson-langgraph-reflection 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| crimson_langgraph_reflection-0.1.0.tar.gz | 9.7 kB | Without provenance | Details for crimson_langgraph_reflection-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crimson_langgraph_reflection-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for crimson_langgraph_reflection-0.1.0-py3-none-any.whl |
Total release size: 20.4 kB
Release files / crimson_langgraph_reflection-0.1.0.tar.gz
| Download URL | crimson_langgraph_reflection-0.1.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cf56e9c963af578b8dd441388944dafdbc728859784bf7e87019343f21e8ad8
|
|
BLAKE2b-256 checksum How to use checksums |
44b2c1a8e81bfc47bda6a0cf45545435640fa7be4b4686356d475af5ad3ad658
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / crimson_langgraph_reflection-0.1.0-py3-none-any.whl
| Download URL | crimson_langgraph_reflection-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0070f66d90f92db25923014ce6828a3311d6ce3fe0226c0c7521f68c74ed8b71
|
|
BLAKE2b-256 checksum How to use checksums |
6b7b15af81551de0522a2019218dcbfc9578f5cce770e43080be8b5ddd673d27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for crimson-langgraph-reflection 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.