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

Function build_lint_agent

openkb/agent/linter.py:47–89  ·  view source on GitHub ↗

Build the semantic knowledge-lint agent. Args: wiki_root: Absolute path to the wiki directory. model: LLM model name. language: Language code for wiki content (e.g. 'en', 'fr'). Returns: Configured :class:`~agents.Agent` instance.

(wiki_root: str, model: str, language: str = "en")

Source from the content-addressed store, hash-verified

45
46
47def build_lint_agent(wiki_root: str, model: str, language: str = "en") -> Agent:
48 """Build the semantic knowledge-lint agent.
49
50 Args:
51 wiki_root: Absolute path to the wiki directory.
52 model: LLM model name.
53 language: Language code for wiki content (e.g. 'en', 'fr').
54
55 Returns:
56 Configured :class:`~agents.Agent` instance.
57 """
58 schema_md = get_agents_md(Path(wiki_root))
59 instructions = _LINTER_INSTRUCTIONS_TEMPLATE.format(schema_md=schema_md)
60 instructions += f"\n\nIMPORTANT: Write the lint report in {language} language."
61
62 @function_tool
63 def list_files(directory: str) -> str:
64 """List all Markdown files in a wiki subdirectory.
65
66 Args:
67 directory: Subdirectory path relative to wiki root (e.g. 'summaries').
68 """
69 return list_wiki_files(directory, wiki_root)
70
71 @function_tool
72 def read_file(path: str) -> str:
73 """Read a Markdown file from the wiki.
74
75 Args:
76 path: File path relative to wiki root (e.g. 'summaries/paper.md').
77 """
78 return read_wiki_file(path, wiki_root)
79
80 return Agent(
81 name="wiki-linter",
82 instructions=instructions,
83 tools=[list_files, read_file],
84 model=f"litellm/{model}",
85 model_settings=ModelSettings(
86 extra_headers=get_extra_headers() or None,
87 extra_args=get_timeout_extra_args(),
88 ),
89 )
90
91
92async def run_knowledge_lint(kb_dir: Path, model: str) -> str:

Calls 3

get_agents_mdFunction · 0.90
get_extra_headersFunction · 0.90
get_timeout_extra_argsFunction · 0.90