feat(core): mint langchain-model-profiles and add profile property to BaseChatModel (#33728)

This commit is contained in:
ccurme
2025-10-31 09:44:46 -04:00
committed by GitHub
parent 106c6ac273
commit 493be259c3
23 changed files with 17266 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
# 🦜🪪 langchain-model-profiles
[![PyPI - Version](https://img.shields.io/pypi/v/langchain-model-profiles?label=%20)](https://pypi.org/project/langchain-model-profiles/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langchain-model-profiles)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langchain-model-profiles)](https://pypistats.org/packages/langchain-model-profiles)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
> [!WARNING]
> This package is currently in development and the API is subject to change.
Centralized reference of LLM capabilities for LangChain chat models.
## Overview
`langchain-model-profiles` enables programmatic access to model capabilities through a `.profile` property on LangChain chat models.
This allows you to query model-specific features such as context window sizes, supported input/output modalities, structured output support, tool calling capabilities, and more.
## Data sources
This package is built on top of the excellent work by the [models.dev](https://github.com/sst/models.dev) project, an open source initiative that provides model capability data.
This package augments the data from models.dev with some additional fields. We intend to keep this aligned with the upstream project as it evolves.
## Installation
```bash
pip install "langchain[model-profiles]"
```
Or with uv:
```bash
uv add "langchain[model-profiles]"
```
## Usage
Access model capabilities through the `.profile` property on any LangChain chat model:
```python
# pip install "langchain[openai]"
from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5")
profile = model.profile
# Check specific capabilities
if profile.get("structured_output"):
print(f"This model supports a dedicated structured output feature.")
if profile.get("max_input_tokens"):
print(f"Max input tokens: {profile.get('max_input_tokens')}")
if profile.get("..."):
...
```
## Available fields
See `ModelProfile` in [`model_profile.py`](./langchain_model_profiles/model_profile.py) for the full list of available fields and their descriptions.
## License
MIT