Commit dae7ebd
deps: remove langchain dependency (#1869)
Remove langchain and associated dependencies to simplify the codebase
and reduce exposure to third-party dependency issues.
Removed dependencies:
- langchain~=0.3.10
- langchain-core~=0.3.81
- langchain-ollama~=0.3.5
- langchain-text-splitters~=0.3.11
Removed files:
- ansible_ai_connect/ai/api/model_pipelines/langchain/ (entire directory)
- configuration.py
- pipelines.py
- tests/test_pipeline.py
Refactored ollama module to be fully self-contained:
Configuration (ollama/configuration.py):
- Created OllamaConfiguration extending BaseConfig directly
- Created OllamaBasePipelineConfiguration
- Removed dependency on langchain configuration classes
Pipelines (ollama/pipelines.py):
- Created custom OllamaClient for direct Ollama API communication
- Moved all utility functions from langchain module:
* message_to_string()
* create_role_outline()
* unwrap_role_answer()
* unwrap_message_with_yaml_answer()
* unwrap_playbook_answer()
* unwrap_task_answer()
- Implemented all pipeline classes without langchain:
* OllamaMetaData
* OllamaCompletionsPipeline
* OllamaPlaybookGenerationPipeline
* OllamaRoleGenerationPipeline
* OllamaRoleExplanationPipeline (returns "nop" health check - not implemented)
* OllamaPlaybookExplanationPipeline
Tests (ollama/tests/test_pipelines.py):
- Migrated relevant tests from deleted langchain/tests/test_pipeline.py
- Added comprehensive test coverage for:
* Unwrap functions (task, playbook, role, message parsing)
* Completions pipeline with mocked requests.post
* Playbook generation pipeline (with and without outline, custom prompt)
* Role generation pipeline (with and without outline)
* Playbook explanation pipeline (with custom prompt)
- All tests updated to mock requests.post instead of langchain's FakeListLLM
- Prevents AttributeError from patching non-existent symbols
Updated configuration:
- pyproject.toml: Removed langchain dependencies and pyright path
- requirements.txt: Regenerated without langchain (15 fewer packages)
- uv.lock: Regenerated without langchain dependencies
- .github/workflows/pyright.yml: Removed langchain from CI dependencies
All functionality preserved. Type checking passes with pyright.
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 374e646 commit dae7ebd
File tree
13 files changed
+773
-1364
lines changed- .github/workflows
- ansible_ai_connect/ai/api/model_pipelines
- langchain
- tests
- ollama
- tests
13 files changed
+773
-1364
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
Whitespace-only changes.
Lines changed: 0 additions & 54 deletions
This file was deleted.
0 commit comments