小乐AI对话微服务(lczChatAIServer)提供用户与AI对话的相关服务,包括:智能问数、文档解决、操作指引、合规校验等业务场景。

支持版本: v8.0.0

本微服务的部署过程如下:

配置yml文件

lczChatAIServer\application.yml 文件:

spring:
  application:
    name: lczChatBI
  servlet:
    multipart:
      enabled: true
      max-file-size: 100MB
      max-request-size: 100MB

server:
  port: 9099
  #Tomcat
  tomcat:
    threads:
      #最小线程数
      min-spare: 10
      #最大线程数
      max: 500
      #等待最大队列长度
    accept-count: 1000
    #最大链接数
    max-connections: 2000
  servlet:
    context-path: /lczServer


# langchain4j 配置
langchain4j:
  ollama: #ollama服务配置
    streaming-chat-model: #流式对话
      base-url: http://localhost:11434 #ollama服务地址
      model-name: deepseek-r1:7b #推理模型名称
      format: text
      timeout: 600000
      temperature: 0.8 #模型的温度。提高温度将使模型更有创意地回答。(默认值:0.8)
      seed: 0 #设置用于生成的随机数种子。将此设置为特定数字将使模型为同一提示生成相同的文本。(默认值:0)
      top-k: 10 #降低产生无意义的可能性。较高的值(例如 100)将给出更多样化的答案,而较低的值(例如 10)将更保守。(默认值:40)
      top-p: 0.9 #与 top-k 一起使用。较高的值(例如 0.95)将导致文本更加多样化,而较低的值(例如 0.5)将生成更集中和保守的文本。(默认值:0.9)
      repeat-penalty: 1.1 #设置对重复项的惩罚强度。较高的值(例如 1.5)将更强烈地惩罚重复,而较低的值(例如 0.9)将更宽松。(默认值:1.1)
      num-ctx: 2048 # 上下文token数
    embedding-model: #向量化模型
      base-url: http://ip:port  #向量模型服务地址
      model-name: bge-m3:latest #向量模型名称
      timeout: 600000
    chat-model: #非流式对话
      base-url: http://localhost:11434
      model-name: llava:7b
      format: text
      max-retries: 1
      timeout: 600000
  xinference: #xinference服务配置
    score-model: #重排模型配置
      base-url: http://122.224.204.131:9997 #xinference服务地址
      model-name: bge-reranker-v2-m3 #重排序模型名称
      timeout: 600000
    streaming-chat-model:
      api-key: sk-d06b4923bd2b4fc281bc817a5c5464bc #key
      model-name: deepseek-r1-distill-qwen-14b
    chat-model:
      #api-key: sk-d06b4923bd2b4fc281bc817a5c5464bc
      base-url: http://144.20.80.250:9997
      model-name: qwen2.5-vl-instruct
  open-ai: #open AI配置
    streaming-chat-model:
      base-url: https://dashscope.aliyuncs.com/compatible-mode/v1 #接口地址
      model-name: qwen-plus #模型名称
      response-format: text
    chat-model:
      api-key: xx
  community:
    dashscope: #阿里百炼
      streaming-chat-model:
        api-key: sk-d06b4923bd2b4fc281bc817a5c5464bc #key
        model-name: deepseek-r1-distill-qwen-14b
      chat-model:
        api-key: sk-d06b4923bd2b4fc281bc817a5c5464bc
        model-name: deepseek-r1-distill-qwen-14b # qwen2.5-vl-7b-instruct

third-platform:
  dify: #dify配置
    base-url: http://ip:port #api服务器地址

logging:
  config: classpath:conf/log4j2.xml

sa-token:
  token-name: authId
  token-prefix: Bearer
  # 允许动态设置 token 有效期
  dynamic-active-timeout: false
  # 允许从 header 读取 token
  is-read-header: true
  is-read-cookie: false
  is-print: false
  timeout: -1
  is-concurrent: false

mybatis-plus:
  mapper-locations: classpath*:/mapper/**/*.xml
  configuration:
    map-underscore-to-camel-case: true
    log-impl: com.datanew.config.MybatisPlusLog
  global-config:
    banner: false

feign:
  client:
    config:
      default:
        readTimeout: 1800000
  httpclient:
    enabled: true
    max-connections: 100
    connection-timeout: 1000
    time-to-live: 10
    time-to-live-unit: minutes
  lcz_log: false
  lcz_server:
    platform:
      name: lczPlatform
      url: http://127.0.0.1:8081/lczServer
    chat_manage:
      name: lczChatManage
      url: http://127.0.0.1:9100/lczServer

#熔断配置
hystrix:
  command:
    execution:
      timeoutInMilliseconds: 2000    #熔断超时时间
      isolation:
        strategy: THREAD
  threadPool:
    coreSize: 20
    maxQueueSize: 200
    maximumSize: 200
    keepAliveTimeMinutes: 6
    queueSizeRejectionThreshold: 201 # 拒绝队列大小

一般需要进行以下配置:
(1) 修改 feign->lcz_server 下各微服务的 url 访问地址。
  url的配置规则:直接配置代理的nginx访问地址即可,格式: http(https)://nginx地址:端口/lczServer;
(2) 修改应用上下文路径(可选):默认为lczServer,如果访问地址中需要重命名,那么 server-> servlet -> context-pathfeign->lcz_server -> url 中都需要一致性修改。同时,nginx.conf文件中也做对应调整。

【警告】yml文件修改时,不要随意调整对象和属性的缩进格式,否则文件配置读取会失败。

作者:柳杨  创建时间:2025-05-22 10:46
最后编辑:柳杨  更新时间:2025-05-22 12:17