Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ COS_ENABLE_OLD_DOMAIN=true
# 如果解析网络连接使用Web代理,需要配置以下参数
# WEB_PROXY=your_web_proxy

# Neo4j 开关
# NEO4J_ENABLE=false

# Neo4j的访问地址
# NEO4J_URI=neo4j://neo4j:7687

# Neo4j的用户名和密码
# NEO4J_USERNAME=neo4j

# Neo4j的密码
# NEO4J_PASSWORD=password

##############################################################

###### 注意: 以下配置不再生效,已在Web“配置初始化”阶段完成 #########
Expand Down
66 changes: 66 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,69 @@ knowledge_base:
split_markers: ["\n\n", "\n", "。"]
image_processing:
enable_multimodal: true

extract:
extract_graph:
description: |
请基于给定文本,按以下步骤完成信息提取任务,确保逻辑清晰、信息完整准确:

## 一、实体提取与属性补充
1. **提取核心实体**:通读文本,按逻辑顺序(如文本叙述顺序、实体关联紧密程度)提取所有与任务相关的核心实体。
2. **补充实体详细属性**:针对每个提取的实体,全面补充其在文本中明确提及的详细属性,确保无关键属性遗漏。

## 二、关系提取与验证
1. **明确关系类型**:仅从指定关系列表中选择对应类型,限定关系类型为: %s。
2. **提取有效关系**:基于已提取的实体及属性,识别文本中真实存在的关系,确保关系符合文本事实、无虚假关联。
3. **明确关系主体**:对每一组提取的关系,清晰标注两个关联主体,避免主体混淆。
4. **补充关联属性**:若文本中存在与该关系直接相关的补充信息,需将该信息作为关系的关联属性补充,进一步完善关系信息。
tags:
- "作者"
- "别名"
examples:
- text: |
《红楼梦》,又名《石头记》,是清代作家曹雪芹创作的中国古典四大名著之一,被誉为中国封建社会的百科全书。该书前80回由曹雪芹所著,后40回一般认为是高鹗所续。
小说以贾、史、王、薛四大家族的兴衰为背景,以贾宝玉、林黛玉和薛宝钗的爱情悲剧为主线,刻画了以贾宝玉和金陵十二钗为中心的正邪两赋、贤愚并出的高度复杂的人物群像。
成书于乾隆年间(1743年前后),是中国文学史上现实主义的高峰,对后世影响深远。
node:
- name: "红楼梦"
attributes:
- "中国古典四大名著之一"
- "又名《石头记》"
- "被誉为中国封建社会的百科全书"
- name: "石头记"
attributes:
- "《红楼梦》的别名"
- name: "曹雪芹"
attributes:
- "清代作家"
- "《红楼梦》前 80 回的作者"
- name: "高鹗"
attributes:
- "一般认为是《红楼梦》后 40 回的续写者"
relation:
- node1: "红楼梦"
node2: "曹雪芹"
type: "作者"
- node1: "红楼梦"
node2: "高鹗"
type: "作者"
- node1: "红楼梦"
node2: "石头记"
type: "别名"
extract_entity:
description: |
请基于用户给的问题,按以下步骤处理关键信息提取任务:
1. 梳理逻辑关联:首先完整分析文本内容,明确其核心逻辑关系,并简要标注该核心逻辑类型;
2. 提取关键实体:围绕梳理出的逻辑关系,精准提取文本中的关键信息并归类为明确实体,确保不遗漏核心信息、不添加冗余内容;
3. 排序实体优先级:按实体与文本核心主题的关联紧密程度排序,优先呈现对理解文本主旨最重要的实体;
examples:
- text: "《红楼梦》,又名《石头记》,是清代作家曹雪芹创作的中国古典四大名著之一,被誉为中国封建社会的百科全书。"
node:
- name: "红楼梦"
- name: "曹雪芹"
- name: "中国古典四大名著"
fabri_text:
with_tag: |
请随机生成一段文本,要求内容与 %s 等相关,字数在 [50-200] 之间,并且尽量包含一些与这些标签相关的专业术语或典型元素,使文本更具针对性和相关性。
with_no_tag: |
请随机生成一段文本,内容请自由发挥,字数在 [50-200] 之间。
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ services:
- REDIS_DB=${REDIS_DB:-}
- REDIS_PREFIX=${REDIS_PREFIX:-}
- ENABLE_GRAPH_RAG=${ENABLE_GRAPH_RAG:-}
- NEO4J_ENABLE=${NEO4J_ENABLE:-}
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USERNAME=${NEO4J_USERNAME:-neo4j}
- NEO4J_PASSWORD=${NEO4J_PASSWORD:-password}
- TENANT_AES_KEY=${TENANT_AES_KEY:-}
- CONCURRENCY_POOL_SIZE=${CONCURRENCY_POOL_SIZE:-5}
- INIT_LLM_MODEL_NAME=${INIT_LLM_MODEL_NAME:-}
Expand All @@ -76,6 +80,8 @@ services:
condition: service_started
docreader:
condition: service_healthy
neo4j:
condition: service_started
networks:
- WeKnora-network
restart: unless-stopped
Expand Down Expand Up @@ -209,6 +215,24 @@ services:
networks:
- WeKnora-network

