feat: add skill and assistant knowledge bases
This commit is contained in:
1 parent
dd0ee282df
commit
fbd8dec48f
45 files changed
+5262
-21
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""Portable entity/relation normalization used by both knowledge products."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
|
||||
def normalize_name(value: str) -> str:
|
||||
text = unicodedata.normalize("NFKC", value or "").strip().casefold()
|
||||
text = text.strip("`'\"“”‘’《》〈〉[](){}")
|
||||
text = re.sub(r"\s+", " ", text)
|
||||
return text
|
||||
|
||||
|
||||
def normalize_predicate(value: str) -> str:
|
||||
normalized = normalize_name(value).replace(" ", "_")
|
||||
aliases = {
|
||||
"依赖": "depends_on",
|
||||
"需要": "depends_on",
|
||||
"requires": "depends_on",
|
||||
"调用": "uses",
|
||||
"使用": "uses",
|
||||
"uses": "uses",
|
||||
"生成": "produces",
|
||||
"输出": "produces",
|
||||
"读取": "consumes",
|
||||
"输入": "consumes",
|
||||
"引用": "references",
|
||||
}
|
||||
return aliases.get(normalized, normalized or "related_to")
|
||||
Reference in new issue
Block a user