1 Star 1 Fork 0

mooye / chat-gpt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ChatGPT 服务提供

License Java Maven

Language Language Language

项目地址

项目简介

本项目利用百度文本校验 Api 实现敏感词、违禁词校验.使用国内开发者提供的 ChatGPT 接口服务实现文本内容的生成。使用 ERNIE-ViLG AI 作画大模型实现绘图。

部分 Api 说明

调用百度鉴权接口获取 token,接口为:

  curl -i -k 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【百度云应用的AK】&client_secret=【百度云应用的SK】'

将获取到的 token 进行存储,每 30 天自动更新一次 详细接口介绍参阅官方文档

百度文本校验 Api

curl -i -k 'https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined?access_token=【调用鉴权接口获取的token】' --data 'text=不要侮辱伟大的乐侃' -H 'Content-Type:application/x-www-form-urlencoded'

详细说明参阅百度官方文档

ERNIE-ViLG AI 作画大模型

注意,该服务需要付费,但官方提供了 200pic的免费调用量,后续加个为 9.9RMB/50pic

获取 token

curl -XPOST "https://wenxin.baidu.com/moduleApi/portal/api/oauth/token?grant_type=client_credentials&client_id={your_ak}&client_secret={your_sk}" -H "Content-Type:application/x-www-form-urlencoded"

该token 有效期为 24 小时

创建预测任务

curl -i -k "https://wenxin.baidu.com/moduleApi/portal/api/rest/1.0/ernievilg/v1/txt2img?access_token=${access_token}" --data-urlencode "text=睡莲" --data-urlencode "style=油画" --data-urlencode "resolution=1024*1024" --data-urlencode "num=4" #分辨率和数量非必须参数,默认resolution=1024*1024、number=4

查询任务

curl -i -k "https://wenxin.baidu.com/moduleApi/portal/api/rest/1.0/ernievilg/v1/getImg?access_token={access_token}" --data-urlencode "taskId={task_id}"

注意,查询任务接口需要轮询,ERNIE-ViLG AI绘制图片时长不稳定

详细说明参阅文心大模型文档

使用

  • 如果你只是想使用这个项目
    1. 首先部署 redis 并修改 redis 的配置文件将密码设置成 chatGPTRedisPwd;
    2. 使用java -jar chat-gpt-0.0.1.jar启动项目即可,启动后访问 http://localhost:11023/system/init 进行配置相关参数,由于ChatGPT 接口不再使用 OpenAI 的接口提供服务,因此页面上的Authorization字段可以随意填写;
    3. 调用http://localhost:11023/chat/gpt?text=参数 即可获取生成的文本;
    4. 调用http://localhost:11023/painting/painting?des=参数 即可获取生成的图片;
  • 如果你想做一些更改请关注cn.com.mooyea.chatgpt.controller.ChatGptController.javacn.com.mooyea.chatgpt.common.GeneralCommon.javacn.com.mooyea.chatgpt.common.PaintingController.java等。

鸣谢

感谢夏柔公益 Api 提供的 ChatGPT 接口服务。

感谢百度智云提供的敏感词校验 Api 试用服务.

MIT License Copyright (c) 2023 mooyea Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

ChatGPT 服务,为 bot 提供相关服务 展开 收起
Java 等 2 种语言
MIT
取消

发行版 (2)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/mooye_Lee/chat-gpt.git
git@gitee.com:mooye_Lee/chat-gpt.git
mooye_Lee
chat-gpt
chat-gpt
master

搜索帮助