neo4j:
image: neo4j:latest
container_name: WeKnora-neo4j
volumes:
- neo4j-data:/data
environment:
- NEO4J_AUTH=${NEO4J_USERNAME:-neo4j}/${NEO4J_PASSWORD:-password}
- NEO4J_apoc_export_file_enabled=true
- NEO4J_apoc_import_file_enabled=true
- NEO4J_apoc_import_file_use__neo4j__config=true
- NEO4JLABS_PLUGINS=["apoc"]
ports:
- "7474:7474"
- "7687:7687"
restart: always
networks:
- WeKnora-network

networks:
WeKnora-network:
driver: bridge
Expand All @@ -219,3 +243,4 @@ volumes:
jaeger_data:
redis_data:
minio_data:
neo4j-data:
102 changes: 98 additions & 4 deletions frontend/src/api/initialization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export interface InitializationConfig {
};
// Frontend-only hint for storage selection UI
storageType?: 'cos' | 'minio';
nodeExtract: {
enabled: boolean,
text: string,
tags: string[],
nodes: Node[],
relations: Relation[]
}
}

// 下载任务状态类型
Expand All @@ -63,8 +70,6 @@ export interface DownloadTask {
endTime?: string;
}



// 根据知识库ID执行配置更新
export function initializeSystemByKB(kbId: string, config: InitializationConfig): Promise<any> {
return new Promise((resolve, reject) => {
Expand All @@ -76,7 +81,7 @@ export function initializeSystemByKB(kbId: string, config: InitializationConfig)
})
.catch((error: any) => {
console.error('知识库配置更新失败:', error);
reject(error);
reject(error.error || error);
});
});
}
Expand Down Expand Up @@ -324,4 +329,93 @@ export function testMultimodalFunction(testData: {
reject(error);
});
});
}
}

// 文本内容关系提取接口
export interface TextRelationExtractionRequest {
text: string;
tags: string[];
llmConfig: LLMConfig;
}

export interface Node {
name: string;
attributes: string[];
}

export interface Relation {
node1: string;
node2: string;
type: string;
}

export interface LLMConfig {
source: 'local' | 'remote';
modelName: string;
baseUrl: string;
apiKey: string;
}

export interface TextRelationExtractionResponse {
nodes: Node[];
relations: Relation[];
}

// 文本内容关系提取
export function extractTextRelations(request: TextRelationExtractionRequest): Promise<TextRelationExtractionResponse> {
return new Promise((resolve, reject) => {
post('/api/v1/initialization/extract/text-relation', request)
.then((response: any) => {
resolve(response.data || { nodes: [], relations: [] });
})
.catch((error: any) => {
console.error('文本内容关系提取失败:', error);
reject(error);
});
});
}

export interface FabriTextRequest {
tags: string[];
llmConfig: LLMConfig;
}

export interface FabriTextResponse {
text: string;
}

// 文本内容生成
export function fabriText(request: FabriTextRequest): Promise<FabriTextResponse> {
return new Promise((resolve, reject) => {
post('/api/v1/initialization/extract/fabri-text', request)
.then((response: any) => {
resolve(response.data || { text: '' });
})
.catch((error: any) => {
console.error('文本内容生成失败:', error);
reject(error);
});
});
}

export interface FabriTagRequest {
llmConfig: LLMConfig;
}

export interface FabriTagResponse {
tags: string[];
}

// 文本内容生成
export function fabriTag(request: FabriTagRequest): Promise<FabriTagResponse> {
return new Promise((resolve, reject) => {
post('/api/v1/initialization/extract/fabri-tag', request)
.then((response: any) => {
resolve(response.data || { tags: [] as string[] });
})
.catch((error: any) => {
console.error('标签生成失败:', error);
reject(error);
});
});
}
5 changes: 4 additions & 1 deletion frontend/src/components/menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ let activeSubmenu = ref<number>(-1);

// 是否处于知识库详情页
const isInKnowledgeBase = computed<boolean>(() => {
return route.name === 'knowledgeBaseDetail' || route.name === 'kbCreatChat' || route.name === 'chat' || route.name === 'knowledgeBaseSettings';
return route.name === 'knowledgeBaseDetail' ||
route.name === 'kbCreatChat' ||
route.name === 'chat' ||
route.name === 'knowledgeBaseSettings';
});

// 统一的菜单项激活状态判断
Expand Down
Loading