fast-langchain-server 0.1.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.
- fast_langchain_server-0.1.2/.envrc +42 -0
- fast_langchain_server-0.1.2/.github/dependabot.yml +43 -0
- fast_langchain_server-0.1.2/.github/workflows/publish-pypi.yml +69 -0
- fast_langchain_server-0.1.2/.github/workflows/python-publish.yml +70 -0
- fast_langchain_server-0.1.2/.github/workflows/security.yml +138 -0
- fast_langchain_server-0.1.2/.gitignore +35 -0
- fast_langchain_server-0.1.2/CHANGELOG.md +274 -0
- fast_langchain_server-0.1.2/Dockerfile +31 -0
- fast_langchain_server-0.1.2/Makefile +35 -0
- fast_langchain_server-0.1.2/PKG-INFO +351 -0
- fast_langchain_server-0.1.2/README.md +321 -0
- fast_langchain_server-0.1.2/docs/GITHUB_ACTIONS_SETUP.md +201 -0
- fast_langchain_server-0.1.2/docs/GIT_WORKFLOW_GUIDE.md +500 -0
- fast_langchain_server-0.1.2/docs/SECURITY_CHECKS.md +290 -0
- fast_langchain_server-0.1.2/example_agent.py +57 -0
- fast_langchain_server-0.1.2/fast_langchain_server/__init__.py +28 -0
- fast_langchain_server-0.1.2/fast_langchain_server/a2a.py +716 -0
- fast_langchain_server-0.1.2/fast_langchain_server/cli.py +180 -0
- fast_langchain_server-0.1.2/fast_langchain_server/memory.py +337 -0
- fast_langchain_server-0.1.2/fast_langchain_server/server.py +623 -0
- fast_langchain_server-0.1.2/fast_langchain_server/serverutils.py +158 -0
- fast_langchain_server-0.1.2/fast_langchain_server/telemetry.py +264 -0
- fast_langchain_server-0.1.2/pyproject.toml +54 -0
- fast_langchain_server-0.1.2/scripts/PUBLISH_README.md +200 -0
- fast_langchain_server-0.1.2/scripts/publish-to-pypi.sh +160 -0
- fast_langchain_server-0.1.2/scripts/publish.py +202 -0
- fast_langchain_server-0.1.2/tests/__init__.py +0 -0
- fast_langchain_server-0.1.2/tests/conftest.py +164 -0
- fast_langchain_server-0.1.2/tests/test_a2a.py +407 -0
- fast_langchain_server-0.1.2/tests/test_memory.py +450 -0
- fast_langchain_server-0.1.2/tests/test_server.py +245 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# direnv environment — copy to .env or source directly
|
|
2
|
+
# ── Required ──────────────────────────────────────────────────────────────────
|
|
3
|
+
export AGENT_NAME=dev-agent
|
|
4
|
+
export MODEL_API_URL=http://localhost:11434/v1 # Ollama / vLLM / LM Studio / etc.
|
|
5
|
+
export MODEL_NAME=llama3.2
|
|
6
|
+
|
|
7
|
+
# ── Identity ──────────────────────────────────────────────────────────────────
|
|
8
|
+
export AGENT_DESCRIPTION="My LangChain agent"
|
|
9
|
+
export AGENT_INSTRUCTIONS="You are a helpful assistant."
|
|
10
|
+
export AGENT_PORT=8000
|
|
11
|
+
export AGENT_LOG_LEVEL=INFO
|
|
12
|
+
export AGENT_ACCESS_LOG=false
|
|
13
|
+
|
|
14
|
+
# ── Model ──────────────────────────────────────────────────────────────────────
|
|
15
|
+
export MODEL_API_KEY=not-needed
|
|
16
|
+
export MODEL_TEMPERATURE=0.7
|
|
17
|
+
# export MODEL_MAX_TOKENS=2048 # omit = no limit
|
|
18
|
+
|
|
19
|
+
# ── Memory ────────────────────────────────────────────────────────────────────
|
|
20
|
+
export MEMORY_ENABLED=true
|
|
21
|
+
export MEMORY_TYPE=local # local | redis | null
|
|
22
|
+
# export MEMORY_REDIS_URL=redis://localhost:6379
|
|
23
|
+
export MEMORY_CONTEXT_LIMIT=20
|
|
24
|
+
export MEMORY_MAX_SESSIONS=1000
|
|
25
|
+
export MEMORY_MAX_MESSAGES_PER_SESSION=500
|
|
26
|
+
|
|
27
|
+
# ── A2A task manager ──────────────────────────────────────────────────────────
|
|
28
|
+
export TASK_MANAGER_TYPE=none # none | local
|
|
29
|
+
# export TASK_MANAGER_MAX_TASKS=10000
|
|
30
|
+
|
|
31
|
+
# ── Autonomous execution (requires TASK_MANAGER_TYPE=local) ───────────────────
|
|
32
|
+
# export AUTONOMOUS_GOAL="Monitor the system and report anomalies every hour"
|
|
33
|
+
# export AUTONOMOUS_INTERVAL_SECONDS=3600
|
|
34
|
+
# export AUTONOMOUS_MAX_ITER_RUNTIME_SECONDS=60
|
|
35
|
+
|
|
36
|
+
# ── OpenTelemetry (optional) ──────────────────────────────────────────────────
|
|
37
|
+
# export OTEL_ENABLED=true
|
|
38
|
+
# export OTEL_SERVICE_NAME=my-agent
|
|
39
|
+
# export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
|
40
|
+
# export OTEL_INCLUDE_HTTP_SERVER=false # opt-in FastAPI spans
|
|
41
|
+
# export OTEL_INCLUDE_HTTP_CLIENT=false # opt-in httpx spans
|
|
42
|
+
# export OTEL_SDK_DISABLED=false
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Python dependencies
|
|
4
|
+
- package-ecosystem: "pip"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
day: "monday"
|
|
9
|
+
time: "03:00"
|
|
10
|
+
open-pull-requests-limit: 5
|
|
11
|
+
reviewers:
|
|
12
|
+
- "michelcub"
|
|
13
|
+
labels:
|
|
14
|
+
- "dependencies"
|
|
15
|
+
- "security"
|
|
16
|
+
commit-message:
|
|
17
|
+
prefix: "chore"
|
|
18
|
+
prefix-development: "chore"
|
|
19
|
+
include: "scope"
|
|
20
|
+
pull-request-branch-name:
|
|
21
|
+
separator: "/"
|
|
22
|
+
rebase-strategy: "auto"
|
|
23
|
+
allow:
|
|
24
|
+
- dependency-type: "all"
|
|
25
|
+
ignore:
|
|
26
|
+
# Ignora actualizaciones menores de dependencias muy estables
|
|
27
|
+
- dependency-name: "setuptools"
|
|
28
|
+
|
|
29
|
+
# GitHub Actions
|
|
30
|
+
- package-ecosystem: "github-actions"
|
|
31
|
+
directory: "/"
|
|
32
|
+
schedule:
|
|
33
|
+
interval: "weekly"
|
|
34
|
+
day: "monday"
|
|
35
|
+
time: "04:00"
|
|
36
|
+
open-pull-requests-limit: 5
|
|
37
|
+
reviewers:
|
|
38
|
+
- "michelcub"
|
|
39
|
+
labels:
|
|
40
|
+
- "ci"
|
|
41
|
+
- "github-actions"
|
|
42
|
+
commit-message:
|
|
43
|
+
prefix: "ci"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- develop
|
|
7
|
+
- main
|
|
8
|
+
release:
|
|
9
|
+
types: [created, published]
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
inputs:
|
|
12
|
+
environment:
|
|
13
|
+
description: 'PyPI environment'
|
|
14
|
+
required: true
|
|
15
|
+
default: 'testpypi'
|
|
16
|
+
type: choice
|
|
17
|
+
options:
|
|
18
|
+
- testpypi
|
|
19
|
+
- pypi
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
publish:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
permissions:
|
|
25
|
+
contents: read
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Set up Python
|
|
31
|
+
uses: actions/setup-python@v4
|
|
32
|
+
with:
|
|
33
|
+
python-version: '3.11'
|
|
34
|
+
cache: 'pip'
|
|
35
|
+
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
pip install -e .
|
|
40
|
+
pip install build twine pytest pytest-asyncio
|
|
41
|
+
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: |
|
|
44
|
+
pytest tests/ -v --tb=short
|
|
45
|
+
|
|
46
|
+
- name: Build package
|
|
47
|
+
run: python -m build
|
|
48
|
+
|
|
49
|
+
- name: Check package integrity
|
|
50
|
+
run: twine check dist/*
|
|
51
|
+
|
|
52
|
+
- name: Publish to TestPyPI
|
|
53
|
+
if: |
|
|
54
|
+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi') ||
|
|
55
|
+
(github.event_name == 'release' && github.event.action == 'created') ||
|
|
56
|
+
(github.event_name == 'push' && github.ref == 'refs/heads/develop')
|
|
57
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
58
|
+
with:
|
|
59
|
+
repository-url: https://test.pypi.org/legacy/
|
|
60
|
+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
61
|
+
|
|
62
|
+
- name: Publish to PyPI
|
|
63
|
+
if: |
|
|
64
|
+
(github.event_name == 'release' && github.event.action == 'published') ||
|
|
65
|
+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi') ||
|
|
66
|
+
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|
|
67
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
68
|
+
with:
|
|
69
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# This workflow will upload a Python Package to PyPI when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
release-build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.x"
|
|
28
|
+
|
|
29
|
+
- name: Build release distributions
|
|
30
|
+
run: |
|
|
31
|
+
# NOTE: put your own distribution build steps here.
|
|
32
|
+
python -m pip install build
|
|
33
|
+
python -m build
|
|
34
|
+
|
|
35
|
+
- name: Upload distributions
|
|
36
|
+
uses: actions/upload-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: release-dists
|
|
39
|
+
path: dist/
|
|
40
|
+
|
|
41
|
+
pypi-publish:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
needs:
|
|
44
|
+
- release-build
|
|
45
|
+
permissions:
|
|
46
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
47
|
+
id-token: write
|
|
48
|
+
|
|
49
|
+
# Dedicated environments with protections for publishing are strongly recommended.
|
|
50
|
+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
|
|
51
|
+
environment:
|
|
52
|
+
name: pypi
|
|
53
|
+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
|
|
54
|
+
# url: https://pypi.org/p/YOURPROJECT
|
|
55
|
+
#
|
|
56
|
+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
|
|
57
|
+
# ALTERNATIVE: exactly, uncomment the following line instead:
|
|
58
|
+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
|
|
59
|
+
|
|
60
|
+
steps:
|
|
61
|
+
- name: Retrieve release distributions
|
|
62
|
+
uses: actions/download-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: release-dists
|
|
65
|
+
path: dist/
|
|
66
|
+
|
|
67
|
+
- name: Publish release distributions to PyPI
|
|
68
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
69
|
+
with:
|
|
70
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
name: Security Checks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- develop
|
|
7
|
+
- main
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- develop
|
|
11
|
+
- main
|
|
12
|
+
schedule:
|
|
13
|
+
# Ejecuta diariamente a las 2 AM UTC
|
|
14
|
+
- cron: '0 2 * * *'
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
security-events: write
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
dependency-check:
|
|
22
|
+
name: Check Dependencies for Vulnerabilities
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Set up Python
|
|
29
|
+
uses: actions/setup-python@v4
|
|
30
|
+
with:
|
|
31
|
+
python-version: '3.11'
|
|
32
|
+
cache: 'pip'
|
|
33
|
+
|
|
34
|
+
- name: Install project dependencies and tools
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade pip
|
|
37
|
+
pip install -e .
|
|
38
|
+
pip install pip-audit
|
|
39
|
+
|
|
40
|
+
- name: Audit Python dependencies
|
|
41
|
+
run: |
|
|
42
|
+
echo "🔍 Analizando dependencias..."
|
|
43
|
+
pip-audit --desc
|
|
44
|
+
continue-on-error: true
|
|
45
|
+
|
|
46
|
+
bandit-scan:
|
|
47
|
+
name: Scan Code for Security Issues
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Set up Python
|
|
54
|
+
uses: actions/setup-python@v4
|
|
55
|
+
with:
|
|
56
|
+
python-version: '3.11'
|
|
57
|
+
|
|
58
|
+
- name: Install bandit
|
|
59
|
+
run: pip install bandit
|
|
60
|
+
|
|
61
|
+
- name: Run Bandit security scan
|
|
62
|
+
run: |
|
|
63
|
+
echo "🔒 Escaneando código para problemas de seguridad..."
|
|
64
|
+
bandit -r fast_langchain_server/ -f json -o bandit-report.json || true
|
|
65
|
+
bandit -r fast_langchain_server/ -f txt
|
|
66
|
+
|
|
67
|
+
- name: Upload Bandit report
|
|
68
|
+
if: always()
|
|
69
|
+
uses: actions/upload-artifact@v4
|
|
70
|
+
with:
|
|
71
|
+
name: bandit-report
|
|
72
|
+
path: bandit-report.json
|
|
73
|
+
|
|
74
|
+
safety-check:
|
|
75
|
+
name: Check for Known Security Vulnerabilities
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
|
|
78
|
+
steps:
|
|
79
|
+
- uses: actions/checkout@v4
|
|
80
|
+
|
|
81
|
+
- name: Set up Python
|
|
82
|
+
uses: actions/setup-python@v4
|
|
83
|
+
with:
|
|
84
|
+
python-version: '3.11'
|
|
85
|
+
cache: 'pip'
|
|
86
|
+
|
|
87
|
+
- name: Install dependencies
|
|
88
|
+
run: |
|
|
89
|
+
python -m pip install --upgrade pip
|
|
90
|
+
pip install safety
|
|
91
|
+
|
|
92
|
+
- name: Run Safety check
|
|
93
|
+
run: |
|
|
94
|
+
echo "⚠️ Verificando vulnerabilidades conocidas..."
|
|
95
|
+
safety check --json
|
|
96
|
+
continue-on-error: true
|
|
97
|
+
|
|
98
|
+
codeql-analysis:
|
|
99
|
+
name: CodeQL Analysis
|
|
100
|
+
runs-on: ubuntu-latest
|
|
101
|
+
|
|
102
|
+
steps:
|
|
103
|
+
- name: Checkout repository
|
|
104
|
+
uses: actions/checkout@v4
|
|
105
|
+
|
|
106
|
+
- name: Initialize CodeQL
|
|
107
|
+
uses: github/codeql-action/init@v2
|
|
108
|
+
with:
|
|
109
|
+
languages: 'python'
|
|
110
|
+
|
|
111
|
+
- name: Autobuild
|
|
112
|
+
uses: github/codeql-action/autobuild@v2
|
|
113
|
+
|
|
114
|
+
- name: Perform CodeQL Analysis
|
|
115
|
+
uses: github/codeql-action/analyze@v2
|
|
116
|
+
|
|
117
|
+
license-check:
|
|
118
|
+
name: Check Dependencies Licenses
|
|
119
|
+
runs-on: ubuntu-latest
|
|
120
|
+
|
|
121
|
+
steps:
|
|
122
|
+
- uses: actions/checkout@v4
|
|
123
|
+
|
|
124
|
+
- name: Set up Python
|
|
125
|
+
uses: actions/setup-python@v4
|
|
126
|
+
with:
|
|
127
|
+
python-version: '3.11'
|
|
128
|
+
cache: 'pip'
|
|
129
|
+
|
|
130
|
+
- name: Install dependencies
|
|
131
|
+
run: |
|
|
132
|
+
python -m pip install --upgrade pip
|
|
133
|
+
pip install pip-licenses
|
|
134
|
+
|
|
135
|
+
- name: Check licenses
|
|
136
|
+
run: |
|
|
137
|
+
echo "📜 Analizando licencias de dependencias..."
|
|
138
|
+
pip-licenses --format=markdown --with-urls
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
.Python
|
|
7
|
+
|
|
8
|
+
# Distribution
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
*.egg
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
|
|
19
|
+
# Testing
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.coverage
|
|
22
|
+
htmlcov/
|
|
23
|
+
|
|
24
|
+
# IDE
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
*.swp
|
|
28
|
+
|
|
29
|
+
# Environment variables
|
|
30
|
+
.env
|
|
31
|
+
.env.*
|
|
32
|
+
|
|
33
|
+
# OS
|
|
34
|
+
.DS_Store
|
|
35
|
+
Thumbs.db
|
|
@@ -0,0 +1,274 @@
|
|
|
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
|
+
### Planned for v0.2.0
|
|
11
|
+
- Batching API for multiple agent invocations
|
|
12
|
+
- Custom session backends (PostgreSQL, DynamoDB)
|
|
13
|
+
- Cost tracking and rate limiting per agent
|
|
14
|
+
|
|
15
|
+
### Planned for v1.0.0
|
|
16
|
+
- Agent versioning and canary deployments
|
|
17
|
+
- Built-in monitoring dashboard
|
|
18
|
+
- WebSocket support for real-time bidirectional communication
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## [0.1.0] - 2026-04-11
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
#### Core Server Implementation
|
|
27
|
+
- FastAPI-based HTTP server for LangChain/LangGraph agents
|
|
28
|
+
- OpenAI-compatible API endpoints:
|
|
29
|
+
- `POST /invoke` - Synchronous agent invocation
|
|
30
|
+
- `POST /stream` - Streaming responses with Server-Sent Events (SSE)
|
|
31
|
+
- `GET /card` - Agent discovery and tool introspection
|
|
32
|
+
- `GET /health` - Health check endpoint
|
|
33
|
+
- Support for both `create_agent()` (LangChain 1.x) and custom `CompiledStateGraph` patterns
|
|
34
|
+
- Automatic tool parameter marshaling and validation with Pydantic
|
|
35
|
+
|
|
36
|
+
#### Session Management
|
|
37
|
+
- Automatic conversation history tracking
|
|
38
|
+
- Optional Redis persistence for distributed deployments
|
|
39
|
+
- Session isolation and management
|
|
40
|
+
- Configurable session timeout
|
|
41
|
+
|
|
42
|
+
#### Observability & Production Readiness
|
|
43
|
+
- OpenTelemetry integration for request tracing
|
|
44
|
+
- Structured logging with context propagation
|
|
45
|
+
- Health check endpoint for container orchestration
|
|
46
|
+
- Async I/O for concurrent request handling
|
|
47
|
+
- Type-safe request/response validation
|
|
48
|
+
|
|
49
|
+
#### Streaming & Real-time
|
|
50
|
+
- Server-Sent Events (SSE) support for streaming responses
|
|
51
|
+
- Token-by-token delivery to reduce perceived latency
|
|
52
|
+
- Proper connection handling and cleanup
|
|
53
|
+
|
|
54
|
+
#### Documentation
|
|
55
|
+
- Comprehensive README with quick start guide
|
|
56
|
+
- API endpoint documentation with curl examples
|
|
57
|
+
- Configuration reference for environment variables
|
|
58
|
+
- Architecture diagram
|
|
59
|
+
- Usage pattern examples (Pattern A & B)
|
|
60
|
+
- Contributing guidelines and roadmap
|
|
61
|
+
- Performance benchmarks
|
|
62
|
+
|
|
63
|
+
#### Docker Support
|
|
64
|
+
- Production-ready Dockerfile with Alpine base
|
|
65
|
+
- Multi-stage build for optimized image size
|
|
66
|
+
- Health check integration for orchestration
|
|
67
|
+
- Non-root user execution for security
|
|
68
|
+
- Fast dependency resolution with `uv`
|
|
69
|
+
|
|
70
|
+
#### Development Tools
|
|
71
|
+
- Makefile with common development tasks
|
|
72
|
+
- `make install` - Install dependencies
|
|
73
|
+
- `make dev` - Install dev dependencies
|
|
74
|
+
- `make test` - Run test suite
|
|
75
|
+
- `make lint` - Code quality checks
|
|
76
|
+
- `make run` - Local development with auto-reload
|
|
77
|
+
- `make docker-build` & `make docker-run` - Container helpers
|
|
78
|
+
- `make clean` - Clean build artifacts
|
|
79
|
+
- `.envrc` configuration for direnv integration
|
|
80
|
+
|
|
81
|
+
#### Examples & Tests
|
|
82
|
+
- Example agent (`example_agent.py`) demonstrating both usage patterns
|
|
83
|
+
- Comprehensive test suite:
|
|
84
|
+
- `test_server.py` - API endpoint testing
|
|
85
|
+
- `test_a2a.py` - OpenAI-compatible API testing
|
|
86
|
+
- `test_memory.py` - Session memory management testing
|
|
87
|
+
- Pytest fixtures for async testing
|
|
88
|
+
- Test configuration with `conftest.py`
|
|
89
|
+
|
|
90
|
+
#### Package Configuration
|
|
91
|
+
- Python 3.11+ support
|
|
92
|
+
- MIT License
|
|
93
|
+
- pyproject.toml with:
|
|
94
|
+
- Core dependencies (LangChain, FastAPI, Pydantic)
|
|
95
|
+
- Optional dependencies (Redis, OpenTelemetry)
|
|
96
|
+
- Dev dependencies (pytest, type checking)
|
|
97
|
+
- CLI entry point configuration
|
|
98
|
+
|
|
99
|
+
### Project Metadata
|
|
100
|
+
- Version: 0.1.0
|
|
101
|
+
- Keywords: langchain, langgraph, agent, server, fastapi, llm
|
|
102
|
+
- Repository structure following Python best practices
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Project Timeline
|
|
107
|
+
|
|
108
|
+
| Version | Date | Status |
|
|
109
|
+
|---------|------|--------|
|
|
110
|
+
| [0.1.0] | 2026-04-11 | ✅ Released |
|
|
111
|
+
| 0.2.0 | Q2 2026 | 🔄 Planned |
|
|
112
|
+
| 1.0.0 | Q3 2026 | 📋 Planned |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Git Flow Information
|
|
117
|
+
|
|
118
|
+
### Release v0.1.0
|
|
119
|
+
|
|
120
|
+
**Features merged (in order):**
|
|
121
|
+
1. `feature/core-server` (7c8b22f) - Core LangChain server implementation
|
|
122
|
+
2. `feature/documentation` (b956919) - Comprehensive documentation
|
|
123
|
+
3. `feature/docker-support` (30c3e00) - Docker containerization
|
|
124
|
+
4. `feature/dev-tools` (e2ffbe0) - Development tooling
|
|
125
|
+
5. `feature/examples-and-tests` (832598f) - Examples and test suite
|
|
126
|
+
|
|
127
|
+
**Merge commits:**
|
|
128
|
+
- `develop` branch: e3a3bf2, 5adb838, c859ac0, aa169aa, 70a3eaa
|
|
129
|
+
- `main` branch: 5c8f195 (release merge)
|
|
130
|
+
- `develop` sync: d34f357 (sync with main after release)
|
|
131
|
+
|
|
132
|
+
**Tag:** `v0.1.0` (anotado)
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Installation & Setup
|
|
137
|
+
|
|
138
|
+
### Quick Start
|
|
139
|
+
```bash
|
|
140
|
+
pip install fast-langchain-server
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### From Source
|
|
144
|
+
```bash
|
|
145
|
+
git clone https://github.com/yourusername/fast-langchain-server.git
|
|
146
|
+
cd fast-langchain-server
|
|
147
|
+
make dev
|
|
148
|
+
make test
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Docker
|
|
152
|
+
```bash
|
|
153
|
+
make docker-build
|
|
154
|
+
make docker-run
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Key Features by Component
|
|
160
|
+
|
|
161
|
+
### `fast_langchain_server/` Module
|
|
162
|
+
- **`__init__.py`** - Package exports and `serve()` function
|
|
163
|
+
- **`server.py`** - Core FastAPI application and endpoints
|
|
164
|
+
- **`cli.py`** - CLI interface with Typer
|
|
165
|
+
- **`memory.py`** - Session memory backends (memory, Redis)
|
|
166
|
+
- **`a2a.py`** - OpenAI-compatible API layer
|
|
167
|
+
- **`telemetry.py`** - OpenTelemetry instrumentation
|
|
168
|
+
- **`serverutils.py`** - Helper utilities and models
|
|
169
|
+
|
|
170
|
+
### Test Suite
|
|
171
|
+
- **`test_server.py`** - HTTP endpoint tests (224 lines)
|
|
172
|
+
- **`test_a2a.py`** - OpenAI compatibility tests (407 lines)
|
|
173
|
+
- **`test_memory.py`** - Session memory tests (444 lines)
|
|
174
|
+
- **`conftest.py`** - Pytest fixtures and configuration
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Known Limitations (v0.1.0)
|
|
179
|
+
|
|
180
|
+
1. Single-server deployments only (no distributed agent state)
|
|
181
|
+
2. In-memory session store by default (Redis required for persistence)
|
|
182
|
+
3. No built-in rate limiting or cost tracking
|
|
183
|
+
4. No agent versioning or canary deployment support
|
|
184
|
+
5. Limited to HTTP/SSE streaming (no WebSocket support yet)
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Migration Guide
|
|
189
|
+
|
|
190
|
+
### From LangChain Agents (without Server)
|
|
191
|
+
|
|
192
|
+
Before:
|
|
193
|
+
```python
|
|
194
|
+
from langchain.agents import create_agent
|
|
195
|
+
agent = create_agent(model=..., tools=...)
|
|
196
|
+
result = agent.invoke({"messages": [...]})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
After:
|
|
200
|
+
```python
|
|
201
|
+
from langchain.agents import create_agent
|
|
202
|
+
from fast_langchain_server import serve
|
|
203
|
+
|
|
204
|
+
agent = create_agent(model=..., tools=...)
|
|
205
|
+
app = serve(agent, tools=TOOLS)
|
|
206
|
+
# Now accessible via HTTP at /invoke and /stream
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Environment Variables Required
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
AGENT_NAME=my-agent # Required
|
|
213
|
+
MODEL_API_URL=... # Required
|
|
214
|
+
MODEL_NAME=gpt-4o # Required
|
|
215
|
+
OPENAI_API_KEY=sk-... # For OpenAI models
|
|
216
|
+
REDIS_URL=redis://... # Optional (for persistence)
|
|
217
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=... # Optional (for tracing)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Performance Notes
|
|
223
|
+
|
|
224
|
+
### Observed Metrics (v0.1.0)
|
|
225
|
+
|
|
226
|
+
- **Latency**: ~100ms for simple tool calls (OpenAI API)
|
|
227
|
+
- **Throughput**: Handles concurrent requests efficiently via async I/O
|
|
228
|
+
- **Memory**: ~150MB baseline (FastAPI + dependencies)
|
|
229
|
+
- **Startup**: ~2-3 seconds cold start
|
|
230
|
+
|
|
231
|
+
### Optimization Recommendations
|
|
232
|
+
|
|
233
|
+
1. Use Redis for session persistence in multi-instance setups
|
|
234
|
+
2. Enable OpenTelemetry sampling for production
|
|
235
|
+
3. Cache agent definitions if using custom graphs
|
|
236
|
+
4. Use connection pooling for database backends
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Contributors
|
|
241
|
+
|
|
242
|
+
- **Initial Release**: Claude (AI Assistant)
|
|
243
|
+
- **Project Lead**: Michel (@michelcub)
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Support & Communication
|
|
254
|
+
|
|
255
|
+
- 📖 [Documentation](https://github.com/yourusername/fast-langchain-server/wiki)
|
|
256
|
+
- 🐛 [Issue Tracker](https://github.com/yourusername/fast-langchain-server/issues)
|
|
257
|
+
- 💬 [Discussions](https://github.com/yourusername/fast-langchain-server/discussions)
|
|
258
|
+
- 📧 [Email](mailto:support@example.com)
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Acknowledgments
|
|
263
|
+
|
|
264
|
+
Built with:
|
|
265
|
+
- [LangChain](https://langchain.com) - Agent orchestration
|
|
266
|
+
- [LangGraph](https://langgraph.dev) - Graph execution
|
|
267
|
+
- [FastAPI](https://fastapi.tiangolo.com) - Web framework
|
|
268
|
+
- [Pydantic](https://pydantic-ai.jina.ai) - Data validation
|
|
269
|
+
- [OpenTelemetry](https://opentelemetry.io) - Observability
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
**Last Updated**: 2026-04-11
|
|
274
|
+
**Version**: 0.1.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
# ── System deps ───────────────────────────────────────────────────────────────
|
|
4
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
5
|
+
curl \
|
|
6
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
7
|
+
|
|
8
|
+
# ── Install uv for fast dependency resolution ─────────────────────────────────
|
|
9
|
+
RUN pip install --no-cache-dir uv
|
|
10
|
+
|
|
11
|
+
WORKDIR /app
|
|
12
|
+
|
|
13
|
+
# ── Dependencies (cached layer) ───────────────────────────────────────────────
|
|
14
|
+
COPY pyproject.toml .
|
|
15
|
+
RUN uv pip install --system --no-cache ".[dev]"
|
|
16
|
+
|
|
17
|
+
# ── Source ────────────────────────────────────────────────────────────────────
|
|
18
|
+
COPY lcas/ ./lcas/
|
|
19
|
+
|
|
20
|
+
# ── Non-root user ─────────────────────────────────────────────────────────────
|
|
21
|
+
RUN useradd --uid 65532 --no-create-home --shell /bin/false agent
|
|
22
|
+
USER agent
|
|
23
|
+
|
|
24
|
+
EXPOSE 8000
|
|
25
|
+
|
|
26
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
27
|
+
CMD curl -f http://localhost:8000/health || exit 1
|
|
28
|
+
|
|
29
|
+
# Expects the user to COPY their agent.py into /app/agent.py
|
|
30
|
+
CMD ["python", "-m", "uvicorn", "lcas.server:get_app", "--factory", \
|
|
31
|
+
"--host", "0.0.0.0", "--port", "8000"]
|