semvec/pypi-packages huggingface dataset:
gen3config 2.1.0
Gen3 Configuration Library
License: Apache-2.0
Requires Python: <4,>=3.13

# gen3config

Handle YAML configurations with a given default/expected configuration.
Library will overlay a provided configration over the default and ignore unknown values.

## Quickstart

Example `config-default.yaml` for your application:

```
---
SOME_VALUE: 'default'

EXAMPLE:
    nested:
        key: 'value'
        is_boolean: true
```

Example `config.py` in your application:

```
from gen3config import Config

class AppConfig(Config):
    def __init__(self, *args, **kwargs):
        super(AppConfig, self).__init__(*args, **kwargs)

    def post_process(self):
        # do custom stuff here after parsing config
        pass

default_cfg_path = os.path.join(
    os.path.dirname(os.path.abspath(__file__)), "config-default.yaml"
)

config = AppConfig(default_cfg_path)
```

---

Now we want to get a specific configuration.

Example file `~/path/to/app-config.yaml`:

```
SOME_VALUE: 'app-specific configuration'

EXAMPLE:
    nested:
        is_boolean: true
```

Example initialization function in your application:

```
from app.config import config

config.load('~/path/to/app-config.yaml')
```

Then from other files:
```
from app.config import config

print(config["SOME_VALUE"])  # 'app-specific configuration'
print(config["EXAMPLE"]["nested"]["key"])  # 'value'
```

> NOTE: `config["EXAMPLE"]["nested"]["key"]` does not exist in the provided configuration, but it does exist in the default configuration. Therefore, the default value, `'value'` is retrieved.

## Details:

- Create a `config-default.yaml` and `config.py` in the top-level folder your app
- Inside `config-default.yaml` add keys and reasonable default values
- Inside `config.py`, create a class that inherits from this Config class
    - See above example
- Add a final line to your `config.py` that instantiates your custom class:
    - Ensure that you provide the default config path
        - If placed in same directory as `config.py` you can use something like:
            ```
            default_cfg_path = os.path.join(
                os.path.dirname(os.path.abspath(__file__)), "config-default.yaml"
            )
            config = FenceConfig(default_cfg_path)
            ```
- Import your instaniated object whenever you need to get configuration
    - Example: `from fence.config import config`
- Load in application configuration during init of your app
    - Example: `config.load('path/to/fence-config.yaml')`
- Now you can safely access anything that was in your `config-default.yaml` from this
  object as if it were a dictionary
    - Example: `storage_creds = config["STORAGE_CREDENTIALS"]`
    - Example: `if config["SOME_BOOLEAN"]: ...`
    - Example: `nested_value = config["TOP_LEVEL"]["nested"]`
- And of course you can import that into any file you want and will have access to
  keys/values
    - Example: `from fence.config import config`
launchdarkly-server-sdk-ai-openai 0.1.0
LaunchDarkly AI SDK OpenAI Provider
License: Apache-2.0
Requires Python: <4,>=3.9

# LaunchDarkly AI SDK OpenAI Provider

[![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai-openai-dev.svg?style=flat-square)](https://pypi.org/project/launchdarkly-server-sdk-ai-openai-dev/)

This package provides an OpenAI integration for the LaunchDarkly AI SDK.

## Installation

```bash
pip install launchdarkly-server-sdk-ai-openai-dev
```

## Quick Start

```python
import asyncio
from ldai import AIClient
from ldai_openai import OpenAIProvider

async def main():
    # Initialize the AI client
    ai_client = AIClient(ld_client)
    
    # Get AI config
    ai_config = ai_client.config(
        "my-ai-config-key",
        context,
        default_value
    )
    
    # Create an OpenAI provider from the config
    provider = await OpenAIProvider.create(ai_config)
    
    # Invoke the model
    response = await provider.invoke_model(ai_config.messages)
    print(response.message.content)

asyncio.run(main())
```

## Features

- Full integration with OpenAI's chat completions API
- Automatic token usage tracking
- Support for structured output (JSON schema)
- Static utility methods for custom integrations

## API Reference

### OpenAIProvider

#### Constructor

```python
OpenAIProvider(client: OpenAI, model_name: str, parameters: Dict[str, Any], logger: Optional[Any] = None)
```

#### Static Methods

- `create(ai_config: AIConfigKind, logger: Optional[Any] = None) -> OpenAIProvider` - Factory method to create a provider from an AI config
- `get_ai_metrics_from_response(response: Any) -> LDAIMetrics` - Extract metrics from an OpenAI response

#### Instance Methods

- `invoke_model(messages: List[LDMessage]) -> ChatResponse` - Invoke the model with messages
- `invoke_structured_model(messages: List[LDMessage], response_structure: Dict[str, Any]) -> StructuredResponse` - Invoke the model with structured output
- `get_client() -> OpenAI` - Get the underlying OpenAI client

## License

Apache-2.0