Skip to content

Commit c7285f7

Browse files
committed
Implements optimization package stub
1 parent aa60c82 commit c7285f7

13 files changed

Lines changed: 289 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,56 @@ jobs:
164164

165165
- name: Run tests
166166
run: make -C packages/ai-providers/server-ai-openai test
167+
168+
server-ai-optimization-linux:
169+
runs-on: ubuntu-latest
170+
strategy:
171+
matrix:
172+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
173+
174+
steps:
175+
- uses: actions/checkout@v4
176+
177+
- uses: ./.github/actions/ci
178+
with:
179+
workspace_path: packages/optimization
180+
python_version: ${{ matrix.python-version }}
181+
182+
- uses: ./.github/actions/build
183+
with:
184+
workspace_path: packages/optimization
185+
186+
server-ai-optimization-windows:
187+
runs-on: windows-latest
188+
defaults:
189+
run:
190+
shell: powershell
191+
192+
strategy:
193+
matrix:
194+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
195+
196+
steps:
197+
- uses: actions/checkout@v4
198+
199+
- name: Set up Python ${{ matrix.python-version }}
200+
uses: actions/setup-python@v5
201+
with:
202+
python-version: ${{ matrix.python-version }}
203+
204+
- name: Install poetry
205+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
206+
207+
- name: Configure poetry for local virtualenvs
208+
run: poetry config virtualenvs.in-project true
209+
210+
- name: Install server-ai dependency first
211+
working-directory: packages/sdk/server-ai
212+
run: poetry install
213+
214+
- name: Install requirements
215+
working-directory: packages/optimization
216+
run: poetry install
217+
218+
- name: Run tests
219+
run: make -C packages/optimization test

.github/workflows/release-please.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ on:
2727
- packages/sdk/server-ai
2828
- packages/ai-providers/server-ai-langchain
2929
- packages/ai-providers/server-ai-openai
30+
- packages/optimization
3031
dry_run:
3132
description: 'Is this a dry run. If so no package will be published.'
3233
type: boolean
@@ -46,6 +47,8 @@ jobs:
4647
package-server-ai-langchain-tag-name: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--tag_name'] }}
4748
package-server-ai-openai-released: ${{ steps.release.outputs['packages/ai-providers/server-ai-openai--release_created'] }}
4849
package-server-ai-openai-tag-name: ${{ steps.release.outputs['packages/ai-providers/server-ai-openai--tag_name'] }}
50+
package-server-ai-optimization-released: ${{ steps.release.outputs['packages/optimization--release_created'] }}
51+
package-server-ai-optimization-tag-name: ${{ steps.release.outputs['packages/optimization--tag_name'] }}
4952
steps:
5053
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
5154
id: release
@@ -250,3 +253,57 @@ jobs:
250253
base64-subjects: "${{ needs.release-server-ai-openai.outputs.package-hashes }}"
251254
upload-assets: true
252255
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-openai-tag-name }}
256+
257+
release-server-ai-optimization:
258+
runs-on: ubuntu-latest
259+
needs: ['release-please']
260+
permissions:
261+
id-token: write # Needed for OIDC to get release secrets from AWS.
262+
if: ${{ needs.release-please.outputs.package-server-ai-optimization-released == 'true' }}
263+
outputs:
264+
package-hashes: ${{ steps.build.outputs.package-hashes }}
265+
steps:
266+
- uses: actions/checkout@v4
267+
with:
268+
fetch-depth: 0
269+
270+
- uses: actions/setup-python@v5
271+
with:
272+
python-version: '3.11'
273+
274+
- name: Install poetry
275+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # 7b6d33e44b4f08d7021a1dee3c044e9c253d6439
276+
277+
- uses: ./.github/actions/ci
278+
with:
279+
workspace_path: packages/optimization
280+
281+
- uses: ./.github/actions/build
282+
id: build
283+
with:
284+
workspace_path: packages/optimization
285+
286+
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
287+
name: 'Get PyPI token'
288+
with:
289+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
290+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
291+
292+
- name: Publish to PyPI
293+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
294+
with:
295+
password: ${{ env.PYPI_AUTH_TOKEN }}
296+
packages-dir: packages/optimization/dist/
297+
298+
release-server-ai-optimization-provenance:
299+
needs: ['release-please', 'release-server-ai-optimization']
300+
if: ${{ needs.release-please.outputs.package-server-ai-optimization-released == 'true' }}
301+
permissions:
302+
actions: read # Needed for detecting the GitHub Actions environment.
303+
id-token: write # Needed for provenance signing.
304+
contents: write # Needed for uploading assets to the release.
305+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
306+
with:
307+
base64-subjects: "${{ needs.release-server-ai-optimization.outputs.package-hashes }}"
308+
upload-assets: true
309+
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-optimization-tag-name }}

packages/optimization/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 0.0.0 (2026-03-24)
4+
5+
### Features
6+
7+
* Initial package scaffolding for optimization helpers.

