GithubHelp home page GithubHelp logo

lazy-gratitude's Introduction

感谢信生成器

Demo

这是一款不走心的微信小程序,专门用于生成一些不走心的感谢信。

如何使用

直接使用微信开发者工具打开此项目即可

1、配置API KEY

cloudfuncitons 目录中实现了 openai 和 chatglm 两个云函数,小程序代码中当前使用的是 chatglm。可以在对应云函数的config.json中配置 API_KEY

2、配置云开发

在 app.ts 中配置你的云开发 env

在云开发面板建表

1、创建两个云数据库的 Collection,名称分别为 access-control 和 concurrency-control 2、给 concurrency-control 创建一个 ID 为 concurrency-control 的 Doc,包含 totalCallCount, lastCallTime 两个字段,值均为0

问题

如何开启访问限制

cloudfuncitons/shared/accessControl 实现了根据用户OPENID的访问限制 cloudfuncitons/shared/concurrencyControl 实现了对大模型API每分钟调用次数的限制,目前为每分不得超过120次,可自行修改或扩展。

云函数中访问控制的代码逻辑

 let canAccess = await accessControl(OPENID)
  if (!canAccess) {
    return {
      code: -1,
      msg: `每个用户可使用10次,额外次数请联系客服\n(${OPENID})`,
    }
  }

  canAccess = await concurrencyControl()
  if (!canAccess) {
    return {
      code: -1,
      msg: '服务器故障,请稍候再试',
    }
  }

lazy-gratitude's People

Contributors

geoffzhu avatar

Watchers

 avatar

Forkers

valdo8

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.