商业版 · 部署文档
商业版/部署文档/后端服务配置

后端服务配置

在配置 SmartAster 后端服务时需要先完成 基础环境安装、Asterisk 的安装并启动成功、大模型服务开通、数据库配置,如果以上内容还没有完成,请先完成它们。

后端服务配置分为单体服务和微服务两种模式,根据不同的启动方式选择相应的配置方式即可。

1. 单体服务配置

  1. 找到单体服务的配置文件,在源码目录下的 smart-boot/src/main/resources/application.yml
  2. 对该配置文件内容进行相应的配置,配置内容参考第三步

2. 微服务配置

微服务模式下,需要有Nacos作为服务注册与发现的工具,以及配置中心。Nacos的安装可以参考Nacos官方文档或者JPower部署文档。

  1. 复制 SmartAster 源码中的 docs/config/nacos 目录下的配置文件到 Nacos 的配置中心。如图选中的配置文件: Nacos Config
  2. 修改smart-aster、smart-maxkb、smart-auth、smart-gateway、smart-log、smart-doc、smart-admin、smart-resource、smart-system、smart-user这些模块的配置文件
spring:
  cloud:
    nacos:
      server-addr: <Nacos地址>:8848
      username: <Nacos用户名>
      password: <Nacos密码>
      config:
        namespace: <Nacos工作空间,默认工作空间没有则直接删除这个配置>
      discovery:
        namespace: <Nacos工作空间,默认工作空间没有则直接删除这个配置>
  1. 然后参考第三步对Nacos中的配置内容进行相应的配置

3. 服务配置

  1. 数据库连接配置

    mybatis-flex:
      datasource:
        master:
          type: com.alibaba.druid.pool.DruidDataSource
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://<数据库地址>:<数据库端口>/smartaster?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
          username: <数据库用户名>
          password: <数据库密码>
        asterisk:
          type: com.alibaba.druid.pool.DruidDataSource
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://<数据库地址>:<数据库端口>/asterisk?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
          username: <数据库用户名>
          password: <数据库密码>
    
  2. Redis配置

    spring:
      data:
        redis:
          host: <Redis地址>
          password: <Redis密码>
          port: <Redis端口>
          database: 1
    
  3. 模型配置

    spring:
      ai:
        dashscope: # 通义千问
          api-key: <大模型服务开通的百炼平台的API密钥>
          chat:
            options:
              model: <选择的百炼模型名称>
              # 根据选择的模型是否是多模态模型配置true或false
              multiModel: true
    
  4. Asterisk配置

    asterisk:
      transport: transport-udp
      media:
         stream:
            host: ${ASTERISK_MEDIA_HOST:127.0.0.1}    # Asterisk 可访问的本服务地址(跨机部署必配)
            port: ${ASTERISK_MEDIA_HOST:8091}             # 监听端口
            connect-timeout: 5000  # 会话建立超时(ms)
      ami:
        host: <Asterisk地址>
        port: 5038
        username: admin
        password: a1b2c3
        # 这个配置决定是否开启当前这个启动的服务要接受AMI通知事件
        event: true
      agi:
        # AGI端口
        port: 4573
      voice-root-dir: /data/
      context:
        out: outbound-dialer # 呼出上下文名称
        in: inbound-dialer # 呼入上下文名称
        exten: robot
    
  5. IVR配置-此处配置只有使用IVR路由时才需要配置,智能体配置不需要

    ivr:
     ali:
       accessKeyId: ${IVR_ALI_KEY_ID:}
       accessKeySecret: ${IVR_ALI_KEY_SECRET:}
       app-key: ${IVR_ALI_APP_KEY:}
       tts-option:
         voice: siyue
         format: wav
         sample-rate: sample_rate_8k
         volume: 50
         pitch-rate: 0
         speech-rate: 0
         min-send-interval-ms: 100
       asr-option:
         format: wav
         sample-rate: sample_rate_8k
         max-sentence-silence: 800
         enable-intermediate-result: true
       asr-file-role:
         region-id: cn-beijing
         version: 2018-08-17
         auto-split: true
         supervise-type: 1
         speaker-num: 2
         enable-inverse-text-normalization: true
         enable-disfluency: true
         enable-semantic-sentence-detection: true
         file-dir: /data/download/
         file-domain: https://xxxxxxxxxxxxxxxxx/ivr-api/maxkb/dataset/transferFile/
     # 这里的配置是默认值,在IVR流程中配置的话会覆盖这里的配置
     # dashscope 配置,默认 DashScope ASR 引擎
     dashscope:
       # DashScope API Key
       api-key: ${IVR_DASHSCOPE_API_KEY:${spring.ai.dashscope.api-key}}
       # 自定义 WebSocket 地址(内网私有化部署时配置,留空使用官方地址)
       # websocket-url: wss://dashscope.aliyuncs.com/api-ws/v1/realtime
       asr-option:
         # 模型
         model: qwen3-asr-flash-realtime
         # 音频格式:pcm(默认)/ wav
         format: wav
         # 采样率:8000(电话场景)
         sample-rate: 8000
         # VAD 断句静音时长(ms),200~6000,默认 800
         max-end-silence: 800
         # 音频源语言
         language: zh
         # VAD 噪音阈值
         turn-detection-threshold: 0.8
         ################################# 以下只有qwen类型模型生效
         # 是否开启服务端 VAD 断句
         enable-turn-detection: true
         # 上下文文本/热词偏置,最大 10000 tokens
         # corpus-text: ""
         ################################# 以下只有fun类型模型生效
         # 是否开启语义标点(根据语义自动断句加标点, 设置为true以后将不根据VAD来判断断句)
         semantic-punctuation-enabled: false
         # 自定义热词表 ID(对应 SDK 字段 phraseId),在 DashScope 控制台创建热词表后填入
         # phrase-id: phrasexxx
       tts-option:
         # TTS 模型:CosyVoice 系列(cosyvoice-v3-flash 推荐)/ Qwen-TTS 系列(qwen3-tts-flash-realtime)
         model: qwen3-tts-flash-realtime
         # 音色:CosyVoice 常用 longanyang / longxiaochun;Qwen-TTS 常用 Cherry / Ethan
    #      voice: Cherry
         # 采样率:8000(电话场景)/ 24000(Qwen-TTS 默认)
         sample-rate: 8000
         # 音量 [0, 100],默认 50
         volume: 50
         # 语速 [0.5, 2.0],默认 1.0
         speech-rate: 1.0
         # 语调 [0.5, 2.0],默认 1.0
         pitch-rate: 1.0
     dianxin:
       asr-url: wss://openapi.teleagi.cn:443/aipaas/voice/v1/asr/fy
       tts-url: wss://openapi.teleagi.cn:443/aipaas/voice/v1/tts/supernaturalrt
       appId: ${IVR_DIANXIN_APP_ID:}
       appKey: ${IVR_DIANXIN_APP_KEY:}
       tts-option:
         voice: kefunv2
         sample-rate: 8000
       asr-option:
         sample-rate: 8000
         enable-punctuation: true
         enable-inverse-text-normalization: false
         enable-emendation: true
         max-end-silence: 600
     openai:
       server-url: ws://127.0.0.1:9090
       asr-option:
         sample-rate: 8000
         language: zh
         task: transcribe
         use-vad: false
         vad-onset: 0.5
    
  6. MaxKB配置

    maxkb:
      # 登录账号
      username: admin
      # 登录密码
      password: MaxKB@123...
      # 内网访问地址
      baseUrl: <MaxKB内网访问地址>
      # 外网访问地址
      externalBaseUrl: <MaxKB互联网网访问地址>