Skip to content

配置说明

本指南将详细介绍 SuperSQL 的各种配置选项。

SuperSQL 基础配置

application.yml 中配置 SuperSQL:

yaml
super-sql:
  init-train: false
  scope: ALONE
  schemas:
    - schema: your_schema
  temperature: 0.0

配置项说明

配置项类型默认值说明
init-trainBooleanfalse是否在启动时自动训练数据库表结构
scopeScopeTypeALONE训练范围:ALONE(单独)或 ALL(全部)
schemasList[]指定训练的 schema 列表
temperatureDouble0.0生成 SQL 的温度参数,影响随机性

Spring AI 配置

Azure OpenAI 配置

yaml
spring:
  ai:
    azure:
      openai:
        api-key: your-api-key
        chat:
          options:
            deployment-name: gpt-4o-latest
            temperature: 0.7
            max-tokens: 2000
        endpoint: https://your-resource-name.openai.azure.com/
        embedding:
          options:
            deployment-name: embedding-ada-002
            dimensions: 1536

Ollama 配置

yaml
spring:
  ai:
    ollama:
      base-url: http://localhost:11434
      chat:
        options:
          model: deep deepseek-r1:32b
          temperature: 0.7
          num-predict: 2000
      embedding:
        options:
          model: mxbai-embed-large
          dimensions: 1024
      init:
        pull-model-strategy: never
        embedding:
          additional-models:
            - mxbai-embed-large

向量数据库配置

Chroma 配置

yaml
spring:
  ai:
    vectorstore:
      chroma:
        client:
          host: localhost
          port: 8000
        collection-name: supersql
        initialize-schema: true

其他向量数据库

SuperSQL 还支持其他向量数据库,如 Milvus、PgVector 等。详细配置请参考 向量数据库集成

ReRank 重排序配置

yaml
spring:
  ai:
    reranker:
      enabled: true
      model: Qwen3-Reranker-8B
      base-url: https://ai.gitee.com/v1/rerank
      api-key: your-api-key
      top-n: 5

ReRank 配置项说明

配置项类型默认值说明
enabledBooleanfalse是否启用重排序
modelString-重排序模型名称
base-urlString-重排序服务地址
api-keyString-API 密钥
top-nInteger5返回的 top N 结果

数据库配置

MySQL 配置

yaml
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/your_database
    username: your_username
    password: your_password
    driver-class-name: com.mysql.cj.jdbc.Driver

PostgreSQL 配置

yaml
spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/your_database
    username: your_username
    password: your_password
    driver-class-name: org.postgresql.Driver

MyBatis Plus 配置

如果使用 MyBatis Plus 集成,需要额外配置:

yaml
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.your.package.entity
  configuration:
    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

日志配置

配置 SuperSQL 的日志级别:

yaml
logging:
  level:
    com.aispace.supersql: DEBUG
    org.springframework.ai: DEBUG

性能优化配置

连接池配置

yaml
spring:
  datasource:
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5
      connection-timeout: 30000
      idle-timeout: 600000
      max-lifetime: 1800000

缓存配置

yaml
spring:
  cache:
    type: redis
    redis:
      time-to-live: 3600
      cache-null-values: false

安全配置

API 密钥管理

建议使用环境变量或配置中心管理敏感信息:

yaml
spring:
  ai:
    azure:
      openai:
        api-key: ${AZURE_OPENAI_API_KEY}

SSL 配置

yaml
server:
  ssl:
    enabled: true
    key-store: classpath:keystore.p12
    key-store-password: ${KEYSTORE_PASSWORD}
    key-store-type: PKCS12
    key-alias: tomcat

配置示例

完整配置示例

yaml
server:
  port: 8080

spring:
  application:
    name: supersql-demo
  
  datasource:
    url: jdbc:mysql://localhost:3306/supersql_db
    username: root
    password: ${DB_PASSWORD}
    driver-class-name: com.mysql.cj.jdbc.Driver
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5

  ai:
    azure:
      openai:
        api-key: ${AZURE_API_KEY}
        chat:
          options:
            deployment-name: gpt-4o-latest
            temperature: 0.7
        endpoint: https://your-resource.openai.azure.com/
        embedding:
          options:
            deployment-name: embedding-ada-002

    vectorstore:
      chroma:
        client:
          host: localhost
          port: 8000
        collection-name: supersql

    reranker:
      enabled: true
      model: Qwen3-Reranker-8B
      base-url: https://ai.gitee.com/v1/rerank
      api-key: ${RERANK_API_KEY}

super-sql:
  init-train: false
  scope: ALONE
  temperature: 0.0

logging:
  level:
    com.aispace.supersql: DEBUG
    root: INFO

配置验证

启动应用后,检查日志确认配置是否正确加载:

SuperSQL configuration loaded successfully
- init-train: false
- scope: ALONE
- temperature: 0.0

下一步

配置完成后,你可以:

最近更新

基于 Apache 2.0 许可证发布