Skip to content

feat(langchain): Broaden AI provider detection beyond OpenAI and Anthropic#5707

Open
ericapisani wants to merge 2 commits intomasterfrom
ep/broaden-langgraph-model-support-6d0
Open

feat(langchain): Broaden AI provider detection beyond OpenAI and Anthropic#5707
ericapisani wants to merge 2 commits intomasterfrom
ep/broaden-langgraph-model-support-6d0

Conversation

@ericapisani
Copy link
Member

@ericapisani ericapisani commented Mar 19, 2026

Summary

  • Extracts a _get_ai_system() helper that generically detects AI providers from LangChain's _type field, replacing hardcoded "anthropic" / "openai" checks.
  • Adds support for Cohere, Ollama, Mistral, Fireworks, HuggingFace, Groq, NVIDIA, xAI, DeepSeek, Google, and any future LangChain providers without code changes.

Test plan

  • Parametrized test with coverage for real LangChain _llm_type values from various providers
  • CI passes

🤖 Generated with Claude Code

…ropic

Extract _get_ai_system() to generically detect AI providers from LangChain's
_type field instead of hardcoding only "anthropic" and "openai". The function
splits on "-" and skips non-provider segments (cloud prefixes like "azure" and
descriptors like "chat"/"llm") to return the actual provider name.

This adds support for Cohere, Ollama, Mistral, Fireworks, HuggingFace, Groq,
NVIDIA, xAI, DeepSeek, Google, and any future LangChain providers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ericapisani ericapisani requested a review from a team as a code owner March 19, 2026 12:07
@ericapisani ericapisani marked this pull request as draft March 19, 2026 12:07
@ericapisani
Copy link
Member Author

@cursoragent please review this

@cursor
Copy link

cursor bot commented Mar 19, 2026

Please finish setting up background agents. Go to Cursor

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 6.92s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14379 uncovered lines.
✅ Project coverage is 30.25%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
langchain.py 3.27% ⚠️ 591 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    25.33%    30.25%    +4.92%
==========================================
  Files          189       189         —
  Lines        20613     20614        +1
  Branches      6738      6736        -2
==========================================
+ Hits          5222      6235     +1013
- Misses       15391     14379     -1012
- Partials       429       474       +45

Generated by Codecov Action

@github-actions
Copy link
Contributor

Codecov Results 📊

9 passed | ⏭️ 1 skipped | Total: 10 | Pass Rate: 90% | Execution Time: 3.63s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14771 uncovered lines.

Files with missing lines (1)
File Patch % Lines
langchain.py 3.24% ⚠️ 598 Missing

Generated by Codecov Action

@ericapisani
Copy link
Member Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

…s-is

Remove string splitting and filtering logic from _get_ai_system. The
function now returns the LangChain _type value directly without
attempting to extract a provider name from it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (asgi) Add option to disable suppressing chained exceptions by alexander-alderman-webb in #5714
  • (langchain) Broaden AI provider detection beyond OpenAI and Anthropic by ericapisani in #5707
  • (logging) Separate ignore lists for events/breadcrumbs and sentry logs by sl0thentr0py in #5698

Bug Fixes 🐛

Anthropic

  • Set exception info on streaming span when applicable by alexander-alderman-webb in #5683
  • Patch AsyncStream.close() and AsyncMessageStream.close() to finish spans by alexander-alderman-webb in #5675
  • Patch Stream.close() and MessageStream.close() to finish spans by alexander-alderman-webb in #5674

Documentation 📚

  • Add note on AI PRs to CONTRIBUTING.md by sentrivana in #5696

Internal Changes 🔧

  • Add -latest alias for each integration test suite by sentrivana in #5706
  • Use date-based branch names for toxgen PRs by sentrivana in #5704
  • 🤖 Update test matrix with new releases (03/19) by github-actions in #5703
  • Add client report tests for span streaming by sentrivana in #5677

Other

  • Update CHANGELOG.md by sentrivana in #5685

🤖 This preview updates automatically when you update the PR.

@ericapisani ericapisani marked this pull request as ready for review March 20, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant