From d22297e66a1be88de0785139cbb7958479146d32 Mon Sep 17 00:00:00 2001 From: rahulpscraftech360 Date: Tue, 9 Sep 2025 12:37:33 +0530 Subject: [PATCH] added dev and prod DB in env file --- main/manager-api/.env.example | 31 ++++++++++ main/manager-api/.gitignore | 7 +++ .../main/java/xiaozhi/AdminApplication.java | 28 ++++++++- .../agent/service/impl/AgentServiceImpl.java | 11 ++++ .../src/main/resources/application-dev.yml | 14 +++-- .../src/main/resources/application-prod.yml | 62 +++++++++++++++++++ .../src/main/resources/application.yml | 4 +- .../changelog/202509061300_add_ana_voice.sql | 3 + .../db/changelog/db.changelog-master.yaml | 7 +++ 9 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 main/manager-api/.env.example create mode 100644 main/manager-api/.gitignore create mode 100644 main/manager-api/src/main/resources/application-prod.yml create mode 100644 main/manager-api/src/main/resources/db/changelog/202509061300_add_ana_voice.sql diff --git a/main/manager-api/.env.example b/main/manager-api/.env.example new file mode 100644 index 000000000..05a426d79 --- /dev/null +++ b/main/manager-api/.env.example @@ -0,0 +1,31 @@ +# Spring Profile Configuration +# Set to 'dev' for development or 'prod' for production +SPRING_PROFILES_ACTIVE=dev + +# Server Configuration +SERVER_PORT=8002 + +# Database Configuration (Override if needed) +# DB_HOST=localhost +# DB_PORT=3306 +# DB_NAME=xiaozhi +# DB_USERNAME=root +# DB_PASSWORD=your_password_here + +# Redis Configuration (Override if needed) +# REDIS_HOST=localhost +# REDIS_PORT=6379 +# REDIS_PASSWORD=your_redis_password + +# External Services +XIAOZHI_PYTHON_SERVER_URL=http://localhost:8003 + +# Vector Database (Qdrant) +QDRANT_URL=your_qdrant_url_here +QDRANT_API_KEY=your_qdrant_api_key_here + +# Voyage AI API Key +VOYAGE_API_KEY=your_voyage_api_key_here + +# Textbook Upload Directory +TEXTBOOK_UPLOAD_DIR=/path/to/uploadfile/textbooks \ No newline at end of file diff --git a/main/manager-api/.gitignore b/main/manager-api/.gitignore new file mode 100644 index 000000000..4fb26ec95 --- /dev/null +++ b/main/manager-api/.gitignore @@ -0,0 +1,7 @@ +# Environment files +.env +.env.local +.env.*.local + +# But keep the example +!.env.example \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/AdminApplication.java b/main/manager-api/src/main/java/xiaozhi/AdminApplication.java index 84e30123d..fb326fb8c 100644 --- a/main/manager-api/src/main/java/xiaozhi/AdminApplication.java +++ b/main/manager-api/src/main/java/xiaozhi/AdminApplication.java @@ -2,12 +2,36 @@ package xiaozhi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.core.env.Environment; +import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication public class AdminApplication { public static void main(String[] args) { - SpringApplication.run(AdminApplication.class, args); - System.out.println("http://localhost:8002/xiaozhi/doc.html"); + // Log profile before Spring Boot starts + String activeProfile = System.getenv("SPRING_PROFILES_ACTIVE"); + if (activeProfile != null && !activeProfile.isEmpty()) { + System.out.println("\n========================================"); + System.out.println("Starting with profile: " + activeProfile.toUpperCase()); + System.out.println("========================================\n"); + } + + ConfigurableApplicationContext context = SpringApplication.run(AdminApplication.class, args); + Environment env = context.getEnvironment(); + String[] profiles = env.getActiveProfiles(); + + if (profiles.length > 0) { + System.out.println("\n========================================"); + System.out.println("Active Profile: " + profiles[0].toUpperCase()); + System.out.println("Configuration: application-" + profiles[0] + ".yml"); + System.out.println("========================================"); + } else { + System.out.println("\n========================================"); + System.out.println("No active profile set - using default configuration"); + System.out.println("========================================"); + } + + System.out.println("Server started: http://localhost:8002/xiaozhi/doc.html\n"); } } \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java index 6eb33612b..2eef83d11 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java @@ -378,6 +378,17 @@ public class AgentServiceImpl extends BaseServiceImpl imp entity.setChatHistoryConf(template.getChatHistoryConf()); entity.setLangCode(template.getLangCode()); entity.setLanguage(template.getLanguage()); + + // Override with custom defaults for memory and voice + entity.setMemModelId("Memory_mem0ai"); // Always use memoAI for memory + entity.setTtsModelId("TTS_EdgeTTS"); // Always use EdgeTTS model + entity.setTtsVoiceId("TTS_EdgeTTS_Ana"); // Always use EdgeTTS Ana voice (en-US-AnaNeural) + + // Log the overridden values for debugging + System.out.println("Creating agent with overridden defaults:"); + System.out.println(" Memory: " + entity.getMemModelId()); + System.out.println(" TTS Model: " + entity.getTtsModelId()); + System.out.println(" TTS Voice: " + entity.getTtsVoiceId()); } // 设置用户ID和创建者信息 diff --git a/main/manager-api/src/main/resources/application-dev.yml b/main/manager-api/src/main/resources/application-dev.yml index c949275f5..195ff5fa6 100644 --- a/main/manager-api/src/main/resources/application-dev.yml +++ b/main/manager-api/src/main/resources/application-dev.yml @@ -7,6 +7,10 @@ knife4j: password: 2ZABCDEUgF setting: enableFooter: false + +# Server configuration +server: + secret: d153e93c-bb2f-42e7-8045-a1ee47a1dcfc spring: datasource: druid: @@ -18,9 +22,9 @@ spring: # password: cTefiuLmZSMqGpcQImUmBIsUBhNyUvrK driver-class-name: com.mysql.cj.jdbc.Driver # Railway MySQL Configuration - Updated for Railway database - url: jdbc:mysql://nozomi.proxy.rlwy.net:25037/railway?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://crossover.proxy.rlwy.net:56145/railway?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=true&allowPublicKeyRetrieval=true username: root - password: OcaVNLKcwNdyElfaeUPqvvfYZiiEHgdm + password: XjOWQwtGNcoMIELTjoMoaaBTfKiBjVcA initial-size: 10 max-active: 100 @@ -46,9 +50,9 @@ spring: data: redis: # Railway Redis Configuration - host: maglev.proxy.rlwy.net # Railway Redis服务器地址 - port: 16780 # Railway Redis服务器连接端口 - password: beVfOKcZjMUCBiZIQnvSMivhpSeijpKP # Railway Redis服务器连接密码 + host: yamanote.proxy.rlwy.net # Railway Redis服务器地址 + port: 34938 # Railway Redis服务器连接端口 + password: YbdhwguVUNowduNpDZjuSefZFhBXiOEP # Railway Redis服务器连接密码 username: default # Railway Redis用户名 database: 0 # Redis数据库索引(默认为0) timeout: 30000ms # 连接超时时间(毫秒)- 增加超时时间 diff --git a/main/manager-api/src/main/resources/application-prod.yml b/main/manager-api/src/main/resources/application-prod.yml new file mode 100644 index 000000000..c949275f5 --- /dev/null +++ b/main/manager-api/src/main/resources/application-prod.yml @@ -0,0 +1,62 @@ +knife4j: + production: false + enable: true + basic: + enable: false + username: renren + password: 2ZABCDEUgF + setting: + enableFooter: false +spring: + datasource: + druid: + #MySQL + # driver-class-name: com.mysql.cj.jdbc.Driver + # # Railway MySQL Configuration - Updated for Railway database + # url: jdbc:mysql://yamanote.proxy.rlwy.net:16958/railway?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=true&allowPublicKeyRetrieval=true + # username: root + # password: cTefiuLmZSMqGpcQImUmBIsUBhNyUvrK + driver-class-name: com.mysql.cj.jdbc.Driver + # Railway MySQL Configuration - Updated for Railway database + url: jdbc:mysql://nozomi.proxy.rlwy.net:25037/railway?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=true&allowPublicKeyRetrieval=true + username: root + password: OcaVNLKcwNdyElfaeUPqvvfYZiiEHgdm + + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 6000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: false + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + data: + redis: + # Railway Redis Configuration + host: maglev.proxy.rlwy.net # Railway Redis服务器地址 + port: 16780 # Railway Redis服务器连接端口 + password: beVfOKcZjMUCBiZIQnvSMivhpSeijpKP # Railway Redis服务器连接密码 + username: default # Railway Redis用户名 + database: 0 # Redis数据库索引(默认为0) + timeout: 30000ms # 连接超时时间(毫秒)- 增加超时时间 + ssl: + enabled: false # 尝试禁用SSL,Railway可能不需要 + lettuce: + pool: + max-active: 8 # 连接池最大连接数(使用负值表示没有限制) + max-idle: 8 # 连接池中的最大空闲连接 + min-idle: 0 # 连接池中的最小空闲连接 + shutdown-timeout: 100ms # 客户端优雅关闭的等待时间 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/application.yml b/main/manager-api/src/main/resources/application.yml index 9a8d3d1f6..56934b317 100644 --- a/main/manager-api/src/main/resources/application.yml +++ b/main/manager-api/src/main/resources/application.yml @@ -14,8 +14,10 @@ server: spring: # 环境 dev|test|prod + # Profile will be set by SPRING_PROFILES_ACTIVE environment variable + # Default to 'dev' if not specified profiles: - active: dev # Using dev profile with Railway database configuration + default: prod messages: encoding: UTF-8 basename: i18n/messages diff --git a/main/manager-api/src/main/resources/db/changelog/202509061300_add_ana_voice.sql b/main/manager-api/src/main/resources/db/changelog/202509061300_add_ana_voice.sql new file mode 100644 index 000000000..a6dbb266e --- /dev/null +++ b/main/manager-api/src/main/resources/db/changelog/202509061300_add_ana_voice.sql @@ -0,0 +1,3 @@ +-- Add EdgeTTS Ana voice (en-US-AnaNeural) for default agent configuration +delete from `ai_tts_voice` where id = 'TTS_EdgeTTS_Ana'; +INSERT INTO `ai_tts_voice` VALUES ('TTS_EdgeTTS_Ana', 'TTS_EdgeTTS', 'EdgeTTS Ana', 'en-US-AnaNeural', 'English', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index 5c5373c9d..e46d8a915 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -410,4 +410,11 @@ databaseChangeLog: - sqlFile: encoding: utf8 path: classpath:db/changelog/202509030001_clear_tts_config_checksum.sql + - changeSet: + id: 202509061300 + author: claude + changes: + - sqlFile: + encoding: utf8 + path: classpath:db/changelog/202509061300_add_ana_voice.sql