Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
post_create_environment:
- python -m pip install poetry
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
- cd packages/sdk/server-ai && VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs

sphinx:
builder: html
Expand Down
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ help: #! Show this help message

.PHONY: install
install:
@poetry install
@cd packages/sdk/server-ai && poetry install

#
# Quality control checks
Expand All @@ -24,21 +24,20 @@ install:
.PHONY: test
test: #! Run unit tests
test: install
@poetry run pytest $(PYTEST_FLAGS)
@cd packages/sdk/server-ai && poetry run pytest $(PYTEST_FLAGS)

.PHONY: lint
lint: #! Run type analysis and linting checks
lint: install
@poetry run mypy ldai
@poetry run isort --check --atomic ldai
@poetry run pycodestyle ldai
@cd packages/sdk/server-ai && poetry run mypy src/ldai
@cd packages/sdk/server-ai && poetry run isort --check --atomic src/ldai
@cd packages/sdk/server-ai && poetry run pycodestyle src/ldai

#
# Documentation generation
#

.PHONY: docs
docs: #! Generate sphinx-based documentation
@poetry install --with docs
@cd docs
@poetry run $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@cd packages/sdk/server-ai && poetry install --with docs
@cd packages/sdk/server-ai && poetry run $(SPHINXBUILD) -M html "../../../$(SOURCEDIR)" "../../../$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
import sys

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

import ldai

Expand Down
13 changes: 13 additions & 0 deletions packages/sdk/server-ai/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Catamorphic, Co.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be duplicated and should stay in the root unless we need it for the packaging process.


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
41 changes: 41 additions & 0 deletions packages/sdk/server-ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# LaunchDarkly Server-side AI library for Python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we have just duplicated this file but left the original at the root. This make sense to move, but we should change the root README in that case.


## LaunchDarkly overview

[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!

[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)

## Supported Python versions

This version of the library has a minimum Python version of 3.9.

## Getting started

Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/ai/python) for instructions on getting started with using the SDK.

## Learn more

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).

## Contributing

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.

## Verifying library build provenance with the SLSA framework

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).

## About LaunchDarkly

- 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:
- 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.
- 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?).
- 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.
- 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.
- 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.
- Explore LaunchDarkly
- [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
- [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
69 changes: 69 additions & 0 deletions packages/sdk/server-ai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[tool.poetry]
name = "launchdarkly-server-sdk-ai"
version = "0.10.1"
description = "LaunchDarkly SDK for AI"
authors = ["LaunchDarkly <dev@launchdarkly.com>"]
license = "Apache-2.0"
readme = "README.md"
homepage = "https://docs.launchdarkly.com/sdk/ai/python"
repository = "https://github.com/launchdarkly/python-server-sdk-ai"
documentation = "https://launchdarkly-python-sdk-ai.readthedocs.io/en/latest/"
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
]
packages = [ { include = "ldai", from = "src" } ]

[tool.poetry.dependencies]
python = ">=3.9,<4"
launchdarkly-server-sdk = ">=9.4.0"
chevron = "=0.14.0"


[tool.poetry.group.dev.dependencies]
pytest = ">=2.8"
pytest-cov = ">=2.4.0"
pytest-mypy = "==1.0.1"
pytest-asyncio = ">=0.21.0"
mypy = "==1.18.2"
pycodestyle = "^2.12.1"
isort = ">=5.13.2,<7.0.0"


[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = ">=6,<8"
sphinx-rtd-theme = ">=1.3,<4.0"
certifi = ">=2018.4.16"
expiringdict = ">=1.1.4"
pyrfc3339 = ">=1.0"
jsonpickle = ">1.4.1"
semver = ">=2.7.9"
urllib3 = ">=1.26.0"
jinja2 = "3.1.6"

[tool.mypy]
python_version = "3.9"
ignore_missing_imports = true
install_types = true
non_interactive = true


[tool.pytest.ini_options]
addopts = ["-ra"]


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
47 changes: 47 additions & 0 deletions packages/sdk/server-ai/src/ldai/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
__version__ = "0.10.1" # x-release-please-version

# Extend __path__ to support namespace packages at the ldai level
# This allows provider packages (like launchdarkly-server-sdk-ai-langchain)
# to extend ldai.providers.* even though ldai itself has an __init__.py
import sys
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)

# Export chat
from ldai.chat import TrackedChat
# Export main client
from ldai.client import LDAIClient
# Export judge
from ldai.judge import AIJudge, EvalScore, JudgeResponse
# Export models for convenience
from ldai.models import ( # Deprecated aliases for backward compatibility
AIAgentConfig, AIAgentConfigDefault, AIAgentConfigRequest, AIAgents,
AICompletionConfig, AICompletionConfigDefault, AIConfig, AIJudgeConfig,
AIJudgeConfigDefault, JudgeConfiguration, LDAIAgent, LDAIAgentConfig,
LDAIAgentDefaults, LDMessage, ModelConfig, ProviderConfig)

__all__ = [
'LDAIClient',
'AIAgentConfig',
'AIAgentConfigDefault',
'AIAgentConfigRequest',
'AIAgents',
'AICompletionConfig',
'AICompletionConfigDefault',
'AIJudgeConfig',
'AIJudgeConfigDefault',
'AIJudge',
'TrackedChat',
'EvalScore',
'JudgeConfiguration',
'JudgeResponse',
'LDMessage',
'ModelConfig',
'ProviderConfig',
# Deprecated exports
'AIConfig',
'LDAIAgent',
'LDAIAgentConfig',
'LDAIAgentDefaults',
]
5 changes: 5 additions & 0 deletions packages/sdk/server-ai/src/ldai/chat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Chat module for LaunchDarkly AI SDK."""

from ldai.chat.tracked_chat import TrackedChat

__all__ = ['TrackedChat']
Loading