开源云开发流量主小程序-AI写诗-CitizenFour

该项目通过AI技术实现诗歌创作,支持自由诗、藏头诗等多种形式。目标用户为18-40岁群体,旨在让每个人都能轻松创作诗歌。项目包括文字安全识别、AI诗句学习及API调用等关键技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目名称:AI写诗

项目背景:每个人心目中都住着一个文艺青年,诗歌是人们的一种自然表达,它没有门槛,人人都是徐志摩

应用场景:可以写押韵自由诗、藏头诗、给定若干字作为主题的诗。生活中任何一件事都可以用诗去表达

目标用户:男女通吃,年龄18-40

实现思路:

1、文字安全识别

// 文字内容检测
async function msgSecCheck(event) {
  try {
    const res = await cloud.openapi.security.msgSecCheck({
      content: event.content
    })
    return res;
  } catch (err) {
    return err;
  }
}

 

//文字检测页面调取 
 msgSecCheck(content) {
    wx.showLoading({
      title: '检测文字中',
      mask:true
    })
    // new Promise((resolve, reject)=>{
      wx.cloud.callFunction({
        name: 'contentCheck',
        data: {
          content: content,
          type: "msgSecCheck"
        },
        success: res => {
          wx.hideLoading();
          if (res.result.errCode == 0) {
            wx.navigateTo({
              url: "../poem_detail/detail?type=" + app.globalData.e.type + "&text=" + content
            });
          }else if (res.result.errCode == 87014) {
            wx.showToast({
              title: '文字含有敏感违法内容!',
              icon: 'none'
            });
          }
        },
        fail: res => {
          wx.hideLoading();
        }
      })
  }

 

2、AI诗句学习搭建

搭建服务端API,服务器环境推荐:LNMP。解压server-api.zip到站点根目录。服务器安装python3和pip3。
python3.6+PIP3安装教程:https://www.cnblogs.com/yangzhaon/p/11203395.html
安装依赖:pip3 install tensorflow==1.14 word2vec numpy
搭建人工智能:解压好server-api.zip后,进入目录运行:python3 train.py,需要学习3把王者荣耀排位赛的时间
学习好之后,前台启动服务: python3  poem_server.py,可以看到只有本地+端口可以访问。
后台启动服务:nohup python3  poem_server.py >/dev/null 2>&1 &
//如果要上线,请用后台启动服务命令,因为前台启动,一会儿就自动断开了
然后nginx做代理
    location /
    {
      root html; 
      proxy_pass http://127.0.0.1:5000; 
      index index.html index.htm;
     }
这样,你就可以用域名访问你的服务端接口。然后把接口放到小程序前端需要修改的位置。
注:服务端为github开源,作者:norybaby,github地址:https://github.com/norybaby/poet

3、调取人工智能写诗API

由于本人考虑服务器安全性,故不开放api接口,自己根据第二步搭建好,替换下方【你的域名】

requestAI/index.js,第20行,替换【你的域名】,例如:mp.weixin.qq.com

async function requestAI(event){
  try{
    var options = {
      uri: "http://【你的域名】/poem?style="+ event.style +"&start=" + encodeURI(event.text),
      headers: {
        "Content-Type": "application/json"
      },
      json: true
    };
    return request(options)
      .then(function (res) {
        console.log(res,"请求获取成功");
        return res;
      })
      .catch(function (err) {
        console.log(err,'请求获取失败');
        return err
      });
  } catch (err) {
    return err;
  }
}

架构图:

效果截图:

第三个图稍微有点出入,懒的改了

视频介绍:https://v.qq.com/x/page/r3153vkhuby.html

代码链接:https://citizenfour.coding.net/public/AIPoem/AIPoem/git

作品体验二维码:

团队简介:玩儿赚流量主,游走在骚操作的第一线。个人主页

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值