+
Test Page - Manager Mobile
+
If you can see this, the server is working!
+
+
+
+
+
\ No newline at end of file
diff --git a/main/manager-mobile/src/uni-polyfill.ts b/main/manager-mobile/src/uni-polyfill.ts
new file mode 100644
index 000000000..8ab078a94
--- /dev/null
+++ b/main/manager-mobile/src/uni-polyfill.ts
@@ -0,0 +1,75 @@
+// Uni-app polyfill for H5 platform
+if (typeof window !== 'undefined' && !window.uni) {
+ window.uni = {
+ getStorageSync: (key: string) => {
+ try {
+ return localStorage.getItem(key)
+ } catch (e) {
+ return null
+ }
+ },
+ setStorageSync: (key: string, value: any) => {
+ try {
+ localStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value))
+ } catch (e) {
+ console.error('Failed to set storage', e)
+ }
+ },
+ removeStorageSync: (key: string) => {
+ try {
+ localStorage.removeItem(key)
+ } catch (e) {
+ console.error('Failed to remove storage', e)
+ }
+ },
+ navigateTo: (options: any) => {
+ console.log('Navigate to:', options)
+ if (options.url) {
+ window.location.href = options.url
+ }
+ },
+ redirectTo: (options: any) => {
+ console.log('Redirect to:', options)
+ if (options.url) {
+ window.location.replace(options.url)
+ }
+ },
+ switchTab: (options: any) => {
+ console.log('Switch tab:', options)
+ if (options.url) {
+ window.location.href = options.url
+ }
+ },
+ showToast: (options: any) => {
+ console.log('Toast:', options.title)
+ },
+ showLoading: (options: any) => {
+ console.log('Loading:', options.title)
+ },
+ hideLoading: () => {
+ console.log('Hide loading')
+ },
+ request: (options: any) => {
+ return fetch(options.url, {
+ method: options.method || 'GET',
+ headers: options.header || {},
+ body: options.data ? JSON.stringify(options.data) : undefined,
+ }).then(res => res.json())
+ },
+ uploadFile: (options: any) => {
+ const formData = new FormData()
+ formData.append(options.name, options.filePath)
+ return fetch(options.url, {
+ method: 'POST',
+ body: formData,
+ })
+ },
+ getSystemInfoSync: () => {
+ return {
+ platform: 'h5',
+ windowWidth: window.innerWidth,
+ windowHeight: window.innerHeight,
+ }
+ },
+ } as any
+}
\ No newline at end of file
diff --git a/main/manager-mobile/src/utils/index.ts b/main/manager-mobile/src/utils/index.ts
index 4d1738253..4d845fb31 100644
--- a/main/manager-mobile/src/utils/index.ts
+++ b/main/manager-mobile/src/utils/index.ts
@@ -1,4 +1,4 @@
-import { pages, subPackages } from '@/pages.json'
+import { pages, subPackages } from '../../pages.json'
import { isMpWeixin } from './platform'
/**
diff --git a/main/manager-mobile/vite.config.ts b/main/manager-mobile/vite.config.backup.ts
similarity index 96%
rename from main/manager-mobile/vite.config.ts
rename to main/manager-mobile/vite.config.backup.ts
index b939d2055..b98ad659f 100644
--- a/main/manager-mobile/vite.config.ts
+++ b/main/manager-mobile/vite.config.backup.ts
@@ -20,7 +20,7 @@ import dayjs from 'dayjs'
import { visualizer } from 'rollup-plugin-visualizer'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig, loadEnv } from 'vite'
-import ViteRestart from 'vite-plugin-restart'
+// import ViteRestart from 'vite-plugin-restart'
// https://vitejs.dev/config/
export default async ({ command, mode }) => {
@@ -100,10 +100,10 @@ export default async ({ command, mode }) => {
logger: false,
}),
- ViteRestart({
- // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
- restart: ['vite.config.js'],
- }),
+ // ViteRestart({
+ // // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
+ // restart: ['vite.config.js'],
+ // }),
// h5环境增加 BUILD_TIME 和 BUILD_BRANCH
UNI_PLATFORM === 'h5' && {
name: 'html-transform',
diff --git a/main/manager-mobile/vite.config.js b/main/manager-mobile/vite.config.js
new file mode 100644
index 000000000..4f69f9e36
--- /dev/null
+++ b/main/manager-mobile/vite.config.js
@@ -0,0 +1,22 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import path from 'path'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [vue()],
+ define: {
+ __UNI_PLATFORM__: JSON.stringify('h5'),
+ __VITE_APP_PROXY__: JSON.stringify(false),
+ },
+ resolve: {
+ alias: {
+ '@/': `${path.resolve(__dirname, 'src')}/`,
+ '@': path.resolve(__dirname, 'src'),
+ },
+ },
+ server: {
+ port: 3000,
+ host: '0.0.0.0',
+ },
+})
\ No newline at end of file
diff --git a/main/manager-mobile/vite.config.js.bak b/main/manager-mobile/vite.config.js.bak
new file mode 100644
index 000000000..83b46a820
--- /dev/null
+++ b/main/manager-mobile/vite.config.js.bak
@@ -0,0 +1,9 @@
+import { defineConfig } from 'vite'
+import uni from '@dcloudio/vite-plugin-uni'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [
+ uni(),
+ ],
+})
\ No newline at end of file
diff --git a/main/manager-mobile/vite.config.simple.ts b/main/manager-mobile/vite.config.simple.ts
new file mode 100644
index 000000000..b26c603df
--- /dev/null
+++ b/main/manager-mobile/vite.config.simple.ts
@@ -0,0 +1,17 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import path from 'path'
+
+export default defineConfig({
+ plugins: [vue()],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
+ },
+ },
+ server: {
+ port: 3000,
+ host: '0.0.0.0',
+ open: true,
+ },
+})
\ No newline at end of file
diff --git a/main/manager-web/src/apis/module/agent.js b/main/manager-web/src/apis/module/agent.js
index 66126237a..d6ea74583 100644
--- a/main/manager-web/src/apis/module/agent.js
+++ b/main/manager-web/src/apis/module/agent.js
@@ -97,6 +97,40 @@ export default {
});
}).send();
},
+ // 更新智能体模板
+ updateAgentTemplate(templateId, templateData, callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/agent/template/${templateId}`)
+ .method('PUT')
+ .data(templateData)
+ .success((res) => {
+ RequestService.clearRequestTime();
+ callback(res);
+ })
+ .networkFail((err) => {
+ console.error('更新模板失败:', err);
+ RequestService.reAjaxFun(() => {
+ this.updateAgentTemplate(templateId, templateData, callback);
+ });
+ }).send();
+ },
+ // 创建智能体模板
+ createAgentTemplate(templateData, callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/agent/template`)
+ .method('POST')
+ .data(templateData)
+ .success((res) => {
+ RequestService.clearRequestTime();
+ callback(res);
+ })
+ .networkFail((err) => {
+ console.error('创建模板失败:', err);
+ RequestService.reAjaxFun(() => {
+ this.createAgentTemplate(templateData, callback);
+ });
+ }).send();
+ },
// 获取智能体会话列表
getAgentSessions(agentId, params, callback) {
RequestService.sendRequest()
diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue
index 56e91101f..1008b868a 100644
--- a/main/manager-web/src/views/roleConfig.vue
+++ b/main/manager-web/src/views/roleConfig.vue
@@ -178,6 +178,7 @@ export default {
modelOptions: {},
templates: [],
loadingTemplate: false,
+ selectedTemplate: null, // Track currently selected template
voiceOptions: [],
showFunctionDialog: false,
currentFunctions: [],
@@ -218,6 +219,30 @@ export default {
})
})
};
+
+ // Check if we need to update template
+ if (this.selectedTemplate && this.hasTemplateChanges()) {
+ this.$confirm('Do you want to save changes to the template as well? This will affect all future uses of this template.', 'Update Template', {
+ confirmButtonText: 'Update Template',
+ cancelButtonText: 'Keep Template Unchanged',
+ type: 'question',
+ distinguishCancelAndClose: true
+ }).then(() => {
+ // User wants to update template
+ this.saveConfigAndTemplate(configData);
+ }).catch((action) => {
+ if (action === 'cancel') {
+ // User wants to save config only
+ this.saveConfigOnly(configData);
+ }
+ });
+ } else {
+ // No template changes, save config only
+ this.saveConfigOnly(configData);
+ }
+ },
+
+ saveConfigOnly(configData) {
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
if (data.code === 0) {
this.$message.success({
@@ -232,6 +257,73 @@ export default {
}
});
},
+
+ saveConfigAndTemplate(configData) {
+ // First save the agent config
+ Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
+ if (data.code === 0) {
+ // Then update the template
+ const templateData = {
+ agentName: this.form.agentName,
+ systemPrompt: this.form.systemPrompt,
+ summaryMemory: this.form.summaryMemory,
+ asrModelId: this.form.model.asrModelId,
+ vadModelId: this.form.model.vadModelId,
+ llmModelId: this.form.model.llmModelId,
+ vllmModelId: this.form.model.vllmModelId,
+ ttsModelId: this.form.model.ttsModelId,
+ ttsVoiceId: this.form.ttsVoiceId,
+ memModelId: this.form.model.memModelId,
+ intentModelId: this.form.model.intentModelId,
+ chatHistoryConf: this.form.chatHistoryConf,
+ langCode: this.form.langCode,
+ language: this.form.language
+ };
+
+ Api.agent.updateAgentTemplate(this.selectedTemplate.id, templateData, ({ data: templateResult }) => {
+ if (templateResult.code === 0) {
+ this.$message.success({
+ message: 'Configuration and template saved successfully',
+ showClose: true
+ });
+ // Refresh templates to reflect changes
+ this.fetchTemplates();
+ } else {
+ this.$message.warning({
+ message: 'Configuration saved but template update failed: ' + (templateResult.msg || 'Unknown error'),
+ showClose: true
+ });
+ }
+ });
+ } else {
+ this.$message.error({
+ message: data.msg || 'Failed to save configuration',
+ showClose: true
+ });
+ }
+ });
+ },
+
+ hasTemplateChanges() {
+ if (!this.selectedTemplate) return false;
+
+ return (
+ this.form.agentName !== this.selectedTemplate.agentName ||
+ this.form.systemPrompt !== this.selectedTemplate.systemPrompt ||
+ this.form.summaryMemory !== this.selectedTemplate.summaryMemory ||
+ this.form.model.asrModelId !== this.selectedTemplate.asrModelId ||
+ this.form.model.vadModelId !== this.selectedTemplate.vadModelId ||
+ this.form.model.llmModelId !== this.selectedTemplate.llmModelId ||
+ this.form.model.vllmModelId !== this.selectedTemplate.vllmModelId ||
+ this.form.model.ttsModelId !== this.selectedTemplate.ttsModelId ||
+ this.form.ttsVoiceId !== this.selectedTemplate.ttsVoiceId ||
+ this.form.model.memModelId !== this.selectedTemplate.memModelId ||
+ this.form.model.intentModelId !== this.selectedTemplate.intentModelId ||
+ this.form.chatHistoryConf !== this.selectedTemplate.chatHistoryConf ||
+ this.form.langCode !== this.selectedTemplate.langCode ||
+ this.form.language !== this.selectedTemplate.language
+ );
+ },
resetConfig() {
this.$confirm('Are you sure you want to reset the configuration?', 'Confirm', {
confirmButtonText: 'Confirm',
@@ -279,6 +371,7 @@ export default {
if (this.loadingTemplate) return;
this.loadingTemplate = true;
try {
+ this.selectedTemplate = template; // Track selected template
this.applyTemplateData(template);
this.$message.success({
message: `"${template.agentName}" template applied`,
diff --git a/setup_english_asr.py b/setup_english_asr.py
deleted file mode 100644
index a174e651e..000000000
--- a/setup_english_asr.py
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/usr/bin/env python3
-"""
-Setup script for English-only ASR configuration
-Automatically configures the best English ASR model for your use case
-"""
-
-import os
-import yaml
-import sys
-
-def setup_english_asr():
- """Setup English-only ASR configuration"""
-
- print("🎯 English-Only ASR Setup")
- print("=" * 40)
- print()
-
- # Check if config file exists
- config_file = "main/xiaozhi-server/data/.config.yaml"
- main_config = "main/xiaozhi-server/config.yaml"
-
- if not os.path.exists("main/xiaozhi-server"):
- print("❌ Please run this script from the project root directory")
- return False
-
- # Create data directory if it doesn't exist
- os.makedirs("main/xiaozhi-server/data", exist_ok=True)
-
- print("🤖 What type of application are you building?")
- print("1. 👶 Kids companion bot (RECOMMENDED: Gigaspeech)")
- print("2. ⚡ Fast response bot (Whisper Tiny)")
- print("3. 🎯 General English bot (Whisper Base)")
- print("4. 🏆 Highest accuracy (Whisper Small)")
- print()
-
- while True:
- try:
- choice = input("Enter your choice (1-4): ").strip()
- if choice in ['1', '2', '3', '4']:
- break
- print("Please enter 1, 2, 3, or 4")
- except KeyboardInterrupt:
- print("\n👋 Setup cancelled")
- return False
-
- # Model configurations
- models = {
- '1': {
- 'name': 'SherpaZipformerGigaspeechEN',
- 'description': 'Gigaspeech English (Best for Kids)',
- 'benefits': ['Massive vocabulary', 'Perfect for creative language', 'YouTube training data', 'Multiple client support']
- },
- '2': {
- 'name': 'SherpaWhisperTinyEN',
- 'description': 'Whisper Tiny English (Fastest)',
- 'benefits': ['Fastest processing', 'Small size (153MB)', 'Quick responses', 'Good for simple conversations']
- },
- '3': {
- 'name': 'SherpaWhisperBaseEN',
- 'description': 'Whisper Base English (Balanced)',
- 'benefits': ['Good balance of speed/accuracy', 'Moderate size (74MB)', 'Reliable performance', 'General purpose']
- },
- '4': {
- 'name': 'SherpaWhisperSmallEN',
- 'description': 'Whisper Small English (Highest Accuracy)',
- 'benefits': ['Best accuracy', 'Large size (244MB)', 'Excellent for complex speech', 'Professional use']
- }
- }
-
- selected_model = models[choice]
-
- print(f"\n✅ Selected: {selected_model['description']}")
- print("📋 Benefits:")
- for benefit in selected_model['benefits']:
- print(f" • {benefit}")
- print()
-
- try:
- # Create or update config
- config = {}
-
- # Load existing config if it exists
- if os.path.exists(config_file):
- with open(config_file, 'r', encoding='utf-8') as f:
- config = yaml.safe_load(f) or {}
-
- # Set up the configuration
- if 'selected_module' not in config:
- config['selected_module'] = {}
-
- config['selected_module']['ASR'] = selected_model['name']
-
- # Ensure ASR configurations exist
- if 'ASR' not in config:
- config['ASR'] = {}
-
- # Add all English ASR configurations
- english_models = {
- 'SherpaZipformerGigaspeechEN': {
- 'type': 'sherpa_onnx_local',
- 'model_dir': 'models/sherpa-onnx-zipformer-gigaspeech-2023-12-12',
- 'model_type': 'zipformer',
- 'output_dir': 'tmp/'
- },
- 'SherpaWhisperTinyEN': {
- 'type': 'sherpa_onnx_local',
- 'model_dir': 'models/sherpa-onnx-whisper-tiny.en',
- 'model_type': 'whisper',
- 'output_dir': 'tmp/'
- },
- 'SherpaWhisperBaseEN': {
- 'type': 'sherpa_onnx_local',
- 'model_dir': 'models/sherpa-onnx-whisper-base.en',
- 'model_type': 'whisper',
- 'output_dir': 'tmp/'
- },
- 'SherpaWhisperSmallEN': {
- 'type': 'sherpa_onnx_local',
- 'model_dir': 'models/sherpa-onnx-whisper-small.en',
- 'model_type': 'whisper',
- 'output_dir': 'tmp/'
- }
- }
-
- config['ASR'].update(english_models)
-
- # Write the config
- with open(config_file, 'w', encoding='utf-8') as f:
- yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
-
- print("✅ Configuration updated successfully!")
- print(f"📁 Config file: {config_file}")
- print(f"🎯 Selected ASR: {selected_model['name']}")
- print()
-
- # Special instructions for Gigaspeech
- if choice == '1':
- print("🔽 Gigaspeech Model Setup:")
- print("The Gigaspeech model will be downloaded automatically when you start the server.")
- print("If automatic download fails, you can run:")
- print(" python download_gigaspeech_manual.py")
- print()
-
- print("🚀 Next Steps:")
- print("1. Start your server: python main/xiaozhi-server/app.py")
- print("2. The English model will download automatically")
- print("3. Enjoy 3x faster English processing!")
- print()
-
- print("🎉 English-only ASR setup complete!")
- return True
-
- except Exception as e:
- print(f"❌ Error setting up configuration: {e}")
- return False
-
-if __name__ == "__main__":
- print("English-Only ASR Setup Script")
- print("Configures the best English ASR model for your needs")
- print()
-
- success = setup_english_asr()
-
- if success:
- print("\n🎯 SUCCESS! Your English ASR is ready!")
- print("Your bot will now process English speech much faster and more accurately.")
- else:
- print("\n❌ Setup failed. Please check the error messages above.")
- sys.exit(1)
\ No newline at end of file