Code Monkey home page Code Monkey logo

chatgpt's Introduction

chat-robot

功能介绍

由于ChatGPT只提供了单纯的api,提供完整服务需要额外的开发工作。OpenIM把实时推送、消息记录、会话隔离、上下文管理、多端同步等强大的工程能力赋予了ChatGPT,协助开发者打造真正的聊天机器人

部署open-im-server

  1. 使用该机器人需要先部署openIM服务器 open-im-server部署文档

  2. 开启openIM回调功能 该机器人使用了openIM的回调功能,关于该功能具体查看openIM官网的第三方回调说明文档。第三方回调官方文档

需要修改openIM服务端config/config.yaml的callback配置。

单聊功能需要打开callbackBeforeSendSingleMsg配置,将enable设置为true。

群聊功能需要打开callbackBeforeSendGroupMsg配置, 将enable设置为true。 avatar

全部配置完成之后需要重启open-im-server

docker-compose down; docker-compose up -d

部署chatGPT机器人

源码部署

部署版本需要python3.9(需要安装好python包管理工具pip3)

安装命令: pip3 install -r requirements.txt

运行命令

 python3 ./main.py --admin_id openIM123456 --api_key {{openai key}} --secret {{secret}} --im_api_url http://127.0.0.1:10002 --robot_user_id {{your robot id}} --host 127.0.0.1 --port 8080 --redis_addr 127.0.0.1:16379 --redis_pwd openIM123

docker部署(推荐)

 docker run --name open_im_chat_gpt --net=host openim/chat_gpt:v0.0.1 python3 main.py --admin_id openIM123456 --api_key {{openai key}} --secret {{secret}} --im_api_url http://127.0.0.1:10002 --robot_user_id {{your robot id}} --host 127.0.0.1 --port 8080 --redis_addr 127.0.0.1:16379 --redis_pwd openIM123

启动参数详解

参数 详解
admin_id openIM管理员的userID, config.yaml文件manager.appManagerUid中的一个,默认为openIM123456
api_key为 chatGPT的密钥,自行获取
secret openIM系统的密钥secret,见config/config.yaml,默认为openIM123
im_api_url im_api_url为im的api地址加端口,如果单机部署则默认为http://127.0.0.1:10002
robot_user_id 机器人userID,可以随意指定,英文字母和数字组成,注意不能和其他userID重复。
host 机器人回调服务器监听地址(单机部署默认为127.0.0.1,和openIM config.yaml的callback配置一样)
port 机器人回调服务器监听端口(默认8080,和openIM config.yaml的callback配置一样)
redis_addr 保存会话上下文使用redis,redis的地址, 单机部署则为127.0.0.1:16379
redis_pwd redis_pwd 密码, 单机部署默认为openIM123

部署验证

avatar 部署成功

单聊向该用户发送文本101消息即可avatar

群聊向该用户发送@106类型消息即可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.