基于浏览器自动化(browser-harness)的 DeepSeek / Gemini LLM 包装器,兼容 LangChain 生态。
# 1. 安装 browser-harness(浏览器自动化基础设施)
pip install browser-harness
# 2. 安装 chat-web
cd chat_web
pip install -e .chat_web/
├── pyproject.toml # 打包配置
├── __init__.py # 包入口
├── deepseek/ # DeepSeek 网页自动化 API
│ ├── __init__.py
│ ├── deepseek_api.py # 对外接口
│ └── core/
│ ├── __init__.py
│ └── deepseek_helper.py # 核心实现
├── gemini/ # Gemini 网页自动化 API
│ ├── __init__.py
│ ├── gemini_api.py # 对外接口
│ └── core/
│ ├── __init__.py
│ └── gemini_helper.py # 核心实现
├── chain_test/ # LangChain 兼容层
│ ├── __init__.py
│ ├── deepseek_llm.py # DeepSeek LangChain LLM 包装器
│ ├── gemini_llm.py # Gemini LangChain LLM 包装器
│ ├── browser_search_tool.py # 浏览器搜索智能体
│ ├── tool_demo.py # ReAct 模式工具调用演示
│ ├── test_chain.py # LangChain 基础测试
│ └── test_advanced.py # LangChain 高级功能测试
├── requirements.txt
└── README.md
from chat_web.chain_test.deepseek_llm import DeepSeekLLM
from langchain_core.prompts import PromptTemplate
# 简单对话
llm = DeepSeekLLM(auto_new_chat=True)
response = llm.chat("你好,请介绍一下你自己")
# LangChain 管道
template = PromptTemplate.from_template("请解释: {topic}")
chain = template | llm
result = chain.invoke({"topic": "量子计算"})# ReAct 工具调用演示
python -m chat_web.chain_test.tool_demo
# LangChain 基础测试
python -m chat_web.chain_test.test_chain
# 高级功能测试
python -m chat_web.chain_test.test_advanced- 新建对话 / 继续对话
- 文件上传与分析
- 对话历史管理
- 智能搜索开关控制
- 新建对话 / 继续对话
- 图片分析与上传
- Thinking 模型限额自动降级到 Flash
- 对话历史管理
BaseLLM完整接口 (_generate,_llm_type,_identifying_params)RunnableSequence管道语法 (template | llm)@tool装饰器工具定义FewShotPromptTemplate少样本学习JsonOutputParser结构化输出解析- Pydantic
BaseModel结构化输出
- Thought → Action → Observation 循环
- 工具自动调用
- 浏览器智能搜索
- 多轮决策
from chat_web.chain_test.deepseek_llm import DeepSeekLLM
from chat_web.chain_test.browser_search_tool import BrowserSearchAgent
llm = DeepSeekLLM(auto_new_chat=True)
llm.disable_search()
agent = BrowserSearchAgent(llm)
result = agent.search("2025年人工智能发展趋势")- Python 3.11+
- Chrome 浏览器
- browser-harness 已安装(
pip install browser-harness)
- 不包含任何 API 密钥或个人隐私信息
- 浏览器自动化通过 browser-harness 实现,无需配置 WebDriver
- 截图和临时文件保存到
screenshots/子目录