mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
fix: restore config.yaml as the CLI config base
run_pageindex.py users configure indexing by editing pageindex/config.yaml; dev silently ignored those edits. Restore the file and load it as the IndexConfig base when present, CLI args winning — same merge semantics and package-relative path as the pre-0.3 ConfigLoader. The SDK stays explicit-args-only.
This commit is contained in:
parent
3ff04d501a
commit
f995e6441e
3 changed files with 26 additions and 1 deletions
|
|
@ -46,6 +46,17 @@ class IndexConfig(BaseModel):
|
|||
_validate_max_concurrency(v)
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
def from_yaml(cls, path: str = None, **overrides) -> "IndexConfig":
|
||||
"""Load config from a YAML file ("yes"/"no" accepted for booleans);
|
||||
keyword overrides take precedence. Defaults to the package config.yaml."""
|
||||
import yaml
|
||||
if path is None:
|
||||
path = os.path.join(os.path.dirname(__file__), "config.yaml")
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
return cls(**{**data, **overrides})
|
||||
|
||||
|
||||
def _env_drop_params_default() -> bool:
|
||||
return os.getenv("PAGEINDEX_DROP_PARAMS", "true").strip().lower() not in (
|
||||
|
|
|
|||
10
pageindex/config.yaml
Normal file
10
pageindex/config.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
model: "gpt-4o-2024-11-20"
|
||||
# model: "anthropic/claude-sonnet-4-6"
|
||||
retrieve_model: "gpt-5.4" # defaults to `model` if not set
|
||||
toc_check_page_num: 20
|
||||
max_page_num_each_node: 10
|
||||
max_token_num_each_node: 20000
|
||||
if_add_node_id: "yes"
|
||||
if_add_node_summary: "yes"
|
||||
if_add_doc_description: "no"
|
||||
if_add_node_text: "no"
|
||||
|
|
@ -64,7 +64,11 @@ if __name__ == "__main__":
|
|||
"if_add_node_text": args.if_add_node_text,
|
||||
}.items() if v is not None
|
||||
}
|
||||
opt = IndexConfig(**config_overrides)
|
||||
# Legacy config.yaml is the base when present, CLI args win
|
||||
try:
|
||||
opt = IndexConfig.from_yaml(**config_overrides)
|
||||
except FileNotFoundError:
|
||||
opt = IndexConfig(**config_overrides)
|
||||
|
||||
if args.pdf_path:
|
||||
# Validate PDF file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue