Giter Site home page Giter Site logo

gg8fkpxq / binglocalhost Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 4.0 305 KB

基于EdgeGPT和gradio,简单快速部署自己的Bing在本地局域网web服务(也可以是非局域网),把Bing部署在本地局域网,一台电脑开代理,其他设备(包括移动设备)都可以使用Bing,无需重定向。

Python 94.66% CSS 5.34%

binglocalhost's Introduction

BingLocalhost

preview 本项目基于gradioEdgeGPT,把Bing部署在本地局域网,一台电脑开代理,其他设备(包括移动设备)也能使用,轻松简单,无需重定向。

不会整前端,CSS抄了几行 ChuanhuChatGPTutils.py用于解决Markdown转义的问题,该文件代码几乎完全来源于 ChuanhuChatGPT,请原谅。

如果您觉得本项目好用请帮忙点 Star

1. 基础准备

  • 安装Python 3.10+ or 您的Python版本低于3.10,请修改main.py中的change_question函数,把其中的match-case语句改为if-elif-else语句。个人建议是安装好Python后,使用单独的venv虚拟环境运行运行本项目。

  • 安装gradioEdgeGPT, Markdown, mdtex2html这4个Python库,安装方法可以直接复制下方的命令,也可以看这几个库的主页,都非常简单。

pip install gradio EdgeGPT Markdown mdtex2html

如果以上命令安装速度很慢(尤其是**用户),可以使用以下命令,或者参考这篇文章进行换源。

pip install gradio EdgeGPT Markdown mdtex2html -i https://pypi.tuna.tsinghua.edu.cn/simple

有时候Bing的回答内容比较长,需要较长的等待时间,但是EdgeGPT默认的最长等待时间只有10秒,就容易出现错误。因此个人建议把EdgeGPT库的EdgeGPT.py中的self.session = httpx.Client这一行把timeout=10改为timeout=60, verify=False

  • **用户需要科学上网手段,可以参考这个项目:free

  • 需要有可使用New Bing的账号,导出Cookie的方法请看EdgeGPT。如果您的微软账户无法使用New Bing,请直接重新注册一个,使用outlook邮箱即可,然后完成账号备用邮箱的安全验证(也可以使用outlook邮箱)。

2. 下载本项目文件

下载后解压缩,然后放到您喜欢的目录

3. 配置Bing Cookie

把用于存放Cookie的json文件放到一个单独的文件夹中,请确保这个文件夹中只有储存cookie的json文件

打开main.py,存放cookie的文件夹路径地址粘贴上去

cookiePath = r"./cookiePath"  # 填写存放Bing的cookies目录,请确保这个文件夹中只有储存cookie的json文件

4. 运行main.py

支持电脑和手机。如果您是在虚拟环境中创建的本项目,请先启动虚拟环境。

在Windows系统创建venv虚拟环境

  1. 创建venv环境

启动CMDPowerShell,运行以下命令

python3 -m venv C:\FilePath\ProjectName\venv

这行代码会在C:\FilePath\ProjectName\venv目录创建名虚拟环境,ProjectName可以更换为您的项目名称,FilePath您也可以自己选择。

以下假设您在C:\FilePath\ProjectName\venv创建了虚拟环境

然后把本项目放在C:\FilePath\ProjectName目录下

  1. 进入虚拟环境

C:\FilePath\ProjectName\venv\Scripts目录中运行CMDPowerShell 或者启动CMDPowerShell后把工作目录切换到C:\FilePath\ProjectName\venv\Scripts 然后运行activate.bat文件启动虚拟环境

  1. 在虚拟环境中安装python库

进入虚拟环境后您的命令行开头会带有(venv)标识,此时说明进入虚拟环境成功,然后安装Python库的方法和平常并无差别,如:

pip install gradio
  1. 删除虚拟环境

直接把C:\FilePath\ProjectName\venv删除即可

Star History

Star History Chart

binglocalhost's People

Contributors

gg8fkpxq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar 立言 Li Yan avatar  avatar George Zhao avatar  avatar  avatar Lewis Liu avatar lefan avatar  avatar Steven Lee avatar  avatar  avatar

Watchers

 avatar  avatar

binglocalhost's Issues

无法运行

report:
Traceback (most recent call last):
File "/root/BingLocalhost/main.py", line 11, in
from utils import postprocess
File "/root/BingLocalhost/utils.py", line 16, in
self, y: List[Tuple[str | None, str | None]]

运行环境:
Debian11 64x 英国 6.3.0Linux内核

Python 3.9

使用了if-elif-else

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.