Skip to content

orangefplus/chat_web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Web - 浏览器自动化 LLM 工具包

基于浏览器自动化(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

功能特性

DeepSeek API

  • 新建对话 / 继续对话
  • 文件上传与分析
  • 对话历史管理
  • 智能搜索开关控制

Gemini API

  • 新建对话 / 继续对话
  • 图片分析与上传
  • Thinking 模型限额自动降级到 Flash
  • 对话历史管理

LangChain 兼容

  • BaseLLM 完整接口 (_generate, _llm_type, _identifying_params)
  • RunnableSequence 管道语法 (template | llm)
  • @tool 装饰器工具定义
  • FewShotPromptTemplate 少样本学习
  • JsonOutputParser 结构化输出解析
  • Pydantic BaseModel 结构化输出

ReAct 智能代理

  • 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/ 子目录

About

控制网页的gemini和deepseek代替api的模型,免费使用对话,封装在方法中,可以嵌入到langchain中使用,可以选择网页端的模式上传文件读取结果等功能,不在为多模态的api和对话api担忧,内置了网页搜索智能体,直接控制浏览器从网页搜索

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages