Add `config` and `model` parameters to `extract()`
- Dominant language
- Python
- Stars
- 38.6k
- Forks
- 2.7k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 3
Description
# Add `config` and `model` parameters to `extract()`
Hey @mariano, creating an issue about the feature you proposed - I think it's a great idea and was something I had in mind, so please feel free to send a PR if you're interested!
Following up from #99, the idea is to let `extract()` accept either a `ModelConfig` or a pre-instantiated model directly for explicit provider selection and model reuse.
The API would look like:
```python
# Pass a config
config = factory.ModelConfig(
model_id="gemini-2.5-flash",
provider="GeminiLanguageModel",
provider_kwargs={"api_key": "...", "temperature": 0.7}
)
result = extract(text_or_documents=content, config=config, ...)
# Or pass a model directly
model = factory.create_model(config)
result = extract(text_or_documents=content, model=model, ...)
```
Precedence would be: `model` > `config` > `model_id+kwargs` > `language_model_type` (deprecated).
We'd need tests for precedence, factory feature preservation, and backward compat. This would complement the factory infrastructure from #97 in a nice way.
Could also be interesting to support loading configs from JSON/YAML files down the road - would make it easy to manage different model configurations.
Contributor guide
Research direction
Start at the extract() entry point and review the factory.ModelConfig and factory.create_model interfaces described in the issue. Add support for config and model inputs while preserving the stated precedence, then add tests for precedence, factory feature preservation, and backward compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100