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

Function _gen_update

openkb/agent/compiler.py:1838–1870  ·  view source on GitHub ↗
(concept: dict)

Source from the content-addressed store, hash-verified

1836 return name, content, False, brief
1837
1838 async def _gen_update(concept: dict) -> tuple[str, str, bool, str]:
1839 name = concept["name"]
1840 title = concept.get("title", name)
1841 concept_path = wiki_dir / "concepts" / f"{_sanitize_concept_name(name)}.md"
1842 if concept_path.exists():
1843 raw_text = concept_path.read_text(encoding="utf-8")
1844 ex_parts = frontmatter.split(raw_text)
1845 existing_content = ex_parts[1].strip() if ex_parts is not None else raw_text
1846 else:
1847 existing_content = "(page not found — create from scratch)"
1848 async with semaphore:
1849 raw = await _llm_call_page_async(
1850 model,
1851 [
1852 system_msg,
1853 doc_msg, # cached (BP1)
1854 summary_msg, # cached (BP2)
1855 known_targets_msg, # cached (BP3) — whitelist
1856 {
1857 "role": "user",
1858 "content": _CONCEPT_UPDATE_USER.format(
1859 title=title,
1860 doc_name=doc_name,
1861 existing_content=existing_content,
1862 ),
1863 },
1864 ],
1865 f"update: {name}",
1866 response_format=_JSON_RESPONSE_FORMAT,
1867 )
1868 brief, content, _ = _page_fields(raw)
1869 _require_nonempty_content(content, name)
1870 return name, content, True, brief
1871
1872 async def _gen_entity_create(ent: dict) -> tuple[str, str, str, str]:
1873 name = ent["name"]

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