MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _gen_entity_update

Function _gen_entity_update

openkb/agent/compiler.py:1901–1936  ·  view source on GitHub ↗
(ent: dict)

Source from the content-addressed store, hash-verified

1899 return name, content, brief, etype_out
1900
1901 async def _gen_entity_update(ent: dict) -> tuple[str, str, str, str]:
1902 name = ent["name"]
1903 title = ent.get("title", name)
1904 etype = ent.get("type", "other")
1905 epath = wiki_dir / "entities" / f"{_sanitize_concept_name(name)}.md"
1906 if epath.exists():
1907 raw_text = epath.read_text(encoding="utf-8")
1908 ex_parts = frontmatter.split(raw_text)
1909 existing_content = ex_parts[1].strip() if ex_parts is not None else raw_text
1910 else:
1911 existing_content = "(page not found — create from scratch)"
1912 async with semaphore:
1913 raw = await _llm_call_page_async(
1914 model,
1915 [
1916 system_msg,
1917 doc_msg, # cached (BP1)
1918 summary_msg, # cached (BP2)
1919 known_targets_msg, # cached (BP3) — whitelist
1920 {
1921 "role": "user",
1922 "content": _ENTITY_UPDATE_USER.format(
1923 title=title,
1924 type=etype,
1925 doc_name=doc_name,
1926 existing_content=existing_content,
1927 ).replace("__ENTITY_TYPES__", types_str),
1928 },
1929 ],
1930 f"entity-update: {name}",
1931 response_format=_JSON_RESPONSE_FORMAT,
1932 )
1933 brief, content, obj = _page_fields(raw)
1934 etype_out = obj.get("type") if obj and obj.get("type") in valid_types else etype
1935 _require_nonempty_content(content, name)
1936 return name, content, brief, etype_out
1937
1938 tasks = []
1939 tasks.extend(_gen_create(c) for c in create_items)

Callers 1

_compile_conceptsFunction · 0.85

Calls 5

_sanitize_concept_nameFunction · 0.85
_llm_call_page_asyncFunction · 0.85
_page_fieldsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected