Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
黄南光
/
wiki_knowledge
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 914553c4
authored
Sep 10, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
wiki-ontology尝试
1 parent
9a953037
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
2 deletions
frontend/package-lock.json
frontend/package.json
frontend/src/components/Sidebar.tsx
main.py
requirements.txt
src/api/routes/ingest.py
src/api/routes/query.py
frontend/package-lock.json
View file @
914553c
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
"dependencies"
:
{
"dependencies"
:
{
"@tailwindcss/typography"
:
"^0.5.19"
,
"@tailwindcss/typography"
:
"^0.5.19"
,
"clsx"
:
"^2.1.1"
,
"clsx"
:
"^2.1.1"
,
"cytoscape"
:
"^3.34.2"
,
"cytoscape-fcose"
:
"^2.2.0"
,
"js-yaml"
:
"^5.2.1"
,
"js-yaml"
:
"^5.2.1"
,
"lucide-react"
:
"^1.17.0"
,
"lucide-react"
:
"^1.17.0"
,
"next"
:
"16.2.6"
,
"next"
:
"16.2.6"
,
...
@@ -3095,6 +3097,15 @@
...
@@ -3095,6 +3097,15 @@
"hasInstallScript"
:
true
,
"hasInstallScript"
:
true
,
"license"
:
"MIT"
"license"
:
"MIT"
},
},
"node_modules/cose-base"
:
{
"version"
:
"2.2.0"
,
"resolved"
:
"https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz"
,
"integrity"
:
"sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g=="
,
"license"
:
"MIT"
,
"dependencies"
:
{
"layout-base"
:
"^2.0.0"
}
},
"node_modules/crc-32"
:
{
"node_modules/crc-32"
:
{
"version"
:
"1.2.2"
,
"version"
:
"1.2.2"
,
"resolved"
:
"https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz"
,
"resolved"
:
"https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz"
,
...
@@ -3140,6 +3151,27 @@
...
@@ -3140,6 +3151,27 @@
"integrity"
:
"sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="
,
"integrity"
:
"sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="
,
"license"
:
"MIT"
"license"
:
"MIT"
},
},
"node_modules/cytoscape"
:
{
"version"
:
"3.34.2"
,
"resolved"
:
"https://registry.npmjs.org/cytoscape/-/cytoscape-3.34.2.tgz"
,
"integrity"
:
"sha512-Cm2jaj1X/PBNlzV9yH8zcfGOxO7U+CJ/+mxSBVPSchLaugdp4jtlGx5qaHtPRZ6tgiZ5P+o1XoRfJA+ba6KM3g=="
,
"license"
:
"MIT"
,
"engines"
:
{
"node"
:
">=0.10"
}
},
"node_modules/cytoscape-fcose"
:
{
"version"
:
"2.2.0"
,
"resolved"
:
"https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz"
,
"integrity"
:
"sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ=="
,
"license"
:
"MIT"
,
"dependencies"
:
{
"cose-base"
:
"^2.2.0"
},
"peerDependencies"
:
{
"cytoscape"
:
"^3.2.0"
}
},
"node_modules/damerau-levenshtein"
:
{
"node_modules/damerau-levenshtein"
:
{
"version"
:
"1.0.8"
,
"version"
:
"1.0.8"
,
"resolved"
:
"https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz"
,
"resolved"
:
"https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz"
,
...
@@ -5344,6 +5376,12 @@
...
@@ -5344,6 +5376,12 @@
"node"
:
">=0.10"
"node"
:
">=0.10"
}
}
},
},
"node_modules/layout-base"
:
{
"version"
:
"2.0.1"
,
"resolved"
:
"https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz"
,
"integrity"
:
"sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg=="
,
"license"
:
"MIT"
},
"node_modules/levn"
:
{
"node_modules/levn"
:
{
"version"
:
"0.4.1"
,
"version"
:
"0.4.1"
,
"resolved"
:
"https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
,
"resolved"
:
"https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
,
...
...
frontend/package.json
View file @
914553c
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
"dependencies"
:
{
"dependencies"
:
{
"@tailwindcss/typography"
:
"^0.5.19"
,
"@tailwindcss/typography"
:
"^0.5.19"
,
"clsx"
:
"^2.1.1"
,
"clsx"
:
"^2.1.1"
,
"cytoscape"
:
"^3.34.2"
,
"cytoscape-fcose"
:
"^2.2.0"
,
"js-yaml"
:
"^5.2.1"
,
"js-yaml"
:
"^5.2.1"
,
"lucide-react"
:
"^1.17.0"
,
"lucide-react"
:
"^1.17.0"
,
"next"
:
"16.2.6"
,
"next"
:
"16.2.6"
,
...
...
frontend/src/components/Sidebar.tsx
View file @
914553c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import Link from "next/link";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { usePathname } from "next/navigation";
import { BookOpen, Database, FileText, Settings, UserRound } from "lucide-react";
import { BookOpen, Database, FileText, Settings, UserRound
, Network
} from "lucide-react";
import { cn } from "@/lib/utils";
import { cn } from "@/lib/utils";
import { fetchMe } from "@/lib/auth";
import { fetchMe } from "@/lib/auth";
...
@@ -19,6 +19,7 @@ const NAV_ITEMS: NavItem[] = [
...
@@ -19,6 +19,7 @@ const NAV_ITEMS: NavItem[] = [
{ href: "/", label: "Wiki 原始文件", icon: FileText },
{ href: "/", label: "Wiki 原始文件", icon: FileText },
{ href: "/wiki-repo", label: "Wiki 知识库", icon: BookOpen },
{ href: "/wiki-repo", label: "Wiki 知识库", icon: BookOpen },
{ href: "/rag", label: "RAG 工作台", icon: Database },
{ href: "/rag", label: "RAG 工作台", icon: Database },
{ href: "/ontology", label: "业务本体", icon: Network },
{ href: "/profile", label: "我的画像", icon: UserRound },
{ href: "/profile", label: "我的画像", icon: UserRound },
{ href: "/system/user", label: "系统管理", icon: Settings, adminOnly: true },
{ href: "/system/user", label: "系统管理", icon: Settings, adminOnly: true },
];
];
...
...
main.py
View file @
914553c
...
@@ -34,6 +34,7 @@ from src.api.routes.oa import router as oa_router
...
@@ -34,6 +34,7 @@ from src.api.routes.oa import router as oa_router
from
src.api.routes.kb
import
router
as
kb_router
from
src.api.routes.kb
import
router
as
kb_router
from
src.api.routes.skills
import
router
as
skills_router
from
src.api.routes.skills
import
router
as
skills_router
from
src.rag.api.routes
import
router
as
rag_router
from
src.rag.api.routes
import
router
as
rag_router
from
src.api.routes.ontology
import
router
as
ontology_router
from
fastapi
import
Depends
from
fastapi
import
Depends
from
src.services.oa.intercept
import
intercept_guard
,
sync_interface_sources
from
src.services.oa.intercept
import
intercept_guard
,
sync_interface_sources
...
@@ -160,6 +161,7 @@ app.include_router(oa_router)
...
@@ -160,6 +161,7 @@ app.include_router(oa_router)
app
.
include_router
(
kb_router
)
app
.
include_router
(
kb_router
)
app
.
include_router
(
skills_router
)
app
.
include_router
(
skills_router
)
app
.
include_router
(
rag_router
)
app
.
include_router
(
rag_router
)
app
.
include_router
(
ontology_router
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
uvicorn
.
run
(
"main:app"
,
host
=
"0.0.0.0"
,
port
=
8104
,
reload
=
False
)
uvicorn
.
run
(
"main:app"
,
host
=
"0.0.0.0"
,
port
=
8104
,
reload
=
False
)
requirements.txt
View file @
914553c
...
@@ -71,3 +71,7 @@ opentelemetry-api==1.42.1
...
@@ -71,3 +71,7 @@ opentelemetry-api==1.42.1
opentelemetry-sdk==1.42.1
opentelemetry-sdk==1.42.1
opentelemetry-exporter-otlp==1.42.1
opentelemetry-exporter-otlp==1.42.1
opentelemetry-semantic-conventions==0.63b1
opentelemetry-semantic-conventions==0.63b1
# 公司业务本体(Ontology)子系统:LightRAG 抽取/图检索 + Neo4j 图后端
lightrag-hku==1.5.6
neo4j==6.3.0
src/api/routes/ingest.py
View file @
914553c
...
@@ -1131,6 +1131,14 @@ async def run_ingest_agent(file_id: str):
...
@@ -1131,6 +1131,14 @@ async def run_ingest_agent(file_id: str):
file_id
,
f
"摄入超时({INGEST_TIMEOUT_SECONDS}s),任务被强制终止"
file_id
,
f
"摄入超时({INGEST_TIMEOUT_SECONDS}s),任务被强制终止"
)
)
logger
.
info
(
f
"[IngestTask] released_work_after_impl file_id={file_id}"
)
logger
.
info
(
f
"[IngestTask] released_work_after_impl file_id={file_id}"
)
# 本体子系统:摄入成功后可选自动沉淀为公司业务本体。
# 开关(ONTOLOGY_AUTO_DISTILL)默认关闭;钩子内部 try/except 兜底,
# 任何失败只记日志、绝不影响摄入结果与状态。
try
:
from
src.ontology.ingest_hook
import
on_ingest_success
await
on_ingest_success
(
file_id
=
file_id
)
except
Exception
:
logger
.
debug
(
"[Ontology] 摄入后沉淀钩子异常(已忽略)"
,
exc_info
=
True
)
except
asyncio
.
CancelledError
:
except
asyncio
.
CancelledError
:
logger
.
info
(
f
"[{file_id}] 摄入任务已被用户终止"
)
logger
.
info
(
f
"[{file_id}] 摄入任务已被用户终止"
)
await
_mark_ingest_cancelled
(
file_id
)
await
_mark_ingest_cancelled
(
file_id
)
...
...
src/api/routes/query.py
View file @
914553c
...
@@ -445,8 +445,22 @@ def build_query_agent(
...
@@ -445,8 +445,22 @@ def build_query_agent(
f
"{lines}
\n
"
f
"{lines}
\n
"
)
)
# 公司业务本体上下文(开关 ONTOLOGY_INJECT_ENABLED 默认关闭)。
# 关闭时为空串,sys_prompt 逐字节不变、不破坏 DashScope 共享缓存前缀;
# 全 try 包裹,本体子系统任何异常都不影响 wiki 问答。
company_prefix
=
""
try
:
from
src.ontology.config
import
ONTOLOGY_INJECT_ENABLED
if
ONTOLOGY_INJECT_ENABLED
:
from
src.ontology.context_api
import
get_company_context
_ctx
=
get_company_context
()
if
_ctx
:
company_prefix
=
_ctx
+
"
\n\n
"
except
Exception
:
company_prefix
=
""
# 定义完整的系统提示词
# 定义完整的系统提示词
sys_prompt
=
f
"""你是一名专业的汽车后市场服务知识顾问。你的任务是基于知识库精确回答用户问题。
sys_prompt
=
company_prefix
+
f
"""你是一名专业的汽车后市场服务知识顾问。你的任务是基于知识库精确回答用户问题。
【知识库地图(index.md,已为你注入,禁止再用工具读取 index.md)】
【知识库地图(index.md,已为你注入,禁止再用工具读取 index.md)】
下面按你本次可用的知识库分段列出(每段标注库名与「页面根目录」)。普通行格式为 `- [[slug]] — 标题`;sources 行会额外带 `| path: <库根>/sources/<品牌系列>/<slug>.md`。请直接据此地图定位目标页面。
下面按你本次可用的知识库分段列出(每段标注库名与「页面根目录」)。普通行格式为 `- [[slug]] — 标题`;sources 行会额外带 `| path: <库根>/sources/<品牌系列>/<slug>.md`。请直接据此地图定位目标页面。
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment