feat(model-profiles): add input/output MIME type fields to ModelProfile#2
feat(model-profiles): add input/output MIME type fields to ModelProfile#2DhirenMhatre wants to merge 1 commit into
Conversation
Adds informational input_mime_types and output_mime_types dict fields
to ModelProfile, keyed by models.dev modality names ('image', 'audio',
'pdf', 'video'). Augments the CLI to dispatch provider-level vs
model-level overrides by ModelProfile field name so non-scalar
provider-level fields (like the new MIME maps) are routed correctly.
Backfills anthropic, openai, and perplexity profile_augmentations.toml
with documented MIME types and regenerates their _profiles.py.
Co-authored-by: Mason Daugherty <61371264+mdrxy@users.noreply.github.com>
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven validation now distinguishes provider-level vs model-level overrides and exits on unknown scalar keys. Partner Models: Added Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Used TypedDict fields rather than nested objects to keep the schema flat and serialization-friendly. CLI validation strictly couples to Scalability & Extensibility: MIME type declarations are per-modality dicts to allow future extension (e.g., audio, video) without schema changes. Out of scope: runtime validation of actual file content. Risks:
Merge StatusMERGEABLE — PR Score 76/100, above threshold (50). All gates passed. |
Security Scan Summary
No critical security issues detected Scan completed in 24.1sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-17 19:28 UTC | Score: 60/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-003]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 2 | 0 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 1 | 2 | 3 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 0 | 3 | 3 |
libs/partners/anthropic/langchain_anthropic/data/_profiles.py |
0 | 1 | 0 | 0 | 1 |
Recommendations
- Resolve High severity issues, especially error handling gaps and performance bottlenecks.
- Run automated tests after applying fixes to verify no regressions.
Greptile SummaryThis PR adds
Confidence Score: 3/5The Anthropic and Perplexity changes are internally consistent, but the OpenAI profiles ship with contradictory data for gpt-3.5-turbo and the CLI has a silent data-corruption path when langchain_core is unavailable. The OpenAI generated profiles for gpt-3.5-turbo carry libs/partners/openai/langchain_openai/data/profile_augmentations.toml and libs/partners/openai/langchain_openai/data/_profiles.py (gpt-3.5-turbo data contradiction), and libs/model-profiles/langchain_model_profiles/cli.py (legacy fallback with dict-valued fields). Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[profile_augmentations.toml] --> B[_load_augmentations]
B --> C{_profile_field_names returns non-empty?}
C -- Yes / Schema-driven --> D{key in ModelProfile fields?}
D -- Yes --> E[provider_aug e.g. input_mime_types]
D -- No --> F{value is dict?}
F -- Yes --> G[model_augs model-id overrides]
F -- No --> H[sys.exit 1 unknown scalar key]
C -- No / Legacy fallback --> I{value is dict?}
I -- Yes --> J[model_augs BUGGY: input_mime_types treated as model ID]
I -- No --> K[provider_aug]
E --> L[_apply_overrides base + provider_aug + model_aug]
G --> L
J --> L
L --> M[_profiles.py generated]
|
| "input_mime_types": { | ||
| "image": [ | ||
| "image/png", | ||
| "image/jpeg", | ||
| "image/gif", | ||
| "image/webp", | ||
| ], | ||
| "pdf": [ | ||
| "application/pdf", | ||
| ], | ||
| }, |
There was a problem hiding this comment.
Contradictory MIME types on
gpt-3.5-turbo
The gpt-3.5-turbo profile explicitly has image_inputs: False, image_url_inputs: False, and pdf_inputs: False, yet the provider-level input_mime_types cascade stamps it with image and PDF MIME types. Any consumer that reads input_mime_types from this profile and uses it to decide whether to attach images or PDFs would draw the wrong conclusion. The [overrides."gpt-3.5-turbo"] block in profile_augmentations.toml needs to clear the MIME map (e.g. input_mime_types = {}) the same way it clears the boolean flags.
| # Legacy fallback when ModelProfile is unavailable. | ||
| elif isinstance(value, dict): | ||
| model_augs[key] = value | ||
| else: | ||
| provider_aug[key] = value |
There was a problem hiding this comment.
Legacy fallback creates bogus model profiles for dict-valued fields
When _profile_field_names() returns an empty frozenset (because langchain_core can't be imported or get_type_hints raises), the legacy branch treats every dict-valued key as a model ID. A [overrides.input_mime_types] block therefore ends up in model_augs under the key "input_mime_types" rather than in provider_aug. Because no model with that ID exists in models.dev, the extra_models loop then inserts a profile whose ID is literally "input_mime_types" into the generated _profiles.py. The fix is to emit a warning and skip the key in the legacy path, or document that the new dict-valued provider fields require langchain_core to be installed.
| [overrides."gpt-3.5-turbo"] | ||
| image_url_inputs = false | ||
| pdf_inputs = false | ||
| pdf_tool_message = false | ||
| image_tool_message = false |
There was a problem hiding this comment.
gpt-3.5-turbo override does not clear input_mime_types
The override correctly disables image_url_inputs, pdf_inputs, pdf_tool_message, and image_tool_message, but it does not nullify input_mime_types. Because _apply_overrides is a shallow key-level merge, the provider-level input_mime_types dict is inherited as-is, leaving the generated profile in a contradictory state. Adding input_mime_types = {} to this block would override the provider-level value with an empty map consistent with the disabled boolean flags.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven validation now distinguishes provider-level vs model-level overrides. Unknown scalar keys trigger Partner Profiles:
Files Changed
Review Focus Areas
ArchitectureDesign Decisions:
Risks:
Merge StatusMERGEABLE — PR Score 78/100, above threshold (50). All gates passed. |
Security Scan Summary
No critical security issues detected Scan completed in 27.6sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-18 16:48 UTC | Score: 63/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-003]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 2 | 2 | 4 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 1 | 3 | 4 |
libs/partners/anthropic/langchain_anthropic/data/_profiles.py |
0 | 0 | 1 | 0 | 1 |
Recommendations
- Run automated tests after applying fixes to verify no regressions.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven override parsing in Partner Data: Populated Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Schema-driven CLI validation replaces ad-hoc parsing. Provider-level vs model-level distinction is based on field name matching rather than explicit markers. This is a deliberate tradeoff for simpler TOML structure. Risks: Strict unknown key rejection ( Merge StatusMERGEABLE — PR Score 72/100, above threshold (50). All gates passed. |
| @@ -1102,6 +1574,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o1-pro": { | |||
| "name": "o1-pro", | |||
| @@ -1128,6 +1611,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o3": { | |||
| "name": "o3", | |||
| @@ -1154,6 +1648,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o3-deep-research": { | |||
| "name": "o3-deep-research", | |||
| @@ -1179,6 +1684,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o3-mini": { | |||
| "name": "o3-mini", | |||
| @@ -1205,6 +1721,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o3-pro": { | |||
| "name": "o3-pro", | |||
| @@ -1231,6 +1758,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o4-mini": { | |||
| "name": "o4-mini", | |||
| @@ -1257,6 +1795,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "o4-mini-deep-research": { | |||
| "name": "o4-mini-deep-research", | |||
| @@ -1282,6 +1831,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "text-embedding-3-large": { | |||
| "name": "text-embedding-3-large", | |||
| @@ -1307,6 +1867,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
| }, | |||
| "text-embedding-3-small": { | |||
| "name": "text-embedding-3-small", | |||
| @@ -1332,6 +1903,17 @@ | |||
| "pdf_tool_message": True, | |||
| "image_tool_message": True, | |||
| "tool_choice": True, | |||
| "input_mime_types": { | |||
| "image": [ | |||
| "image/png", | |||
| "image/jpeg", | |||
| "image/gif", | |||
| "image/webp", | |||
| ], | |||
| "pdf": [ | |||
| "application/pdf", | |||
| ], | |||
| }, | |||
There was a problem hiding this comment.
These MIME type declarations now claim image and PDF support for models such as o1-mini, o1-preview, and the embedding models even where the surrounding capability flags say attachments or image inputs are unsupported, so derive input_mime_types from the existing capability booleans or omit unsupported categories.
Suggested fix
"input_mime_types": {
**({
"image": [
"image/png",
"image/jpeg",
"image/gif",
"image/webp",
],
} if profile.get("image_inputs") and profile.get("attachment") else {}),
**({
"pdf": [
"application/pdf",
],
} if profile.get("pdf_inputs") and profile.get("attachment") else {}),
},Prompt for AI assistance
Copy the prompt below and paste it into ChatGPT, Claude, or any LLM:
You are an expert python developer with deep knowledge of security, performance, and best practices.
### Context
File: libs/partners/openai/langchain_openai/data/_profiles.py
Lines: 1541-1916
Issue Type: functional-high
Severity: high
Issue Description:
These MIME type declarations now claim image and PDF support for models such as `o1-mini`, `o1-preview`, and the embedding models even where the surrounding capability flags say attachments or image inputs are unsupported, so derive `input_mime_types` from the existing capability booleans or omit unsupported categories.
Current Code:
"input_mime_types": {
"image": [
"image/png",
"image/jpeg",
"image/gif",
"image/webp",
],
"pdf": [
"application/pdf",
],
},
---
### Instructions
1. Fix the issue described above
2. Maintain the exact indentation and code style from the original
3. Follow python best practices and language-specific idioms
4. Ensure the fix addresses the root cause, not just the symptoms
5. Add brief inline comments explaining the fix if needed
### Constraints
- Do not change functionality beyond fixing the identified issue
- Preserve existing variable names and function signatures unless they are part of the problem
- Ensure the fix is production-ready
---
| if profile_fields: | ||
| # Schema-driven: known profile field names are provider-level; all | ||
| # other keys are treated as model identifiers (whose values must be | ||
| # dict overrides). | ||
| if key in profile_fields: | ||
| provider_aug[key] = value | ||
| elif isinstance(value, dict): | ||
| model_augs[key] = value | ||
| else: | ||
| msg = ( | ||
| f"Augmentation key '{key}' is not a declared ModelProfile " | ||
| f"field and its value is not a table of overrides." | ||
| ) | ||
| print(f"❌ {msg}", file=sys.stderr) | ||
| sys.exit(1) |
There was a problem hiding this comment.
The new schema-driven branch rejects any non-dict key not present on ModelProfile, which breaks forward compatibility when profile_augmentations.toml contains a newly added provider-level field; keep unknown scalar keys as provider overrides instead of exiting.
Suggested fix
if profile_fields:
# Schema-driven: known profile field names are provider-level; dict
# values for unknown keys are treated as model identifiers.
if key in profile_fields:
provider_aug[key] = value
elif isinstance(value, dict):
model_augs[key] = value
else:
provider_aug[key] = valuePrompt for AI assistance
Copy the prompt below and paste it into ChatGPT, Claude, or any LLM:
You are an expert python developer with deep knowledge of security, performance, and best practices.
### Context
File: libs/model-profiles/langchain_model_profiles/cli.py
Lines: 115-129
Issue Type: robustness-medium
Severity: medium
Issue Description:
The new schema-driven branch rejects any non-dict key not present on `ModelProfile`, which breaks forward compatibility when `profile_augmentations.toml` contains a newly added provider-level field; keep unknown scalar keys as provider overrides instead of exiting.
Current Code:
if profile_fields:
# Schema-driven: known profile field names are provider-level; all
# other keys are treated as model identifiers (whose values must be
# dict overrides).
if key in profile_fields:
provider_aug[key] = value
elif isinstance(value, dict):
model_augs[key] = value
else:
msg = (
f"Augmentation key '{key}' is not a declared ModelProfile "
f"field and its value is not a table of overrides."
)
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
---
### Instructions
1. Fix the issue described above
2. Maintain the exact indentation and code style from the original
3. Follow python best practices and language-specific idioms
4. Ensure the fix addresses the root cause, not just the symptoms
5. Add brief inline comments explaining the fix if needed
### Constraints
- Do not change functionality beyond fixing the identified issue
- Preserve existing variable names and function signatures unless they are part of the problem
- Ensure the fix is production-ready
---
Security Scan Summary
No critical security issues detected Scan completed in 26.6sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-18 17:07 UTC | Score: 67/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-003]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 2 | 2 | 4 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 1 | 3 | 4 |
libs/partners/anthropic/langchain_anthropic/data/_profiles.py |
0 | 0 | 0 | 1 | 1 |
Recommendations
- Run automated tests after applying fixes to verify no regressions.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven validation now distinguishes provider-level vs model-level overrides and exits on unknown scalar keys. Anthropic Models: Added OpenAI Models: Added Perplexity Models: Added Files Changed
Review Focus Areas
ArchitectureDesign Decisions: MIME types are declared per-model rather than per-provider to allow fine-grained differences (e.g., older models lacking webp support). The CLI uses runtime schema introspection to stay in sync with Scalability & Extensibility: New MIME types or modalities require only profile updates, no code changes. Out of scope: automatic discovery of MIME type support from provider APIs. Risks: Intentional: Strict CLI validation may break existing augmentation files with typos or unofficial keys. This is acceptable to prevent silent misconfiguration. Merge StatusMERGEABLE — PR Score 79/100, above threshold (50). All gates passed. |
| "input_mime_types": { | ||
| "image": [ | ||
| "image/png", | ||
| "image/jpeg", | ||
| "image/gif", | ||
| "image/webp", | ||
| ], | ||
| "pdf": [ | ||
| "application/pdf", | ||
| ], | ||
| }, |
There was a problem hiding this comment.
These profiles now advertise image and PDF MIME types even for models whose capability flags in this file disable those inputs, so generate input_mime_types conditionally or omit unsupported categories.
Also reported at: libs/partners/openai/langchain_openai/data/_profiles.py L1577–L1587, L1724–L1734, L1870–L1880, L1906–L1916, L1942–L1944
Suggested fix
"input_mime_types": {
"pdf": [
"application/pdf",
],
},Prompt for AI assistance
Copy the prompt below and paste it into ChatGPT, Claude, or any LLM:
You are an expert python developer with deep knowledge of security, performance, and best practices.
### Context
File: libs/partners/openai/langchain_openai/data/_profiles.py
Lines: 1541-1551
Issue Type: functional-high
Severity: high
Issue Description:
These profiles now advertise image and PDF MIME types even for models whose capability flags in this file disable those inputs, so generate `input_mime_types` conditionally or omit unsupported categories.
_Also reported at: `libs/partners/openai/langchain_openai/data/_profiles.py` L1577–L1587, L1724–L1734, L1870–L1880, L1906–L1916, L1942–L1944_
Current Code:
"input_mime_types": {
"image": [
"image/png",
"image/jpeg",
"image/gif",
"image/webp",
],
"pdf": [
"application/pdf",
],
},
---
### Instructions
1. Fix the issue described above
2. Maintain the exact indentation and code style from the original
3. Follow python best practices and language-specific idioms
4. Ensure the fix addresses the root cause, not just the symptoms
5. Add brief inline comments explaining the fix if needed
### Constraints
- Do not change functionality beyond fixing the identified issue
- Preserve existing variable names and function signatures unless they are part of the problem
- Ensure the fix is production-ready
---
Security Scan Summary
No critical security issues detected Scan completed in 28.6sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-19 19:41 UTC | Score: 89/100 | Provider: github Executive Summary
Top Findings[CQ-002]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 0 | 3 | 3 |
Recommendations
- Run automated tests after applying fixes to verify no regressions.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Model Profiles: Extended OpenAI Partner: Added MIME type support for GPT-5.x, o1, and image generation models. Image inputs support png/jpeg/gif/webp. PDF input supported for most models. Image generation models declare output formats. Anthropic Partner: Populated MIME types for all models with image (jpeg/png/gif/webp) and PDF support. Perplexity Partner: Added image MIME type support for CLI Tooling: Added commands to manage MIME type overrides in Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Used dict-of-lists structure ( Scalability & Extensibility: Structure supports new modalities (audio, video) by adding new keys to the dict. Out of scope: runtime validation logic (this PR only declares capabilities). Risks:
Merge StatusMERGEABLE — PR Score 66/100, above threshold (50). All gates passed. |
Security Scan Summary
No critical security issues detected Scan completed in 27.9sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-20 20:03 UTC | Score: 67/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-003]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 2 | 2 | 4 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 1 | 3 | 4 |
libs/partners/anthropic/langchain_anthropic/data/_profiles.py |
0 | 0 | 0 | 1 | 1 |
Recommendations
- Run automated tests after applying fixes to verify no regressions.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven validation now distinguishes provider-level from model-level overrides. Unknown scalar keys trigger Anthropic Models: All 16 Claude models now declare image ( OpenAI Models: All GPT and o1 families plus Perplexity Models: Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Using Scalability & Extensibility: MIME type declarations are intentionally flat lists rather than structured per-modality. This keeps the schema simple but may require revisiting if modality-specific metadata (e.g., max image dimensions) becomes needed. Risks:
|
Security Scan Summary
No critical security issues detected Scan completed in 28.8sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Tooling: Added strict validation in the augmentation loader to reject unknown scalar override keys. Partner Models:
Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Used per-modality MIME type maps instead of flat lists to allow future extension (e.g., audio, video) without schema changes. The CLI strict validation prevents silent misconfiguration. Scalability & Extensibility: The modality-keyed structure ( Risks:
Merge StatusMERGEABLE — PR Score 67/100, above threshold (50). All gates passed. |
Security Scan Summary
No critical security issues detected Scan completed in 25.8sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-20 21:06 UTC | Score: 68/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-003]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 2 | 2 | 4 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 0 | 1 | 3 | 4 |
Recommendations
- Run automated tests after applying fixes to verify no regressions.
|
@codity review |
Policy Check Failed✗ 3/3 policy checks failed: • Need 2 more approval(s) (0/2) — comment LGTM or approve via review To merge this PR:
|
PR SummaryWhat Changed
Key Changes by AreaCore Schema: Added CLI Validation: Schema-driven validation now distinguishes provider-level vs model-level overrides and exits on unknown scalar keys Partner Models:
Files Changed
Review Focus Areas
ArchitectureDesign Decisions: Used TypedDict fields rather than free-form dicts to enable static validation. CLI validation enforces schema compliance at build time rather than runtime. Scalability & Extensibility: The schema-driven approach allows new MIME type modalities to be added without CLI code changes. Out of scope: runtime validation of actual file content. Risks:
Merge StatusNOT MERGEABLE — PR Score 55/100, below threshold (50)
|
| profile_fields = _profile_field_names() | ||
|
|
||
| for key, value in overrides.items(): | ||
| if isinstance(value, dict): | ||
| if profile_fields: | ||
| # Schema-driven: known profile field names are provider-level; all | ||
| # other keys are treated as model identifiers (whose values must be | ||
| # dict overrides). | ||
| if key in profile_fields: | ||
| provider_aug[key] = value | ||
| elif isinstance(value, dict): | ||
| model_augs[key] = value | ||
| else: | ||
| msg = ( | ||
| f"Augmentation key '{key}' is not a declared ModelProfile " | ||
| f"field and its value is not a table of overrides." | ||
| ) | ||
| print(f"❌ {msg}", file=sys.stderr) | ||
| sys.exit(1) | ||
| # Legacy fallback when ModelProfile is unavailable. | ||
| elif isinstance(value, dict): |
There was a problem hiding this comment.
If ModelProfile imports successfully but get_type_hints(ModelProfile) returns an empty mapping, the new branch silently falls back to the legacy heuristic and can misclassify provider-level dict-valued fields as model-specific overrides; treat successful schema discovery separately from whether the field set is empty.
Suggested fix
profile_fields = _profile_field_names()
schema_available = profile_fields is not None
for key, value in overrides.items():
if schema_available:
# Schema-driven: known profile field names are provider-level; all
# other keys are treated as model identifiers (whose values must be
# dict overrides).
if key in profile_fields:
provider_aug[key] = value
elif isinstance(value, dict):
model_augs[key] = value
else:
msg = (
f"Augmentation key '{key}' is not a declared ModelProfile "
f"field and its value is not a table of overrides."
)
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
elif isinstance(value, dict):
model_augs[key] = value
else:
provider_aug[key] = valuePrompt for AI assistance
Copy the prompt below and paste it into ChatGPT, Claude, or any LLM:
You are an expert python developer with deep knowledge of security, performance, and best practices.
### Context
File: libs/model-profiles/langchain_model_profiles/cli.py
Lines: 112-131
Issue Type: functional-high
Severity: high
Issue Description:
If `ModelProfile` imports successfully but `get_type_hints(ModelProfile)` returns an empty mapping, the new branch silently falls back to the legacy heuristic and can misclassify provider-level dict-valued fields as model-specific overrides; treat successful schema discovery separately from whether the field set is empty.
Current Code:
profile_fields = _profile_field_names()
for key, value in overrides.items():
if profile_fields:
# Schema-driven: known profile field names are provider-level; all
# other keys are treated as model identifiers (whose values must be
# dict overrides).
if key in profile_fields:
provider_aug[key] = value
elif isinstance(value, dict):
model_augs[key] = value
else:
msg = (
f"Augmentation key '{key}' is not a declared ModelProfile "
f"field and its value is not a table of overrides."
)
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
# Legacy fallback when ModelProfile is unavailable.
elif isinstance(value, dict):
model_augs[key] = value
else:
provider_aug[key] = value
---
### Instructions
1. Fix the issue described above
2. Maintain the exact indentation and code style from the original
3. Follow python best practices and language-specific idioms
4. Ensure the fix addresses the root cause, not just the symptoms
5. Add brief inline comments explaining the fix if needed
### Constraints
- Do not change functionality beyond fixing the identified issue
- Preserve existing variable names and function signatures unless they are part of the problem
- Ensure the fix is production-ready
---
Security Scan Summary
No critical security issues detected Scan completed in 28.5sSecurity scan powered by Codity.ai |
License Compliance Scan
All licenses are low-risk and compliant Powered by Codity.ai · Docs |
Code Quality Report — test-org-codity/langchain · PR #2Scanned: 2026-05-21 10:08 UTC | Score: 58/100 | Provider: github Executive Summary
Top Findings[CQ-LLM-005]
|
| File | Critical | High | Medium | Low | Total |
|---|---|---|---|---|---|
libs/core/langchain_core/language_models/model_profile.py |
0 | 0 | 0 | 2 | 2 |
libs/model-profiles/langchain_model_profiles/cli.py |
0 | 0 | 2 | 2 | 4 |
libs/model-profiles/tests/unit_tests/test_cli.py |
0 | 1 | 0 | 3 | 4 |
libs/partners/anthropic/langchain_anthropic/data/_profiles.py |
0 | 0 | 1 | 0 | 1 |
Recommendations
- Resolve High severity issues, especially error handling gaps and performance bottlenecks.
- Run automated tests after applying fixes to verify no regressions.
Adds informational input_mime_types and output_mime_types dict fields to ModelProfile, keyed by models.dev modality names ('image', 'audio', 'pdf', 'video'). Augments the CLI to dispatch provider-level vs model-level overrides by ModelProfile field name so non-scalar provider-level fields (like the new MIME maps) are routed correctly.
Backfills anthropic, openai, and perplexity profile_augmentations.toml with documented MIME types and regenerates their _profiles.py.
Fixes #
Read the full contributing guidelines: https://docs.langchain.com/oss/python/contributing/overview
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
Thank you for contributing to LangChain! Follow these steps to have your pull request considered as ready for review.
Fixes #xxline at the top is required for external contributions — update the issue number and keep the keyword. This links your PR to the approved issue and auto-closes it on merge.make format,make lintandmake testfrom the root of the package(s) you've modified.Additional guidelines:
uv.lockfiles or add dependencies topyproject.tomlfiles (even optional ones) unless you have explicit permission to do so by a maintainer.Social handles (optional)
Twitter: @
LinkedIn: https://linkedin.com/in/