feat(ai-writing): 检索类型加回「知识库检索」(直连内网 ES 接口)
弱模型常识别不了配置技能(deepseek-chat 等),恢复旧的"不用技能"检索路径 作为独立检索类型 knowledge_base:绕过技能编排,直接调 ai_writing.intranet_search_url 内网知识库 ES 接口(IntranetSearchProvider) 对检索词并发检索;未配地址 → 无素材 + skill_error 告警。 - researcher.py: material_source 归一保留 knowledge_base + 新增直连内网分支 - state.py: material_source 三值注释 - 前端 AIWritingForm/WritingFormContext/types: 下拉新增「知识库检索」 - tests/test_ai_writing_knowledge_base.py: 直连/未配/不编排技能 3 用例 - backend CLAUDE.md: 检索类型段更新为三值 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a400989f64
commit
3d60651491
7 files changed
+182
-16
No files matched your search
@@ -40,11 +40,12 @@ const INPUT_CLASS =
|
||||
|
||||
const DEFAULT_KEYWORD_COUNT = 1;
|
||||
const DEFAULT_AUDIENCE = '普通读者';
|
||||
type MaterialSource = 'general' | 'notebook';
|
||||
type MaterialSource = 'general' | 'knowledge_base' | 'notebook';
|
||||
const MAX_INTENT_LENGTH = 500;
|
||||
|
||||
const MATERIAL_SOURCE_OPTIONS: Array<{ value: MaterialSource; label: string; desc: string }> = [
|
||||
{ value: 'general', label: '通用检索', desc: '用素材收集专家配置的技能检索(默认:知识库检索)' },
|
||||
{ value: 'knowledge_base', label: '知识库检索', desc: '直连内网知识库检索接口,不走技能编排' },
|
||||
{ value: 'notebook', label: '我的空间', desc: '从空间中检索素材' },
|
||||
];
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ export interface WritingFormValue {
|
||||
/** 是否在成稿里加参考文献(正文 [n] 角标 + 文末「参考文献」列表,像论文)。默认开。 */
|
||||
addReferences: boolean;
|
||||
setAddReferences: (v: boolean) => void;
|
||||
materialSource: 'general' | 'notebook';
|
||||
setMaterialSource: (v: 'general' | 'notebook') => void;
|
||||
materialSource: 'general' | 'knowledge_base' | 'notebook';
|
||||
setMaterialSource: (v: 'general' | 'knowledge_base' | 'notebook') => void;
|
||||
/** 不收集素材,直接用通用知识写作:勾选后跳过素材检索阶段(含素材确认暂停点)。默认关。 */
|
||||
skipResearch: boolean;
|
||||
setSkipResearch: (v: boolean) => void;
|
||||
@@ -75,7 +75,7 @@ export function WritingFormProvider({
|
||||
initialDocumentIds,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
initialMaterialSource?: 'general' | 'notebook';
|
||||
initialMaterialSource?: 'general' | 'knowledge_base' | 'notebook';
|
||||
initialNotebookId?: number | null;
|
||||
initialDocumentIds?: number[];
|
||||
}) {
|
||||
@@ -88,7 +88,7 @@ export function WritingFormProvider({
|
||||
const [audience, setAudience] = useState('普通读者');
|
||||
const [strictMode, setStrictMode] = useState(false);
|
||||
const [addReferences, setAddReferences] = useState(true);
|
||||
const [materialSource, setMaterialSource] = useState<'general' | 'notebook'>(initialMaterialSource ?? 'general');
|
||||
const [materialSource, setMaterialSource] = useState<'general' | 'knowledge_base' | 'notebook'>(initialMaterialSource ?? 'general');
|
||||
const [skipResearch, setSkipResearch] = useState(false);
|
||||
const [selectedNotebookId, setSelectedNotebookId] = useState<number | null>(initialNotebookId ?? null);
|
||||
const [selectedDocumentIds, setSelectedDocumentIds] = useState<number[]>(initialDocumentIds ?? []);
|
||||
@@ -105,8 +105,10 @@ export function WritingFormProvider({
|
||||
if (payload.target_audience?.trim()) setAudience(payload.target_audience.trim());
|
||||
if (payload.writing_mode === 'strict') setStrictMode(true);
|
||||
else if (payload.writing_mode === 'loose') setStrictMode(false);
|
||||
// 旧值 skill / knowledge_base 已合并为通用检索 general
|
||||
if (payload.material_source === 'skill' || payload.material_source === 'knowledge_base' || payload.material_source === 'general') {
|
||||
// knowledge_base=知识库检索(直连内网 ES)保留;旧值 skill 归一为通用检索 general
|
||||
if (payload.material_source === 'knowledge_base') {
|
||||
setMaterialSource('knowledge_base');
|
||||
} else if (payload.material_source === 'skill' || payload.material_source === 'general') {
|
||||
setMaterialSource('general');
|
||||
}
|
||||
if (payload.outline?.trim()) {
|
||||
|
||||
@@ -265,8 +265,9 @@ export interface AIWritingRequest {
|
||||
writingMode: "strict" | "loose";
|
||||
/** 是否在成稿里加参考文献(正文 [n] 角标 + 文末「参考文献」列表,像论文)。默认 true。 */
|
||||
addReferences?: boolean;
|
||||
/** 检索类型:general=通用检索(素材收集专家按配置技能检索,默认知识库检索技能)/ notebook=我的空间 */
|
||||
materialSource: "general" | "notebook";
|
||||
/** 检索类型:general=通用检索(素材收集专家按配置技能检索,默认知识库检索技能)/
|
||||
* knowledge_base=知识库检索(直连内网知识库 ES 接口,不走技能编排)/ notebook=我的空间 */
|
||||
materialSource: "general" | "knowledge_base" | "notebook";
|
||||
/** 不收集素材,直接用通用知识写作:勾选后跳过整个素材检索流程(含素材确认暂停点),
|
||||
* 直接进入大纲规划;后端强制 loose 写作模式。默认 false。 */
|
||||
skipResearch?: boolean;
|
||||
|
||||
Reference in new issue
Block a user