Configuration API
Programmatic configuration of scinr.newton.
Core Functions
scinr.newton.config.configure
configure(
llm: Any | None = None,
repair_llm: Any | None = None,
neo4j_uri: str | None = None,
neo4j_user: str | None = None,
neo4j_password: str | None = None,
enabled_base_themes: list[ThemePath | str]
| None = None,
enabled_user_themes: list[str] | None = None,
extra_models_paths: list[str | Path] | None = None,
storage_backend: Literal["none", "mongodb", "custom"]
| None = None,
mongodb_uri: str | None = None,
mongodb_database: str | None = None,
mongodb_raw_files_collection: str | None = None,
mongodb_pages_collection: str | None = None,
mongodb_gridfs_bucket: str | None = None,
custom_storage: tuple | None = None,
extra_converters: dict[str, type] | None = None,
mistral_api_key: str | None = None,
mistral_ocr_safe_max_pages: int | None = None,
mistral_ocr_safe_max_bytes: int | None = None,
mistral_ocr_max_retries: int | None = None,
mistral_ocr_retry_backoff_seconds: float | None = None,
mistral_ocr_chunk_concurrency: int | None = None,
mistral_ocr_error_strategy: Literal[
"fail_fast", "best_effort"
]
| None = None,
prompt_caching_enabled: bool | None = None,
full_docstring: bool | None = None,
extraction_batch_size: int | None = None,
llm_concurrency: int | None = None,
neo4j_concurrency: int | None = None,
neo4j_sync_concurrency: int | None = None,
log_level: str = "INFO",
prompt_family: PromptFamily
| Literal["generic", "claude", "gpt_reasoning"]
| None = None,
normalization_enabled: bool | None = None,
normalization_batch_size: int | None = None,
normalization_llm: Any | None = None,
) -> ScinrConfig
Configure the scinr-ingest library.
Parameter resolution order: explicit argument > environment variable > default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm
|
Any | None
|
LangChain BaseChatModel instance to use for all LLM calls. |
None
|
repair_llm
|
Any | None
|
LangChain BaseChatModel for the JSON repair loop. Falls back to |
None
|
neo4j_uri
|
str | None
|
Neo4j connection URI. Env: |
None
|
neo4j_user
|
str | None
|
Neo4j username. Env: |
None
|
neo4j_password
|
str | None
|
Neo4j password. Env: |
None
|
enabled_base_themes
|
list[ThemePath | str] | None
|
Whitelist of built-in theme paths to activate ( |
None
|
enabled_user_themes
|
list[str] | None
|
Whitelist of user theme paths to activate. |
None
|
extra_models_paths
|
list[str | Path] | None
|
Filesystem paths to scan for additional user-defined theme models. |
None
|
storage_backend
|
Literal['none', 'mongodb', 'custom'] | None
|
Storage type: |
None
|
mongodb_uri
|
str | None
|
MongoDB connection URI. Env: |
None
|
mongodb_database
|
str | None
|
MongoDB database name. Env: |
None
|
mongodb_raw_files_collection
|
str | None
|
Collection for raw file metadata. |
None
|
mongodb_pages_collection
|
str | None
|
Collection for converted pages. |
None
|
mongodb_gridfs_bucket
|
str | None
|
GridFS bucket name for binary files. |
None
|
custom_storage
|
tuple | None
|
Tuple |
None
|
extra_converters
|
dict[str, type] | None
|
Dict mapping file extensions to custom |
None
|
mistral_api_key
|
str | None
|
Mistral API key for PDF OCR conversion. |
None
|
mistral_ocr_safe_max_pages
|
int | None
|
Máximo de páginas por chunk de PDF enviado a la
API de Mistral OCR antes de dividirlo. Env: |
None
|
mistral_ocr_safe_max_bytes
|
int | None
|
Máximo de bytes por chunk de PDF (tamaño ya
serializado) enviado a la API de Mistral OCR antes de dividirlo.
Env: |
None
|
mistral_ocr_max_retries
|
int | None
|
Número máximo de intentos por chunk ante errores
de red o HTTP reintentables. Env: |
None
|
mistral_ocr_retry_backoff_seconds
|
float | None
|
Base (en segundos) del backoff exponencial
entre reintentos. Env: |
None
|
mistral_ocr_chunk_concurrency
|
int | None
|
Reservado para paralelismo futuro entre chunks
de PDF; actualmente no se usa (procesamiento siempre secuencial).
Env: |
None
|
mistral_ocr_error_strategy
|
Literal['fail_fast', 'best_effort'] | None
|
Estrategia de manejo de errores al convertir
PDFs divididos en chunks: |
None
|
prompt_caching_enabled
|
bool | None
|
Enable prompt caching for supported LLM providers. |
None
|
full_docstring
|
bool | None
|
Use the full class docstring (True, default) or only its first
non-empty line (False) when building the model catalog description shown
to the LLM during annotation and stored as |
None
|
extraction_batch_size
|
int | None
|
Pages per extraction chunk (default: |
None
|
llm_concurrency
|
int | None
|
Max concurrent LLM calls (semaphore size, default: |
None
|
neo4j_concurrency
|
int | None
|
Max concurrent Neo4j write sessions (default: |
None
|
neo4j_sync_concurrency
|
int | None
|
Max concurrent Stage 2 (sync ingestion) dispatches
to asyncio.to_thread() (default: |
None
|
log_level
|
str
|
Logging level string ( |
'INFO'
|
prompt_family
|
PromptFamily | Literal['generic', 'claude', 'gpt_reasoning'] | None
|
Prompt family to use ( |
None
|
normalization_enabled
|
bool | None
|
Enable post-extraction normalization for tabular data. |
None
|
normalization_batch_size
|
int | None
|
Max normalization entries per LLM batch (default: |
None
|
normalization_llm
|
Any | None
|
Dedicated LLM model instance for tabular normalization. |
None
|
Returns:
| Type | Description |
|---|---|
ScinrConfig
|
ScinrConfig singleton containing active library settings. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If conflicting settings or invalid URIs are supplied. |
scinr.newton.config.get_config
Return the current ScinrConfig singleton.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If configure() has not been called yet. |
scinr.newton.config.get_available_themes
Return all currently registered theme paths, grouped by origin.
Does not require :func:configure to have been called first —
it initialises the registry with default settings if needed.
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
dict with two keys: |
dict[str, list[str]]
|
|
dict[str, list[str]]
|
|
Examples::
from scinr.newton import get_available_themes
themes = get_available_themes()
print(themes["builtin"]) # ['default', 'equipment_qualification', ...]
print(themes["user"]) # ['my_custom_theme', ...]
Configuration Classes
scinr.newton.config.ScinrConfig
dataclass
scinr.newton.config.ThemePath
module-attribute
ThemePath = Literal[
"default",
"equipment_qualification",
"pharmaceutical_quality",
"structural_specs",
"pharma_operations",
"pharma_operations/product_master",
"pharma_operations/commercial_sales",
"pharma_operations/regulatory_portfolio",
"pharma_operations/batch_manufacturing",
"pharma_operations/serialization",
"pharma_regulatory/qa",
"pharma_regulatory/bpg",
"pharma_regulatory/variation_guidelines",
]
Theme path identifiers for the built-in scinr-ingest theme library.
Use these values in enabled_base_themes to activate specific built-in themes.
Extend with plain str values for user-defined themes added via
extra_models_paths.
Examples::
configure(
llm=...,
enabled_base_themes=["pharmaceutical_quality", "pharma_operations/batch_manufacturing"],
)
scinr.newton.config.PromptFamily
Bases: str, Enum
Selects which prompt variant family to use for LLM calls.
GENERIC (default): Simplified, model-agnostic prompts. Work correctly across all LLM families (OpenAI, Kimi, GLM, Claude, Ollama, etc.). CLAUDE: Prompts optimized for Claude/Sonnet. Use XML-structured instructions, multi-step protocols, and internal checklists that leverage Claude's extended reasoning capabilities. GPT_REASONING: Prompts for OpenAI reasoning models (GPT-5.5, o3, o4-mini). Use Markdown section headers and goal-based language. No step-by-step protocols, no auto-checklists, no XML instruction wrappers. Use GENERIC for non-reasoning GPT models (GPT-4o, GPT-4.1, GPT-4.5).
To add support for a new model family in the future, add a new member here and create the corresponding prompt files (_newmodel.py) in each stage directory.