Skip to content

Commit 83d3030

Browse files
committed
feat: REL-10772 Added core SDK files including models, providers, and metrics tracking.
1 parent d248fa3 commit 83d3030

28 files changed

+3501
-10
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
post_create_environment:
99
- python -m pip install poetry
1010
post_install:
11-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
11+
- cd packages/sdk/server-ai && VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
1212

1313
sphinx:
1414
builder: html

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ help: #! Show this help message
1515

1616
.PHONY: install
1717
install:
18-
@poetry install
18+
@cd packages/sdk/server-ai && poetry install
1919

2020
#
2121
# Quality control checks
@@ -24,21 +24,21 @@ install:
2424
.PHONY: test
2525
test: #! Run unit tests
2626
test: install
27-
@poetry run pytest $(PYTEST_FLAGS)
27+
@cd packages/sdk/server-ai && poetry run pytest $(PYTEST_FLAGS)
2828

2929
.PHONY: lint
3030
lint: #! Run type analysis and linting checks
3131
lint: install
32-
@poetry run mypy ldai
33-
@poetry run isort --check --atomic ldai
34-
@poetry run pycodestyle ldai
32+
@cd packages/sdk/server-ai && poetry run mypy src/ldai
33+
@cd packages/sdk/server-ai && poetry run isort --check --atomic src/ldai
34+
@cd packages/sdk/server-ai && poetry run pycodestyle src/ldai
3535

3636
#
3737
# Documentation generation
3838
#
3939

4040
.PHONY: docs
4141
docs: #! Generate sphinx-based documentation
42-
@poetry install --with docs
42+
@cd packages/sdk/server-ai && poetry install --with docs
4343
@cd docs
44-
@poetry run $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
44+
@cd packages/sdk/server-ai && poetry run $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import sys
2121

22-
sys.path.insert(0, os.path.abspath('..'))
22+
sys.path.insert(0, os.path.abspath('../packages/sdk/server-ai/src'))
2323

2424
import ldai
2525

packages/sdk/server-ai/LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2024 Catamorphic, Co.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

packages/sdk/server-ai/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# LaunchDarkly Server-side AI library for Python
2+
3+
## LaunchDarkly overview
4+
5+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
6+
7+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
8+
9+
## Supported Python versions
10+
11+
This version of the library has a minimum Python version of 3.9.
12+
13+
## Getting started
14+
15+
Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/ai/python) for instructions on getting started with using the SDK.
16+
17+
## Learn more
18+
19+
Read our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [reference guide for the python SDK](http://docs.launchdarkly.com/docs/python-sdk-ai-reference).
20+
21+
## Contributing
22+
23+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this library.
24+
25+
## Verifying library build provenance with the SLSA framework
26+
27+
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published library packages. To learn more, see the [provenance guide](PROVENANCE.md).
28+
29+
## About LaunchDarkly
30+
31+
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
32+
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
33+
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
34+
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
35+
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
36+
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
37+
- Explore LaunchDarkly
38+
- [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
39+
- [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
40+
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
41+
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[tool.poetry]
2+
name = "launchdarkly-server-sdk-ai"
3+
version = "0.10.1"
4+
description = "LaunchDarkly SDK for AI"
5+
authors = ["LaunchDarkly <[email protected]>"]
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+
documentation = "https://launchdarkly-python-sdk-ai.readthedocs.io/en/latest/"
11+
classifiers = [
12+
"Intended Audience :: Developers",
13+
"License :: OSI Approved :: Apache Software License",
14+
"Operating System :: OS Independent",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
"Topic :: Software Development",
22+
"Topic :: Software Development :: Libraries",
23+
]
24+
packages = [ { include = "ldai", from = "src" } ]
25+
26+
[tool.poetry.dependencies]
27+
python = ">=3.9,<4"
28+
launchdarkly-server-sdk = ">=9.4.0"
29+
chevron = "=0.14.0"
30+
31+
32+
[tool.poetry.group.dev.dependencies]
33+
pytest = ">=2.8"
34+
pytest-cov = ">=2.4.0"
35+
pytest-mypy = "==1.0.1"
36+
pytest-asyncio = ">=0.21.0"
37+
mypy = "==1.18.2"
38+
pycodestyle = "^2.12.1"
39+
isort = ">=5.13.2,<7.0.0"
40+
41+
42+
[tool.poetry.group.docs]
43+
optional = true
44+
45+
[tool.poetry.group.docs.dependencies]
46+
sphinx = ">=6,<8"
47+
sphinx-rtd-theme = ">=1.3,<4.0"
48+
certifi = ">=2018.4.16"
49+
expiringdict = ">=1.1.4"
50+
pyrfc3339 = ">=1.0"
51+
jsonpickle = ">1.4.1"
52+
semver = ">=2.7.9"
53+
urllib3 = ">=1.26.0"
54+
jinja2 = "3.1.6"
55+
56+
[tool.mypy]
57+
python_version = "3.9"
58+
ignore_missing_imports = true
59+
install_types = true
60+
non_interactive = true
61+
62+
63+
[tool.pytest.ini_options]
64+
addopts = ["-ra"]
65+
66+
67+
[build-system]
68+
requires = ["poetry-core"]
69+
build-backend = "poetry.core.masonry.api"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
__version__ = "0.10.1" # x-release-please-version
2+
3+
# Extend __path__ to support namespace packages at the ldai level
4+
# This allows provider packages (like launchdarkly-server-sdk-ai-langchain)
5+
# to extend ldai.providers.* even though ldai itself has an __init__.py
6+
import sys
7+
from pkgutil import extend_path
8+
9+
__path__ = extend_path(__path__, __name__)
10+
11+
# Export chat
12+
from ldai.chat import TrackedChat
13+
# Export main client
14+
from ldai.client import LDAIClient
15+
# Export judge
16+
from ldai.judge import AIJudge, EvalScore, JudgeResponse
17+
# Export models for convenience
18+
from ldai.models import ( # Deprecated aliases for backward compatibility
19+
AIAgentConfig, AIAgentConfigDefault, AIAgentConfigRequest, AIAgents,
20+
AICompletionConfig, AICompletionConfigDefault, AIConfig, AIJudgeConfig,
21+
AIJudgeConfigDefault, JudgeConfiguration, LDAIAgent, LDAIAgentConfig,
22+
LDAIAgentDefaults, LDMessage, ModelConfig, ProviderConfig)
23+
24+
__all__ = [
25+
'LDAIClient',
26+
'AIAgentConfig',
27+
'AIAgentConfigDefault',
28+
'AIAgentConfigRequest',
29+
'AIAgents',
30+
'AICompletionConfig',
31+
'AICompletionConfigDefault',
32+
'AIJudgeConfig',
33+
'AIJudgeConfigDefault',
34+
'AIJudge',
35+
'TrackedChat',
36+
'EvalScore',
37+
'JudgeConfiguration',
38+
'JudgeResponse',
39+
'LDMessage',
40+
'ModelConfig',
41+
'ProviderConfig',
42+
# Deprecated exports
43+
'AIConfig',
44+
'LDAIAgent',
45+
'LDAIAgentConfig',
46+
'LDAIAgentDefaults',
47+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Chat module for LaunchDarkly AI SDK."""
2+
3+
from ldai.chat.tracked_chat import TrackedChat
4+
5+
__all__ = ['TrackedChat']

0 commit comments

Comments
 (0)