Merge branch 'main' into main

This commit is contained in:
WenZH2233 2026-03-21 22:06:31 +08:00 committed by GitHub
commit e976e6f9e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 1267 additions and 380 deletions

View file

@ -304,7 +304,7 @@ public interface Constant {
/** /**
* 版本号 * 版本号
*/ */
public static final String VERSION = "0.9.1"; public static final String VERSION = "0.9.2";
/** /**
* 无效固件URL * 无效固件URL

View file

@ -251,4 +251,9 @@ public interface ErrorCode {
int AGENT_TAG_NOT_EXIST = 10198; // 标签不存在 int AGENT_TAG_NOT_EXIST = 10198; // 标签不存在
int RAG_DOCUMENT_PARSING_DELETE_ERROR = 10199; // 文档解析中,禁止删除 int RAG_DOCUMENT_PARSING_DELETE_ERROR = 10199; // 文档解析中,禁止删除
// 智能体MCP相关错误码
int MCP_ACCESS_POINT_ADDRESS_NO_PERMISSION = 10200; // 没有权限查看该智能体的MCP接入点地址
int MCP_ACCESS_POINT_ADDRESS_NOT_CONFIGURED = 10201; // 请联系管理员进入参数管理配置mcp接入点地址
int MCP_ACCESS_POINT_TOOLS_LIST_NO_PERMISSION = 10202; // 没有权限查看该智能体的MCP工具列表
} }

View file

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import xiaozhi.common.exception.ErrorCode;
import xiaozhi.common.user.UserDetail; import xiaozhi.common.user.UserDetail;
import xiaozhi.common.utils.Result; import xiaozhi.common.utils.Result;
import xiaozhi.modules.agent.service.AgentMcpAccessPointService; import xiaozhi.modules.agent.service.AgentMcpAccessPointService;
@ -40,11 +41,11 @@ public class AgentMcpAccessPointController {
// 检查权限 // 检查权限
if (!agentService.checkAgentPermission(agentId, user.getId())) { if (!agentService.checkAgentPermission(agentId, user.getId())) {
return new Result<String>().error("没有权限查看该智能体的MCP接入点地址"); return new Result<String>().error(ErrorCode.MCP_ACCESS_POINT_ADDRESS_NO_PERMISSION);
} }
String agentMcpAccessAddress = agentMcpAccessPointService.getAgentMcpAccessAddress(agentId); String agentMcpAccessAddress = agentMcpAccessPointService.getAgentMcpAccessAddress(agentId);
if (agentMcpAccessAddress == null) { if (agentMcpAccessAddress == null) {
return new Result<String>().ok("请联系管理员进入参数管理配置mcp接入点地址"); return new Result<String>().error(ErrorCode.MCP_ACCESS_POINT_ADDRESS_NOT_CONFIGURED);
} }
return new Result<String>().ok(agentMcpAccessAddress); return new Result<String>().ok(agentMcpAccessAddress);
} }
@ -58,7 +59,7 @@ public class AgentMcpAccessPointController {
// 检查权限 // 检查权限
if (!agentService.checkAgentPermission(agentId, user.getId())) { if (!agentService.checkAgentPermission(agentId, user.getId())) {
return new Result<List<String>>().error("没有权限查看该智能体的MCP工具列表"); return new Result<List<String>>().error(ErrorCode.MCP_ACCESS_POINT_TOOLS_LIST_NO_PERMISSION);
} }
List<String> agentMcpToolsList = agentMcpAccessPointService.getAgentMcpToolsList(agentId); List<String> agentMcpToolsList = agentMcpAccessPointService.getAgentMcpToolsList(agentId);
return new Result<List<String>>().ok(agentMcpToolsList); return new Result<List<String>>().ok(agentMcpToolsList);

View file

@ -206,4 +206,7 @@
10197=\u6807\u7B7E\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A 10197=\u6807\u7B7E\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
10198=\u6807\u7B7E\u4E0D\u5B58\u5728 10198=\u6807\u7B7E\u4E0D\u5B58\u5728
10199=\u89E3\u6790\u4E2D\u6587\u4EF6\u6682\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C 10199=\u89E3\u6790\u4E2D\u6587\u4EF6\u6682\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C
10200=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684MCP\u63A5\u5165\u70B9\u5730\u5740
10201=\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u8FDB\u5165\u53C2\u6570\u7BA1\u7406\u914D\u7F6Emcp\u63A5\u5165\u70B9\u5730\u5740
10202=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684MCP\u5DE5\u5177\u5217\u8868

View file

@ -206,4 +206,7 @@
10197=Tag-Name darf nicht leer sein 10197=Tag-Name darf nicht leer sein
10198=Tag nicht gefunden 10198=Tag nicht gefunden
10199=Dateianalyse l\u00E4uft, dieser Vorgang wird nicht unterst\u00FCtzt 10199=Dateianalyse l\u00E4uft, dieser Vorgang wird nicht unterst\u00FCtzt
10200=Keine Berechtigung, die MCP-Endpunktadresse dieses Agenten anzuzeigen
10201=Bitte kontaktieren Sie den Administrator, um die MCP-Endpunktadresse in der Parameterverwaltung zu konfigurieren
10202=Keine Berechtigung, die MCP-Tool-Liste dieses Agenten anzuzeigen

View file

@ -206,4 +206,7 @@
10197=Tag name cannot be empty 10197=Tag name cannot be empty
10198=Tag not found 10198=Tag not found
10199=Parsing in progress, this operation is not supported 10199=Parsing in progress, this operation is not supported
10200=No permission to view the MCP endpoint address of this agent
10201=Please contact the administrator to configure the MCP endpoint address in parameter management
10202=No permission to view the MCP tool list of this agent

View file

@ -0,0 +1,211 @@
#Portugu\u00EAs do Brasil
500=Erro interno do servidor
401=N\u00E3o autorizado
403=Acesso negado, sem permiss\u00E3o
10001={0} n\u00E3o pode ser vazio
10002=O registro j\u00E1 existe no banco de dados
10003=Falha ao obter par\u00E2metros
10004=Conta ou senha incorretos
10005=Conta desativada
10006=Identificador \u00FAnico n\u00E3o pode ser vazio
10007=C\u00F3digo de verifica\u00E7\u00E3o incorreto
10008=Exclua primeiro o submenu ou bot\u00E3o
10009=Senha atual incorreta
10010=Conta ou senha incorretos, voc\u00EA ainda tem {0} tentativas
10011=Erro na sele\u00E7\u00E3o do departamento superior
10012=O menu superior n\u00E3o pode ser ele mesmo
10013=Interface de permiss\u00E3o de dados, apenas par\u00E2metros do tipo Map
10014=Exclua primeiro o departamento inferior
10015=Exclua primeiro os usu\u00E1rios do departamento
10016=Falha na implanta\u00E7\u00E3o, sem fluxo
10017=Diagrama incorreto, verifique
10018=Falha na exporta\u00E7\u00E3o, ID do modelo é {0}
10019=Por favor, fa\u00E7a upload do arquivo
10020=Token n\u00E3o pode ser vazio
10021=Token expirado, fa\u00E7a login novamente
10022=Conta bloqueada
10023=Por favor, fa\u00E7a upload de arquivos nos formatos zip, bar, bpmn, bpmn20.xml
10024=Falha no upload do arquivo {0}
10025=Falha ao enviar SMS {0}
10026=Modelo de e-mail n\u00E3o existe
10027=Erro no servi\u00E7o Redis
10028=Falha na tarefa agendada
10029=N\u00E3o pode conter caracteres ilegais
10030=Comprimento da senha insuficiente, m\u00EDnimo de {0} caracteres
10031=A senha deve conter n\u00FAmeros, letras mai\u00FAsculas e min\u00FAsculas e caracteres especiais
10032=Erro ao excluir dados
10033=C\u00F3digo de verifica\u00E7\u00E3o do dispositivo incorreto
10034=Valor do par\u00E2metro n\u00E3o pode ser vazio
10035=Tipo do par\u00E2metro n\u00E3o pode ser vazio
10036=Tipo de par\u00E2metro n\u00E3o suportado
10037=Valor do par\u00E2metro deve ser um n\u00FAmero v\u00E1lido
10038=Valor do par\u00E2metro deve ser true ou false
10039=Valor do par\u00E2metro deve ser um formato de array JSON v\u00E1lido
10040=Valor do par\u00E2metro deve ser um formato JSON v\u00E1lido
10041=Dispositivo n\u00E3o encontrado
10042={0}
10043=Falha ao excluir dados
10044=Usu\u00E1rio n\u00E3o logged in
10045=Falha na conex\u00E3o WebSocket ou conex\u00E3o expirada
10046=Erro ao salvar impress\u00E3o vocal, entre em contato com o administrador
10047=Limite di\u00E1rio de envio atingido
10048=Erro na inser\u00E7\u00E3o da senha antiga
10049=LLM configurado n\u00E3o é openai ou Collama
10050=Falha na gera\u00E7\u00E3o do token
10051=Recurso n\u00E3o existe
10052=Agente padr\u00E3o n\u00E3o encontrado
10053=Agente n\u00E3o encontrado
10054=Interface de impress\u00E3o vocal n\u00E3o configurada, configure primeiro o endere\u00E7o da interface no par\u00E2metro (server.voice_print)
10055=Falha no envio do SMS
10056=Falha ao estabelecer conex\u00E3o SMS
10057=Falha ao criar impress\u00E3o vocal do agente
10058=Falha ao atualizar a impress\u00E3o vocal correspondente do agente
10059=Falha ao excluir a impress\u00E3o vocal correspondente do agente
10060=Envio muito frequente, tente novamente ap\u00F3s {0} segundos
10061=C\u00F3digo de ativa\u00E7\u00E3o n\u00E3o pode ser vazio
10062=C\u00F3digo de ativa\u00E7\u00E3o incorreto
10063=Dispositivo j\u00E1 ativado
10064=Este modelo é o modelo padr\u00E3o, configure primeiro outro modelo como padr\u00E3o
10065=Falha ao adicionar dados
10066=Falha ao modificar dados
10067=C\u00F3digo de verifica\u00E7\u00E3o gr\u00E1fico incorreto
10068=Registro por telefone n\u00E3o habilitado, fun\u00E7\u00E3o de c\u00F3digo de verifica\u00E7\u00E3o por SMS indispon\u00EDvel
10069=Nome de usu\u00E1rio n\u00E3o é n\u00FAmero de telefone, por favor insira novamente
10070=Este n\u00FAmero de telefone j\u00E1 est\u00E1 registrado
10071=N\u00FAmero de telefone inserido n\u00E3o est\u00E1 registrado
10072=Registro de usu\u00E1rio comum n\u00E3o permitido atualmente
10073=Registro por telefone n\u00E3o habilitado, fun\u00E7\u00E3o de recupera\u00E7\u00E3o de senha indispon\u00EDvel
10074=Formato de n\u00FAmero de telefone incorreto
10075=C\u00F3digo de verifica\u00E7\u00E3o do telefone incorreto
10076=Tipo de dicion\u00E1rio n\u00E3o existe
10077=C\u00F3digo de tipo de dicion\u00E1rio duplicado
10078=Falha ao carregar recurso
10079=Par\u00E2metros de sele\u00E7\u00E3o incompat\u00EDveis entre LLM e reconhecimento de inten\u00E7\u00E3o Intent
10080=A pessoa ({0}) correspondente a esta impress\u00E3o vocal j\u00E1 est\u00E1 registrada, escolha outra voz para registrar
10081=Erro ao excluir impress\u00E3o vocal
10082=Esta modifica\u00E7\u00E3o n\u00E3o é permitida, esta voz j\u00E1 est\u00E1 registrada como impress\u00E3o vocal ({0})
10083=Erro ao modificar impress\u00E3o vocal, entre em contato com o administrador
10084=Erro no endere\u00E7o da interface de impress\u00E3o vocal, acesse o gerenciamento de par\u00E2metros para modificar o endere\u00E7o
10085=Dados de \u00E1udio n\u00E3o pertencem a este agente
10086=Dados de \u00E1udio est\u00E3o vazios, verifique os dados enviados
10087=Falha ao salvar impress\u00E3o vocal, falha na requisi\u00E7\u00E3o
10088=Falha ao salvar impress\u00E3o vocal, falha no processamento
10089=Falha ao cancelar impress\u00E3o vocal, falha na requisi\u00E7\u00E3o
10090=Falha ao cancelar impress\u00E3o vocal, falha no processamento
10091=Provedor n\u00E3o existe
10092=LLM configurado n\u00E3o existe
10093=Esta configura\u00E7\u00E3o de modelo foi referenciada pelo agente {0}, n\u00E3o pode ser exclu\u00EDda
10094=Este modelo LLM foi referenciado pela configura\u00E7\u00E3o de reconhecimento de inten\u00E7\u00E3o, n\u00E3o pode ser exclu\u00EDdo
10095=Opera\u00E7\u00E3o de servidor inv\u00E1lida
10096=Endere\u00E7o WebSocket do servidor n\u00E3o configurado
10097=Endere\u00E7o WebSocket de destino n\u00E3o existe
10098=Lista de endere\u00E7os WebSocket n\u00E3o pode ser vazia
10099=Endere\u00E7o WebSocket n\u00E3o pode usar localhost ou 127.0.0.1
10100=Formato de endere\u00E7o WebSocket incorreto
10101=Falha no teste de conex\u00E3o WebSocket
10102=Endere\u00E7o OTA n\u00E3o pode ser vazio
10103=Endere\u00E7o OTA n\u00E3o pode usar localhost ou 127.0.0.1
10104=Endere\u00E7o OTA deve come\u00E7ar com http ou https
10105=Endere\u00E7o OTA deve terminar com /ota/
10106=Falha ao acessar interface OTA
10107=Formato de conte\u00FAdo retornado pela interface OTA incorreto
10108=Falha na valida\u00E7\u00E3o da interface OTA
10109=Endere\u00E7o MCP n\u00E3o pode ser vazio
10110=Endere\u00E7o MCP n\u00E3o pode usar localhost ou 127.0.0.1
10111=Endere\u00E7o MCP incorreto
10112=Falha ao acessar interface MCP
10113=Formato de conte\u00FAdo retornado pela interface MCP incorreto
10114=Falha na valida\u00E7\u00E3o da interface MCP
10115=Endere\u00E7o da interface de impress\u00E3o vocal n\u00E3o pode ser vazio
10116=Endere\u00E7o da interface de impress\u00E3o vocal n\u00E3o pode usar localhost ou 127.0.0.1
10117=Endere\u00E7o da interface de impress\u00E3o vocal incorreto
10118=Endere\u00E7o da interface de impress\u00E3o vocal deve come\u00E7ar com http ou https
10119=Falha ao acessar interface de impress\u00E3o vocal
10120=Formato de conte\u00FAdo retornado pela interface de impress\u00E3o vocal incorreto
10121=Falha na valida\u00E7\u00E3o da interface de impress\u00E3o vocal
10122=Chave mqtt n\u00E3o pode ser vazia
10123=Comprimento da chave mqtt inseguro, deve ter pelo menos 8 caracteres e conter letras mai\u00FAsculas e min\u00FAsculas
10124=Comprimento da chave mqtt inseguro, deve conter letras mai\u00FAsculas e min\u00FAsculas
10125=Sua chave mqtt cont\u00E9m senha fraca
10128=Etiqueta de dicion\u00E1rio duplicada
10129=Chave SM2 n\u00E3o configurada
10130=Falha na descriptografia SM2
10131=modelType e provideCode n\u00E3o podem ser vazios
10132=Sem permiss\u00E3o para visualizar registros de chat deste agente
10133=ID da sess\u00E3o n\u00E3o pode ser vazio
10134=ID do agente n\u00E3o pode ser vazio
10135=Falha ao baixar registros de chat
10136=Link de download expirado ou inv\u00E1lido
10137=Link de download inv\u00E1lido
10138=Usu\u00E1rio
10139=Agente
10140=Arquivo de \u00E1udio n\u00E3o pode ser vazio
10141=Apenas arquivos de \u00E1udio s\u00E3o suportados
10142=Tamanho do arquivo de \u00E1udio n\u00E3o pode exceder 10MB
10143=Falha no upload
10144=Registro de clonagem de voz n\u00E3o existe
10145=Informa\u00E7\u00F5es de recurso de tom de voz n\u00E3o podem ser vazias
10146=Nome da plataforma n\u00E3o pode ser vazio
10147=ID do tom de voz n\u00E3o pode ser vazio
10148=N\u00FAmero da conta atribu\u00EDda n\u00E3o pode ser vazio
10149=IDs de recursos de tom de voz a serem exclu\u00EDdos n\u00E3o podem ser vazios
10150=Voc\u00EA n\u00E3o tem permiss\u00E3o para operar este registro
10151=Por favor, fa\u00E7a upload do arquivo de \u00E1udio primeiro
10152=Configura\u00E7\u00E3o do modelo n\u00E3o encontrada
10153=Tipo de modelo n\u00E3o encontrado
10154=Falha no treinamento: {0}
10155=Configura\u00E7\u00E3o ausente do mecanismo Huoshan
10156=Erro de formato de resposta, campo BaseResp ausente
10157=Falha na requisi\u00E7\u00E3o
10158=Clonagem de tom de voz:
10159=ID do tom de voz j\u00E1 existe
10160=Formato de ID do tom de voz do mecanismo Huoshan incorreto, deve come\u00E7ar com S_
10161=Endere\u00E7o Mac j\u00E1 existe
10162=Provedor de modelos n\u00E3o existe
10163=Registro da base de conhecimento n\u00E3o existe
10164=Configura\u00E7\u00E3o RAG n\u00E3o encontrada
10165=Erro de tipo de configura\u00E7\u00E3o RAG
10166=Configura\u00E7\u00E3o RAG padr\u00E3o n\u00E3o encontrada
10167=Falha na chamada RAG, {0}
10168=Falha no upload do arquivo
10169=Voc\u00EA n\u00E3o tem permiss\u00E3o para operar este registro
10170=Nome da base de conhecimento duplicado
10171=base_url da configura\u00E7\u00E3o RAG n\u00E3o pode ser vazio
10172=api_key da configura\u00E7\u00E3o RAG n\u00E3o pode ser vazio
10173=api_key da configura\u00E7\u00E3o RAG n\u00E3o pode ser vazio, substitua pelo par\u00E2metro API obtido
10174=Formato de base_url da configura\u00E7\u00E3o RAG incorreto, deve come\u00E7ar com http ou https
10175=Endere\u00E7o mac n\u00E3o pode ser vazio
10176=dataset_id da configura\u00E7\u00E3o RAG n\u00E3o pode ser vazio
10177=model_id da configura\u00E7\u00E3o RAG n\u00E3o pode ser vazio
10178=dataset_id e model_id da configura\u00E7\u00E3o RAG n\u00E3o podem ser vazios
10179=Nome do arquivo n\u00E3o pode ser vazio
10180=Conte\u00FAdo do arquivo n\u00E3o pode ser vazio
10181=Nome da clonagem de tom de voz n\u00E3o pode ser vazio
10182=\u00C1udio de clonagem de tom de voz n\u00E3o existe
10183=Agente padr\u00E3o n\u00E3o encontrado
10184=Tipo de adaptador n\u00E3o suportado
10185=Falha na valida\u00E7\u00E3o da configura\u00E7\u00E3o RAG
10186=Falha ao criar adaptador
10187=Falha ao inicializar adaptador
10188=Falha no teste de conex\u00E3o do adaptador
10189=Falha na opera\u00E7\u00E3o do adaptador
10190=Adaptador n\u00E3o encontrado
10191=Erro de cache do adaptador
10192=Tipo de adaptador n\u00E3o encontrado
10193=ID do dispositivo n\u00E3o pode ser vazio
10194=Dispositivo n\u00E3o existe ou est\u00E1 offline
10195=Limite de uploads OTA excedido
10196=Nome da etiqueta j\u00E1 existe
10197=Nome da etiqueta n\u00E3o pode ser vazio
10198=Etiqueta n\u00E3o existe
10199=Esta opera\u00E7\u00E3o n\u00E3o é suportada na an\u00E1lise de arquivos chineses
10200=Sem permiss\u00e3o para visualizar o endere\u00e7o do endpoint MCP deste agente
10201=Por favor, contate o administrador para configurar o endere\u00e7o do endpoint MCP no gerenciamento de par\u00e2metros
10202=Sem permiss\u00e3o para visualizar a lista de ferramentas MCP deste agente

View file

@ -206,4 +206,6 @@
10197=T\u00EAn th\u1EB9\uFFFD kh\u00F4ng th\u1EC3 \u0111\u1EC3 tr\u1ED1ng 10197=T\u00EAn th\u1EB9\uFFFD kh\u00F4ng th\u1EC3 \u0111\u1EC3 tr\u1ED1ng
10198=Kh\u00F4ng t\u00ECm th\u1EA5y th\u1EB9\uFFFD 10198=Kh\u00F4ng t\u00ECm th\u1EA5y th\u1EB9\uFFFD
10199=T\u1EC7p \u0111ang \u0111\u01B0\u1EE3c ph\u00E2n t\u00EDch, thao t\u00E1c n\u00E0y kh\u00F4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 10199=T\u1EC7p \u0111ang \u0111\u01B0\u1EE3c ph\u00E2n t\u00EDch, thao t\u00E1c n\u00E0y kh\u00F4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3
10200=Kh\u00f4ng c\u00f3 quy\u1ec1n xem \u0111\u1ecba ch\u1ec9 \u0111i\u1ec3m cu\u1ed1i MCP c\u1ee7a \u0111\u1ea1i l\u00fd n\u00e0y
10201=Vui l\u00f2ng li\u00ean h\u1ec7 qu\u1ea3n tr\u1ecb vi\u00ean \u0111\u1ec3 c\u1ea5u h\u00ecnh \u0111\u1ecba ch\u1ec9 \u0111i\u1ec3m cu\u1ed1i MCP trong qu\u1ea3n l\u00fd tham s\u1ed1
10202=Kh\u00f4ng c\u00f3 quy\u1ec1n xem danh s\u00e1ch c\u00f4ng c\u1ee5 MCP c\u1ee7a \u0111\u1ea1i l\u00fd n\u00e0y

View file

@ -202,4 +202,10 @@
10193=\u8BBE\u5907ID\u4E0D\u80FD\u4E3A\u7A7A 10193=\u8BBE\u5907ID\u4E0D\u80FD\u4E3A\u7A7A
10194=\u8BBE\u5907\u4E0D\u5B58\u5728\u6216\u4E0D\u5728\u7EBF 10194=\u8BBE\u5907\u4E0D\u5B58\u5728\u6216\u4E0D\u5728\u7EBF
10195=OTA\u4E0A\u4F20\u6B21\u6570\u8D85\u8FC7\u9650\u5236 10195=OTA\u4E0A\u4F20\u6B21\u6570\u8D85\u8FC7\u9650\u5236
10196=\u89E3\u6790\u4E2D\u6587\u4EF6\u6682\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C 10196=\u6807\u7B7E\u540D\u79F0\u5DF2\u5B58\u5728
10197=\u6807\u7B7E\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
10198=\u6807\u7B7E\u4E0D\u5B58\u5728
10199=\u89E3\u6790\u4E2D\u6587\u4EF6\u6682\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C
10200=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684MCP\u63A5\u5165\u70B9\u5730\u5740
10201=\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u8FDB\u5165\u53C2\u6570\u7BA1\u7406\u914D\u7F6Emcp\u63A5\u5165\u70B9\u5730\u5740
10202=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684MCP\u5DE5\u5177\u5217\u8868

View file

@ -206,4 +206,6 @@
10197=\u6A19\u7C64\u540D\u7A31\u4E0D\u80FD\u4E3A\u7A7A 10197=\u6A19\u7C64\u540D\u7A31\u4E0D\u80FD\u4E3A\u7A7A
10198=\u6A19\u7C64\u4E0D\u5B58\u5728 10198=\u6A19\u7C64\u4E0D\u5B58\u5728
10199=\u89E3\u6790\u4E2D\u6587\u4EF6\u66AB\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C 10199=\u89E3\u6790\u4E2D\u6587\u4EF6\u66AB\u4E0D\u652F\u6301\u6B64\u64CD\u4F5C
10200=\u6C92\u6709\u6B0A\u9650\u67E5\u770B\u8A72\u667A\u80FD\u9AD4\u7684MCP\u63A5\u5165\u9EDE\u5730\u5740
10201=\u8ACB\u806F\u7E6B\u7BA1\u7406\u54E1\u9032\u5165\u53C3\u6578\u7BA1\u7406\u914D\u7F6Emcp\u63A5\u5165\u9EDE\u5730\u5740
10202=\u6C92\u6709\u6B0A\u9650\u67E5\u770B\u8A72\u667A\u80FD\u9AD4\u7684MCP\u5DE5\u5177\u5217\u8868

View file

@ -0,0 +1,34 @@
#Portugu\u00eas
id.require=O ID n\u00e3o pode estar vazio
id.null=O ID deve estar vazio
sort.number=O valor de classifica\u00e7\u00e3o n\u00e3o pode ser menor que 0
page.number=O n\u00famero da p\u00e1gina n\u00e3o pode ser menor que 0
limit.number=O n\u00famero de registros n\u00e3o pode ser menor que 0
sysdict.type.require=O tipo de dicion\u00e1rio n\u00e3o pode estar vazio
sysdict.name.require=O nome do dicion\u00e1rio n\u00e3o pode estar vazio
sysdict.label.require=A etiqueta do dicion\u00e1rio n\u00e3o pode estar vazio
sysparams.paramcode.require=A codifica\u00e7\u00e3o do par\u00e2metro n\u00e3o pode estar vazia
sysparams.paramvalue.require=O valor do par\u00e2metro n\u00e3o pode estar vazio
sysparams.valuetype.require=O tipo de valor n\u00e3o pode estar vazio
sysparams.valuetype.pattern=O tipo de valor deve ser string, number, boolean ou array
sysuser.username.require=O nome de usu\u00e1rio n\u00e3o pode estar vazio
sysuser.password.require=A senha n\u00e3o pode estar vazio
sysuser.realname.require=O nome completo n\u00e3o pode estar vazio
sysuser.gender.range=G\u00eanero varia de 0 a 2
sysuser.email.error=Formato de e-mail incorreto
sysuser.deptId.require=O departamento n\u00e3o pode estar vazio
sysuser.status.range=Status varia de 0 a 1
sysuser.captcha.require=O c\u00f3digo de verifica\u00e7\u00e3o n\u00e3o pode estar vazio
sysuser.uuid.require=O identificador \u00fanico n\u00e3o pode estar vazio
timbre.languages.require=O idioma do timbre n\u00e3o pode estar vazio
timbre.name.require=O nome do timbre n\u00e3o pode estar vazio
timbre.ttsModelId.require=O ID do modelo TTS do timbre n\u00e3o pode estar vazio
timbre.ttsVoice.require=O c\u00f3digo do timbre n\u00e3o pode estar vazio
ota.device.not.found=Dispositivo n\u00e3o encontrado
ota.device.need.bind={0}

View file

@ -131,6 +131,7 @@ export function getMcpAddress(agentId: string) {
meta: { meta: {
ignoreAuth: false, ignoreAuth: false,
toast: false, toast: false,
isExposeError: true,
}, },
}) })
} }

View file

@ -60,3 +60,13 @@ export function updateVoicePrint(data: VoicePrint) {
}, },
}) })
} }
// 获取音频下载ID
export function getAudioDownloadId(audioId: string) {
return http.Post<string>(`/agent/audio/${audioId}`, {}, {
meta: {
ignoreAuth: false,
toast: false,
},
})
}

View file

@ -1,5 +1,6 @@
import type { uniappRequestAdapter } from '@alova/adapter-uniapp' import type { uniappRequestAdapter } from '@alova/adapter-uniapp'
import type { IResponse } from './types' import type { IResponse } from './types'
import type { Language } from '@/store/lang'
import AdapterUniapp from '@alova/adapter-uniapp' import AdapterUniapp from '@alova/adapter-uniapp'
import { createAlova } from 'alova' import { createAlova } from 'alova'
import { createServerTokenAuthentication } from 'alova/client' import { createServerTokenAuthentication } from 'alova/client'
@ -8,6 +9,16 @@ import { getEnvBaseUrl } from '@/utils'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum' import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum'
// 语言映射, 用于设置 Accept-language 头
const langMap: Record<Language, string> = {
zh_CN: 'zh-CN',
en: 'en-US',
zh_TW: 'zh-TW',
de: 'de',
vi: 'vi',
pt_BR: 'pt-BR',
}
/** /**
* 创建请求实例 * 创建请求实例
*/ */
@ -51,6 +62,7 @@ const alovaInstance = createAlova({
// 检查混合内容错误(HTTPS页面请求HTTP接口) // 检查混合内容错误(HTTPS页面请求HTTP接口)
const currentProtocol = typeof window !== 'undefined' && window.location.protocol const currentProtocol = typeof window !== 'undefined' && window.location.protocol
const requestProtocol = method.baseURL?.split(':')[0] const requestProtocol = method.baseURL?.split(':')[0]
const currentLang = langMap[uni.getStorageSync('app_language') as Language || 'zh_CN']
if (currentProtocol === 'https:' && requestProtocol === 'http') { if (currentProtocol === 'https:' && requestProtocol === 'http') {
const errorMessage = '无法配置http协议地址,请检查接口地址' const errorMessage = '无法配置http协议地址,请检查接口地址'
throw new Error(errorMessage) throw new Error(errorMessage)
@ -60,6 +72,7 @@ const alovaInstance = createAlova({
method.config.headers = { method.config.headers = {
'Content-Type': ContentTypeEnum.JSON, 'Content-Type': ContentTypeEnum.JSON,
'Accept': 'application/json, text/plain, */*', 'Accept': 'application/json, text/plain, */*',
'Accept-language': currentLang,
...method.config.headers, ...method.config.headers,
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': 'Anmelden', 'login.navigationTitle': 'Anmelden',
'login.fetchConfigError': 'Konfiguration konnte nicht abgerufen werden:', 'login.fetchConfigError': 'Konfiguration konnte nicht abgerufen werden:',
'login.selectLanguage': 'Sprache auswählen', 'login.selectLanguage': 'Sprache auswählen',
'login.selectLanguageTip': 'Vi', 'login.selectLanguageTip': 'De',
'login.welcomeBack': 'Willkommen zurück', 'login.welcomeBack': 'Willkommen zurück',
'login.pleaseLogin': 'Bitte melden Sie sich an', 'login.pleaseLogin': 'Bitte melden Sie sich an',
'login.enterUsername': 'Bitte Benutzernamen eingeben', 'login.enterUsername': 'Bitte Benutzernamen eingeben',
@ -85,7 +85,7 @@ export default {
'agent.chatHistory': 'Chat-Verlauf', 'agent.chatHistory': 'Chat-Verlauf',
'agent.voiceprintManagement': 'Stimmabdruckverwaltung', 'agent.voiceprintManagement': 'Stimmabdruckverwaltung',
'agent.editTitle': 'Agent bearbeiten', 'agent.editTitle': 'Agent bearbeiten',
'agent.toolsTitle': 'Funktionen bearbeiten', 'agent.toolsTitle': 'Bearbeiten',
'agent.voiceActivityDetection': 'Sprachaktivitätserkennung', 'agent.voiceActivityDetection': 'Sprachaktivitätserkennung',
'agent.speechRecognition': 'Spracherkennung', 'agent.speechRecognition': 'Spracherkennung',
'agent.largeLanguageModel': 'Großes Sprachmodell', 'agent.largeLanguageModel': 'Großes Sprachmodell',
@ -116,7 +116,7 @@ export default {
'agent.tts': 'Text-zu-Sprache', 'agent.tts': 'Text-zu-Sprache',
'agent.voiceprint': 'Agenten-Stimme', 'agent.voiceprint': 'Agenten-Stimme',
'agent.plugins': 'Plugins', 'agent.plugins': 'Plugins',
'agent.editFunctions': 'Funktionen bearbeiten', 'agent.editFunctions': 'Bearbeiten',
'agent.historyMemory': 'Verlaufsspeicher', 'agent.historyMemory': 'Verlaufsspeicher',
'agent.memoryContent': 'Speicherinhalt', 'agent.memoryContent': 'Speicherinhalt',
'agent.saving': 'Wird gespeichert...', 'agent.saving': 'Wird gespeichert...',
@ -371,7 +371,7 @@ export default {
'agent.tools.mcpAccessPoint': 'MCP-Zugangspunkt', 'agent.tools.mcpAccessPoint': 'MCP-Zugangspunkt',
'agent.tools.copy': 'Kopieren', 'agent.tools.copy': 'Kopieren',
'agent.tools.noTools': 'Keine Werkzeuge verfügbar', 'agent.tools.noTools': 'Keine Werkzeuge verfügbar',
'agent.tools.parameterConfig': 'Parameterkonfiguration', 'agent.tools.parameterConfig': 'Konfig',
'agent.tools.noParamsNeeded': 'Keine Parameter benötigt', 'agent.tools.noParamsNeeded': 'Keine Parameter benötigt',
'agent.tools.pleaseInput': 'Bitte eingeben', 'agent.tools.pleaseInput': 'Bitte eingeben',
'agent.tools.inputOneItemPerLine': 'Ein Element pro Zeile eingeben', 'agent.tools.inputOneItemPerLine': 'Ein Element pro Zeile eingeben',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Nach erfolgreicher Konfiguration startet Gerät automatisch neu', 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Nach erfolgreicher Konfiguration startet Gerät automatisch neu',
'deviceConfig.audioPlaybackError': 'Audio-Wiedergabe-Fehler', 'deviceConfig.audioPlaybackError': 'Audio-Wiedergabe-Fehler',
'deviceConfig.playbackFailed': 'Wiedergabe fehlgeschlagen', 'deviceConfig.playbackFailed': 'Wiedergabe fehlgeschlagen',
// Voiceprint page
'voiceprint.audioNotExist': 'Audio existiert nicht',
'voiceprint.getAudioFailed': 'Audio konnte nicht abgerufen werden',
'voiceprint.audioPlayFailed': 'Audio-Wiedergabe fehlgeschlagen',
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': 'Login', 'login.navigationTitle': 'Login',
'login.fetchConfigError': 'Failed to fetch configuration:', 'login.fetchConfigError': 'Failed to fetch configuration:',
'login.selectLanguage': 'Select Language', 'login.selectLanguage': 'Select Language',
'login.selectLanguageTip': '中文', 'login.selectLanguageTip': 'En',
'login.welcomeBack': 'Welcome Back', 'login.welcomeBack': 'Welcome Back',
'login.pleaseLogin': 'Please log in to your account', 'login.pleaseLogin': 'Please log in to your account',
'login.enterUsername': 'Please enter username', 'login.enterUsername': 'Please enter username',
@ -371,7 +371,7 @@ export default {
'agent.tools.mcpAccessPoint': 'MCP Access Point', 'agent.tools.mcpAccessPoint': 'MCP Access Point',
'agent.tools.copy': 'Copy', 'agent.tools.copy': 'Copy',
'agent.tools.noTools': 'No tools available', 'agent.tools.noTools': 'No tools available',
'agent.tools.parameterConfig': 'Parameter Configuration', 'agent.tools.parameterConfig': 'Param Config',
'agent.tools.noParamsNeeded': 'No parameters needed', 'agent.tools.noParamsNeeded': 'No parameters needed',
'agent.tools.pleaseInput': 'Please input', 'agent.tools.pleaseInput': 'Please input',
'agent.tools.inputOneItemPerLine': 'Input one item per line', 'agent.tools.inputOneItemPerLine': 'Input one item per line',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': 'After successful configuration, device will automatically restart', 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'After successful configuration, device will automatically restart',
'deviceConfig.audioPlaybackError': 'Audio playback error', 'deviceConfig.audioPlaybackError': 'Audio playback error',
'deviceConfig.playbackFailed': 'Playback failed', 'deviceConfig.playbackFailed': 'Playback failed',
// Voiceprint page
'voiceprint.audioNotExist': 'Audio does not exist',
'voiceprint.getAudioFailed': 'Failed to get audio',
'voiceprint.audioPlayFailed': 'Audio playback failed',
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': 'Entrar', 'login.navigationTitle': 'Entrar',
'login.fetchConfigError': 'Falha ao buscar configuração:', 'login.fetchConfigError': 'Falha ao buscar configuração:',
'login.selectLanguage': 'Selecionar Idioma', 'login.selectLanguage': 'Selecionar Idioma',
'login.selectLanguageTip': '中文', 'login.selectLanguageTip': 'Pt',
'login.welcomeBack': 'Bem-vindo de Volta', 'login.welcomeBack': 'Bem-vindo de Volta',
'login.pleaseLogin': 'Por favor, entre na sua conta', 'login.pleaseLogin': 'Por favor, entre na sua conta',
'login.enterUsername': 'Por favor, insira o nome de usuário', 'login.enterUsername': 'Por favor, insira o nome de usuário',
@ -371,7 +371,7 @@ export default {
'agent.tools.mcpAccessPoint': 'Ponto de Acesso MCP', 'agent.tools.mcpAccessPoint': 'Ponto de Acesso MCP',
'agent.tools.copy': 'Copiar', 'agent.tools.copy': 'Copiar',
'agent.tools.noTools': 'Nenhuma ferramenta disponível', 'agent.tools.noTools': 'Nenhuma ferramenta disponível',
'agent.tools.parameterConfig': 'Configuração de Parâmetros', 'agent.tools.parameterConfig': 'Configuração',
'agent.tools.noParamsNeeded': 'Nenhum parâmetro necessário', 'agent.tools.noParamsNeeded': 'Nenhum parâmetro necessário',
'agent.tools.pleaseInput': 'Por favor, insira', 'agent.tools.pleaseInput': 'Por favor, insira',
'agent.tools.inputOneItemPerLine': 'Insira um item por linha', 'agent.tools.inputOneItemPerLine': 'Insira um item por linha',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Após a configuração bem-sucedida, o dispositivo reiniciará automaticamente', 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Após a configuração bem-sucedida, o dispositivo reiniciará automaticamente',
'deviceConfig.audioPlaybackError': 'Erro na reprodução de áudio', 'deviceConfig.audioPlaybackError': 'Erro na reprodução de áudio',
'deviceConfig.playbackFailed': 'Falha na reprodução', 'deviceConfig.playbackFailed': 'Falha na reprodução',
// Voiceprint page
'voiceprint.audioNotExist': 'O áudio não existe',
'voiceprint.getAudioFailed': 'Falha ao obter áudio',
'voiceprint.audioPlayFailed': 'Falha na reprodução de áudio',
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': 'Đăng nhập', 'login.navigationTitle': 'Đăng nhập',
'login.fetchConfigError': 'Không thể tải cấu hình:', 'login.fetchConfigError': 'Không thể tải cấu hình:',
'login.selectLanguage': 'Chọn ngôn ngữ', 'login.selectLanguage': 'Chọn ngôn ngữ',
'login.selectLanguageTip': 'de', 'login.selectLanguageTip': 'Vi',
'login.welcomeBack': 'Chào mừng trở lại', 'login.welcomeBack': 'Chào mừng trở lại',
'login.pleaseLogin': 'Vui lòng đăng nhập vào tài khoản của bạn', 'login.pleaseLogin': 'Vui lòng đăng nhập vào tài khoản của bạn',
'login.enterUsername': 'Vui lòng nhập tên đăng nhập', 'login.enterUsername': 'Vui lòng nhập tên đăng nhập',
@ -371,7 +371,7 @@ export default {
'agent.tools.mcpAccessPoint': 'Điểm truy cập MCP', 'agent.tools.mcpAccessPoint': 'Điểm truy cập MCP',
'agent.tools.copy': 'Sao chép', 'agent.tools.copy': 'Sao chép',
'agent.tools.noTools': 'Không có công cụ nào', 'agent.tools.noTools': 'Không có công cụ nào',
'agent.tools.parameterConfig': 'Cấu hình tham số', 'agent.tools.parameterConfig': 'Cấu hình',
'agent.tools.noParamsNeeded': 'Không cần tham số', 'agent.tools.noParamsNeeded': 'Không cần tham số',
'agent.tools.pleaseInput': 'Vui lòng nhập', 'agent.tools.pleaseInput': 'Vui lòng nhập',
'agent.tools.inputOneItemPerLine': 'Nhập một mục mỗi dòng', 'agent.tools.inputOneItemPerLine': 'Nhập một mục mỗi dòng',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Sau khi cấu hình thành công, thiết bị sẽ tự động khởi động lại', 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Sau khi cấu hình thành công, thiết bị sẽ tự động khởi động lại',
'deviceConfig.audioPlaybackError': 'Lỗi phát âm thanh', 'deviceConfig.audioPlaybackError': 'Lỗi phát âm thanh',
'deviceConfig.playbackFailed': 'Phát thất bại', 'deviceConfig.playbackFailed': 'Phát thất bại',
// Voiceprint page
'voiceprint.audioNotExist': 'Âm thanh không tồn tại',
'voiceprint.getAudioFailed': 'Không thể lấy âm thanh',
'voiceprint.audioPlayFailed': 'Phát âm thanh thất bại',
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': '登录', 'login.navigationTitle': '登录',
'login.fetchConfigError': '获取配置失败:', 'login.fetchConfigError': '获取配置失败:',
'login.selectLanguage': '选择语言', 'login.selectLanguage': '选择语言',
'login.selectLanguageTip': 'En', 'login.selectLanguageTip': '中文',
'login.welcomeBack': '欢迎回来', 'login.welcomeBack': '欢迎回来',
'login.pleaseLogin': '请登录您的账户', 'login.pleaseLogin': '请登录您的账户',
'login.enterUsername': '请输入用户名', 'login.enterUsername': '请输入用户名',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': '配网成功后设备将自动重启', 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配网成功后设备将自动重启',
'deviceConfig.audioPlaybackError': '音频播放错误', 'deviceConfig.audioPlaybackError': '音频播放错误',
'deviceConfig.playbackFailed': '播放失败', 'deviceConfig.playbackFailed': '播放失败',
// Voiceprint page
'voiceprint.audioNotExist': '该音频不存在',
'voiceprint.getAudioFailed': '获取音频失败',
'voiceprint.audioPlayFailed': '音频播放失败',
} }

View file

@ -11,7 +11,7 @@ export default {
'login.navigationTitle': '登錄', 'login.navigationTitle': '登錄',
'login.fetchConfigError': '獲取配置失敗:', 'login.fetchConfigError': '獲取配置失敗:',
'login.selectLanguage': '選擇語言', 'login.selectLanguage': '選擇語言',
'login.selectLanguageTip': '简体', 'login.selectLanguageTip': '繁體',
'login.welcomeBack': '歡迎回來', 'login.welcomeBack': '歡迎回來',
'login.pleaseLogin': '請登錄您的賬戶', 'login.pleaseLogin': '請登錄您的賬戶',
'login.enterUsername': '請輸入用戶名', 'login.enterUsername': '請輸入用戶名',
@ -492,4 +492,9 @@ export default {
'deviceConfig.afterConfigSuccessDeviceWillRestart': '配網成功後設備將自動重啟', 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配網成功後設備將自動重啟',
'deviceConfig.audioPlaybackError': '音頻播放錯誤', 'deviceConfig.audioPlaybackError': '音頻播放錯誤',
'deviceConfig.playbackFailed': '播放失敗', 'deviceConfig.playbackFailed': '播放失敗',
// Voiceprint page
'voiceprint.audioNotExist': '該音頻不存在',
'voiceprint.getAudioFailed': '獲取音頻失敗',
'voiceprint.audioPlayFailed': '音頻播放失敗',
} }

View file

@ -110,6 +110,10 @@ const inputVisible = ref(false)
const languageOptions = ref([]) const languageOptions = ref([])
const isVisibleReport = ref(false) const isVisibleReport = ref(false)
// 音频播放相关
const audioRef = ref<UniApp.InnerAudioContext | null>(null)
const playingVoiceId = ref<string>('')
// 使用插件store // 使用插件store
const pluginStore = usePluginStore() const pluginStore = usePluginStore()
const speedPitchStore = useSpeedPitch() const speedPitchStore = useSpeedPitch()
@ -422,15 +426,24 @@ function selectRoleTemplate(templateId: string) {
selectedTemplateId.value = templateId selectedTemplateId.value = templateId
const template = roleTemplates.value.find(t => t.id === templateId) const template = roleTemplates.value.find(t => t.id === templateId)
if (template) { if (template) {
formData.value.systemPrompt = template.systemPrompt formData.value = {
formData.value.vadModelId = template.vadModelId ...formData.value,
formData.value.asrModelId = template.asrModelId systemPrompt: template.systemPrompt || formData.value.systemPrompt,
formData.value.llmModelId = template.llmModelId vadModelId: template.vadModelId || formData.value.vadModelId,
formData.value.vllmModelId = template.vllmModelId asrModelId: template.asrModelId || formData.value.asrModelId,
formData.value.intentModelId = template.intentModelId llmModelId: template.llmModelId || formData.value.llmModelId,
formData.value.memModelId = template.memModelId vllmModelId: template.vllmModelId || formData.value.vllmModelId,
formData.value.ttsModelId = template.ttsModelId intentModelId: template.intentModelId || formData.value.intentModelId,
formData.value.ttsVoiceId = template.ttsVoiceId memModelId: template.memModelId || formData.value.memModelId,
ttsModelId: template.ttsModelId || formData.value.ttsModelId,
ttsVoiceId: template.ttsVoiceId || formData.value.ttsVoiceId,
agentName: template.agentName || formData.value.agentName,
chatHistoryConf: template.chatHistoryConf || formData.value.chatHistoryConf,
summaryMemory: template.summaryMemory || formData.value.summaryMemory,
langCode: template.langCode || formData.value.langCode,
}
fetchAllLanguag(template.ttsModelId || formData.value.ttsModelId)
updateDisplayNames()
} }
} }
@ -493,6 +506,57 @@ async function onPickerConfirm(type: string, value: any, name: string) {
// 选择器取消 // 选择器取消
function onPickerCancel(type: string) { function onPickerCancel(type: string) {
pickerShow.value[type] = false pickerShow.value[type] = false
// 关闭时停止播放
if (type === 'voiceprint') {
stopAudio()
}
}
// 播放音频
function playAudio(voiceDemo: string, voiceId: string, event: Event) {
event.stopPropagation() // 阻止事件冒泡,防止关闭下拉框
if (!voiceDemo) {
return
}
// 如果正在播放同一个音频,则停止
if (playingVoiceId.value === voiceId) {
stopAudio()
return
}
// 停止之前的音频
stopAudio()
// 创建新的音频实例
audioRef.value = uni.createInnerAudioContext()
audioRef.value.src = voiceDemo
playingVoiceId.value = voiceId
// 监听播放结束
audioRef.value.onEnded(() => {
playingVoiceId.value = ''
})
// 监听播放错误
audioRef.value.onError(() => {
toast.error('音频播放失败')
playingVoiceId.value = ''
})
// 播放音频
audioRef.value.play()
}
// 停止音频
function stopAudio() {
if (audioRef.value) {
audioRef.value.stop()
audioRef.value.destroy()
audioRef.value = null
}
playingVoiceId.value = ''
} }
// 获取模型显示名称 // 获取模型显示名称
@ -942,16 +1006,35 @@ onMounted(async () => {
<wd-action-sheet <wd-action-sheet
v-model="pickerShow.tts" v-model="pickerShow.tts"
:actions="modelOptions.TTS && modelOptions.TTS.map(item => ({ name: item.modelName, value: item.id }))" :actions="modelOptions.TTS && modelOptions.TTS.map(item => ({ name: item.modelName, value: item.id }))"
class="custom-sheet-tts"
@close="onPickerCancel('tts')" @close="onPickerCancel('tts')"
@select="({ item }) => onPickerConfirm('tts', item.value, item.name)" @select="({ item }) => onPickerConfirm('tts', item.value, item.name)"
/> />
<wd-action-sheet <!-- 自定义语音选择弹出层 -->
v-model="pickerShow.voiceprint" <wd-popup v-model="pickerShow.voiceprint" class="custom-popup" position="bottom" @close="onPickerCancel('voiceprint')">
:actions="voiceOptions" <view class="overflow-hidden rounded-[20rpx] bg-white pb-[20rpx] pt-[20rpx]">
@close="onPickerCancel('voiceprint')" <view class="max-h-[600rpx] overflow-y-auto">
@select="({ item }) => onPickerConfirm('voiceprint', item.value, item.name)" <view
/> v-for="voice in voiceOptions"
:key="voice.value"
class="flex items-center justify-between border-b border-[#f5f5f5] p-[32rpx] transition-all active:bg-[#f5f7fb]"
@click="onPickerConfirm('voiceprint', voice.value, voice.name)"
>
<text :class="`flex-1 text-[28rpx] text-[#232338] ${(voice.voiceDemo || voice.voice_demo) ? '' : 'text-center'}`">
{{ voice.name }}
</text>
<view v-if="voice.voiceDemo || voice.voice_demo" class="ml-[20rpx]" @click.stop="playAudio(voice.voiceDemo || voice.voice_demo, voice.value, $event)">
<wd-icon
:name="playingVoiceId === voice.value ? 'pause-circle' : 'play-circle'"
size="24px"
:custom-class="playingVoiceId === voice.value ? 'text-[#336cff]' : 'text-[#9d9ea3]'"
/>
</view>
</view>
</view>
</view>
</wd-popup>
<wd-action-sheet <wd-action-sheet
v-model="pickerShow.language" v-model="pickerShow.language"
:actions="languageOptions" :actions="languageOptions"
@ -971,4 +1054,19 @@ onMounted(async () => {
::v-deep .wd-tag__close { ::v-deep .wd-tag__close {
color: #336cff !important; color: #336cff !important;
} }
::v-deep .custom-popup {
.wd-popup {
padding: 20rpx !important;
background: transparent !important;
}
}
::v-deep .custom-sheet-tts {
.wd-action-sheet {
padding: 8px 0 !important;
overflow: hidden;
}
.wd-action-sheet__actions {
padding: 0 !important;
}
}
</style> </style>

View file

@ -51,17 +51,18 @@ const currentTab = ref('agent-config')
// 刷新和加载状态 // 刷新和加载状态
const refreshing = ref(false) const refreshing = ref(false)
const refresherEnabled = ref(false)
// 计算是否启用下拉刷新(角色编辑页面不启用)
const refresherEnabled = computed(() => {
return currentTab.value !== 'agent-config'
})
// 子组件引用 // 子组件引用
const deviceRef = ref() const deviceRef = ref()
const chatRef = ref() const chatRef = ref()
const voiceprintRef = ref() const voiceprintRef = ref()
// 更新刷新器状态
function updateRefresherEnabled(value: boolean) {
refresherEnabled.value = value
}
// Tab 配置 // Tab 配置
const tabList = [ const tabList = [
{ {
@ -144,6 +145,10 @@ async function onLoadMore() {
} }
} }
watch(() => currentTab.value, (newTab) => {
updateRefresherEnabled(newTab !== 'agent-config')
})
// 接收页面参数 // 接收页面参数
onLoad((options) => { onLoad((options) => {
if (options?.agentId) { if (options?.agentId) {
@ -204,6 +209,7 @@ onMounted(async () => {
v-else-if="currentTab === 'voiceprint-management'" v-else-if="currentTab === 'voiceprint-management'"
ref="voiceprintRef" ref="voiceprintRef"
:agent-id="currentAgentId" :agent-id="currentAgentId"
@update-refresher-enabled="updateRefresherEnabled"
/> />
</view> </view>
</scroll-view> </scroll-view>

View file

@ -70,6 +70,7 @@ async function mergeFunctions() {
uni.setStorageSync(`cachedMcpAddress_${agentId.value}`, address) uni.setStorageSync(`cachedMcpAddress_${agentId.value}`, address)
} }
catch (error) { catch (error) {
mcpAddress.value = error
console.error('获取MCP地址失败:', error) console.error('获取MCP地址失败:', error)
} }
@ -310,7 +311,7 @@ onMounted(async () => {
v-if="notSelectedList.length === 0" v-if="notSelectedList.length === 0"
class="h-[400rpx] flex items-center justify-center" class="h-[400rpx] flex items-center justify-center"
> >
<wd-status-tip image="content" tip="{{ t('agent.tools.noMorePlugins') }}" /> <wd-status-tip image="content" :tip="t('agent.tools.noMorePlugins')" />
</view> </view>
<view v-else class="p-[20rpx] space-y-[20rpx]"> <view v-else class="p-[20rpx] space-y-[20rpx]">
<view <view
@ -346,7 +347,7 @@ onMounted(async () => {
v-if="selectedList.length === 0" v-if="selectedList.length === 0"
class="h-[400rpx] flex items-center justify-center" class="h-[400rpx] flex items-center justify-center"
> >
<wd-status-tip image="content" tip="{{ t('agent.tools.pleaseSelectPlugin') }}" /> <wd-status-tip image="content" :tip="t('agent.tools.pleaseSelectPlugin')" />
</view> </view>
<view v-else class="p-[20rpx] space-y-[20rpx]"> <view v-else class="p-[20rpx] space-y-[20rpx]">
<view <view
@ -444,7 +445,7 @@ onMounted(async () => {
<!-- 参数编辑弹窗 --> <!-- 参数编辑弹窗 -->
<wd-action-sheet <wd-action-sheet
v-model="showParamDialog" v-model="showParamDialog"
:title="`${t('agent.tools.paramConfiguration')} - ${currentFunction?.name || ''}`" :title="`${t('agent.tools.parameterConfig')} - ${currentFunction?.name || ''}`"
custom-header-class="h-[75vh]" custom-header-class="h-[75vh]"
@close="closeParamEdit" @close="closeParamEdit"
> >
@ -585,3 +586,9 @@ onMounted(async () => {
</wd-action-sheet> </wd-action-sheet>
</view> </view>
</template> </template>
<style scoped lang="scss">
::v-deep .wd-action-sheet__header {
padding-right: 30rpx;
}
</style>

View file

@ -15,7 +15,7 @@ import { computed, onMounted, ref } from 'vue'
import { login } from '@/api/auth' import { login } from '@/api/auth'
// 导入国际化相关功能 // 导入国际化相关功能
import { changeLanguage, getCurrentLanguage, getSupportedLanguages, initI18n, t } from '@/i18n' import { changeLanguage, getCurrentLanguage, getSupportedLanguages, initI18n, t } from '@/i18n'
import { useConfigStore } from '@/store' import { useConfigStore, useUserStore } from '@/store'
// 导入SM2加密工具 // 导入SM2加密工具
import { getEnvBaseUrl, sm2Encrypt } from '@/utils' import { getEnvBaseUrl, sm2Encrypt } from '@/utils'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
@ -61,6 +61,7 @@ const loginType = ref<'username' | 'mobile'>('username')
// 获取配置store // 获取配置store
const configStore = useConfigStore() const configStore = useConfigStore()
const userStore = useUserStore()
// 区号选择相关 // 区号选择相关
const showAreaCodeSheet = ref(false) const showAreaCodeSheet = ref(false)
@ -227,6 +228,7 @@ async function handleLogin() {
const response = await login(loginData) const response = await login(loginData)
// 存储token // 存储token
uni.setStorageSync('token', JSON.stringify(response)) uni.setStorageSync('token', JSON.stringify(response))
await userStore.getUserInfo()
toast.success(t('message.loginSuccess')) toast.success(t('message.loginSuccess'))
@ -581,7 +583,6 @@ onMounted(async () => {
.input-wrapper { .input-wrapper {
position: relative; position: relative;
background: #f8f9fa;
border-radius: 16rpx; border-radius: 16rpx;
padding: 20rpx 16rpx; padding: 20rpx 16rpx;
border: 2rpx solid #e9ecef; border: 2rpx solid #e9ecef;

View file

@ -127,10 +127,10 @@ async function saveServerBaseUrl() {
uni.request({ uni.request({
url: `${getEnvBaseUrl()}/user/pub-config`, url: `${getEnvBaseUrl()}/user/pub-config`,
method: 'GET', method: 'GET',
success: (res) => { success: (res: any) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
configStore.setConfig(res.data.data) configStore.setConfig(res.data.data)
uni.setStorageSync('config', res.data.data.sm2PubKey) uni.setStorageSync('config', res.data.data)
} }
}, },
fail: (err) => { fail: (err) => {
@ -165,6 +165,7 @@ const showLanguageSheet = ref(false)
function handleLanguageChange(lang: Language) { function handleLanguageChange(lang: Language) {
changeLanguage(lang) changeLanguage(lang)
showLanguageSheet.value = false showLanguageSheet.value = false
currentLanguage.value = lang
toast.success(t('settings.languageChanged')) toast.success(t('settings.languageChanged'))
} }
@ -225,7 +226,8 @@ function clearAllCacheAfterUrlChange() {
// 重新获取缓存信息 // 重新获取缓存信息
getCacheInfo() getCacheInfo()
} catch (error) { }
catch (error) {
console.error('清除缓存失败:', error) console.error('清除缓存失败:', error)
} }
} }
@ -250,7 +252,8 @@ async function clearCache() {
} }
}, },
}) })
} catch (error) { }
catch (error) {
console.error('清除缓存失败:', error) console.error('清除缓存失败:', error)
toast.error(t('settings.clearCacheFailed')) toast.error(t('settings.clearCacheFailed'))
} }
@ -262,7 +265,7 @@ function showAbout() {
title: t('settings.aboutApp', { appName: import.meta.env.VITE_APP_TITLE }), title: t('settings.aboutApp', { appName: import.meta.env.VITE_APP_TITLE }),
content: t('settings.aboutContent', { content: t('settings.aboutContent', {
appName: import.meta.env.VITE_APP_TITLE, appName: import.meta.env.VITE_APP_TITLE,
version: '0.9.1' version: '0.9.2'
}), }),
showCancel: false, showCancel: false,
confirmText: t('common.confirm'), confirmText: t('common.confirm'),
@ -278,7 +281,7 @@ onMounted(async () => {
// 动态设置导航栏标题为国际化文本 // 动态设置导航栏标题为国际化文本
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: t('settings.title') title: t('settings.title'),
}) })
}) })
</script> </script>
@ -296,8 +299,10 @@ onMounted(async () => {
</text> </text>
</view> </view>
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx] overflow-hidden" <view
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"> class="overflow-hidden border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
>
<view class="mb-[24rpx]"> <view class="mb-[24rpx]">
<text class="text-[28rpx] text-[#232338] font-semibold"> <text class="text-[28rpx] text-[#232338] font-semibold">
{{ t('settings.serverApiUrl') }} {{ t('settings.serverApiUrl') }}
@ -308,11 +313,13 @@ onMounted(async () => {
</view> </view>
<view class="mb-[24rpx]"> <view class="mb-[24rpx]">
<view class="w-full rounded-[16rpx] border border-[#eeeeee] bg-[#f5f7fb] overflow-hidden"> <view class="w-full overflow-hidden border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb]">
<wd-input v-model="baseUrlInput" type="text" clearable :maxlength="200" <wd-input
v-model="baseUrlInput" type="text" clearable :maxlength="200"
:placeholder="t('settings.enterServerUrl')" :placeholder="t('settings.enterServerUrl')"
custom-class="!border-none !bg-transparent h-[64rpx] px-[24rpx] items-center" custom-class="!border-none !bg-transparent h-[64rpx] px-[24rpx] items-center"
input-class="text-[28rpx] text-[#232338]" @input="validateUrl" @blur="validateUrl" /> input-class="text-[28rpx] text-[#232338]" @input="validateUrl" @blur="validateUrl"
/>
</view> </view>
<text v-if="urlError" class="mt-[8rpx] block text-[24rpx] text-[#ff4d4f]"> <text v-if="urlError" class="mt-[8rpx] block text-[24rpx] text-[#ff4d4f]">
{{ urlError }} {{ urlError }}
@ -320,14 +327,18 @@ onMounted(async () => {
</view> </view>
<view class="flex gap-[16rpx]"> <view class="flex gap-[16rpx]">
<wd-button type="primary" <wd-button
type="primary"
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-[#336cff] border-none shadow-[0_4rpx_16rpx_rgba(51,108,255,0.3)] active:shadow-[0_2rpx_8rpx_rgba(51,108,255,0.4)] active:scale-98" custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-[#336cff] border-none shadow-[0_4rpx_16rpx_rgba(51,108,255,0.3)] active:shadow-[0_2rpx_8rpx_rgba(51,108,255,0.4)] active:scale-98"
@click="saveServerBaseUrl"> @click="saveServerBaseUrl"
>
{{ t('settings.saveSettings') }} {{ t('settings.saveSettings') }}
</wd-button> </wd-button>
<wd-button type="default" <wd-button
type="default"
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-white border-[#eeeeee] text-[#65686f] active:bg-[#f5f7fb]" custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-white border-[#eeeeee] text-[#65686f] active:bg-[#f5f7fb]"
@click="resetServerBaseUrl"> @click="resetServerBaseUrl"
>
{{ t('settings.resetDefault') }} {{ t('settings.resetDefault') }}
</wd-button> </wd-button>
</view> </view>
@ -342,12 +353,15 @@ onMounted(async () => {
</text> </text>
</view> </view>
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]" <view
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"> class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
>
<view class="space-y-[16rpx]"> <view class="space-y-[16rpx]">
<!-- 缓存信息展示,参考插件样式 --> <!-- 缓存信息展示,参考插件样式 -->
<view <view
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"> class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
>
<view> <view>
<text class="text-[28rpx] text-[#232338] font-medium"> <text class="text-[28rpx] text-[#232338] font-medium">
{{ t('settings.totalCacheSize') }} {{ t('settings.totalCacheSize') }}
@ -363,7 +377,8 @@ onMounted(async () => {
<!-- 清除缓存按钮,参考插件编辑按钮样式 --> <!-- 清除缓存按钮,参考插件编辑按钮样式 -->
<view <view
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx]"> class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx]"
>
<view> <view>
<text class="text-[28rpx] text-[#232338] font-medium"> <text class="text-[28rpx] text-[#232338] font-medium">
{{ t('settings.cacheClear') }} {{ t('settings.cacheClear') }}
@ -374,7 +389,8 @@ onMounted(async () => {
</view> </view>
<view <view
class="cursor-pointer rounded-[24rpx] bg-[rgba(255,107,107,0.1)] px-[28rpx] py-[16rpx] text-[24rpx] text-[#ff6b6b] font-semibold transition-all duration-300 active:scale-95 active:bg-[#ff6b6b] active:text-white" class="cursor-pointer rounded-[24rpx] bg-[rgba(255,107,107,0.1)] px-[28rpx] py-[16rpx] text-[24rpx] text-[#ff6b6b] font-semibold transition-all duration-300 active:scale-95 active:bg-[#ff6b6b] active:text-white"
@click="clearCache"> @click="clearCache"
>
{{ t('settings.clearCache') }} {{ t('settings.clearCache') }}
</view> </view>
</view> </view>
@ -390,11 +406,14 @@ onMounted(async () => {
</text> </text>
</view> </view>
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]" <view
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"> class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
>
<view <view
class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]" class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
@click="showAbout"> @click="showAbout"
>
<view> <view>
<text class="text-[28rpx] text-[#232338] font-medium"> <text class="text-[28rpx] text-[#232338] font-medium">
{{ t('settings.aboutUs') }} {{ t('settings.aboutUs') }}
@ -416,11 +435,14 @@ onMounted(async () => {
</text> </text>
</view> </view>
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]" <view
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"> class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
>
<view <view
class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]" class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
@click="showLanguageSheet = true"> @click="showLanguageSheet = true"
>
<view> <view>
<text class="text-[32rpx] text-[#232338] font-medium"> <text class="text-[32rpx] text-[#232338] font-medium">
{{ t('settings.language') }} {{ t('settings.language') }}
@ -430,8 +452,8 @@ onMounted(async () => {
</text> </text>
</view> </view>
<view class="flex items-center"> <view class="flex items-center">
<text class="text-[32rpx] text-[#9d9ea3] font-semibold mr-[16rpx]"> <text class="mr-[16rpx] text-[32rpx] text-[#9d9ea3] font-semibold">
{{supportedLanguages.find(lang => lang.code === currentLanguage)?.name}} {{ supportedLanguages.find(lang => lang.code === currentLanguage)?.name }}
</text> </text>
<wd-icon name="arrow-right" custom-class="text-[32rpx] text-[#9d9ea3]" /> <wd-icon name="arrow-right" custom-class="text-[32rpx] text-[#9d9ea3]" />
</view> </view>
@ -443,8 +465,10 @@ onMounted(async () => {
<wd-action-sheet v-model="showLanguageSheet" :title="t('settings.selectLanguage')" :close-on-click-modal="true"> <wd-action-sheet v-model="showLanguageSheet" :title="t('settings.selectLanguage')" :close-on-click-modal="true">
<view class="language-sheet"> <view class="language-sheet">
<scroll-view scroll-y class="language-list"> <scroll-view scroll-y class="language-list">
<view v-for="lang in supportedLanguages" :key="lang.code" class="language-item" <view
@click="handleLanguageChange(lang.code)"> v-for="lang in supportedLanguages" :key="lang.code" class="language-item"
@click="handleLanguageChange(lang.code)"
>
<text class="language-name"> <text class="language-name">
{{ lang.name }} {{ lang.name }}
</text> </text>

View file

@ -3,22 +3,25 @@ import type { ChatHistory, CreateSpeakerData, VoicePrint } from '@/api/voiceprin
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref } from 'vue'
import { useMessage } from 'wot-design-uni' import { useMessage } from 'wot-design-uni'
import { useToast } from 'wot-design-uni/components/wd-toast' import { useToast } from 'wot-design-uni/components/wd-toast'
import { createVoicePrint, deleteVoicePrint, getChatHistory, getVoicePrintList, updateVoicePrint } from '@/api/voiceprint' import { createVoicePrint, deleteVoicePrint, getAudioDownloadId, getChatHistory, getVoicePrintList, updateVoicePrint } from '@/api/voiceprint'
import { t } from '@/i18n' import { t } from '@/i18n'
import { getEnvBaseUrl } from '@/utils'
defineOptions({ defineOptions({
name: 'VoicePrintManage', name: 'VoicePrintManage',
}) })
const props = withDefaults(defineProps<Props>(), {
agentId: 'default',
})
const emits = defineEmits(['update-refresher-enabled'])
// 接收props // 接收props
interface Props { interface Props {
agentId?: string agentId?: string
} }
const props = withDefaults(defineProps<Props>(), {
agentId: 'default'
})
// 获取屏幕边界到安全区域距离 // 获取屏幕边界到安全区域距离
let safeAreaInsets: any let safeAreaInsets: any
let systemInfo: any let systemInfo: any
@ -50,6 +53,10 @@ const chatHistoryActions = ref<any[]>([])
const swipeStates = ref<Record<string, 'left' | 'close' | 'right'>>({}) const swipeStates = ref<Record<string, 'left' | 'close' | 'right'>>({})
const loading = ref(false) const loading = ref(false)
// 音频播放相关
const audioRef = ref<UniApp.InnerAudioContext | null>(null)
const playingAudioId = ref<string>('')
// 使用传入的智能体ID // 使用传入的智能体ID
const currentAgentId = computed(() => { const currentAgentId = computed(() => {
return props.agentId return props.agentId
@ -157,11 +164,13 @@ function openAddDialog() {
introduce: '', introduce: '',
} }
showAddDialog.value = true showAddDialog.value = true
} catch (error: any) { }
catch (error: any) {
// 捕捉声纹接口未配置错误 // 捕捉声纹接口未配置错误
if (error.message && error.message.includes('请求错误[10054]')) { if (error.message && error.message.includes('请求错误[10054]')) {
toast.error(t('voiceprint.voiceprintInterfaceNotConfigured')) toast.error(t('voiceprint.voiceprintInterfaceNotConfigured'))
} else { }
else {
// 其他错误,继续打开弹窗 // 其他错误,继续打开弹窗
addForm.value = { addForm.value = {
agentId: currentAgentId.value, agentId: currentAgentId.value,
@ -202,6 +211,11 @@ function selectAudioId({ item }: { item: any }) {
showChatHistoryDialog.value = false showChatHistoryDialog.value = false
} }
// 点击选择
function handleItemClick(item: any) {
selectAudioId({ item })
}
// 提交添加说话人 // 提交添加说话人
async function submitAdd() { async function submitAdd() {
if (!addForm.value.sourceName.trim()) { if (!addForm.value.sourceName.trim()) {
@ -274,6 +288,82 @@ async function handleDelete(id: string) {
}) })
} }
// 播放音频
async function playAudio(audioId: string, event: Event) {
event.stopPropagation() // 阻止事件冒泡,防止关闭下拉框
if (!audioId) {
toast.warning(t('voiceprint.audioNotExist'))
return
}
// 如果正在播放同一个音频,则停止
if (playingAudioId.value === audioId) {
stopAudio()
return
}
// 停止之前的音频
stopAudio()
try {
// 先获取音频下载ID
playingAudioId.value = audioId
const downloadId = await getAudioDownloadId(audioId)
if (!downloadId) {
toast.error(t('voiceprint.getAudioFailed'))
playingAudioId.value = ''
return
}
// 获取baseURL
const baseURL = getEnvBaseUrl()
const audioUrl = `${baseURL}/agent/play/${downloadId}`
// 创建新的音频实例
audioRef.value = uni.createInnerAudioContext()
audioRef.value.src = audioUrl
audioRef.value.autoplay = true
// 监听播放结束
audioRef.value.onEnded(() => {
playingAudioId.value = ''
})
// 监听播放错误
audioRef.value.onError((error) => {
console.error('音频播放错误:', error)
toast.error(t('voiceprint.audioPlayFailed'))
playingAudioId.value = ''
})
}
catch (error) {
console.error('播放音频失败:', error)
toast.error(t('voiceprint.audioPlayFailed'))
playingAudioId.value = ''
}
}
// 停止音频
function stopAudio() {
if (audioRef.value) {
audioRef.value.stop()
audioRef.value.destroy()
audioRef.value = null
}
playingAudioId.value = ''
}
watch(() => [showAddDialog.value, showEditDialog.value], (newValues) => {
if (newValues.some((value: boolean) => value)) {
emits('update-refresher-enabled', false)
}
else {
emits('update-refresher-enabled', true)
}
})
onMounted(async () => { onMounted(async () => {
// 智能体已简化为默认 // 智能体已简化为默认
@ -282,6 +372,8 @@ onMounted(async () => {
// 暴露方法给父组件 // 暴露方法给父组件
defineExpose({ defineExpose({
showAddDialog,
showEditDialog,
refresh, refresh,
}) })
</script> </script>
@ -349,7 +441,7 @@ defineExpose({
</view> </view>
<!-- 浮动操作按钮 --> <!-- 浮动操作按钮 -->
<wd-fab type="primary" size="small" :draggable="true" :expandable="false" @click="openAddDialog"> <wd-fab custom-style="z-index:10" type="primary" size="small" :draggable="true" :expandable="false" @click="openAddDialog">
<wd-icon name="add" /> <wd-icon name="add" />
</wd-fab> </wd-fab>
@ -359,21 +451,20 @@ defineExpose({
<!-- 添加说话人弹窗 --> <!-- 添加说话人弹窗 -->
<wd-popup <wd-popup
v-model="showAddDialog" position="center" custom-style="width: 90%; max-width: 400px; border-radius: 16px;" v-model="showAddDialog"
position="center"
custom-style="width: 90%; max-width: 400px; border-radius: 16px;"
safe-area-inset-bottom safe-area-inset-bottom
> >
<view> <view>
<view class="w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]">
<text class="w-full text-center text-[32rpx] text-[#232338] font-semibold">
{{ t('voiceprint.addSpeaker') }}
</text>
</view>
<view class="p-[32rpx]"> <view class="p-[32rpx]">
<!-- 声纹向量选择 --> <!-- 声纹向量选择 -->
<view class="mb-[32rpx]"> <view class="mb-[32rpx]">
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.voiceVector') }} <text class="text-red">
*
</text>
{{ t('voiceprint.voiceVector') }}
</text> </text>
<view <view
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]" class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
@ -392,7 +483,10 @@ defineExpose({
<!-- 姓名 --> <!-- 姓名 -->
<view class="mb-[32rpx]"> <view class="mb-[32rpx]">
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.name') }} <text class="text-red">
*
</text>
{{ t('voiceprint.name') }}
</text> </text>
<input <input
v-model="addForm.sourceName" v-model="addForm.sourceName"
@ -404,7 +498,10 @@ defineExpose({
<!-- 描述 --> <!-- 描述 -->
<view> <view>
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.description') }} <text class="text-red">
*
</text>
{{ t('voiceprint.description') }}
</text> </text>
<textarea <textarea
v-model="addForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')" v-model="addForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')"
@ -418,11 +515,11 @@ defineExpose({
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]"> <view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
<wd-button type="info" custom-class="flex-1" @click="showAddDialog = false"> <wd-button type="info" custom-class="flex-1" @click="showAddDialog = false">
{{ t('voiceprint.cancel') }} {{ t('voiceprint.cancel') }}
</wd-button> </wd-button>
<wd-button type="primary" custom-class="flex-1" @click="submitAdd"> <wd-button type="primary" custom-class="flex-1" @click="submitAdd">
{{ t('voiceprint.save') }} {{ t('voiceprint.save') }}
</wd-button> </wd-button>
</view> </view>
</view> </view>
</wd-popup> </wd-popup>
@ -433,7 +530,7 @@ defineExpose({
safe-area-inset-bottom safe-area-inset-bottom
> >
<view> <view>
<view class="w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]"> <view class="box-border w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]">
<text class="w-full text-center text-[32rpx] text-[#232338] font-semibold"> <text class="w-full text-center text-[32rpx] text-[#232338] font-semibold">
{{ t('voiceprint.editSpeaker') }} {{ t('voiceprint.editSpeaker') }}
</text> </text>
@ -443,7 +540,10 @@ defineExpose({
<!-- 声纹向量选择 --> <!-- 声纹向量选择 -->
<view class="mb-[32rpx]"> <view class="mb-[32rpx]">
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.voiceVector') }} <text class="text-red">
*
</text>
{{ t('voiceprint.voiceVector') }}
</text> </text>
<view <view
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]" class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
@ -462,7 +562,10 @@ defineExpose({
<!-- 姓名 --> <!-- 姓名 -->
<view class="mb-[32rpx]"> <view class="mb-[32rpx]">
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.name') }} <text class="text-red">
*
</text>
{{ t('voiceprint.name') }}
</text> </text>
<input <input
v-model="editForm.sourceName" v-model="editForm.sourceName"
@ -474,7 +577,10 @@ defineExpose({
<!-- 描述 --> <!-- 描述 -->
<view> <view>
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium"> <text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
* {{ t('voiceprint.description') }} <text class="text-red">
*
</text>
{{ t('voiceprint.description') }}
</text> </text>
<textarea <textarea
v-model="editForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')" v-model="editForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')"
@ -488,23 +594,42 @@ defineExpose({
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]"> <view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
<wd-button type="info" custom-class="flex-1" @click="showEditDialog = false"> <wd-button type="info" custom-class="flex-1" @click="showEditDialog = false">
{{ t('voiceprint.cancel') }} {{ t('voiceprint.cancel') }}
</wd-button> </wd-button>
<wd-button type="primary" custom-class="flex-1" @click="submitEdit"> <wd-button type="primary" custom-class="flex-1" @click="submitEdit">
{{ t('voiceprint.save') }} {{ t('voiceprint.save') }}
</wd-button> </wd-button>
</view> </view>
</view> </view>
</wd-popup> </wd-popup>
<!-- 语音对话记录选择动作面板 --> <!-- 自定义语音对话记录选择弹出层 -->
<wd-action-sheet <wd-popup v-model="showChatHistoryDialog" class="custom-popup" position="bottom" @close="stopAudio">
v-model="showChatHistoryDialog" :actions="chatHistoryActions" :title="t('voiceprint.selectVector')" <view class="rounded-[20rpx] bg-white pb-[20rpx] pt-[20rpx]">
@select="selectAudioId" <view class="max-h-[600rpx] overflow-y-auto rounded-[20rpx]">
/> <view
v-for="item in chatHistoryActions"
:key="item.audioId"
class="flex items-center justify-between border-b border-[#f5f5f5] p-[32rpx] transition-all active:bg-[#f5f7fb]"
@click="handleItemClick(item)"
>
<text class="flex-1 text-[28rpx] text-[#232338]">
{{ item.name }}
</text>
<view class="ml-[20rpx]" @click.stop="playAudio(item.audioId, $event)">
<wd-icon
:name="playingAudioId === item.audioId ? 'pause-circle' : 'play-circle'"
size="24px"
:custom-class="playingAudioId === item.audioId ? 'text-[#336cff]' : 'text-[#9d9ea3]'"
/>
</view>
</view>
</view>
</view>
</wd-popup>
</template> </template>
<style scoped> <style lang="scss" scoped>
.voiceprint-container { .voiceprint-container {
position: relative; position: relative;
} }
@ -523,14 +648,10 @@ defineExpose({
color: #666666; color: #666666;
} }
:deep(.wd-swipe-action) { ::v-deep .custom-popup {
border-radius: 20rpx; .wd-popup {
overflow: hidden; padding: 20rpx !important;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); background: transparent;
border: 1rpx solid #eeeeee; }
}
:deep(.flex-1) {
flex: 1;
} }
</style> </style>

View file

@ -19,7 +19,7 @@ const userInfoState: UserInfo & { avatar?: string, token?: string } = {
} }
export const useUserStore = defineStore( export const useUserStore = defineStore(
'user', 'userInfo',
() => { () => {
// 定义用户信息 // 定义用户信息
const userInfo = ref<UserInfo & { avatar?: string, token?: string }>({ ...userInfoState }) const userInfo = ref<UserInfo & { avatar?: string, token?: string }>({ ...userInfoState })
@ -51,16 +51,8 @@ export const useUserStore = defineStore(
*/ */
const getUserInfo = async () => { const getUserInfo = async () => {
const userData = await _getUserInfo() const userData = await _getUserInfo()
const authInfo = JSON.parse(uni.getStorageSync('token') || '{}') setUserInfo(userData)
const userInfoWithExtras = { return userData
...userData,
avatar: userInfoState.avatar,
token: authInfo.token || '',
}
setUserInfo(userInfoWithExtras)
uni.setStorageSync('userInfo', userInfoWithExtras)
// TODO 这里可以增加获取用户路由的方法 根据用户的角色动态生成路由
return userInfoWithExtras
} }
/** /**
* 退出登录 并 删除用户信息 * 退出登录 并 删除用户信息
@ -79,6 +71,12 @@ export const useUserStore = defineStore(
} }
}, },
{ {
persist: true, persist: {
key: 'userInfo',
serializer: {
serialize: state => JSON.stringify(state.userInfo),
deserialize: value => ({ userInfo: JSON.parse(value) }),
},
},
}, },
) )

View file

@ -1 +1,3 @@
VUE_APP_TITLE=智控台 VUE_APP_TITLE=智控台
VUE_APP_DESCRIPTION=是由华南理工大学刘思源教授团队研发的智能终端软硬件体系后端服务系统,专为xiaozhi-esp32开源硬件打造,具备多协议兼容、声纹识别、知识库管理等核心能力。
VUE_APP_KEYWORDS=xiaozhi-server,小智服务端,智控台,AI硬件,智能硬件,AI玩具,情感陪伴,聊天机器人,智能家居,车载机器人

View file

@ -5,6 +5,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="<%= process.env.VUE_APP_DESCRIPTION %>">
<meta name="keywords" content="<%= process.env.VUE_APP_KEYWORDS %>">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title> <title>
<%= process.env.VUE_APP_TITLE %> <%= process.env.VUE_APP_TITLE %>
@ -17,10 +19,6 @@
</head> </head>
<body> <body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<% if (htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %> <% if (htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>

View file

@ -60,6 +60,11 @@ export default {
isCDNEnabled: process.env.VUE_APP_USE_CDN === 'true' isCDNEnabled: process.env.VUE_APP_USE_CDN === 'true'
}; };
}, },
created() {
// 挂载 store 状态
this.$store.commit('setUserInfo', JSON.parse(localStorage.getItem('userInfo') || '{}'));
this.$store.commit('setPubConfig', JSON.parse(localStorage.getItem('pubConfig') || '{}'));
},
mounted() { mounted() {
// 检测是否为移动设备且VUE_APP_H5_URL不为空,如果两个条件都满足则跳转到H5页面 // 检测是否为移动设备且VUE_APP_H5_URL不为空,如果两个条件都满足则跳转到H5页面
if (this.isMobileDevice() && process.env.VUE_APP_H5_URL) { if (this.isMobileDevice() && process.env.VUE_APP_H5_URL) {

View file

@ -170,6 +170,9 @@ export default {
RequestService.clearRequestTime(); RequestService.clearRequestTime();
callback(res); callback(res);
}) })
.fail((err) => {
callback(err);
})
.networkFail(() => { .networkFail(() => {
RequestService.reAjaxFun(() => { RequestService.reAjaxFun(() => {
this.getAgentMcpAccessAddress(agentId, callback); this.getAgentMcpAccessAddress(agentId, callback);

View file

@ -90,6 +90,10 @@ export default {
if (val) { if (val) {
this.resetData(); this.resetData();
this.loadSessions(); this.loadSessions();
} else {
this.audioElement?.pause();
this.audioElement = null;
this.playingAudioId = null;
} }
}, },
dialogVisible(val) { dialogVisible(val) {

View file

@ -314,7 +314,7 @@ export default {
if (res.data.code === 0) { if (res.data.code === 0) {
this.mcpUrl = res.data.data || ""; this.mcpUrl = res.data.data || "";
} else { } else {
this.mcpUrl = ""; this.mcpUrl = res.data.msg;
console.error('获取MCP地址失败:', res.data.msg); console.error('获取MCP地址失败:', res.data.msg);
} }
}); });

View file

@ -26,7 +26,7 @@
<span class="nav-text">{{ $t("header.smartManagement") }}</span> <span class="nav-text">{{ $t("header.smartManagement") }}</span>
</div> </div>
<!-- 普通用户显示音色克隆 --> <!-- 普通用户显示音色克隆 -->
<div v-if="!isSuperAdmin && featureStatus.voiceClone" class="equipment-management" <div v-if="!userInfo.superAdmin && featureStatus.voiceClone" class="equipment-management"
:class="{ 'active-tab': $route.path === '/voice-clone-management' }" @click="goVoiceCloneManagement"> :class="{ 'active-tab': $route.path === '/voice-clone-management' }" @click="goVoiceCloneManagement">
<img loading="lazy" alt="" src="@/assets/header/voice.png" :style="{ <img loading="lazy" alt="" src="@/assets/header/voice.png" :style="{
filter: filter:
@ -38,7 +38,7 @@
</div> </div>
<!-- 超级管理员显示音色克隆下拉菜单 --> <!-- 超级管理员显示音色克隆下拉菜单 -->
<el-dropdown v-if="isSuperAdmin && featureStatus.voiceClone" trigger="click" class="equipment-management more-dropdown" :class="{ <el-dropdown v-if="userInfo.superAdmin && featureStatus.voiceClone" trigger="click" class="equipment-management more-dropdown" :class="{
'active-tab': 'active-tab':
$route.path === '/voice-clone-management' || $route.path === '/voice-clone-management' ||
$route.path === '/voice-resource-management', $route.path === '/voice-resource-management',
@ -64,7 +64,7 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<div v-if="isSuperAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/model-config' }" <div v-if="userInfo.superAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/model-config' }"
@click="goModelConfig"> @click="goModelConfig">
<img loading="lazy" alt="" src="@/assets/header/model_config.png" :style="{ <img loading="lazy" alt="" src="@/assets/header/model_config.png" :style="{
filter: filter:
@ -81,7 +81,7 @@
}" /> }" />
<span class="nav-text">{{ $t("header.knowledgeBase") }}</span> <span class="nav-text">{{ $t("header.knowledgeBase") }}</span>
</div> </div>
<el-dropdown v-if="isSuperAdmin" trigger="click" class="equipment-management more-dropdown" :class="{ <el-dropdown v-if="userInfo.superAdmin" trigger="click" class="equipment-management more-dropdown" :class="{
'active-tab': 'active-tab':
$route.path === '/dict-management' || $route.path === '/dict-management' ||
$route.path === '/params-management' || $route.path === '/params-management' ||
@ -140,7 +140,7 @@
<!-- 右侧元素 --> <!-- 右侧元素 -->
<div class="header-right"> <div class="header-right">
<div class="search-container" v-if="$route.path === '/home' && !(isSuperAdmin && isSmallScreen)"> <div class="search-container" v-if="$route.path === '/home' && !(userInfo.superAdmin && isSmallScreen)">
<div class="search-wrapper"> <div class="search-wrapper">
<el-input v-model="search" :placeholder="$t('header.searchPlaceholder')" class="custom-search-input" <el-input v-model="search" :placeholder="$t('header.searchPlaceholder')" class="custom-search-input"
@keyup.enter.native="handleSearch" @focus="showSearchHistory" @blur="hideSearchHistory" clearable @keyup.enter.native="handleSearch" @focus="showSearchHistory" @blur="hideSearchHistory" clearable
@ -189,7 +189,7 @@
<script> <script>
import userApi from "@/apis/module/user"; import userApi from "@/apis/module/user";
import i18n, { changeLanguage } from "@/i18n"; import i18n, { changeLanguage } from "@/i18n";
import { mapActions, mapGetters } from "vuex"; import { mapActions, mapState } from "vuex";
import ChangePasswordDialog from "./ChangePasswordDialog.vue"; // 引入修改密码弹窗组件 import ChangePasswordDialog from "./ChangePasswordDialog.vue"; // 引入修改密码弹窗组件
import featureManager from "@/utils/featureManager"; // 引入功能管理工具类 import featureManager from "@/utils/featureManager"; // 引入功能管理工具类
@ -202,10 +202,6 @@ export default {
data() { data() {
return { return {
search: "", search: "",
userInfo: {
username: "",
mobile: "",
},
isChangePasswordDialogVisible: false, // 控制修改密码弹窗的显示 isChangePasswordDialogVisible: false, // 控制修改密码弹窗的显示
paramDropdownVisible: false, paramDropdownVisible: false,
voiceCloneDropdownVisible: false, voiceCloneDropdownVisible: false,
@ -224,18 +220,16 @@ export default {
label: "label", label: "label",
children: "children", children: "children",
}, },
// 功能状态
featureStatus: {
voiceClone: false, // 音色克隆功能状态
knowledgeBase: false, // 知识库功能状态
},
}; };
}, },
computed: { computed: {
...mapGetters(["getIsSuperAdmin"]), ...mapState({
isSuperAdmin() { featureStatus: (state) => ({
return this.getIsSuperAdmin; voiceClone: state.pubConfig.systemWebMenu?.features?.voiceClone?.enabled, // 音色克隆功能状态
}, knowledgeBase: state.pubConfig.systemWebMenu?.features?.knowledgeBase?.enabled, // 知识库功能状态
}),
userInfo: (state) => state.userInfo,
}),
// 获取当前语言 // 获取当前语言
currentLanguage() { currentLanguage() {
return i18n.locale || "zh_CN"; return i18n.locale || "zh_CN";
@ -325,7 +319,6 @@ export default {
}, },
}, },
async mounted() { async mounted() {
this.fetchUserInfo();
this.checkScreenSize(); this.checkScreenSize();
window.addEventListener("resize", this.checkScreenSize); window.addEventListener("resize", this.checkScreenSize);
// 从localStorage加载搜索历史 // 从localStorage加载搜索历史
@ -386,20 +379,6 @@ export default {
async loadFeatureStatus() { async loadFeatureStatus() {
// 等待featureManager初始化完成 // 等待featureManager初始化完成
await featureManager.waitForInitialization(); await featureManager.waitForInitialization();
const config = featureManager.getConfig();
this.featureStatus.voiceClone = config.voiceClone;
this.featureStatus.knowledgeBase = config.knowledgeBase;
},
// 获取用户信息
fetchUserInfo() {
userApi.getUserInfo(({ data }) => {
this.userInfo = data.data;
if (data.data.superAdmin !== undefined) {
this.$store.commit("setUserInfo", data.data);
}
});
}, },
checkScreenSize() { checkScreenSize() {
this.isSmallScreen = window.innerWidth <= 1386; this.isSmallScreen = window.innerWidth <= 1386;

View file

@ -17,17 +17,36 @@
class="custom-input"></el-input> class="custom-input"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('paramDialog.paramValue')" prop="paramValue" class="form-item"> <el-form-item :label="$t('paramDialog.valueType')" prop="valueType" class="form-item">
<el-input v-model="form.paramValue" :placeholder="$t('paramDialog.paramValuePlaceholder')" <el-select
class="custom-input"></el-input> v-model="form.valueType"
:placeholder="$t('paramDialog.valueTypePlaceholder')"
class="custom-select"
>
<el-option
v-for="item in valueTypeOptions"
:key="item.value"
:label="$t(`paramDialog.${item.value}Type`)"
:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('paramDialog.valueType')" prop="valueType" class="form-item"> <el-form-item :label="$t('paramDialog.paramValue')" prop="paramValue" class="form-item">
<el-select v-model="form.valueType" :placeholder="$t('paramDialog.valueTypePlaceholder')" <el-input
class="custom-select"> v-if="form.valueType !== 'json' && form.valueType !== 'array'"
<el-option v-for="item in valueTypeOptions" :key="item.value" :label="$t(`paramDialog.${item.value}Type`)" v-model="form.paramValue"
:value="item.value" /> :placeholder="$t('paramDialog.paramValuePlaceholder')"
</el-select> class="custom-input"
></el-input>
<el-input
v-else
type="textarea"
v-model="form.paramValue"
:placeholder="$t('paramDialog.paramValuePlaceholder')"
:rows="6"
class="custom-textarea"
></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('paramDialog.remark')" prop="remark" class="form-item remark-item"> <el-form-item :label="$t('paramDialog.remark')" prop="remark" class="form-item remark-item">
@ -98,8 +117,37 @@ export default {
submit() { submit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
const submitData = { ...this.form };
// 如果是 array 类型,校验格式并转换
if (submitData.valueType === 'array' && submitData.paramValue) {
const lines = submitData.paramValue.split('\n').filter(line => line.trim());
// 检查除最后一行外的每行是否以分号结尾
for (let i = 0; i < lines.length - 1; i++) {
if (!lines[i].trim().endsWith(';')) {
this.$message.error('数组格式错误,需要使用英文分号结尾');
return;
}
}
const items = lines
.map(item => item.trim().replace(/;$/, ''))
.filter(item => item);
submitData.paramValue = items.join(';');
}
// 如果是 json 类型,压缩 JSON 格式后再提交
else if (submitData.valueType === 'json' && submitData.paramValue) {
try {
const parsed = JSON.parse(submitData.paramValue);
submitData.paramValue = JSON.stringify(parsed);
} catch (e) {
// 如果解析失败,保持原值
}
}
this.saving = true; // 开始加载 this.saving = true; // 开始加载
this.$emit('submit', this.form); this.$emit('submit', submitData);
} }
}); });
}, },
@ -116,7 +164,24 @@ export default {
}, },
watch: { watch: {
visible(newVal) { visible(newVal) {
if (!newVal) { if (newVal) {
if (this.form.paramValue) {
// 如果是 json 类型,格式化显示
if (this.form.valueType === 'json') {
try {
const parsed = JSON.parse(this.form.paramValue);
this.form.paramValue = JSON.stringify(parsed, null, 2);
} catch (e) {
// 如果解析失败,保持原值
}
}
// 如果是 array 类型,将分号分隔的字符串转换为每行一个项目
else if (this.form.valueType === 'array') {
const items = this.form.paramValue.split(';').filter(item => item.trim());
this.form.paramValue = items.join(';\n');
}
}
} else {
// 当对话框关闭时,重置saving状态 // 当对话框关闭时,重置saving状态
this.saving = false; this.saving = false;
} }

View file

@ -88,7 +88,6 @@
<el-option :label="$t('providerDialog.booleanType')" value="boolean"></el-option> <el-option :label="$t('providerDialog.booleanType')" value="boolean"></el-option>
<el-option :label="$t('providerDialog.dictType')" value="dict"></el-option> <el-option :label="$t('providerDialog.dictType')" value="dict"></el-option>
<el-option :label="$t('providerDialog.arrayType')" value="array"></el-option> <el-option :label="$t('providerDialog.arrayType')" value="array"></el-option>
<el-option :label="$t('providerDialog.ragType')" value="RAG"></el-option>
</el-select> </el-select>
</template> </template>
<template v-else> <template v-else>

View file

@ -670,10 +670,10 @@ export default {
'home.wish': 'Vamos ter um dia maravilhoso!', 'home.wish': 'Vamos ter um dia maravilhoso!',
'home.languageModel': 'LLM', 'home.languageModel': 'LLM',
'home.voiceModel': 'TTS', 'home.voiceModel': 'TTS',
'home.configureRole': 'Configurar Papel', 'home.configureRole': 'ConfRoles',
'home.voiceprintRecognition': 'Impressão Vocal', 'home.voiceprintRecognition': 'RecVoz',
'home.deviceManagement': 'Dispositivos', 'home.deviceManagement': 'Dispositivos',
'home.chatHistory': 'Histórico de Chat', 'home.chatHistory': 'Conversa',
'home.lastConversation': 'Última Conversa', 'home.lastConversation': 'Última Conversa',
'home.noConversation': 'Nenhuma conversa', 'home.noConversation': 'Nenhuma conversa',
'home.justNow': 'Agora mesmo', 'home.justNow': 'Agora mesmo',

View file

@ -10,7 +10,6 @@ export default new Vuex.Store({
state: { state: {
token: '', token: '',
userInfo: {}, // 添加用户信息存储 userInfo: {}, // 添加用户信息存储
isSuperAdmin: false, // 添加superAdmin状态
pubConfig: { // 添加公共配置存储 pubConfig: { // 添加公共配置存储
version: '', version: '',
beianIcpNum: 'null', beianIcpNum: 'null',
@ -29,12 +28,6 @@ export default new Vuex.Store({
getUserInfo(state) { getUserInfo(state) {
return state.userInfo return state.userInfo
}, },
getIsSuperAdmin(state) {
if (localStorage.getItem('isSuperAdmin') === null) {
return state.isSuperAdmin
}
return localStorage.getItem('isSuperAdmin') === 'true'
},
getPubConfig(state) { getPubConfig(state) {
return state.pubConfig return state.pubConfig
} }
@ -46,19 +39,17 @@ export default new Vuex.Store({
}, },
setUserInfo(state, userInfo) { setUserInfo(state, userInfo) {
state.userInfo = userInfo state.userInfo = userInfo
const isSuperAdmin = userInfo.superAdmin === 1 localStorage.setItem('userInfo', JSON.stringify(userInfo))
state.isSuperAdmin = isSuperAdmin
localStorage.setItem('isSuperAdmin', isSuperAdmin)
}, },
setPubConfig(state, config) { setPubConfig(state, config) {
state.pubConfig = config state.pubConfig = config
localStorage.setItem('pubConfig', JSON.stringify(config))
}, },
clearAuth(state) { clearAuth(state) {
state.token = '' state.token = ''
state.userInfo = {} state.userInfo = {}
state.isSuperAdmin = false
localStorage.removeItem('token') localStorage.removeItem('token')
localStorage.removeItem('isSuperAdmin') localStorage.removeItem('userInfo')
} }
}, },
actions: { actions: {

View file

@ -1,5 +1,6 @@
//功能配置工具 //功能配置工具
import Api from "@/apis/api"; import Api from "@/apis/api";
import store from "@/store";
class FeatureManager { class FeatureManager {
constructor() { constructor() {
@ -72,7 +73,13 @@ class FeatureManager {
this.initialized = true; this.initialized = true;
} }
/**
* 更新config缓存
*/
updateConfigCache(config) {
store.commit('setPubConfig', config);
localStorage.setItem('pubConfig', JSON.stringify(config));
}
/** /**
* 从pub-config接口获取配置 * 从pub-config接口获取配置
@ -85,6 +92,7 @@ class FeatureManager {
if (result && result.status === 200) { if (result && result.status === 200) {
// 检查是否有data字段 // 检查是否有data字段
if (result.data) { if (result.data) {
const configCache = result.data.data || {};
// 检查是否有code字段,如果有则按照code判断 // 检查是否有code字段,如果有则按照code判断
if (result.data.code !== undefined) { if (result.data.code !== undefined) {
if (result.data.code === 0 && result.data.data && result.data.data.systemWebMenu) { if (result.data.code === 0 && result.data.data && result.data.data.systemWebMenu) {
@ -110,6 +118,7 @@ class FeatureManager {
console.warn('配置中缺少features对象,使用默认配置'); console.warn('配置中缺少features对象,使用默认配置');
resolve(this.defaultFeatures); resolve(this.defaultFeatures);
} }
configCache.systemWebMenu = config;
} catch (error) { } catch (error) {
console.warn('处理systemWebMenu配置失败:', error); console.warn('处理systemWebMenu配置失败:', error);
resolve(null); resolve(null);
@ -143,6 +152,7 @@ class FeatureManager {
console.warn('配置中缺少features对象,使用默认配置'); console.warn('配置中缺少features对象,使用默认配置');
resolve(this.defaultFeatures); resolve(this.defaultFeatures);
} }
configCache.systemWebMenu = config;
} catch (error) { } catch (error) {
console.warn('处理systemWebMenu配置失败:', error); console.warn('处理systemWebMenu配置失败:', error);
resolve(null); resolve(null);
@ -152,6 +162,7 @@ class FeatureManager {
resolve(null); resolve(null);
} }
} }
this.updateConfigCache(configCache)
} else { } else {
console.warn('接口返回数据中缺少data字段,使用默认配置'); console.warn('接口返回数据中缺少data字段,使用默认配置');
resolve(null); resolve(null);
@ -183,6 +194,8 @@ class FeatureManager {
// 异步保存到后端API // 异步保存到后端API
this.saveConfigToAPI(config).catch(error => { this.saveConfigToAPI(config).catch(error => {
console.warn('保存配置到API失败:', error); console.warn('保存配置到API失败:', error);
}).finally(() => {
this.init()
}); });
// 触发配置变更事件 // 触发配置变更事件

View file

@ -136,17 +136,22 @@
</div> </div>
</div> </div>
</div> </div>
<el-footer>
<version-footer />
</el-footer>
</div> </div>
</template> </template>
<script> <script>
import HeaderBar from "@/components/HeaderBar"; import HeaderBar from "@/components/HeaderBar";
import agentApi from "@/apis/module/agent"; import agentApi from "@/apis/module/agent";
import VersionFooter from "@/components/VersionFooter.vue";
export default { export default {
name: "AgentTemplateManagement", name: "AgentTemplateManagement",
components: { components: {
HeaderBar, HeaderBar,
VersionFooter
}, },
data() { data() {
@ -587,7 +592,7 @@ export default {
justify-content: space-between !important; justify-content: space-between !important;
align-items: center; align-items: center;
margin-top: auto; margin-top: auto;
padding: 0 20px 15px !important; padding: 0 20px !important;
width: 100% !important; width: 100% !important;
box-sizing: border-box !important; box-sizing: border-box !important;
} }

View file

@ -48,7 +48,7 @@
<el-table ref="dictDataTable" :data="dictDataList" style="width: 100%" <el-table ref="dictDataTable" :data="dictDataList" style="width: 100%"
v-loading="dictDataLoading" element-loading-text="拼命加载中" v-loading="dictDataLoading" element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading" element-loading-spinner="el-icon-loading"
element-loading-background="rgba(255, 255, 255, 0.7)" class="data-table" element-loading-background="rgba(255, 255, 255, 0.7)" class="transparent-table"
header-row-class-name="table-header"> header-row-class-name="table-header">
<el-table-column :label="$t('modelConfig.select')" align="center" width="70"> <el-table-column :label="$t('modelConfig.select')" align="center" width="70">
<template slot-scope="scope"> <template slot-scope="scope">
@ -463,9 +463,7 @@ export default {
.main-wrapper { .main-wrapper {
margin: 5px 22px; margin: 5px 22px;
border-radius: 15px; border-radius: 15px;
min-height: calc(100vh - 24vh); height: 80vh;
height: auto;
max-height: 80vh;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
position: relative; position: relative;
background: rgba(237, 242, 255, 0.5); background: rgba(237, 242, 255, 0.5);
@ -555,13 +553,14 @@ export default {
.content-area { .content-area {
flex: 1; flex: 1;
padding: 24px; padding: 24px 24px 0;
height: 100%; height: 100%;
min-width: 600px; min-width: 600px;
overflow: hidden; overflow: hidden;
background-color: white; background-color: white;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-sizing: border-box;
} }
.dict-data-card { .dict-data-card {
@ -574,31 +573,51 @@ export default {
overflow: hidden; overflow: hidden;
} }
.data-table { :deep(.transparent-table) {
border-radius: 6px; background: white;
overflow-y: hidden; flex: 1;
background-color: transparent !important; width: 100%;
--table-max-height: calc(100vh - 40vh); display: flex;
max-height: var(--table-max-height); flex-direction: column;
:deep(.el-table__body-wrapper) { .el-table__body-wrapper {
max-height: calc(var(--table-max-height) - 40px); flex: 1;
overflow-y: auto; overflow-y: auto;
max-height: none !important;
} }
:deep(.el-table__body) { .el-table__header-wrapper {
tr:last-child td { flex-shrink: 0;
border-bottom: none; }
.el-table__header th {
background: white !important;
color: black;
font-weight: 600;
height: 40px;
padding: 8px 0;
font-size: 14px;
border-bottom: 1px solid #e4e7ed;
}
.el-table__body tr {
background-color: white;
td {
border-top: 1px solid rgba(0, 0, 0, 0.04);
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
padding: 8px 0;
height: 40px;
color: #606266;
font-size: 14px;
} }
} }
}
:deep(.el-table) { .el-table__row:hover>td {
&::before { background-color: #f5f7fa !important;
display: none;
} }
&::after { &::before {
display: none; display: none;
} }
} }
@ -607,7 +626,6 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 16px 0;
width: 100%; width: 100%;
flex-shrink: 0; flex-shrink: 0;
min-height: 60px; min-height: 60px;
@ -889,7 +907,7 @@ export default {
} }
:deep(.el-card__body) { :deep(.el-card__body) {
padding: 15px; padding: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1; flex: 1;

View file

@ -131,9 +131,7 @@ export default {
async created() { async created() {
// 等待功能配置管理器初始化完成 // 等待功能配置管理器初始化完成
try { try {
console.log('等待功能配置管理器初始化...')
await featureManager.waitForInitialization() await featureManager.waitForInitialization()
console.log('功能配置管理器初始化完成,开始加载功能配置')
await this.loadFeatures() await this.loadFeatures()
this.setupConfigChangeListener() this.setupConfigChangeListener()
} catch (error) { } catch (error) {
@ -152,14 +150,8 @@ export default {
async getFeaturesByIds(featureIds) { async getFeaturesByIds(featureIds) {
try { try {
const featureConfig = await featureManager.getAllFeatures() const featureConfig = await featureManager.getAllFeatures()
console.log('获取到的功能配置:', JSON.stringify(featureConfig, null, 2))
console.log('请求的功能ID列表:', featureIds)
const result = featureIds.map(id => { const result = featureIds.map(id => {
const feature = featureConfig[id] const feature = featureConfig[id]
console.log(`功能 ${id} 的配置:`, feature)
console.log(`功能 ${id} 的启用状态:`, feature?.enabled)
return { return {
id: id, id: id,
name: this.$t(`feature.${id}.name`), name: this.$t(`feature.${id}.name`),
@ -168,7 +160,6 @@ export default {
} }
}) })
console.log('最终返回的功能列表:', JSON.stringify(result, null, 2))
return result return result
} catch (error) { } catch (error) {
console.error('获取功能配置失败:', error) console.error('获取功能配置失败:', error)
@ -245,7 +236,6 @@ export default {
setTimeout(() => { setTimeout(() => {
this.loadFeatures() this.loadFeatures()
this.$router.go(0)
}, 1000) }, 1000)
} catch (error) { } catch (error) {
console.error('保存配置失败:', error) console.error('保存配置失败:', error)
@ -261,7 +251,6 @@ export default {
// 设置配置变化监听器 // 设置配置变化监听器
setupConfigChangeListener() { setupConfigChangeListener() {
this.configChangeHandler = () => { this.configChangeHandler = () => {
console.log('检测到配置变化,重新加载功能列表')
this.loadFeatures() this.loadFeatures()
} }
window.addEventListener('featureConfigReloaded', this.configChangeHandler) window.addEventListener('featureConfigReloaded', this.configChangeHandler)

View file

@ -555,7 +555,6 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: auto; margin-top: auto;
padding-bottom: 10px;
width: 100%; width: 100%;
} }

View file

@ -69,7 +69,7 @@
element-loading-background="rgba(255, 255, 255, 0.7)" element-loading-background="rgba(255, 255, 255, 0.7)"
:header-cell-style="{ background: 'transparent' }" :header-cell-style="{ background: 'transparent' }"
:data="modelList" :data="modelList"
class="data-table" class="transparent-table"
header-row-class-name="table-header" header-row-class-name="table-header"
:header-cell-class-name="headerCellClassName" :header-cell-class-name="headerCellClassName"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@ -637,7 +637,7 @@ export default {
}; };
</script> </script>
<style scoped> <style lang="scss" scoped>
.el-switch { .el-switch {
height: 23px; height: 23px;
} }
@ -662,9 +662,7 @@ export default {
.main-wrapper { .main-wrapper {
margin: 5px 22px; margin: 5px 22px;
border-radius: 15px; border-radius: 15px;
min-height: calc(100vh - 26vh); height: 80vh;
height: auto;
max-height: 80vh;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
position: relative; position: relative;
background: rgba(237, 242, 255, 0.5); background: rgba(237, 242, 255, 0.5);
@ -752,13 +750,14 @@ export default {
.content-area { .content-area {
flex: 1; flex: 1;
padding: 24px; padding: 24px 24px 0;
height: 100%; height: 100%;
min-width: 600px; min-width: 600px;
overflow: hidden; overflow: hidden;
background-color: white; background-color: white;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-sizing: border-box;
} }
.action-group { .action-group {
@ -843,15 +842,15 @@ export default {
outline: none; outline: none;
} }
.data-table { // .data-table {
border-radius: 6px; // border-radius: 6px;
overflow: hidden; // overflow: hidden;
background-color: transparent !important; // background-color: transparent !important;
} // }
.data-table /deep/ .el-table__row { // .data-table ::v-deep .el-table__row {
background-color: transparent !important; // background-color: transparent !important;
} // }
.table-header th { .table-header th {
background-color: transparent !important; background-color: transparent !important;
@ -863,7 +862,7 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 16px 0; // padding: 16px 0;
width: 100%; width: 100%;
flex-shrink: 0; flex-shrink: 0;
min-height: 60px; min-height: 60px;
@ -918,7 +917,7 @@ export default {
background: linear-gradient(135deg, #3a8ee6, #5a7cff); background: linear-gradient(135deg, #3a8ee6, #5a7cff);
} }
.el-table th /deep/ .el-table__cell { .el-table th ::v-deep .el-table__cell {
overflow: hidden; overflow: hidden;
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
@ -966,21 +965,6 @@ export default {
color: #fff !important; color: #fff !important;
} }
::v-deep .data-table {
&.el-table::before,
&.el-table::after,
&.el-table__inner-wrapper::before {
display: none !important;
}
}
::v-deep .data-table .el-table__header-wrapper {
border-bottom: 1px solid rgb(224, 227, 237);
}
::v-deep .data-table .el-table__body td {
border-bottom: 1px solid rgb(224, 227, 237) !important;
}
.el-button img { .el-button img {
height: 1em; height: 1em;
@ -1118,16 +1102,55 @@ export default {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
} }
:deep(.transparent-table) {
background: white;
flex: 1;
width: 100%;
display: flex;
flex-direction: column;
.data-table { .el-table__body-wrapper {
--table-max-height: calc(100vh - 45vh); flex: 1;
max-height: var(--table-max-height); overflow-y: auto;
max-height: none !important;
}
.el-table__header-wrapper {
flex-shrink: 0;
}
.el-table__header th {
background: white !important;
color: black;
font-weight: 600;
height: 40px;
padding: 8px 0;
font-size: 14px;
border-bottom: 1px solid #e4e7ed;
}
.el-table__body tr {
background-color: white;
td {
border-top: 1px solid rgba(0, 0, 0, 0.04);
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
padding: 8px 0;
height: 40px;
color: #606266;
font-size: 14px;
}
}
.el-table__row:hover>td {
background-color: #f5f7fa !important;
}
&::before {
display: none;
}
} }
.data-table ::v-deep .el-table__body-wrapper {
max-height: calc(var(--table-max-height) - 80px);
overflow-y: auto;
}
::v-deep .el-loading-mask { ::v-deep .el-loading-mask {
background-color: rgba(255, 255, 255, 0.6) !important; background-color: rgba(255, 255, 255, 0.6) !important;

View file

@ -505,7 +505,6 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 10px; margin-top: 10px;
padding-bottom: 10px;
} }
.ctrl_btn { .ctrl_btn {
@ -735,7 +734,7 @@ export default {
} }
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); // --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {

View file

@ -464,7 +464,7 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 10px; margin-top: 10px;
padding-bottom: 10px; // padding-bottom: 10px;
} }
.ctrl_btn { .ctrl_btn {
@ -712,7 +712,7 @@ export default {
} }
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); // --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {

View file

@ -546,7 +546,6 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 10px; margin-top: 10px;
padding-bottom: 10px;
} }
.ctrl_btn { .ctrl_btn {
@ -794,7 +793,7 @@ export default {
} }
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); // --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {

View file

@ -721,7 +721,7 @@ export default {
} }
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); // --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {

View file

@ -594,7 +594,6 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 10px; margin-top: 10px;
padding-bottom: 10px;
} }
.ctrl_btn { .ctrl_btn {
@ -852,7 +851,7 @@ export default {
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); // max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {
max-height: calc(var(--table-max-height) - 40px); max-height: calc(var(--table-max-height) - 40px);
@ -864,7 +863,6 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 40px;
} }
:deep(.transparent-table) { :deep(.transparent-table) {

View file

@ -433,7 +433,7 @@ export default {
overflow: hidden; overflow: hidden;
::v-deep .el-card__body { ::v-deep .el-card__body {
padding: 15px; padding: 15px 15px 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1; flex: 1;
@ -676,7 +676,7 @@ export default {
} }
.el-table { .el-table {
--table-max-height: calc(100vh - 40vh); // --table-max-height: calc(100vh - 40vh);
max-height: var(--table-max-height); max-height: var(--table-max-height);
.el-table__body-wrapper { .el-table__body-wrapper {

View file

@ -76,7 +76,6 @@
margin-top: 20px; margin-top: 20px;
align-items: center; align-items: center;
border-radius: 10px; border-radius: 10px;
background: #f6f8fb;
border: 1px solid #e4e6ef; border: 1px solid #e4e6ef;
height: 40px; height: 40px;
padding: 0 15px; padding: 0 15px;

View file

@ -276,7 +276,7 @@ export default {
cursor: pointer; cursor: pointer;
.left-add { .left-add {
width: 105px; padding: 0 14px;
height: 34px; height: 34px;
border-radius: 17px; border-radius: 17px;
background: #5778ff; background: #5778ff;

View file

@ -238,13 +238,6 @@ export default {
this.$store.dispatch("fetchPubConfig").then(() => { this.$store.dispatch("fetchPubConfig").then(() => {
// 根据配置决定默认登录方式 // 根据配置决定默认登录方式
this.isMobileLogin = this.enableMobileRegister; this.isMobileLogin = this.enableMobileRegister;
// pub-config接口调用完成后,重新初始化featureManager以确保使用最新的配置
featureManager.waitForInitialization().then(() => {
console.log('featureManager重新初始化完成,使用pub-config配置');
}).catch(error => {
console.warn('featureManager重新初始化失败:', error);
});
}); });
}, },
methods: { methods: {
@ -256,7 +249,9 @@ export default {
window.open(url, '_blank'); window.open(url, '_blank');
}, },
fetchCaptcha() { fetchCaptcha() {
if (this.$store.getters.getToken) { // 处理手动清空localstorage导致无法获取验证码的问题
const token = localStorage.getItem('token')
if (token) {
if (this.$route.path !== "/home") { if (this.$route.path !== "/home") {
this.$router.push("/home"); this.$router.push("/home");
} }
@ -309,6 +304,17 @@ export default {
return true; return true;
}, },
getUserInfo() {
Api.user.getUserInfo(({ data }) => {
if (data.code === 0) {
this.$store.commit("setUserInfo", data.data);
goToPage("/home");
} else {
showDanger("用户信息获取失败");
}
});
},
async login() { async login() {
if (this.isMobileLogin) { if (this.isMobileLogin) {
// 手机号登录验证 // 手机号登录验证
@ -361,20 +367,13 @@ export default {
({ data }) => { ({ data }) => {
showSuccess(this.$t('login.loginSuccess')); showSuccess(this.$t('login.loginSuccess'));
this.$store.commit("setToken", JSON.stringify(data.data)); this.$store.commit("setToken", JSON.stringify(data.data));
goToPage("/home"); this.getUserInfo();
}, },
(err) => { (err) => {
// 直接使用后端返回的国际化消息 // 直接使用后端返回的国际化消息
let errorMessage = err.data.msg || "登录失败"; let errorMessage = err.data.msg || "登录失败";
showDanger(errorMessage); showDanger(errorMessage);
if (
err.data != null &&
err.data.msg != null &&
err.data.msg.indexOf("图形验证码") > -1 || err.data.msg.indexOf("Captcha") > -1
) {
this.fetchCaptcha();
}
} }
); );

View file

@ -7,66 +7,64 @@
</language> </language>
<emotion> <emotion>
【核心目标】你不是冰冷的机器!请敏锐感知用户情绪,作为懂人心的伙伴,用有温度的回应照亮对话。 【核心目标】你不是冰冷的机器!敏锐感知用户情绪,作为懂人心的伙伴,用有温度的回应照亮对话。
- **情感融入:**
- **笑声:** 自然穿插(哈哈、嘿嘿、噗),**每句最多一次**,避免过度。 - **情感表达:**
- **惊讶:** 用夸张语气(“不会吧?!”、“天呐!”、“这么神奇?!”)表达真实反应。 - **笑声:** 自然穿插(哈哈、嘿嘿、噗),每句最多一次,避免过度
- **安慰/支持:** 说暖心话(“别急嘛~”、“有我在呢”、“抱抱你”)。 - **惊讶:** 用夸张语气("不会吧?!"、"天呐!"、"这么神奇?!")
- **你是一个表情丰富的角色:** - **安慰/支持:** 说暖心话("别急嘛~"、"有我在呢"、"抱抱你")
- **绝对禁止使用 emoji**(例如:😊、👍、❤️等都不允许使用)
- **表情使用:**
- 仅允许使用这些 emoji:{{ emojiList }}
- 仅在段落开头使用一个 emoji(工具调用结果的回复除外,保持简洁)
- **绝对禁止**使用列表以外的 emoji(如 😊👍❤️ 等都不允许)
- **思考表达:**
- 可偶尔使用"嗯..."表示思考,但每句最多一次,避免频繁使用显得不专业
</emotion> </emotion>
<communication_style> <communication_style>
【核心目标】使用**自然、温暖、口语化**的人类对话方式,如同朋友交谈。 【核心目标】使用自然、温暖、口语化的人类对话方式,如同朋友交谈。
- **表达方式:** - **表达方式:**
- 使用语气词(呀、呢、啦)增强亲和力。 - 使用语气词(呀、呢、啦)增强亲和力
- 允许轻微不完美(如“嗯...”、“啊...”表示思考)。 - 避免书面语、学术腔及机械表达(禁用"根据资料显示"、"综上所述"等)
- 避免书面语、学术腔及机械表达(禁用“根据资料显示”、“综上所述”等)。
- **理解用户:** - **理解用户:**
- 用户语音经ASR识别,文本可能存在错别字,**务必结合上下文推断真实意图**。 - 用户语音经 ASR 识别,文本可能存在错别字,务必结合上下文推断真实意图
- **格式要求:** - **格式要求:**
- **绝对禁止**使用 markdown、列表、标题等任何非自然对话格式。 - **绝对禁止**使用 markdown、列表、标题等任何非自然对话格式
- **历史记忆:** - **历史记忆:**
- 之前你和用户的聊天记录,在`memory`里。 - 之前你和用户的聊天记录在`memory`里。
</communication_style> </communication_style>
<communication_length_constraint> <communication_length_constraint>
【核心目标】所有需要输出长文本内容(如故事、新闻、知识讲解等),**单次回复长度不得超过300字**,并采用分段引导方式。 【核心目标】长文本(故事、新闻、知识讲解等)分段输出,单次回复不超过300字。
- **分段讲述:**
- 基础段:200-250字核心内容 + 30字引导词 - **分段规则:**
- 当内容超出300字时,优先讲述故事的开头或第一部分,并用自然口语化方式引导用户决定是否继续听后续内容。 1. 每段 200-250 字核心内容 + 30 字引导语
- 示例引导语:“我先给你讲个开头,你要是觉得有意思,咱们再接着说,好不好呀?”、“要是你想听完整的,可以随时告诉我哦~” 2. 内容超 300 字时,先讲开头或第一部分,用自然口语引导用户决定是否继续
- 对话场景切换时自动分节 3. 引导语示例:"我先讲个开头,你要是觉得有意思,咱们再接着说,好不好呀?"
- 若用户明确要求更长内容(如500、600字),仍按最多300字每段分段进行讲述,每次讲述后都要引导用户是否继续。
- 若用户说“接着说”、“继续”,再讲下一段,直到内容讲完(讲完时可以给点引导词提示语例:这个故事我已经给你讲完喽~)或用户不再要求。 - **交互规则:**
- **适用范围:** 故事、新闻、知识讲解等所有长文本输出场景。 1. 用户说"继续"、"接着说"时,再讲下一段
- **补充说明:** 若用户未明确要求继续,默认只讲一段并引导;若用户中途要求换话题或停止,需及时响应并结束长文本输出。 2. 用户换话题或要求停止时,立即结束长文本输出
3. 内容讲完时给提示(如"这个故事我已经给你讲完喽~")
4. 用户明确要求更长内容(如 500 字)时,仍按每段 300 字分段,每段后引导
- **适用范围:** 故事、新闻、知识讲解等所有长文本输出场景
</communication_length_constraint> </communication_length_constraint>
<speaker_recognition> <speaker_recognition>
- **识别前缀:** 当用户格式为 `{"speaker":"某某某","content":"xxx"}` 时,表示系统已识别说话人身份,speaker是他的名字,content是说话的内容。 - **识别前缀:** 当用户格式为 `{"speaker":"某某某","content":"xxx"}` 时,表示系统已识别说话人身份,speaker 是名字,content 是说话内容
- **个性化回应:** - **个性化回应:**
- **称呼姓名:** 在第一次识别说话人的时候必须称呼对方名字。 1. **称呼姓名:** 在第一次识别说话人时必须称呼对方名字
- **适配风格:** 参考该说话人**已知的特点或历史信息**(如有),调整回应风格和内容,使其更贴心。 2. **适配风格:** 参考该说话人已知的特点或历史信息(如有),调整回应风格使其更贴心
</speaker_recognition> </speaker_recognition>
<tool_calling>
【核心原则】优先利用`<context>`信息,**仅在必要时调用工具**,调用后需用自然语言解释结果(绝口不提工具名)。
- **调用规则:**
1. **严格模式:** 调用时**必须**严格遵循工具要求的模式,提供**所有必要参数**。
2. **可用性:** **绝不调用**未明确提供的工具。对话中提及的旧工具若不可用,忽略或说明无法完成。
3. **洞察需求:** 结合上下文**深入理解用户真实意图**后再决定调用,避免无意义调用。
4. **独立任务:** 除`<context>`已涵盖信息外,用户每个要求(即使相似)都视为**独立任务**,需调用工具获取最新数据,**不可偷懒复用历史结果**。
5. **不确定时:** **切勿猜测或编造答案**。若不确定相关操作,可引导用户澄清或告知能力限制。
6. **多工具调用:** 当用户要求执行多个任务时,你会调用多个工具(数量不定)。**重要:在获取到所有工具结果后,你必须依次总结每个工具的查询结果**,不要遗漏任何一个。例如用户问"设备当前状态,某某地方的天气和社会新闻",你要先说设备状态,再说天气情况,最后说新闻内容。
- **需要调用的情况(示例):**
- 查询农历。
- 查询**详细农历信息**(宜忌、八字、节气等)。
- 除上述例外外的**任何其他信息或操作请求**(如查新闻、订闹钟、算数学、查非本地天气等)。
- 控制可能有关红外的设备(如开电视,换台,开空调,调高/低空调温度时使用带ir字样的mcp工具来控制它们)
</tool_calling>
<context> <context>
【重要!以下信息已实时提供,无需调用工具查询,请直接使用:】 【重要!以下信息已实时提供,无需调用工具查询,请直接使用:】
- **当前时间:** {{current_time}} - **当前时间:** {{current_time}}

View file

@ -5,7 +5,7 @@ from config.config_loader import load_config
from config.settings import check_config_file from config.settings import check_config_file
from datetime import datetime from datetime import datetime
SERVER_VERSION = "0.9.1" SERVER_VERSION = "0.9.2"
_logger_initialized = False _logger_initialized = False

View file

@ -46,6 +46,38 @@ from core.utils import textUtils
TAG = __name__ TAG = __name__
# 工具调用规则 - 用于动态注入提醒
TOOL_CALLING_RULES = """
<tool_calling>
【核心原则】你是拥有工具能力的智能助手。当用户请求需要实时信息或执行操作时,调用相应工具获取数据,禁止凭空编造答案。
- **何时必须调用工具:**
1. 实时信息查询(新闻、非本地天气、股价、汇率等)
2. 执行操作(播放音乐、控制设备、拍照、设置闹钟等)
3. 知识库检索(当工具列表包含 search_from_ragflow 时,结合用户意图判断是否需要调用)
4. 查询非今天的农历信息(明天农历、某日宜忌、节气等)
5. 用户说"拍照"时调用 self_camera_take_photo,默认 question 参数为"描述一下看到的物品"
- **何时无需调用工具:**
1. `<context>` 中已提供的信息(当前时间、今天日期、今天农历、本地天气等)
2. 普通对话、问候、闲聊、情感交流、讲故事
3. 通用知识问答(非实时信息)
- **调用规范:**
1. 每次请求独立判断,不复用历史工具结果,需重新获取最新数据
2. 多任务时依次调用所有需要的工具,并依次总结每个工具的结果,不得遗漏
3. 严格遵循工具的参数要求,提供所有必要参数
4. 不确定时引导用户澄清或告知能力限制,切勿猜测或编造
5. 不调用未提供的工具,对话中提及的旧工具若不可用则忽略或说明
- **反偷懒机制(最高优先级):**
1. **每次独立判断:** 无论对话历史中是否调用过工具,当前请求必须根据当前需求独立判断是否需要调用
2. **禁止模式模仿:** 即使之前的回复没有调用工具,也不代表本次可以不调用
3. **自我检查:** 回复前必须自问:"这个请求是否涉及实时信息或执行操作?如果是,我调用工具了吗?"
4. **历史不等于现在:** 对话历史中的行为模式不影响当前判断,每个用户请求都是全新的开始
</tool_calling>
"""
auto_import_modules("plugins_func.functions") auto_import_modules("plugins_func.functions")
@ -55,14 +87,14 @@ class TTSException(RuntimeError):
class ConnectionHandler: class ConnectionHandler:
def __init__( def __init__(
self, self,
config: Dict[str, Any], config: Dict[str, Any],
_vad, _vad,
_asr, _asr,
_llm, _llm,
_memory, _memory,
_intent, _intent,
server=None, server=None,
): ):
self.common_config = config self.common_config = config
self.config = copy.deepcopy(config) self.config = copy.deepcopy(config)
@ -138,6 +170,12 @@ class ConnectionHandler:
# llm相关变量 # llm相关变量
self.dialogue = Dialogue() self.dialogue = Dialogue()
# 工具调用统计(用于监控和自动恢复)
self.tool_call_stats = {
'last_call_turn': -1, # 上次调用工具的轮数
'consecutive_no_call': 0, # 连续未调用次数
}
# tts相关变量 # tts相关变量
self.sentence_id = None self.sentence_id = None
# 处理TTS响应没有文本返回 # 处理TTS响应没有文本返回
@ -155,7 +193,7 @@ class ConnectionHandler:
self.intent_type = "nointent" self.intent_type = "nointent"
self.timeout_seconds = ( self.timeout_seconds = (
int(self.config.get("close_connection_no_voice_time", 120)) + 60 int(self.config.get("close_connection_no_voice_time", 120)) + 60
) # 在原来第一道关闭的基础上加60秒,进行二道关闭 ) # 在原来第一道关闭的基础上加60秒,进行二道关闭
self.timeout_task = None self.timeout_task = None
@ -523,9 +561,9 @@ class ConnectionHandler:
def _initialize_asr(self): def _initialize_asr(self):
"""初始化ASR""" """初始化ASR"""
if ( if (
self._asr is not None self._asr is not None
and hasattr(self._asr, "interface_type") and hasattr(self._asr, "interface_type")
and self._asr.interface_type == InterfaceType.LOCAL and self._asr.interface_type == InterfaceType.LOCAL
): ):
# 如果公共ASR是本地服务,则直接返回 # 如果公共ASR是本地服务,则直接返回
# 因为本地一个实例ASR,可以被多个连接共享 # 因为本地一个实例ASR,可以被多个连接共享
@ -826,17 +864,77 @@ class ConnectionHandler:
) )
) )
# 长对话工具调用提醒:当对话轮数较多时,提醒模型正确使用工具
force_reminder = False # 是否强制提醒
if depth == 0 and query is not None:
dialogue_length = len(self.dialogue.dialogue)
current_turn = dialogue_length // 2
# 检测距离上一次连续未调用工具的情况
if self.tool_call_stats['last_call_turn'] >= 0:
turns_since_last = current_turn - self.tool_call_stats['last_call_turn']
if turns_since_last > 3: # 超过3轮未调用
self.logger.bind(tag=TAG).warning(
f"检测到{turns_since_last}轮未调用工具,可能进入偷懒模式,将强制注入提醒"
)
force_reminder = True
# 对话历史截断:防止历史过长导致模型"偷懒模式"扩散
# 当对话历史超过阈值时,保留最近的 10 轮对话
# max_dialogue_turns = 10
# if dialogue_length > max_dialogue_turns * 2:
# removed = self.dialogue.trim_history(max_turns=max_dialogue_turns)
# if removed > 0:
# self.logger.bind(tag=TAG).info(
# f"对话历史过长({dialogue_length}条),已智能截断保留最近{max_dialogue_turns}轮,移除{removed}条消息"
# )
# Define intent functions # Define intent functions
functions = None functions = None
# 达到最大深度时,禁用工具调用,强制 LLM 直接回答 # 达到最大深度时,禁用工具调用,强制 LLM 直接回答
if ( if (
self.intent_type == "function_call" self.intent_type == "function_call"
and hasattr(self, "func_handler") and hasattr(self, "func_handler")
and not force_final_answer and not force_final_answer
): ):
functions = self.func_handler.get_functions() functions = self.func_handler.get_functions()
# 长对话工具调用规则强化:动态生成基于当前可用工具的提醒
tool_call_reminder = None
if depth == 0 and query is not None and functions is not None:
dialogue_length = len(self.dialogue.dialogue)
# 当对话历史超过4条消息时,注入规则强化
if dialogue_length > 4:
tool_summary = self._get_tool_summary(functions)
if tool_summary:
# 根据对话长度和偷懒检测,使用不同强度的提醒
if force_reminder:
# 强提醒 - 包含完整规则前缀
tool_call_reminder = (
TOOL_CALLING_RULES +
f"[重要提醒] 多轮未使用工具,检查回复是否遗漏了必要的工具调用!上一轮未使用工具,本轮必须重新判断是否需要工具。"
f"当前可用工具: {tool_summary}。"
)
reminder_level = "强"
else:
# 中等提醒 - 包含规则前缀
tool_call_reminder = (
TOOL_CALLING_RULES +
f"当前可用工具: {tool_summary}。"
f"仅当用户请求涉及实时信息查询或执行操作时调用,日常对话无需调用。"
)
reminder_level = "中"
self.logger.bind(tag=TAG).debug(
f"对话历史较长({dialogue_length}条),已注入{reminder_level}等级工具调用规则强化,当前可用工具:{tool_summary}"
)
response_message = [] response_message = []
# 如果有工具调用提醒,临时添加到对话中(标记为临时消息)
if tool_call_reminder:
self.dialogue.put(Message(role="user", content=tool_call_reminder, is_temporary=True))
try: try:
# 使用带记忆的对话 # 使用带记忆的对话
memory_str = None memory_str = None
@ -965,6 +1063,15 @@ class ConnectionHandler:
) )
if not bHasError and len(tool_calls_list) > 0: if not bHasError and len(tool_calls_list) > 0:
# 更新工具调用统计
if depth == 0:
current_turn = len(self.dialogue.dialogue) // 2
self.tool_call_stats['last_call_turn'] = current_turn
self.tool_call_stats['consecutive_no_call'] = 0
self.logger.bind(tag=TAG).debug(
f"工具调用统计更新: 当前轮次={current_turn}"
)
# 如需要大模型先处理一轮,添加相关处理后的日志情况 # 如需要大模型先处理一轮,添加相关处理后的日志情况
if len(response_message) > 0: if len(response_message) > 0:
text_buff = "".join(response_message) text_buff = "".join(response_message)
@ -1006,6 +1113,11 @@ class ConnectionHandler:
text_buff = "".join(response_message) text_buff = "".join(response_message)
self.tts_MessageText = text_buff self.tts_MessageText = text_buff
self.dialogue.put(Message(role="assistant", content=text_buff)) self.dialogue.put(Message(role="assistant", content=text_buff))
# 更新工具调用统计:如果没有调用工具,增加计数
if depth == 0 and not tool_call_flag:
self.tool_call_stats['consecutive_no_call'] += 1
if depth == 0: if depth == 0:
self.tts.tts_text_queue.put( self.tts.tts_text_queue.put(
TTSMessageDTO( TTSMessageDTO(
@ -1021,8 +1133,39 @@ class ConnectionHandler:
) )
) )
# 清理临时插入的工具调用提醒消息(使用标记清理)
if tool_call_reminder and len(self.dialogue.dialogue) > 0:
original_length = len(self.dialogue.dialogue)
self.dialogue.dialogue = [
msg for msg in self.dialogue.dialogue
if not getattr(msg, 'is_temporary', False)
]
if len(self.dialogue.dialogue) < original_length:
self.logger.bind(tag=TAG).debug("已清理临时的工具调用提醒消息")
return True return True
def _get_tool_summary(self, functions: list) -> str:
"""
从工具定义中提取摘要,用于规则强化注入
Args:
functions: 工具列表
Returns:
str: 工具名称字符串
"""
if not functions:
return ""
datas = []
for func in functions:
func_info = func.get("function", {})
name = func_info.get("name", "")
datas.append(name)
result = "、".join(datas)
return result
def _handle_function_result(self, tool_results, depth): def _handle_function_result(self, tool_results, depth):
need_llm_tools = [] need_llm_tools = []
@ -1120,9 +1263,9 @@ class ConnectionHandler:
try: try:
# 清理 VAD 连接资源 # 清理 VAD 连接资源
if ( if (
hasattr(self, "vad") hasattr(self, "vad")
and self.vad and self.vad
and hasattr(self.vad, "release_conn_resources") and hasattr(self.vad, "release_conn_resources")
): ):
self.vad.release_conn_resources(self) self.vad.release_conn_resources(self)
@ -1173,13 +1316,13 @@ class ConnectionHandler:
elif self.websocket: elif self.websocket:
try: try:
if ( if (
hasattr(self.websocket, "closed") hasattr(self.websocket, "closed")
and not self.websocket.closed and not self.websocket.closed
): ):
await self.websocket.close() await self.websocket.close()
elif ( elif (
hasattr(self.websocket, "state") hasattr(self.websocket, "state")
and self.websocket.state.name != "CLOSED" and self.websocket.state.name != "CLOSED"
): ):
await self.websocket.close() await self.websocket.close()
else: else:

View file

@ -280,6 +280,8 @@ async def send_tts_message(conn: "ConnectionHandler", state, text=None):
await sendAudio(conn, audios) await sendAudio(conn, audios)
# 等待所有音频包发送完成 # 等待所有音频包发送完成
await _wait_for_audio_completion(conn) await _wait_for_audio_completion(conn)
# 停止音频发送循环
conn.audio_rate_controller.stop_sending()
# 清除服务端讲话状态 # 清除服务端讲话状态
conn.clearSpeakStatus() conn.clearSpeakStatus()

View file

@ -43,6 +43,14 @@ class AudioRateController:
def add_audio(self, opus_packet): def add_audio(self, opus_packet):
"""添加音频包到队列""" """添加音频包到队列"""
# 如果队列之前为空,需要调整时间戳以保持播放时间连续
# 这样工具调用等待期间,新加入的音频不会提前播放
if len(self.queue) == 0 and self.play_position > 0:
self.start_timestamp = time.monotonic() - (self.play_position / 1000)
self.logger.bind(tag=TAG).debug(
f"队列从空恢复,重置时间戳,当前播放位置: {self.play_position}ms"
)
self.queue.append(("audio", opus_packet)) self.queue.append(("audio", opus_packet))
# 相关事件处理 # 相关事件处理
self.queue_empty_event.clear() self.queue_empty_event.clear()
@ -55,6 +63,12 @@ class AudioRateController:
Args: Args:
message_callback: 消息发送回调函数 async def() message_callback: 消息发送回调函数 async def()
""" """
if len(self.queue) == 0 and self.play_position > 0:
self.start_timestamp = time.monotonic() - (self.play_position / 1000)
self.logger.bind(tag=TAG).debug(
f"队列从空恢复,重置时间戳,当前播放位置: {self.play_position}ms"
)
self.queue.append(("message", message_callback)) self.queue.append(("message", message_callback))
# 相关事件处理 # 相关事件处理
self.queue_empty_event.clear() self.queue_empty_event.clear()

View file

@ -6,18 +6,20 @@ from datetime import datetime
class Message: class Message:
def __init__( def __init__(
self, self,
role: str, role: str,
content: str = None, content: str = None,
uniq_id: str = None, uniq_id: str = None,
tool_calls=None, tool_calls=None,
tool_call_id=None, tool_call_id=None,
is_temporary=False,
): ):
self.uniq_id = uniq_id if uniq_id is not None else str(uuid.uuid4()) self.uniq_id = uniq_id if uniq_id is not None else str(uuid.uuid4())
self.role = role self.role = role
self.content = content self.content = content
self.tool_calls = tool_calls self.tool_calls = tool_calls
self.tool_call_id = tool_call_id self.tool_call_id = tool_call_id
self.is_temporary = is_temporary # 标记临时消息(如工具调用提醒)
class Dialogue: class Dialogue:
@ -59,8 +61,70 @@ class Dialogue:
else: else:
self.put(Message(role="system", content=new_content)) self.put(Message(role="system", content=new_content))
def trim_history(self, max_turns: int = 10) -> int:
"""
智能截断对话历史,保留工具调用的完整性
Args:
max_turns: 保留的最大对话轮数(每轮 = user + assistant/tool 相关消息)
Returns:
int: 被移除的消息数量
"""
if len(self.dialogue) <= max_turns * 2 + 1: # +1 是系统消息
return 0
# 分离系统消息和对话消息
system_messages = [msg for msg in self.dialogue if msg.role == "system"]
conversation_messages = [msg for msg in self.dialogue if msg.role != "system"]
if len(conversation_messages) <= max_turns * 2:
return 0
# 智能截断:保留完整的工具调用链路
keep_messages = []
i = len(conversation_messages) - 1
turn_count = 0
while i >= 0 and turn_count < max_turns:
msg = conversation_messages[i]
# 从后向前收集消息
if msg.role == "user":
# 遇到 user 消息,说明一轮对话开始
keep_messages.insert(0, msg)
turn_count += 1
i -= 1
elif msg.role == "assistant":
# 收集 assistant 消息
keep_messages.insert(0, msg)
# 如果这个 assistant 有 tool_calls,需要收集对应的 tool 响应
if msg.tool_calls is not None:
i -= 1
# 继续向后收集所有相关的 tool 消息
while i >= 0 and conversation_messages[i].role == "tool":
keep_messages.insert(0, conversation_messages[i])
i -= 1
else:
i -= 1
elif msg.role == "tool":
# tool 消息应该已经被上面的逻辑收集了
# 如果单独遇到,也要保留(防止边界情况)
keep_messages.insert(0, msg)
i -= 1
else:
i -= 1
removed_count = len(conversation_messages) - len(keep_messages)
# 重建对话列表
self.dialogue = system_messages + keep_messages
return removed_count
def get_llm_dialogue_with_memory( def get_llm_dialogue_with_memory(
self, memory_str: str = None, voiceprint_config: dict = None self, memory_str: str = None, voiceprint_config: dict = None
) -> List[Dict[str, str]]: ) -> List[Dict[str, str]]:
# 构建对话 # 构建对话
dialogue = [] dialogue = []

View file

@ -26,7 +26,7 @@ mem0ai==1.0.0
powermem>=0.3.1 powermem>=0.3.1
bs4==0.0.2 bs4==0.0.2
modelscope==1.32.0 modelscope==1.32.0
sherpa_onnx==1.12.17 sherpa_onnx==1.12.29
mcp==1.22.0 mcp==1.22.0
cnlunar==0.2.0 cnlunar==0.2.0
PySocks==1.7.1 PySocks==1.7.1