GithubHelp home page GithubHelp logo

jieli1990 / chatglm-flask-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from t4wefan/chatglm-flask-api

0.0 0.0 0.0 5.62 MB

ChatGLM-flask-api 简单的请求即可与ChatGLM对话

Home Page: https://chat.t4wefan.pub

License: Apache License 2.0

Shell 3.21% Python 96.79%

chatglm-flask-api's Introduction

注意

本项目暂不支持提供一键包,也不会提供官方的一键包。未来会支持 Docker 镜像。

我们做了什么

我们使用flask框架创建了并且定制了一个ChatGLM的api

什么是定制的 API?

为了满足一些应用场景的需要,我们定制了一个 API(原作者尚不清楚,可能是 ChatGPT),可以使用简单的 GETPOST 请求与 ChatGLM 进行对话。

如何使用 API?

  1. 首先需要部署 Python 环境,版本要求大于 3.10。
  2. 克隆本仓库并转到本仓库的目录。
  3. 安装 requirements.txt 中的依赖:
pip install -r requirements.txt
  1. 运行 api_fp16.py 文件,需要至少 13GB 的显存,在不启用量化模型的前提下:
python api_fp16.py
  1. 等待模型加载(下载)完毕,输出地址时即可使用。
  2. 使用 GET 或者 POST 方式调用 API,例如:
GET https://api.chat.t4wefan.pub/chatglm?msg=hello&usrid=0&source=0

可以获得输出:“Hello! How can I help you today?”

关于 API

API 的请求要求三个参数并且缺一不可,分别是 msgusridsource。还有一个附加参数 preset 用来设置对话的预设,可以使用 GET 或者 POST 请求

  • msg:请求的正文内容。
  • usrid:确定上下文及用户身份所用的 ID。
  • source:请求的来源(为了安全和其他开发的需要)。
  • preset:设置对话的预设(可选,注意使用预设需要每次都带上预设参数)

API 的一些特殊用法

  • msg(正文部分)为 clear 时,清空当前 usrid 下的历史记录(记忆或者说上下文)。
  • msgping 时,将返回后端状态。
  • 这个 API 可以用于 koishi 机器人的搭建。
  • 如果使用 AutoDL 算力平台,在安装完依赖后启动 api_autodl.py 即可在 AutoDL 的自定义服务中使用 API。

chatglm-flask-api's People

Contributors

1049451037 avatar adambear avatar cjld avatar coderabbit214 avatar duzx16 avatar eltociear avatar ganymedenil avatar holk-h avatar hscspring avatar lemonqu-git avatar mojianhao avatar oedosoldier avatar rainatam avatar ronething avatar secsilm avatar sengxian avatar songxxzp avatar t4wefan avatar xiao9905 avatar yvrjsharma avatar zhangerling avatar

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.