langchain-copilot 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. langchain_copilot-0.2.2/.github/workflows/ci.yml +31 -0
  2. langchain_copilot-0.2.2/.github/workflows/release.yml +98 -0
  3. langchain_copilot-0.2.2/.github/workflows/test-publish.yml +113 -0
  4. langchain_copilot-0.2.2/.gitignore +18 -0
  5. langchain_copilot-0.2.2/.python-version +1 -0
  6. langchain_copilot-0.2.2/CHANGELOG.md +75 -0
  7. langchain_copilot-0.2.2/LICENSE +21 -0
  8. langchain_copilot-0.2.2/Makefile +29 -0
  9. langchain_copilot-0.2.2/PKG-INFO +346 -0
  10. langchain_copilot-0.2.2/QUICKSTART.md +55 -0
  11. langchain_copilot-0.2.2/README.md +317 -0
  12. langchain_copilot-0.2.2/RELEASE.md +281 -0
  13. langchain_copilot-0.2.2/TESTING.md +306 -0
  14. langchain_copilot-0.2.2/examples/01_simple_invoke.py +25 -0
  15. langchain_copilot-0.2.2/examples/02_streaming.py +24 -0
  16. langchain_copilot-0.2.2/examples/03_async_invoke.py +23 -0
  17. langchain_copilot-0.2.2/examples/04_async_streaming.py +25 -0
  18. langchain_copilot-0.2.2/examples/05_langchain_chain.py +40 -0
  19. langchain_copilot-0.2.2/examples/07_tools.py +103 -0
  20. langchain_copilot-0.2.2/examples/08_bind_tools.py +93 -0
  21. langchain_copilot-0.2.2/examples/09_memory.py +25 -0
  22. langchain_copilot-0.2.2/examples/README.md +35 -0
  23. langchain_copilot-0.2.2/pyproject.toml +50 -0
  24. langchain_copilot-0.2.2/pytest.ini +8 -0
  25. langchain_copilot-0.2.2/src/langchain_copilot/__init__.py +6 -0
  26. langchain_copilot-0.2.2/src/langchain_copilot/chat_models.py +620 -0
  27. langchain_copilot-0.2.2/tests/__init__.py +1 -0
  28. langchain_copilot-0.2.2/tests/integration_tests/__init__.py +1 -0
  29. langchain_copilot-0.2.2/tests/integration_tests/test_integration_chat_model.py +83 -0
  30. langchain_copilot-0.2.2/tests/integration_tests/test_standard.py +121 -0
  31. langchain_copilot-0.2.2/tests/unit_tests/__init__.py +1 -0
  32. langchain_copilot-0.2.2/tests/unit_tests/test_chat_models.py +743 -0
  33. langchain_copilot-0.2.2/tests/unit_tests/test_standard.py +125 -0
  34. langchain_copilot-0.2.2/uv.lock +1516 -0
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test-and-lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v7
16
+ - name: Install Python 3.13
17
+ run: uv python install 3.13
18
+ - name: Install dependencies
19
+ run: uv sync --all-extras --dev
20
+
21
+ - name: Lint with ruff
22
+ run: |
23
+ uv run ruff check .
24
+
25
+ - name: Check formatting with black
26
+ run: |
27
+ uv run black --check .
28
+
29
+ - name: Run tests
30
+ run: |
31
+ make test
@@ -0,0 +1,98 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ github-release:
10
+ name: Create GitHub Release
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write # Required for creating releases
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Extract version from tag
19
+ id: version
20
+ run: |
21
+ VERSION=${GITHUB_REF#refs/tags/v}
22
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
23
+ echo "Releasing version: $VERSION"
24
+
25
+ - name: Extract changelog section
26
+ id: changelog
27
+ uses: mindsers/changelog-reader-action@v2
28
+ with:
29
+ version: ${{ steps.version.outputs.version }}
30
+ path: ./CHANGELOG.md
31
+
32
+ - name: Create GitHub Release
33
+ uses: softprops/action-gh-release@v2
34
+ with:
35
+ body: ${{ steps.changelog.outputs.changes }}
36
+ draft: false
37
+ prerelease: false
38
+ generate_release_notes: true # Adds auto-generated notes from PRs/commits
39
+ env:
40
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41
+
42
+ build:
43
+ name: Build distribution
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - name: Checkout code
47
+ uses: actions/checkout@v4
48
+
49
+ - name: Set up uv
50
+ uses: astral-sh/setup-uv@v7
51
+
52
+ - name: Set up Python
53
+ run: uv python install 3.13
54
+
55
+ - name: Verify version matches tag
56
+ run: |
57
+ TAG_VERSION=${GITHUB_REF#refs/tags/v}
58
+ PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2)
59
+
60
+ if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then
61
+ echo "❌ Version mismatch detected!"
62
+ echo " Tag version: $TAG_VERSION"
63
+ echo " pyproject.toml version: $PYPROJECT_VERSION"
64
+ echo "Please update pyproject.toml version before creating the tag."
65
+ exit 1
66
+ fi
67
+
68
+ echo "✅ Version match confirmed: $TAG_VERSION"
69
+
70
+ - name: Build package
71
+ run: uv build
72
+
73
+ - name: Upload distribution artifacts
74
+ uses: actions/upload-artifact@v4
75
+ with:
76
+ name: python-package-distributions
77
+ path: dist/
78
+
79
+ pypi-publish:
80
+ name: Publish to PyPI
81
+ needs: [github-release, build]
82
+ runs-on: ubuntu-latest
83
+ environment:
84
+ name: pypi
85
+ url: https://pypi.org/p/langchain-copilot
86
+ permissions:
87
+ id-token: write # REQUIRED for PyPI Trusted Publishing
88
+ steps:
89
+ - name: Download distribution artifacts
90
+ uses: actions/download-artifact@v4
91
+ with:
92
+ name: python-package-distributions
93
+ path: dist/
94
+
95
+ - name: Publish to PyPI
96
+ uses: pypa/gh-action-pypi-publish@release/v1
97
+ # No password needed with Trusted Publishing
98
+ # Configure at https://pypi.org/manage/account/publishing/
@@ -0,0 +1,113 @@
1
+ name: Test Publish to TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: 'Version to publish (e.g., 0.2.0-rc1, 0.3.0-beta.1)'
8
+ required: true
9
+ type: string
10
+ dry-run:
11
+ description: 'Dry run (build only, no publish)'
12
+ required: false
13
+ type: boolean
14
+ default: false
15
+
16
+ jobs:
17
+ test-publish:
18
+ name: Build and publish to TestPyPI
19
+ runs-on: ubuntu-latest
20
+ environment:
21
+ name: testpypi
22
+ url: https://test.pypi.org/p/langchain-copilot
23
+ permissions:
24
+ id-token: write # REQUIRED for TestPyPI Trusted Publishing
25
+ steps:
26
+ - name: Checkout code
27
+ uses: actions/checkout@v4
28
+
29
+ - name: Validate version input
30
+ run: |
31
+ VERSION="${{ inputs.version }}"
32
+
33
+ # Check if version follows semantic versioning pattern
34
+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
35
+ echo "❌ Invalid version format: $VERSION"
36
+ echo "Expected format: X.Y.Z or X.Y.Z-prerelease (e.g., 0.2.0, 0.3.0-rc1, 1.0.0-beta.1)"
37
+ exit 1
38
+ fi
39
+
40
+ echo "✅ Version format valid: $VERSION"
41
+
42
+ - name: Set up uv
43
+ uses: astral-sh/setup-uv@v7
44
+
45
+ - name: Set up Python
46
+ run: uv python install 3.13
47
+
48
+ - name: Update version in pyproject.toml
49
+ run: |
50
+ VERSION="${{ inputs.version }}"
51
+ echo "📝 Updating version to: $VERSION"
52
+
53
+ # Update version in pyproject.toml
54
+ sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
55
+
56
+ # Update version in __init__.py
57
+ sed -i.bak "s/__version__ = .*/__version__ = \"$VERSION\"/" src/langchain_copilot/__init__.py
58
+
59
+ # Show changes
60
+ echo "pyproject.toml:"
61
+ grep '^version = ' pyproject.toml
62
+ echo "__init__.py:"
63
+ grep '__version__' src/langchain_copilot/__init__.py
64
+
65
+ - name: Install dependencies
66
+ run: uv sync --all-extras --dev
67
+
68
+ - name: Run tests
69
+ run: make test
70
+
71
+ - name: Build package
72
+ run: uv build
73
+
74
+ - name: List distribution files
75
+ run: |
76
+ echo "📦 Distribution files:"
77
+ ls -lh dist/
78
+
79
+ - name: Publish to TestPyPI
80
+ if: ${{ !inputs.dry-run }}
81
+ uses: pypa/gh-action-pypi-publish@release/v1
82
+ with:
83
+ repository-url: https://test.pypi.org/legacy/
84
+ skip-existing: true
85
+ # No password needed with Trusted Publishing
86
+ # Configure at https://test.pypi.org/manage/account/publishing/
87
+
88
+ - name: Dry run summary
89
+ if: ${{ inputs.dry-run }}
90
+ run: |
91
+ echo "🏃 DRY RUN MODE - Package built but not published"
92
+ echo ""
93
+ echo "To publish this version to TestPyPI, re-run without dry-run option"
94
+ echo "To install from TestPyPI after publishing:"
95
+ echo " pip install --index-url https://test.pypi.org/simple/ \\"
96
+ echo " --extra-index-url https://pypi.org/simple \\"
97
+ echo " langchain-copilot==${{ inputs.version }}"
98
+
99
+ - name: Post-publish instructions
100
+ if: ${{ !inputs.dry-run }}
101
+ run: |
102
+ echo "✅ Package published to TestPyPI!"
103
+ echo ""
104
+ echo "To test the installation:"
105
+ echo " pip install --index-url https://test.pypi.org/simple/ \\"
106
+ echo " --extra-index-url https://pypi.org/simple \\"
107
+ echo " langchain-copilot==${{ inputs.version }}"
108
+ echo ""
109
+ echo "View on TestPyPI: https://test.pypi.org/project/langchain-copilot/${{ inputs.version }}/"
110
+ echo ""
111
+ echo "If everything works, create a release tag to publish to PyPI:"
112
+ echo " git tag v${{ inputs.version }}"
113
+ echo " git push origin v${{ inputs.version }}"
@@ -0,0 +1,18 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ .pytest_cache/
13
+ .ruff_cache/
14
+ .blackd/
15
+
16
+ .github/*.md
17
+ .github/SDK*
18
+ .coverage
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.2] - 2026-02-26
11
+ ### Added
12
+ - Memory example demonstrating conversation history with `RunnableWithMessageHistory` (example 09)
13
+
14
+ ### Fixed
15
+ - Fixed `cli_url` TypeError by passing options as dictionary to `CopilotClient`
16
+ - Fixed indefinite hang when only system messages are provided
17
+ - Improved message validation to raise clear errors for empty prompts
18
+
19
+ ### Changed
20
+ - Refactored message handling and prompt construction logic
21
+ - Improved error messages for invalid message configurations
22
+ - Enhanced test coverage for edge cases
23
+
24
+ ### Removed
25
+ - Removed temperature example (06_temperature.py) as it was redundant
26
+
27
+ ## [0.2.1] - 2026-01-29
28
+
29
+ ### Added
30
+ - GitHub Actions workflow for automated PyPI releases
31
+ - TestPyPI manual publishing workflow for pre-release testing
32
+ - Comprehensive release documentation (RELEASE.md)
33
+
34
+ ### Fixed
35
+ - Fixed author name in pyproject.toml metadata
36
+ - Fixed project URLs configuration
37
+ - Fixed dependency declarations in pyproject.toml
38
+
39
+ ## [0.2.0] - 2026-01-28
40
+
41
+ ### Added
42
+ - LangChain standard interface compliance via `langchain-tests`
43
+ - Comprehensive test suite with unit and integration tests
44
+ - Support for tool binding and function calling
45
+ - Additional examples showcasing temperature control, async operations, and tool usage
46
+ - CI/CD automation with GitHub Actions for testing and publishing
47
+ - Automated PyPI publishing via GitHub Releases with Trusted Publishing
48
+ - TestPyPI manual publishing workflow for pre-release testing
49
+
50
+ ### Changed
51
+ - Improved error handling and SDK event suppression
52
+ - Enhanced documentation with QUICKSTART.md, TESTING.md, and RELEASE.md
53
+ - Synchronized versioning between pyproject.toml and __init__.py
54
+
55
+ ### Fixed
56
+ - AsyncIO event loop handling in synchronous contexts
57
+ - Version mismatch between package metadata and source code
58
+
59
+ ## [0.1.0] - 2026-01-15
60
+
61
+ ### Added
62
+ - Initial release of langchain-copilot
63
+ - CopilotChatModel implementing LangChain BaseChatModel interface
64
+ - Shared client pattern with lazy initialization
65
+ - Full async/sync support for generate and stream operations
66
+ - Event-based SDK integration with GitHub Copilot CLI
67
+ - Support for system, human, and AI messages
68
+ - Basic examples demonstrating invoke, streaming, and async operations
69
+ - Development tooling: pytest, black, ruff, uv integration
70
+ - MIT License
71
+
72
+ [unreleased]: https://github.com/derf974/copilot-langchain/compare/v0.2.1...HEAD
73
+ [0.2.1]: https://github.com/derf974/copilot-langchain/compare/v0.2.0...v0.2.1
74
+ [0.2.0]: https://github.com/derf974/copilot-langchain/compare/v0.1.0...v0.2.0
75
+ [0.1.0]: https://github.com/derf974/copilot-langchain/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LangChain Copilot Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ .PHONY: help install test integration-test lint format clean
2
+
3
+ help: ## Afficher cette aide
4
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
5
+
6
+ install: ## Installer les dépendances
7
+ uv sync --all-extras --dev
8
+
9
+ test: ## Exécuter les tests unitaires
10
+ uv run pytest tests/unit_tests/ -v
11
+
12
+ integration-test: ## Exécuter les tests d'intégration (nécessite Copilot CLI)
13
+ uv run pytest tests/integration_tests/ -v
14
+
15
+ test-all: ## Exécuter tous les tests (unitaires + intégration)
16
+ uv run pytest tests/ -v
17
+
18
+ lint: ## Vérifier le code avec ruff
19
+ uv run ruff check .
20
+
21
+ format: ## Formater le code avec black et ruff
22
+ uv run black .
23
+ uv run ruff check --fix .
24
+
25
+ clean: ## Nettoyer les fichiers générés
26
+ find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
27
+ find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
28
+ find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
29
+ find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true