自己制作微信博客小程序开源(支持免费GPT-4 和 图生图 文生图功能)

前言

因为之前开源的两个项目 ChatGPT Web应用和小程序应用都挺火的 涨了将近600个小星星😁
最近刚好 想重置一下以前写的博客小程序,另外把GPT-4 和 绘图功能(文生图 图生图),大概花了 2周时间写完了这个程序

B站演示地址: https://b23.tv/l8uhPDT

讲一下主要功能

GPT

支持GPT-4 流式对话(之前弄得SuperBot小程序是不支持的哈哈哈🤣)无需任何代理以及OpenAiKey,另外之前开源的输入框不会根据内容自动延长现在有了 上效果图

GPT对话

Stable Diffusion

支持文生图 图生图等绘图操作 另外绘图时 是做了异步队列处理 并且一次只执行一个任务 后续任务需要等待上一个任务执行完毕后才会被绘制,这个如果你的SD支持多并发的话可以在 application-prod.yml中进行修改

绘图

用户选择文生图和图生图功能时 会展现出两种不同的风格 也就是对比,另外在操作绘图时 首先会对 SD服务 进行异步心跳检测 从而得知 服务是否正常开启,另外还对用户输入的词进行了润词,这里接入的是 百度翻译API,提示词输入英文也可中文也可, 选择百度翻译的原因为 在进行开发者认证后免费调用API,另外刚好百度翻译标准版只支持单并发,很契合SD,因为SD我做了队列处理一次性只处理一个任务 所以非常契合😁, 另外图片生成完毕后 是会通过微信通知 给用户 告诉他图片生成成功了 或者 失败了 失败原因基本都是用户输入了敏感词 OK上效果图

图生图
文生图

下面就介绍一下其他的功能

  1. 支持 发布文章 设置专题 以及配置首页轮播图文章
  1. 支持评论功能 以及 二级回复功能
  1. 支持文章搜索功能 可通过摘要 关键词 以及 标签 标题 模糊搜索
  1. 撰写文章功能 支持 插入视频 插入图片 插入CODE代码标签(可自定义输入语言 如Java Python等)
  1. 在进行删除文章 或者在撰写文章时 插入了图片但是没有保存 则会自动清理(删除垃圾数据节省服务器空间)
  1. 绘制的图片如果没有被管理员设置为推荐作品 则会在每天晚上12点进行删除 设置为推荐后永久保存 并且推荐作品 所有人可见
  1. 支持文章数据分页滑动加载 另外文章这一块是结合Redis以及mysql实现 通过redis来进行阅读量排序取ID查MDB
  1. 支持文章点赞以及最上边最下边切换
  1. 支持用户自定义上传头像以及昵称 ,另外这里也接入了微信头像填写能力
  1. 所有用户操作接口都做了微信敏感词检测和微信图片检测
  1. 支持GPT个性化定义 如给他取个初始名字什么的....
  1. 支持过滤GPT对话时 过滤哪些数据,前端的话只做了可以限制用户输入哪些关键词
  1. 代码高亮支持主流语言 如 Java Python Js C++ C Go PHP 等等....

还有很多功能 可以自行体验我的小程序 已经上线了

部署文档还在整理当中 后面搞完放GitHub仓库 可以先简单看一下 整体小程序仅需自备SD就能玩所有功能 服务器方面 2h2g足矣 不过小程序部署需要域名备案才行 另外的 都随便玩了 全功能

前端代码结构
前端代码结构

后端代码结构
后端代码结构展示

部署文档教程(英文) 这一版做了很多改进 后端数据填充时都做了校验主要是不做校验太多小白部署总是出问题就很麻烦,现在这一版基本功能只需携带SD即可! 下面可以看看 部署教程 很简单 只需配置yml即可 前端的话只需配置 env.js另外教程我也附带了参考值


Time Sea Blog

GitHub @TimeSea

Supported Platform

This section applies to which platforms the project applies to

Platform Supported
WeChat ✔️️
Alipay ✔️️
TikTok
Baidu
QQ ✔️

Please report security issues to author WeChat: SeatimeIsland

function Introduction

  • GPT-4 dialogue function no vpn or other proxy is required
  • Stable Diffusion Text2Img You need to own it (the server)
  • Stable Diffusion Img2Img You need to own it (the server)
  • Custom storage files
  • Ability to upload user avatars
  • Publish an article(blog)
  • Custom themes
  • Manage articles
  • Recommended articles
  • Search article function (random read)
  • Article Leaderboard (All) (lazy loading)
  • Cool UI interface
  • Support uploading images or videos for article content (Canceling save cleans up file asynchronously)
  • Article comments (support secondary reply)
  • AI personalized management(Example: Give it a name)
  • Block sensitive words(Support wechatApp and java double verification)
  • Support user input content check
  • Image generation notifies users in a timely manner
  • drawing task queue processing(line up), After the generation is successful, the WeChat message notifies the user

Tired of writing, omit this time..............

Environment and tools (preparation)

