Skip to content

biantaishabi2/think

Repository files navigation

ReasonSphere 递归增强思维系统

ReasonSphere是一个基于大语言模型的递归思维增强系统,它能够通过多轮迭代和不同思维策略的动态切换,对复杂问题进行深入分析和思考。

主要特点

1. 多样化思维策略

  • 标准思维(standard): 深入分析问题,进行连贯性思考
  • 对比思维(contrastive): 提出与主流观点不同的替代方案
  • 假设检验(hypothesis_testing): 批判性检验关键假设
  • 发散思维(divergent): 探索新角度和创新解决方案
  • 收敛思维(convergent): 综合分析,得出最终结论

2. 智能验证系统

  • 基础验证与专业领域验证相结合
  • 支持技术、商业、教育等多个专业领域
  • 提供详细的问题反馈和改进建议

3. 可视化分析

  • 思考路径可视化
  • 验证分数趋势分析
  • 思维策略转换追踪

4. 灵活的存储系统

  • 支持线性、树状、图状等多种存储结构
  • 自动保存思考历史和验证结果
  • 便于回溯和分析思考过程

安装说明

  1. 克隆仓库:
git clone [email protected]:biantaishabi2/think.git
cd think
  1. 安装依赖:
pip install -r requirements.txt
  1. 设置环境变量:
export DEEPSEEK_API_KEY=your_api_key

使用示例

基本用法

from reasonsphere import ReasonSphereEngine
from reasonsphere.api import DeepseekAPI

# 创建API客户端
api_client = DeepseekAPI(
    api_key=os.environ.get("DEEPSEEK_API_KEY"),
    model="deepseek-reasoner"
)

# 创建引擎实例
engine = ReasonSphereEngine(
    main_llm=api_client,
    validator_llm=api_client,
    config={
        "max_iterations": 5,
        "verbose": True
    }
)

# 执行递归思考
question = "如何设计一个高效的微服务架构系统?"
summary, thought_history, metrics = await engine.recursive_think(question)

自定义验证器

from reasonsphere.validation import ValidationSystem

class CustomValidator(ValidationSystem):
    async def validate(self, new_thought, thought_history):
        base_result = await super().validate(new_thought, thought_history)
        # 添加自定义验证逻辑
        return base_result

engine.validator = CustomValidator(api_client)

可视化思考过程

from examples.visualization import visualize_thinking_process

visualization_file = visualize_thinking_process(
    engine.thought_store.storage_path,
    engine.thought_store.session_id
)

目录结构

reasonsphere/
├── __init__.py
├── engine.py         # 主控制引擎
├── thinking.py       # 思考生成模块
├── validation.py     # 验证系统
├── strategy.py       # 策略控制器
├── context.py        # 上下文管理
├── storage.py        # 思考存储
└── utils.py          # 工具函数

示例代码

  • examples/basic_usage.py: 基本使用示例
  • examples/advanced_strategies.py: 高级策略示例
  • examples/custom_validators.py: 自定义验证器示例
  • examples/visualization.py: 思考可视化示例

许可证

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages