当前位置:   article > 正文

chatglm3-6b 模型部署+结合flask进行调用_chaglm3 接口调用集成

chaglm3 接口调用集成

模型下载
git lfs install
git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git

  1. from flask import Flask,jsonify,request
  2. from transformers import AutoTokenizer, AutoModel
  3. app = Flask(__name__)
  4. tokenizer = AutoTokenizer.from_pretrained("E:/yi\chatglm3-6b", trust_remote_code=True)
  5. model = AutoModel.from_pretrained("E:/yi\chatglm3-6b", trust_remote_code=True).half().cuda()
  6. model = model.eval()
  7. @app.route('/goodsApi',methods=['get'])
  8. def transaction():
  9. item ={}
  10. title = request.args.get("title")
  11. title1 = request.args.get("title1")
  12. response, history = model.chat(tokenizer,title, history=[])
  13. response, history = model.chat(tokenizer, title+'和'+title1+' 这两句话的相似度是多少', history=[])
  14. item['data'] =response
  15. return item,200
  16. if __name__ == '__main__':
  17. app.run(host='0.0.0.0', port=5000)

最后访问地址因为是开的5000端口所以本地访问5000端口

http://127.0.0.1:5000/goodsApi?title=hello&title1=hello123

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/272774
推荐阅读
相关标签
  

闽ICP备14008679号