Oracle JDK 17

Maven 3.8.6

HBuilder 3.8.7

NODEJS 18

IntelliJ IDEA 2023

BT Panel MySQL Redis JDK17 Jar

wechatApp WeChat DEV Platform to Get AppID and Secret

Stable Diffusion not required,however, create Image feature is not available

Server configuration 2C2M

SSL certificate pfx Domain name registration is required.

server deployment (Java)

When deploying artifacts, please make sure that JDK17, BT panel, MySQL8, Redis7 are installed on the server
,If not, install it yourself

Use IDEA to open this artifact

1. Create database

In the Java artifact, find .sql folder in the root directory and execute the SQL into a database with the name sea_time

2. Configure SSL certificate

Please place YOUR_SSL.pfx certificate in the resource directory

3. EDIT /resource/application-prod.yml

server:
  ssl:
    key-store: 
    key-store-password: 
    key-store-type: 
spring:
  data:
    redis:
      database: 
      host: 
      port: 
      password: 
  datasource:
    url: 
    username: 
    password: 

we-chat:
  appId: 
  secret: 
  template: 
  
baidu:
  appId: 
  secret: 

admin: 
sensitive: 
isSensitive: 
file:
  path:

suggestion

key description reference
key-store your SSL certificate ️️ classpath:baidu.com.pfx
key-store-password your SSL certificate password ️️ OOP882SS
key-store-type SSL certificate type ️️ PKCS12
redis.database specifies the Redis data source ️️ 0
redis.host IP address of the server where Redis is located ️️ 127.0.0.1
redis.port Redis port ️️ 6379
redis.password Redis password , If not, delete the attribute directly ️️ 123
datasource.url MySQL database connection address ️️ jdbc:mysql://127.0.0.1:3306/sea_time?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&allowMultiQueries=true&useSSL=true
datasource.username MySQL Connect user name ️️ root
datasource.password MySQL Connect user password ️️ 123
we-chat.appId Your WeChat Mini Program App ID ️️ wxbe287021223c78b38
we-chat.secret Your WeChat Mini Program secret ️️ a25aad11090c991ab01601470e1cfbb2
we-chat.template Your WeChat Mini Program templateId ️️ _K8fdGIqxa16m0djxSAAAYS-eCY0lZwpLXkqNrGIRzY
admin Administrator OpenId,Please separate multiple with commas ️️ okdYI5GP-ifLzNJEtsnml0u9J3dc,okdYI5GP-ifLzNJEtsnml0u9J3ac,
sensitive Prevent GPT from talking nonsense ️️ (CHAT)
isSensitive Whether to enable text blocking ️️ false
file.path Resource storage path ️️ /app/desktop/blog/resource/
baidu.appid Baidu Translation(appid) ️️ wxbe287021223c78b38
baidu.secret Baidu Translation(secret) ️️ K8fdGIqxa16m0djxSAAAYS-eCY0lZwpLXkqNrGIRzY

Deployment tutorials(WeChatApp)

Use HBuilder to open this artifact

1. Install dependencies

npm install

2. EDIT root/utils/env.js

"use strict";

export default {
    lazyLoading: true,
    adminLabel: '',
    userLabel: '',
    user: '',
    author: '',
    baseUrl: '',
    baseWs: '',
    filtration: [],
    memory: 6,
    contextLength: 200,
    botInitialization: [],
    templateId:[]
}

suggestion

key description reference
lazyLoading render component timing ️️ true
adminLabel administrator label ️️ Super Man
userLabel access user label ️️ Trainee Man
user default access user nickname ️️ CXK
author default administrator nickname ️️ WYF
baseUrl server (IP address and port) HTTPS ️️ http://127.0.0.1:8624
baseWs server (IP address and port) WSS ️️ ws://127.0.0.1:8624
filtration filter keywords,Users are prevented from entering keywords that contain the content ️️ ["GPT", "OPENAI"]
memory bot maximum number of sentences to remember ️️ 10
contextLength bot can remember the text length of historical data ️️ 200
botInitialization superBot initializes the animation vocabulary (randomly picking a prompt word from the array each time) ️️ ["你有什么问题或者困惑需要我帮助解答吗?", "你好!很高兴与您交流,有什么我可以为您做的吗?"]
templateId weChat notification template ID ️️ ["_K8fdGIqxa16m0djxSAAAYS-eCY0lZwpLXkqNrGIRzY"]

3. Write WeChatApp configuration

Locate the manifest.json file located in the root directory,
replace YOU_APPID with your own WeChat developer APPID

manifest.json criticalCode

  "mp-weixin" : {
        "appid" : "YOU_APPID",
        "setting" : {
            "urlCheck" : false
        },
        "optimization" : {
            "subPackages" : true
        },
        "lazyCodeLoading" : "requiredComponents",
        "usingComponents" : true
    },

Please note that the parameters are filled in according to the reference value and attribute interpretation

posted @ 2023-07-18 01:08  独来独往_303  阅读(617)  评论(0编辑  收藏  举报