feat: 支持智能体文档附件与轻量读取
- 建立文档上传、异步读取、对象存储、补偿与聊天绑定闭环 - 按智能体 20K 上下文预算选择文档片段并保留稳定引用 - 统一聊天文件卡片、类型图标、草稿恢复与可靠下载
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package tech.easyflow.agent.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.agent.entity.AgentDocumentAttachment;
|
||||
|
||||
/**
|
||||
* Agent 文档附件状态账本服务。
|
||||
*/
|
||||
public interface AgentDocumentAttachmentService extends IService<AgentDocumentAttachment> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package tech.easyflow.agent.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.agent.entity.AgentDocumentSnapshot;
|
||||
|
||||
/**
|
||||
* Agent 文档快照元数据服务。
|
||||
*/
|
||||
public interface AgentDocumentSnapshotService extends IService<AgentDocumentSnapshot> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package tech.easyflow.agent.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.agent.entity.AgentDocumentAttachment;
|
||||
import tech.easyflow.agent.mapper.AgentDocumentAttachmentMapper;
|
||||
import tech.easyflow.agent.service.AgentDocumentAttachmentService;
|
||||
|
||||
/**
|
||||
* Agent 文档附件状态账本服务实现。
|
||||
*/
|
||||
@Service
|
||||
public class AgentDocumentAttachmentServiceImpl
|
||||
extends ServiceImpl<AgentDocumentAttachmentMapper, AgentDocumentAttachment>
|
||||
implements AgentDocumentAttachmentService {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package tech.easyflow.agent.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.agent.entity.AgentDocumentSnapshot;
|
||||
import tech.easyflow.agent.mapper.AgentDocumentSnapshotMapper;
|
||||
import tech.easyflow.agent.service.AgentDocumentSnapshotService;
|
||||
|
||||
/**
|
||||
* Agent 文档快照元数据服务实现。
|
||||
*/
|
||||
@Service
|
||||
public class AgentDocumentSnapshotServiceImpl
|
||||
extends ServiceImpl<AgentDocumentSnapshotMapper, AgentDocumentSnapshot>
|
||||
implements AgentDocumentSnapshotService {
|
||||
}
|
||||
@@ -195,6 +195,37 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
||||
}
|
||||
agent.setVisibilityScope(VisibilityScope.fromOrDefault(agent.getVisibilityScope(), VisibilityScope.PRIVATE).name());
|
||||
agent.setInteractionConfigJson(AgentInteractionConfigSupport.normalize(agent.getInteractionConfigJson()));
|
||||
agent.setExecutionConfigJson(normalizeExecutionConfig(agent.getExecutionConfigJson()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范并校验 Agent 运行配置中的文档上下文预算。
|
||||
*
|
||||
* @param source 原运行配置
|
||||
* @return 带默认预算的运行配置
|
||||
*/
|
||||
private Map<String, Object> normalizeExecutionConfig(Map<String, Object> source) {
|
||||
Map<String, Object> normalized = source == null
|
||||
? new LinkedHashMap<>() : new LinkedHashMap<>(source);
|
||||
Object value = normalized.get("documentContextBudgetTokens");
|
||||
if (value == null || String.valueOf(value).isBlank()) {
|
||||
normalized.put("documentContextBudgetTokens", 20_000);
|
||||
return normalized;
|
||||
}
|
||||
try {
|
||||
String text = String.valueOf(value).trim();
|
||||
if (!text.matches("\\d+")) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
int budget = Integer.parseInt(text);
|
||||
if (budget <= 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
normalized.put("documentContextBudgetTokens", budget);
|
||||
return normalized;
|
||||
} catch (NumberFormatException error) {
|
||||
throw new BusinessException("文档上下文预算必须为正整数");
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDraftDefaults(Agent agent) {
|
||||
|
||||
Reference in New Issue
Block a user