# langchain-examples **Repository Path**: bytesifter/langchain-examples ## Basic Information - **Project Name**: langchain-examples - **Description**: LangChain 示例代码集合 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-03 - **Last Updated**: 2026-04-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LangChain DeepSeek 翻译工具 基于LangChain和DeepSeek API的翻译工具,支持交互式文本翻译。 ## 功能特性 - 使用DeepSeek API进行高质量翻译 - 交互式命令行界面 - 支持中英文互译 - 环境变量配置API密钥 ## 安装 ### 使用uv(推荐) ```bash # uv 0.9.18 版本使用 uv pip install uv pip install . # 较新版本的uv可能支持 uv install . # uv install . ``` ### 使用pip(兼容性) ```bash pip install -e . ``` ## 使用方法 ### 命令行使用 ```bash # 运行翻译工具 python translate.py # 或者直接运行 translate ``` ### 程序内使用 ```python from src.translationtool import setup_environment, create_translation_chain # 设置环境 setup_environment() # 创建翻译链 chain = create_translation_chain() # 执行翻译 result = chain.invoke({"input_text": "Hello, world!"}) print(result) ``` ## 配置 1. 获取DeepSeek API密钥:访问[DeepSeek官网](https://platform.deepseek.com/) 2. 设置环境变量: ```bash export DEEPSEEK_API_KEY="your-api-key-here" ``` 或者创建`.env`文件: ``` DEEPSEEK_API_KEY=your-api-key-here ``` ## 项目结构 ``` langchain-examples/ ├── src/ # 源代码 │ ├── __init__.py │ └── translationtool.py ├── tests/ # 测试文件 │ ├── __init__.py │ └── test_translationtool.py ├── scripts/ # 工具脚本 │ ├── test_structure.py │ ├── test_import.py │ └── dev.ps1 ├── docs/ # 文档 ├── translate.py # 命令行入口 ├── pyproject.toml # 项目配置 ├── .env.example # 环境变量示例 ├── .gitignore # Git忽略规则 ├── README.md # 项目说明 └── AGENTS.md # 团队规范 ``` ## 开发 ### 使用开发工具脚本(推荐) ```powershell # 显示帮助信息 .\scripts\dev.ps1 help # 安装开发依赖 .\scripts\dev.ps1 dev-install # 格式化代码 .\scripts\dev.ps1 format # 代码检查和类型检查 .\scripts\dev.ps1 lint .\scripts\dev.ps1 typecheck # 运行测试 .\scripts\dev.ps1 test # 清理构建文件 .\scripts\dev.ps1 clean # 运行翻译工具 .\scripts\dev.ps1 run ``` ### 手动命令 ```bash # 安装开发依赖 uv pip install .[dev] # 运行测试 uv run pytest tests/ ``` ## 许可证 MIT License