feat(权限优化)1.AI对话中点击快捷标签问题时,明明已经配置了默认默写为什么还会提示配置?必须点击一下保存并关闭才可以这个不对,只要配置了就可以问答不需要再让用户过来点击一次!如图一、二所示
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s
2.知识库中的企业培训(课件)、企业培训(试题)、配置中心、组织架构、共享空间如图三所示可查看权限归属到超级管理员权限中!如何对
This commit is contained in:
1 parent
353f60a175
commit
043e0485e2
14 files changed
+368
-74
No files matched your search
@@ -1,28 +1,47 @@
|
||||
import type { CustomAgentConfig } from '@/api/agent'
|
||||
import type { ModelConfig } from '@/api/model'
|
||||
import { allowedToolsInclude } from './legacy-tool-names'
|
||||
import { selectInitialModelId } from './modelDefaults'
|
||||
|
||||
export type AgentNotReadyReasonKey = 'summary_model' | 'rerank_model' | 'allowed_tools'
|
||||
|
||||
/**
|
||||
* An agent is chat-ready only when it explicitly references a usable chat
|
||||
* model. Merely having some built-in/default model in the tenant must not hide
|
||||
* incomplete agent configuration.
|
||||
* An agent is chat-ready when it references a usable chat model, or when it
|
||||
* may fall back to the workspace default: an empty model_id is resolved at run
|
||||
* time from the agent's knowledge base or the workspace's default KnowledgeQA
|
||||
* model (backend UsesWorkspaceModelFallback + selectChatModelID), so a local
|
||||
* agent without an explicit model is ready as long as the workspace has a
|
||||
* usable default. Only a model_id that points at a missing/non-KnowledgeQA
|
||||
* model counts as incomplete configuration.
|
||||
*
|
||||
* For shared agents the model belongs to the source tenant, so the caller can
|
||||
* require a non-empty ID but must leave existence validation to the backend.
|
||||
*/
|
||||
export function agentHasConfiguredChatModel(
|
||||
config: Pick<CustomAgentConfig, 'model_id'> | undefined,
|
||||
models: Pick<ModelConfig, 'id' | 'type'>[],
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
sourceModelIsRemote = false,
|
||||
): boolean {
|
||||
const modelID = config?.model_id?.trim()
|
||||
if (!modelID) return false
|
||||
if (!modelID) {
|
||||
if (sourceModelIsRemote) return false
|
||||
return hasWorkspaceDefaultChatModel(models)
|
||||
}
|
||||
if (sourceModelIsRemote) return true
|
||||
return models.some(model => model.type === 'KnowledgeQA' && model.id === modelID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Workspace default chat model: the declared KnowledgeQA default, else the
|
||||
* first active KnowledgeQA model — same rule as the backend's
|
||||
* PickDefaultModelID and the agent editor's auto pre-fill.
|
||||
*/
|
||||
export function hasWorkspaceDefaultChatModel(
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
): boolean {
|
||||
return selectInitialModelId(models, 'KnowledgeQA') != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep this aligned with backend agentRequiresRerankModel.
|
||||
*
|
||||
@@ -50,8 +69,8 @@ export function getAgentNotReadyReasonKeys(
|
||||
CustomAgentConfig,
|
||||
'model_id' | 'rerank_model_id' | 'kb_selection_mode' | 'allowed_tools' | 'agent_mode'
|
||||
> | undefined,
|
||||
models: Pick<ModelConfig, 'id' | 'type'>[],
|
||||
options: { isAgentMode: boolean; isSharedAgent: boolean },
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
options: { isAgentMode: boolean; isSharedAgent: boolean; isBuiltin?: boolean },
|
||||
): AgentNotReadyReasonKey[] {
|
||||
const reasons: AgentNotReadyReasonKey[] = []
|
||||
|
||||
@@ -61,12 +80,20 @@ export function getAgentNotReadyReasonKeys(
|
||||
|
||||
if (options.isAgentMode && agentRequiresRerankModel(config)) {
|
||||
const rerankModelID = config?.rerank_model_id?.trim()
|
||||
const rerankExists = !!rerankModelID && (
|
||||
options.isSharedAgent
|
||||
|| models.some(model => model.type === 'Rerank' && model.id === rerankModelID)
|
||||
)
|
||||
if (!rerankExists) {
|
||||
reasons.push('rerank_model')
|
||||
if (!rerankModelID) {
|
||||
// Built-in agents are seeded without a rerank model; the run falls back
|
||||
// to the workspace rerank (or searches without reranking) instead of
|
||||
// blocking, mirroring session_agent_qa.go's UsesWorkspaceModelFallback
|
||||
// branch. Custom agents must declare their own rerank model.
|
||||
if (!options.isBuiltin || options.isSharedAgent) {
|
||||
reasons.push('rerank_model')
|
||||
}
|
||||
} else {
|
||||
const rerankExists = options.isSharedAgent
|
||||
|| models.some(model => model.type === 'Rerank' && model.id === rerankModelID)
|
||||
if (!rerankExists) {
|
||||
reasons.push('rerank_model')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user