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

Function init

openkb/cli.py:909–985  ·  view source on GitHub ↗

Initialise a new knowledge base in the current directory.

(model, language)

Source from the content-addressed store, hash-verified

907 help="Wiki output language (e.g. 'en', 'ko'). Skips the interactive prompt when set.",
908)
909def init(model, language):
910 """Initialise a new knowledge base in the current directory."""
911 openkb_dir = Path(".openkb")
912 if openkb_dir.exists():
913 click.echo("Knowledge base already initialized.")
914 return
915
916 # Interactive prompts
917 click.echo("Pick an LLM in `provider/model` LiteLLM format:")
918 click.echo(" OpenAI: gpt-5.4, gpt-5.4-mini")
919 click.echo(" Anthropic: anthropic/claude-sonnet-4-6, anthropic/claude-opus-4-6")
920 click.echo(" Gemini: gemini/gemini-3.1-pro-preview, gemini/gemini-3-flash-preview")
921 click.echo(" DeepSeek: deepseek/deepseek-v4-flash, deepseek/deepseek-v4-pro")
922 click.echo(" Others: see https://docs.litellm.ai/docs/providers")
923 click.echo()
924 if model is None and _stdin_is_tty():
925 model = _coerce_model(
926 click.prompt(
927 f"Model (enter for default {DEFAULT_CONFIG['model']})",
928 default=DEFAULT_CONFIG["model"],
929 show_default=False,
930 )
931 )
932 if not model:
933 model = DEFAULT_CONFIG["model"]
934 api_key = click.prompt(
935 "LLM API Key (saved to .env, enter to skip)",
936 default="",
937 hide_input=True,
938 show_default=False,
939 ).strip()
940 if language is None and _stdin_is_tty():
941 language = _coerce_language(
942 click.prompt(
943 f"Wiki language (enter for default {DEFAULT_CONFIG['language']})",
944 default=DEFAULT_CONFIG["language"],
945 show_default=False,
946 )
947 )
948 if not language:
949 language = DEFAULT_CONFIG["language"]
950 # Create directory structure
951 Path("raw").mkdir(exist_ok=True)
952 Path("wiki/sources/images").mkdir(parents=True, exist_ok=True)
953 Path("wiki/summaries").mkdir(parents=True, exist_ok=True)
954 Path("wiki/concepts").mkdir(parents=True, exist_ok=True)
955 Path("wiki/entities").mkdir(parents=True, exist_ok=True)
956
957 # Write wiki files
958 atomic_write_text(Path("wiki/AGENTS.md"), AGENTS_MD)
959 atomic_write_text(Path("wiki/index.md"), INDEX_SEED)
960 atomic_write_text(Path("wiki/log.md"), "# Operations Log\n\n")
961
962 # Create .openkb/ state directory
963 openkb_dir.mkdir()
964 config = {
965 "model": model,
966 "language": language,

Callers

nothing calls this directly

Calls 7

atomic_write_textFunction · 0.90
save_configFunction · 0.90
atomic_write_jsonFunction · 0.90
register_kbFunction · 0.90
_stdin_is_ttyFunction · 0.85
_coerce_modelFunction · 0.85
_coerce_languageFunction · 0.85

Tested by

no test coverage detected