packages/optimization/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
PYTEST_FLAGS=-W error::SyntaxWarning
2+
3+
.PHONY: help
4+
help: #! Show this help message
5+
@echo 'Usage: make [target] ... '
6+
@echo ''
7+
@echo 'Targets:'
8+
@grep -h -F '#!' $(MAKEFILE_LIST) | grep -v grep | sed 's/:.*#!/:/' | column -t -s":"
9+
10+
.PHONY: install
11+
install: #! Install package dependencies
12+
poetry install
13+
14+
.PHONY: test
15+
test: #! Run unit tests
16+
test: install
17+
poetry run pytest $(PYTEST_FLAGS)
18+
19+
.PHONY: lint
20+
lint: #! Run type analysis and linting checks
21+
lint: install
22+
poetry run mypy src/ldai_optimization
23+
poetry run isort --check --atomic src/ldai_optimization
24+
poetry run pycodestyle src/ldai_optimization
25+
26+
.PHONY: build
27+
build: #! Build distribution files
28+
build: install
29+
poetry build

packages/optimization/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# LaunchDarkly AI SDK — optimization
2+
3+
[![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai-optimization.svg?style=flat-square)](https://pypi.org/project/launchdarkly-server-sdk-ai-optimization/)
4+
5+
> [!CAUTION]
6+
> This package is in pre-release and not subject to backwards compatibility
7+
> guarantees. The API may change based on feedback.
8+
>
9+
> Pin to a specific minor version and review the [changelog](CHANGELOG.md) before upgrading.
10+
11+
This package will provide helpers to run selected tools against the [LaunchDarkly API](https://apidocs.launchdarkly.com/) from SDK-based workflows. The public surface is not yet finalized; see [CHANGELOG.md](CHANGELOG.md) for updates.
12+
13+
## Installation
14+
15+
```bash
16+
pip install launchdarkly-server-sdk-ai-optimization
17+
```
18+
19+
## Status
20+
21+
- 3/24/26: Initial package creation
22+
23+
## License
24+
25+
Apache-2.0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[tool.poetry]
2+
name = "launchdarkly-server-sdk-ai-optimization"
3+
version = "0.0.0"
4+
description = "LaunchDarkly AI SDK optimization helpers"
5+
authors = ["LaunchDarkly <dev@launchdarkly.com>"]
6+
license = "Apache-2.0"
7+
readme = "README.md"
8+
homepage = "https://docs.launchdarkly.com/sdk/ai/python"
9+
repository = "https://github.com/launchdarkly/python-server-sdk-ai"
10+
classifiers = [
11+
"Intended Audience :: Developers",
12+
"License :: OSI Approved :: Apache Software License",
13+
"Operating System :: OS Independent",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.9",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
20+
"Topic :: Software Development",
21+
"Topic :: Software Development :: Libraries",
22+
]
23+
packages = [{ include = "ldai_optimization", from = "src" }]
24+
25+
[tool.poetry.dependencies]
26+
python = ">=3.9,<4"
27+
launchdarkly-server-sdk-ai = ">=0.16.0"
28+
29+
[tool.poetry.group.dev.dependencies]
30+
pytest = ">=2.8"
31+
pytest-cov = ">=2.4.0"
32+
pytest-asyncio = ">=0.21.0,<1.0.0"
33+
mypy = "==1.18.2"
34+
pycodestyle = ">=2.11.0"
35+
isort = ">=5.12.0"
36+
37+
[tool.mypy]
38+
python_version = "3.9"
39+
ignore_missing_imports = true
40+
install_types = true
41+
non_interactive = true
42+
43+
[tool.isort]
44+
profile = "black"
45+
known_third_party = ["ldai"]
46+
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
47+
48+
49+
[tool.pytest.ini_options]
50+
addopts = ["-ra"]
51+
testpaths = ["tests"]
52+
asyncio_mode = "auto"
53+
54+
55+
[build-system]
56+
requires = ["poetry-core"]
57+
build-backend = "poetry.core.masonry.api"

packages/optimization/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pycodestyle]
2+
max-line-length = 120
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""LaunchDarkly AI SDK — optimization.
2+
3+
This package will provide helpers to run selected tools against the LaunchDarkly API from SDK-based workflows.
4+
"""
5+
6+
from ldai_optimization.client import ApiAgentOptimizationClient
7+
8+
__version__ = "0.0.0"
9+
10+
__all__ = [
11+
'__version__',
12+
'ApiAgentOptimizationClient',
13+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Client placeholder for LaunchDarkly API tool execution."""
2+
3+
from typing import Any, Dict
4+
5+
6+
class ApiAgentOptimizationClient:
7+
"""Coordinates running supported tools against the LaunchDarkly API.
8+
9+
This type is scaffolding; concrete behavior will be added in a future release.
10+
"""
11+
12+
def optimize(self, tool_name: str, parameters: Dict[str, Any]) -> Any:
13+
"""Execute a supported LaunchDarkly API tool by name.
14+
15+
:param tool_name: Identifier of the tool to invoke.
16+
:param parameters: Tool-specific request parameters.
17+
:return: Tool-specific response data.
18+
:raises NotImplementedError: Until the API integration is implemented.
19+
"""
20+
raise NotImplementedError

packages/optimization/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)