mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
update:优化插件显示
This commit is contained in:
+4
-7
@@ -4,7 +4,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
@@ -35,7 +34,6 @@ import xiaozhi.common.redis.RedisKeys;
|
||||
import xiaozhi.common.redis.RedisUtils;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.common.utils.JsonUtils;
|
||||
import xiaozhi.common.utils.Result;
|
||||
import xiaozhi.common.utils.ResultUtils;
|
||||
import xiaozhi.modules.agent.dto.AgentChatHistoryDTO;
|
||||
@@ -45,14 +43,14 @@ import xiaozhi.modules.agent.dto.AgentDTO;
|
||||
import xiaozhi.modules.agent.dto.AgentMemoryDTO;
|
||||
import xiaozhi.modules.agent.dto.AgentUpdateDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentPluginMapping;
|
||||
import xiaozhi.modules.agent.entity.AgentTemplateEntity;
|
||||
import xiaozhi.modules.agent.service.*;
|
||||
import xiaozhi.modules.agent.service.AgentChatAudioService;
|
||||
import xiaozhi.modules.agent.service.AgentChatHistoryService;
|
||||
import xiaozhi.modules.agent.service.AgentService;
|
||||
import xiaozhi.modules.agent.service.AgentTemplateService;
|
||||
import xiaozhi.modules.agent.vo.AgentInfoVO;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
import xiaozhi.modules.device.service.DeviceService;
|
||||
import xiaozhi.modules.model.dto.ModelProviderDTO;
|
||||
import xiaozhi.modules.model.service.ModelProviderService;
|
||||
import xiaozhi.modules.security.user.SecurityUser;
|
||||
|
||||
@Tag(name = "智能体管理")
|
||||
@@ -155,7 +153,6 @@ public class AgentController {
|
||||
return new Result<>();
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除智能体")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
|
||||
-2
@@ -35,7 +35,6 @@ import xiaozhi.modules.agent.service.AgentService;
|
||||
import xiaozhi.modules.agent.vo.AgentInfoVO;
|
||||
import xiaozhi.modules.device.service.DeviceService;
|
||||
import xiaozhi.modules.model.service.ModelConfigService;
|
||||
import xiaozhi.modules.model.service.ModelProviderService;
|
||||
import xiaozhi.modules.security.user.SecurityUser;
|
||||
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
||||
import xiaozhi.modules.timbre.service.TimbreService;
|
||||
@@ -49,7 +48,6 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
||||
private final RedisUtils redisUtils;
|
||||
private final DeviceService deviceService;
|
||||
private final AgentPluginMappingService agentPluginMappingService;
|
||||
private final ModelProviderService modelProviderService;
|
||||
private final AgentChatHistoryService agentChatHistoryService;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
-- 更新intent_llmM供应器
|
||||
update `ai_model_provider` set fields = '[{"key":"llm","label":"LLM模型","type":"string"},{"key":"functions","label":"函数列表","type":"dict","dict_name":"functions"}]' where id = 'SYSTEM_Intent_intent_llm';
|
||||
-- 更新ChatGLMLLM的意图识别配置
|
||||
update `ai_model_config` set config_json = '{\"type\": \"intent_llm\", \"llm\": \"LLM_ChatGLMLLM\", \"functions\": \"get_weather;get_news_from_newsnow;play_music\"}' where id = 'Intent_intent_llm';
|
||||
-- 更新函数调用意图识别配置
|
||||
UPDATE `ai_model_config` SET config_json = REPLACE(config_json, ';get_news;', ';get_news_from_newsnow;') WHERE id = 'Intent_function_call';
|
||||
@@ -3,6 +3,15 @@
|
||||
-- ===============================
|
||||
START TRANSACTION;
|
||||
|
||||
|
||||
-- intent_llm和function_call不设置函数列表
|
||||
update `ai_model_provider` set fields = '[{"key":"llm","label":"LLM模型","type":"string"}]' where id = 'SYSTEM_Intent_intent_llm';
|
||||
update `ai_model_provider` set fields = '[]' where id = 'SYSTEM_Intent_function_call';
|
||||
update `ai_model_config` set config_json = '{\"type\": \"intent_llm\", \"llm\": \"LLM_ChatGLMLLM\"}' where id = 'Intent_intent_llm';
|
||||
UPDATE `ai_model_config` SET config_json = '{}' WHERE id = 'Intent_function_call';
|
||||
|
||||
|
||||
delete from ai_model_provider where model_type = 'Plugin';
|
||||
-- 1. 天气查询
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
@@ -37,10 +46,10 @@ VALUES ('SYSTEM_PLUGIN_WEATHER',
|
||||
-- 2. 新闻订阅
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
VALUES ('SYSTEM_PLUGIN_NEWS',
|
||||
VALUES ('SYSTEM_PLUGIN_NEWS_CHINANEWS',
|
||||
'Plugin',
|
||||
'get_news_from_newsnow',
|
||||
'新闻订阅',
|
||||
'get_news_from_chinanews',
|
||||
'中新网新闻',
|
||||
JSON_ARRAY(
|
||||
JSON_OBJECT(
|
||||
'key', 'default_rss_url',
|
||||
@@ -50,16 +59,48 @@ VALUES ('SYSTEM_PLUGIN_NEWS',
|
||||
(SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_news.default_rss_url')
|
||||
),
|
||||
JSON_OBJECT(
|
||||
'key', 'category_urls',
|
||||
'type', 'json',
|
||||
'label', '分类 RSS 地址映射',
|
||||
'key', 'society_rss_url',
|
||||
'type', 'string',
|
||||
'label', '社会新闻 RSS 地址',
|
||||
'default',
|
||||
(SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_news.category_urls')
|
||||
'https://www.chinanews.com.cn/rss/society.xml'
|
||||
),
|
||||
JSON_OBJECT(
|
||||
'key', 'world_rss_url',
|
||||
'type', 'string',
|
||||
'label', '国际新闻 RSS 地址',
|
||||
'default',
|
||||
'https://www.chinanews.com.cn/rss/world.xml'
|
||||
),
|
||||
JSON_OBJECT(
|
||||
'key', 'finance_rss_url',
|
||||
'type', 'string',
|
||||
'label', '财经新闻 RSS 地址',
|
||||
'default',
|
||||
'https://www.chinanews.com.cn/rss/finance.xml'
|
||||
)
|
||||
),
|
||||
20, 0, NOW(), 0, NOW());
|
||||
|
||||
-- 3. HomeAssistant 状态查询
|
||||
-- 3. 新闻订阅
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
VALUES ('SYSTEM_PLUGIN_NEWS_NEWSNOW',
|
||||
'Plugin',
|
||||
'get_news_from_newsnow',
|
||||
'newsnow新闻聚合',
|
||||
JSON_ARRAY(
|
||||
JSON_OBJECT(
|
||||
'key', 'url',
|
||||
'type', 'string',
|
||||
'label', '接口地址',
|
||||
'default',
|
||||
'https://newsnow.busiyi.world/api/s?id='
|
||||
)
|
||||
),
|
||||
20, 0, NOW(), 0, NOW());
|
||||
|
||||
-- 4. HomeAssistant 状态查询
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
VALUES ('SYSTEM_PLUGIN_HA_GET_STATE',
|
||||
@@ -91,7 +132,7 @@ VALUES ('SYSTEM_PLUGIN_HA_GET_STATE',
|
||||
),
|
||||
30, 0, NOW(), 0, NOW());
|
||||
|
||||
-- 4. HomeAssistant 状态写入
|
||||
-- 5. HomeAssistant 状态写入
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
VALUES ('SYSTEM_PLUGIN_HA_SET_STATE',
|
||||
@@ -123,36 +164,14 @@ VALUES ('SYSTEM_PLUGIN_HA_SET_STATE',
|
||||
),
|
||||
40, 0, NOW(), 0, NOW());
|
||||
|
||||
-- 5. 本地播放
|
||||
-- 6. 本地播放音乐
|
||||
INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields,
|
||||
sort, creator, create_date, updater, update_date)
|
||||
VALUES ('SYSTEM_PLUGIN_MUSIC',
|
||||
'Plugin',
|
||||
'play_music',
|
||||
'本地播放',
|
||||
JSON_ARRAY(
|
||||
JSON_OBJECT(
|
||||
'key', 'music_dir',
|
||||
'type', 'string',
|
||||
'label', '音乐文件根目录',
|
||||
'default',
|
||||
(SELECT param_value FROM sys_params WHERE param_code = 'plugins.play_music.music_dir')
|
||||
),
|
||||
JSON_OBJECT(
|
||||
'key', 'music_ext',
|
||||
'type', 'array',
|
||||
'label', '支持的文件后缀',
|
||||
'default',
|
||||
(SELECT param_value FROM sys_params WHERE param_code = 'plugins.play_music.music_ext')
|
||||
),
|
||||
JSON_OBJECT(
|
||||
'key', 'refresh_time',
|
||||
'type', 'number',
|
||||
'label', '列表刷新间隔(秒)',
|
||||
'default',
|
||||
(SELECT param_value FROM sys_params WHERE param_code = 'plugins.play_music.refresh_time')
|
||||
)
|
||||
),
|
||||
'本地音乐播放',
|
||||
JSON_ARRAY(),
|
||||
50, 0, NOW(), 0, NOW());
|
||||
|
||||
|
||||
|
||||
@@ -107,13 +107,6 @@ databaseChangeLog:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202505081146.sql
|
||||
- changeSet:
|
||||
id: 202505091409
|
||||
author: hrz
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202505091409.sql
|
||||
- changeSet:
|
||||
id: 202505091555
|
||||
author: whosmyqueen
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
a.asr_model_id AS asrModelId,
|
||||
a.vad_model_id AS vadModelId,
|
||||
a.llm_model_id AS llmModelId,
|
||||
a.vllm_model_id AS vllmModelId,
|
||||
a.tts_model_id AS ttsModelId,
|
||||
a.tts_voice_id AS ttsVoiceId,
|
||||
a.mem_model_id AS memModelId,
|
||||
|
||||
@@ -275,7 +275,6 @@ export default {
|
||||
|
||||
this.$emit('update-functions', selected);
|
||||
this.dialogVisible = false;
|
||||
this.$message.success('配置保存成功');
|
||||
// 通知父组件对话框已关闭且已保存
|
||||
this.$emit('dialog-closed', true);
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="供应器编码" prop="providerCode" style="flex: 1;">
|
||||
<el-form-item label="编码" prop="providerCode" style="flex: 1;">
|
||||
<el-input v-model="form.providerCode" placeholder="请输入供应器编码" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -87,6 +87,7 @@
|
||||
<el-option label="数字" value="number"></el-option>
|
||||
<el-option label="布尔值" value="boolean"></el-option>
|
||||
<el-option label="字典" value="dict"></el-option>
|
||||
<el-option label="分号分割的列表" value="array"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -161,7 +162,8 @@ export default {
|
||||
'string': '字符串',
|
||||
'number': '数字',
|
||||
'boolean': '布尔值',
|
||||
'dict': '字典'
|
||||
'dict': '字典',
|
||||
'array': '分号分割的列表'
|
||||
};
|
||||
return typeMap[type];
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar/>
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">角色配置</h2>
|
||||
@@ -34,36 +34,33 @@
|
||||
<div class="form-grid">
|
||||
<div class="form-column">
|
||||
<el-form-item label="助手昵称:">
|
||||
<el-input v-model="form.agentName" class="form-input" maxlength="10"/>
|
||||
<el-input v-model="form.agentName" class="form-input" maxlength="10" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色模版:">
|
||||
<div class="template-container">
|
||||
<div v-for="(template, index) in templates" :key="`template-${index}`" class="template-item"
|
||||
:class="{ 'template-loading': loadingTemplate }" @click="selectTemplate(template)">
|
||||
:class="{ 'template-loading': loadingTemplate }" @click="selectTemplate(template)">
|
||||
{{ template.agentName }}
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色介绍:">
|
||||
<el-input type="textarea" rows="9" resize="none" placeholder="请输入内容"
|
||||
v-model="form.systemPrompt"
|
||||
maxlength="2000" show-word-limit class="form-textarea"/>
|
||||
<el-input type="textarea" rows="9" resize="none" placeholder="请输入内容" v-model="form.systemPrompt"
|
||||
maxlength="2000" show-word-limit class="form-textarea" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="记忆:">
|
||||
<el-input type="textarea" rows="6" resize="none" v-model="form.summaryMemory" maxlength="2000"
|
||||
show-word-limit class="form-textarea"
|
||||
:disabled="form.model.memModelId !== 'Memory_mem_local_short'"/>
|
||||
show-word-limit class="form-textarea"
|
||||
:disabled="form.model.memModelId !== 'Memory_mem_local_short'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="语言编码:" style="display: none;">
|
||||
<el-input v-model="form.langCode" placeholder="请输入语言编码,如:zh_CN" maxlength="10"
|
||||
show-word-limit
|
||||
class="form-input"/>
|
||||
<el-input v-model="form.langCode" placeholder="请输入语言编码,如:zh_CN" maxlength="10" show-word-limit
|
||||
class="form-input" />
|
||||
</el-form-item>
|
||||
<el-form-item label="交互语种:" style="display: none;">
|
||||
<el-input v-model="form.language" placeholder="请输入交互语种,如:中文" maxlength="10"
|
||||
show-word-limit
|
||||
class="form-input"/>
|
||||
<el-input v-model="form.language" placeholder="请输入交互语种,如:中文" maxlength="10" show-word-limit
|
||||
class="form-input" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="form-column">
|
||||
@@ -91,13 +88,13 @@
|
||||
class="model-item">
|
||||
<div class="model-select-wrapper">
|
||||
<el-select v-model="form.model[model.key]" filterable placeholder="请选择" class="form-select"
|
||||
@change="handleModelChange(model.type, $event)">
|
||||
@change="handleModelChange(model.type, $event)">
|
||||
<el-option v-for="(item, optionIndex) in modelOptions[model.type]"
|
||||
:key="`option-${index}-${optionIndex}`" :label="item.label" :value="item.value"/>
|
||||
:key="`option-${index}-${optionIndex}`" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<div v-if="showFunctionIcons(model.type)" class="function-icons">
|
||||
<el-tooltip v-for="func in currentFunctions" :key="func.name" effect="dark" placement="top"
|
||||
popper-class="custom-tooltip">
|
||||
popper-class="custom-tooltip">
|
||||
<div slot="content">
|
||||
<div><strong>功能名称:</strong> {{ func.name }}</div>
|
||||
<div v-if="Object.keys(func.params).length > 0">
|
||||
@@ -112,15 +109,13 @@
|
||||
{{ func.name.charAt(0) }}
|
||||
</div>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
class="edit-function-btn"
|
||||
@click="openFunctionDialog"
|
||||
:class="{ 'active-btn': showFunctionDialog }">
|
||||
<el-button class="edit-function-btn" @click="openFunctionDialog"
|
||||
:class="{ 'active-btn': showFunctionDialog }">
|
||||
编辑功能
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="model.type === 'Memory' && form.model.memModelId !== 'Memory_nomem'"
|
||||
class="chat-history-options">
|
||||
class="chat-history-options">
|
||||
<el-radio-group v-model="form.chatHistoryConf" @change="updateChatHistoryConf">
|
||||
<el-radio-button :label="1">上报文字</el-radio-button>
|
||||
<el-radio-button :label="2">上报文字+语音</el-radio-button>
|
||||
@@ -131,7 +126,7 @@
|
||||
<el-form-item label="角色音色">
|
||||
<el-select v-model="form.ttsVoiceId" placeholder="请选择" class="form-select">
|
||||
<el-option v-for="(item, index) in voiceOptions" :key="`voice-${index}`" :label="item.label"
|
||||
:value="item.value"/>
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -143,12 +138,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<function-dialog
|
||||
v-model="showFunctionDialog"
|
||||
:functions="currentFunctions"
|
||||
:all-functions="allFunctions"
|
||||
@update-functions="handleUpdateFunctions"
|
||||
@dialog-closed="handleDialogClosed"/>
|
||||
<function-dialog v-model="showFunctionDialog" :functions="currentFunctions" :all-functions="allFunctions"
|
||||
@update-functions="handleUpdateFunctions" @dialog-closed="handleDialogClosed" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -159,7 +150,7 @@ import HeaderBar from "@/components/HeaderBar.vue";
|
||||
|
||||
export default {
|
||||
name: 'RoleConfigPage',
|
||||
components: {HeaderBar, FunctionDialog},
|
||||
components: { HeaderBar, FunctionDialog },
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
@@ -234,7 +225,7 @@ export default {
|
||||
})
|
||||
})
|
||||
};
|
||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({data}) => {
|
||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
message: '配置保存成功',
|
||||
@@ -283,7 +274,7 @@ export default {
|
||||
});
|
||||
},
|
||||
fetchTemplates() {
|
||||
Api.agent.getAgentTemplate(({data}) => {
|
||||
Api.agent.getAgentTemplate(({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.templates = data.data;
|
||||
} else {
|
||||
@@ -331,7 +322,7 @@ export default {
|
||||
};
|
||||
},
|
||||
fetchAgentConfig(agentId) {
|
||||
Api.agent.getDeviceConfig(agentId, ({data}) => {
|
||||
Api.agent.getDeviceConfig(agentId, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.form = {
|
||||
...this.form,
|
||||
@@ -351,8 +342,8 @@ export default {
|
||||
|
||||
// 先保证 allFunctions 已经加载(如果没有,则先 fetchAllFunctions)
|
||||
const ensureFuncs = this.allFunctions.length
|
||||
? Promise.resolve()
|
||||
: this.fetchAllFunctions();
|
||||
? Promise.resolve()
|
||||
: this.fetchAllFunctions();
|
||||
|
||||
ensureFuncs.then(() => {
|
||||
// 合并:按照 pluginId(id 字段)把全量元数据信息补齐
|
||||
@@ -380,7 +371,7 @@ export default {
|
||||
},
|
||||
fetchModelOptions() {
|
||||
this.models.forEach(model => {
|
||||
Api.model.getModelNames(model.type, '', ({data}) => {
|
||||
Api.model.getModelNames(model.type, '', ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$set(this.modelOptions, model.type, data.data.map(item => ({
|
||||
value: item.id,
|
||||
@@ -397,7 +388,7 @@ export default {
|
||||
this.voiceOptions = [];
|
||||
return;
|
||||
}
|
||||
Api.model.getModelVoices(modelId, '', ({data}) => {
|
||||
Api.model.getModelVoices(modelId, '', ({ data }) => {
|
||||
if (data.code === 0 && data.data) {
|
||||
this.voiceOptions = data.data.map(voice => ({
|
||||
value: voice.id,
|
||||
@@ -414,7 +405,7 @@ export default {
|
||||
},
|
||||
showFunctionIcons(type) {
|
||||
return type === 'Intent' &&
|
||||
this.form.model.intentModelId !== 'Intent_nointent';
|
||||
this.form.model.intentModelId !== 'Intent_nointent';
|
||||
},
|
||||
handleModelChange(type, value) {
|
||||
if (type === 'Intent' && value !== 'Intent_nointent') {
|
||||
@@ -450,14 +441,13 @@ export default {
|
||||
openFunctionDialog() {
|
||||
// 显示编辑对话框时,确保 allFunctions 已经加载
|
||||
if (this.allFunctions.length === 0) {
|
||||
this.fetchAllFunctions().then(() => this.showFunctionDialog=true);
|
||||
this.fetchAllFunctions().then(() => this.showFunctionDialog = true);
|
||||
} else {
|
||||
this.showFunctionDialog = true;
|
||||
}
|
||||
},
|
||||
handleUpdateFunctions(selected) {
|
||||
this.currentFunctions = selected;
|
||||
this.$message.success('功能配置已保存');
|
||||
},
|
||||
handleDialogClosed(saved) {
|
||||
if (!saved) {
|
||||
|
||||
@@ -117,10 +117,9 @@ plugins:
|
||||
# 更多类型的新闻列表查看 https://www.chinanews.com.cn/rss/
|
||||
get_news_from_chinanews:
|
||||
default_rss_url: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
category_urls:
|
||||
society: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
world: "https://www.chinanews.com.cn/rss/world.xml"
|
||||
finance: "https://www.chinanews.com.cn/rss/finance.xml"
|
||||
society_rss_url: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
world_rss_url: "https://www.chinanews.com.cn/rss/world.xml"
|
||||
finance_rss_url: "https://www.chinanews.com.cn/rss/finance.xml"
|
||||
get_news_from_newsnow: {"url": "https://newsnow.busiyi.world/api/s?id="}
|
||||
home_assistant:
|
||||
devices:
|
||||
|
||||
@@ -120,16 +120,16 @@ def map_category(category_text):
|
||||
# 类别映射字典,目前支持社会、国际、财经新闻,如需更多类型,参见配置文件
|
||||
category_map = {
|
||||
# 社会新闻
|
||||
"社会": "society",
|
||||
"社会新闻": "society",
|
||||
"社会": "society_rss_url",
|
||||
"社会新闻": "society_rss_url",
|
||||
# 国际新闻
|
||||
"国际": "world",
|
||||
"国际新闻": "world",
|
||||
"国际": "world_rss_url",
|
||||
"国际新闻": "world_rss_url",
|
||||
# 财经新闻
|
||||
"财经": "finance",
|
||||
"财经新闻": "finance",
|
||||
"金融": "finance",
|
||||
"经济": "finance",
|
||||
"财经": "finance_rss_url",
|
||||
"财经新闻": "finance_rss_url",
|
||||
"金融": "finance_rss_url",
|
||||
"经济": "finance_rss_url",
|
||||
}
|
||||
|
||||
# 转换为小写并去除空格
|
||||
@@ -205,8 +205,8 @@ def get_news_from_chinanews(
|
||||
|
||||
# 如果提供了类别,尝试从配置中获取对应的URL
|
||||
rss_url = default_rss_url
|
||||
if mapped_category and mapped_category in rss_config.get("category_urls", {}):
|
||||
rss_url = rss_config["category_urls"][mapped_category]
|
||||
if mapped_category and mapped_category in rss_config:
|
||||
rss_url = rss_config[mapped_category]
|
||||
|
||||
logger.bind(tag=TAG).info(
|
||||
f"获取新闻: 原始类别={category}, 映射类别={mapped_category}, URL={rss_url}"
|
||||
|
||||
Reference in New Issue
Block a user