Skip to content

Commit a7a5f4e

Browse files
authored
Merge pull request #3 from RadCod3/feat/langchain-py
Feat/langchain py
2 parents 8a2b267 + b493c19 commit a7a5f4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+9377
-7
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: LangChain Interpreter CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
paths:
7+
- "langchain-interpreter/**"
8+
- ".github/workflows/langchain-interpreter.yml"
9+
pull_request:
10+
branches: [main, dev]
11+
paths:
12+
- "langchain-interpreter/**"
13+
- ".github/workflows/langchain-interpreter.yml"
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: langchain-interpreter
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
enable-cache: true
30+
31+
- name: Install dependencies
32+
run: uv sync --dev
33+
34+
- name: Run tests
35+
run: uv run pytest
36+
37+
- name: Lint with ruff
38+
run: uv run ruff check .
39+
40+
docker:
41+
runs-on: ubuntu-latest
42+
needs: test
43+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
44+
permissions:
45+
packages: write
46+
defaults:
47+
run:
48+
working-directory: langchain-interpreter
49+
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Login to GHCR
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Determine image name
65+
id: meta
66+
env:
67+
OWNER: ${{ github.repository_owner }}
68+
run: |
69+
# GHCR requires lowercase repository names
70+
OWNER_LOWER=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')
71+
echo "image_name=ghcr.io/$OWNER_LOWER/afm-langchain-interpreter" >> $GITHUB_OUTPUT
72+
73+
- name: Build and push Docker image
74+
uses: docker/build-push-action@v5
75+
with:
76+
context: langchain-interpreter
77+
push: true
78+
platforms: linux/amd64,linux/arm64
79+
tags: |
80+
${{ steps.meta.outputs.image_name }}:latest
81+
${{ steps.meta.outputs.image_name }}:${{ github.sha }}
82+
labels: |
83+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
84+
org.opencontainers.image.revision=${{ github.sha }}
85+
org.opencontainers.image.title=AFM LangChain Interpreter
86+
org.opencontainers.image.licenses=Apache-2.0
87+
annotations: |
88+
index:org.opencontainers.image.source=https://github.com/${{ github.repository }}
89+
index:org.opencontainers.image.licenses=Apache-2.0

.github/workflows/release-common.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828

2929
env:
3030
# Allowed implementations - update this list when adding new implementations
31-
ALLOWED_IMPLEMENTATIONS: ballerina-interpreter
31+
ALLOWED_IMPLEMENTATIONS: ballerina-interpreter langchain-interpreter
3232

3333
jobs:
3434
release:
@@ -84,6 +84,21 @@ jobs:
8484
bal build
8585
bal test
8686
87+
- name: Install uv
88+
if: inputs.implementation == 'langchain-interpreter'
89+
uses: astral-sh/setup-uv@v5
90+
with:
91+
enable-cache: true
92+
93+
- name: Build and test (Python)
94+
if: inputs.implementation == 'langchain-interpreter'
95+
env:
96+
IMPLEMENTATION: ${{ inputs.implementation }}
97+
working-directory: ${{ inputs.implementation }}
98+
run: |
99+
uv sync --dev
100+
uv run pytest
101+
87102
- name: Create release branch
88103
env:
89104
IMPLEMENTATION: ${{ inputs.implementation }}

.github/workflows/release.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
type: choice
1010
options:
1111
- ballerina-interpreter
12+
- langchain-interpreter
1213
branch:
1314
description: 'Branch to release from'
1415
required: false
@@ -49,12 +50,22 @@ jobs:
4950
env:
5051
IMPLEMENTATION: ${{ inputs.implementation }}
5152
run: |
52-
# Read version from Ballerina.toml (first match is package version)
53-
RELEASE_VERSION=$(grep '^version = ' "$IMPLEMENTATION/Ballerina.toml" | head -1 | sed 's/version = "\(.*\)"/\1/')
53+
# Determine version file
54+
if [ -f "$IMPLEMENTATION/Ballerina.toml" ]; then
55+
VERSION_FILE="$IMPLEMENTATION/Ballerina.toml"
56+
elif [ -f "$IMPLEMENTATION/pyproject.toml" ]; then
57+
VERSION_FILE="$IMPLEMENTATION/pyproject.toml"
58+
else
59+
echo "::error::No version file found for implementation: $IMPLEMENTATION"
60+
exit 1
61+
fi
62+
63+
# Read version (first match is package version)
64+
RELEASE_VERSION=$(grep '^version = ' "$VERSION_FILE" | head -1 | sed 's/version = "\(.*\)"/\1/')
5465
5566
# Validate version format
5667
if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
57-
echo "::error::Version in Ballerina.toml must be in format X.Y.Z, got: $RELEASE_VERSION"
68+
echo "::error::Version in $VERSION_FILE must be in format X.Y.Z, got: $RELEASE_VERSION"
5869
exit 1
5970
fi
6071
@@ -120,7 +131,14 @@ jobs:
120131
git config user.name "github-actions[bot]"
121132
git config user.email "github-actions[bot]@users.noreply.github.com"
122133
git pull origin "$BRANCH" --rebase
123-
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/" "$IMPLEMENTATION/Ballerina.toml"
124-
git add "$IMPLEMENTATION/Ballerina.toml"
134+
# Determine version file
135+
if [ -f "$IMPLEMENTATION/Ballerina.toml" ]; then
136+
VERSION_FILE="$IMPLEMENTATION/Ballerina.toml"
137+
elif [ -f "$IMPLEMENTATION/pyproject.toml" ]; then
138+
VERSION_FILE="$IMPLEMENTATION/pyproject.toml"
139+
fi
140+
141+
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/" "$VERSION_FILE"
142+
git add "$VERSION_FILE"
125143
git commit -m "Bump $IMPLEMENTATION version to $NEXT_VERSION"
126144
git push origin "$BRANCH"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Reference implementations for [Agent-Flavored Markdown (AFM)](https://wso2.githu
77
| Implementation | Language/Framework | Status |
88
|----------------|-------------------|--------|
99
| [ballerina-interpreter](./ballerina-interpreter) | Ballerina | Active |
10-
| langchain-interpreter | Python/LangChain | Planned |
10+
| [langchain-interpreter](./langchain-interpreter) | Python/LangChain | Active |
1111

1212
## Repository Structure
1313

1414
```
1515
reference-implementations-afm/
1616
├── ballerina-interpreter/ # Ballerina-based AFM interpreter
17+
├── langchain-interpreter/ # LangChain-based AFM interpreter
1718
└── .github/workflows/ # CI/CD (path-filtered per implementation)
1819
```
1920

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.venv
2+
.git
3+
.github
4+
__pycache__
5+
*.pyc
6+
.pytest_cache
7+
.coverage
8+
htmlcov
9+
.env
10+
dist
11+
build
12+
*.egg-info

0 commit comments

Comments
 (0)