Coder Social home page Coder Social logo

hehan2-chatbot's Introduction

chatgpt 聊天机器人

项目介绍

本项目是一个基于DDD(COLA)架构的聊天机器人,解耦业务逻辑与外部接口。并且使用了【策略模式】来为后续增加支持平台其他回答模型提供拓展点。

代码运行演示:

代码演示

知识星球演示:

星球展示

一键启动

  1. 修改start模块下的application.yml,或者通过环境变量的方式不用把密码硬编码在配置中
    • 修改open-ai的apikey
    • 修改知识星球的cookie
    • 修改知识星球的id
spring:
  profiles:
    active: ${SPRING_PROFILES_ACTIVE:prod}
  task:
    scheduling:
      pool:
        size: 5
server:
  port: 8080
openai:
  model: ${OPENAI_MODEL:gpt-3.5-turbo}
  apiKey: ${OPENAI_API_KEY:你的apiKey}
zsxq:
  cookie: ${ZSXQ_COOKIE:你的星球cookie}
  groupId: ${ZSXQ_GROUP_ID:你的星球id}
  silenced: ${ZSXQ_SILENCED :true}
scheduler:
  list:
    - name: chatbotTask
      platform: zsxq
      answer: openai
      cron: '0/30 * * * * ?'
#    - name: demoTask
#      platform: demo
#      answer: demo
#      cron: '0/10 * * * * ?'
  1. 运行start模块下的Application就可以开始定时任务的调度啦🎉

一键部署

Deploy on Railway

点这个就可以复制我们模板一键部署到Railway上,最重要的是不用担心科学上网的问题!

Railway

架构设计

架构图

架构图

  • Adapter层:负责任务调度(目前采用spring任务调度,可以随意切换成xxl-job等等)
  • App层:由于没有复杂跨领域调用,所以空置。
  • Domain层:负责核心领域对象的编排,不依赖于任务框(包括spring)。
  • Infrastructure层:负责与外界API对接的具体技术细节实现。

核心领域建模

  • ChatBot为聚合根负责每一个问答的核心业务逻辑包含一个AnswerEngine实体和Platform实体
  • AnswerEngine实体负责根据提问对问题进行相应
  • Platform实体负责从平台爬取问题并使用api进行回答

核心领域建模

拓展开发

支持平台拓展

支持平台策略

  1. domain层增加一个PlatformType枚举
  2. infra层增加一个Platform实现类

支持回答模型拓展

回答引擎策略

  1. domain层增加一个AnswerEngineType枚举
  2. infra层增加一个AnswerEngine实现类

RoadMap

  • 增加敏感词过滤
  • 接入微信群

欢迎交流

后续会根据逐步完善,欢迎大家提出宝贵意见,也欢迎大家提issue pr,还有star⭐️。

可以加入星球使劲向我提问哈~

星球展示

星球展示

hehan2-chatbot's People

Watchers

James Cloos avatar chenjiabing avatar  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.