Giter VIP home page Giter VIP logo

chatgpt-magic-plug's Introduction

Chatgpt油猴插件

这是一个最新的ai交互功能chatgpt,与搜索引擎融合的油猴插件,通过这个插件可以实现左边查看搜索引擎搜索结果,右边查看ai给的答案方便日常工作同时优化传统搜索引擎。

部署&&体验

文章:https://www.laijiahao.cn/posts/bb8fab97/

项目结构

- AiRedis.py  Redis配置
- RecordLog.py 日志写入 
- app.py 主程序接口
- check_ip.py IP异常判断
- config.py 配置文件
- oil_monkyjs.js 油猴JS脚本
- openai.py openai实现

优势

  1. 有别于chatgpt,其实是直接调用了openai的接口,详细可看openai文档
  2. 只需替换你的key,就可以使用,或者使用本项目提供的key(支持多个key,随机使用)
  3. 无需获取token,也无需任何梯子即可使用
  4. 使用text-davinci-003模型
  5. 后端可部署自己的服务器,有异常记录
  6. 有线程池,可以并发
  7. 通过插件形式即可快速使用chatgpt功能,并且运用到实际工作中

后端实现

使用纯Python实现

必备组件

redis
pandoc

必备模块

你可以使用pip安装它们

flask
flask_cors
redis
flask_cors
pypandoc

配置项

config.py文件可以看到以下选项

configs = \
{
# 替换为你的api_key <https://beta.openai.com/account/api-keys>
"keys" : ["key1",
          "key2"
          ],
# 这个是设置回答的长度,最大可以设置到4096 (免费额度为$18,该值影响你的用量)
"max_tokens":1000,
#值越高意味着模型将承担更多风险。对于更具创造性的应用程序,请尝试 0.9,建议0.5-0.6
"temperature":0.5,
}

如何获取key

  1. 拥有一个openai的账号
  2. 进入https://beta.openai.com/account/api-keys
  3. 点击Create new secret key即可获取

接口文档

请求参数

参数 类型 说明
key(无需) api_key https://beta.openai.com/account/api-keys
prompt(必须) str 问题(必须)
max_tokens(无需) int 这个是设置回答的长度,最大可以设置到4096 (免费额度为$18,该值影响你的用量)
默认:1000
temperature(无需) float 值越高意味着模型将承担更多风险。建议0.5-0.6,最大可以为0.9
默认:0.5

请求示例

{
  "prompt":"写一个关于数学建模的论文"
}

结果返回

成功示例
{
    "code": 200,
    "msg": "\n\n摘要\n\n本文旨在探讨数学建模在解决实际问题中的应用。首先,我们简要介绍了数学建模的定义和特点,以及它在工程和科学中的重要性。其次,我们给出了一个具体的数学建模案例,该案例涉及货运"
}
失败示例1

条件:未知错误

{
    "code": 400,
    "error": "your_error",
    "msg":"出现意外的错误,请检查你的配置"
}
失败示例2

条件:服务器端出现异常

{
    "code": 404,
    "msg": "服务器出现错误,开发者正在抢修中!"
}
失败示例3
{
    "code": 202,
    "msg": "请勿频繁搜索,请30S后再进行搜索,否则将禁止使用此脚本"
}
失败示例4
{
    "code": 202,
    "msg": "由于请求过于频繁,你的IP已禁,请联系开发者解除"
}

前端实现

油猴插件项目文件为oil_monkeyjs.js 引入jquery做ajax请求,在19行中填入请求服务的url

油猴脚本发布

插件发布地址如下所示,大家可以复现后发布自己的插件 https://greasyfork.org/zh-CN/script_versions/new

油猴脚本下载地址

https://greasyfork.org/zh-CN/scripts/456447-chatgpt-magic

效果展示

进入百度或者csdn点击搜索或者回车即可触发chatgpt功能

  • 百度 z4MYTK.png
  • csdn z4M6Tf.png

Todolist

  • 接入更多搜索引擎
  • 代码块展示优化
  • 并发优化
  • 窗口样式优化可拖拽

联系作者

在使用过程中如果有遇到bug的情况可以联系作者,邮箱如下

MIT开源协议

请遵循MIT开源协议

chatgpt-magic-plug's People

Contributors

kjhuanhao avatar yangziteng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chatgpt-magic-plug's Issues

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.