vikramkoka opened a new pull request, #67191:
URL: https://github.com/apache/airflow/pull/67191
- Adds LangChainHook to bridge Airflow connections to LangChain model
constructors (ChatOpenAI, OpenAIEmbeddings), using constructor injection for
credentials
- Reuses the existing pydanticai connection type so users configure one
connection for PydanticAI, LlamaIndex, and LangChain
- Follows the same pattern as LlamaIndexHook: _resolve_connection_kwargs()
extracts api_key and base_url from the Airflow connection and passes them
directly to LangChain constructors
- Adds langchain optional dependency extra (langchain>=1.0.0,
langchain-openai>=0.3.0)
What's included
- hooks/langchain.py — LangChainHook(BaseHook) with get_chat_model() and
get_embedding_model()
- tests/unit/common/ai/hooks/test_langchain.py — full test coverage (init,
connection resolution, chat model, embedding model)
- docs/hooks/langchain.rst — hook documentation with usage examples
- provider.yaml — LangChain integration and hook registration
- pyproject.toml — langchain optional dependency extra
Design decisions
- BaseHook, not BaseAIHook — BaseAIHook is still in development. Will
migrate in a follow-up PR once it ships.
- Constructor injection — credentials passed as api_key=/base_url= kwargs
to LangChain constructors. No environment variable mutation. Matches the
LlamaIndexHook pattern.
- Shared connection type — reuses pydanticai connection type rather than
introducing a new one. One connection works across all three frameworks.
- No @task.langchain yet — consistent with LlamaIndex (no
@task.llamaindex). Deferred to the BaseAIHook migration PR.
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
---
##### Was generative AI tooling used to co-author this PR?
Yes, Claude
-
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]