semvec/pypi-packages huggingface dataset:
openai-async 0.0.3
A light-weight, asynchronous client for OpenAI API - text completion, image generation and embeddings.
License: MIT

# openai-async

A light-weight, asynchronous client for OpenAI API - chat completion, text completion, image generation and embeddings.<br><br>
For the full documentation, go to the [openAI website](https://beta.openai.com/docs/api-reference).


# Installation

`pip install openai-async`

# Use

## Chat completion
    response = await openai_async.chat_complete(
        _OPEN_AI_API_KEY,
        timeout=2,
        payload={
            "model": "gpt-3.5-turbo",
            "messages": [{"role": "user", "content": "Hello!"}],
        },
    )
    print(response.json()["choices"][0]["message"])
    >>> {"role": "assistant", "content": "\n\nHello there! How can I assist you today?"}
Visit the [official documentation](https://platform.openai.com/docs/api-reference/chat) for more info.
## Text completion
    import openai_async

    response = await openai_async.complete(
        "<API KEY>",
        timeout=2,
        payload={
            "model": "text-davinci-003",
            "prompt": "Correct this sentence: Me like you.",
            "temperature": 0.7,
        },
    )
    print(response.json()["choices"][0]["text"].strip())
    >>> "I like you."
Visit the [official documentation](https://platform.openai.com/docs/api-reference/completions) for more info.
## Image generation
    import openai_async
    import urllib.request
    from PIL import Image

    response = await openai_async.generate_img(
        "<API KEY>",
        timeout=8,
        payload={
            "prompt": "a white siamese cat",
            "n": 1,
            "size": "512x512"
        },
    )
    urllib.request.urlretrieve(response.json()["data"][0]["url"], "img.png")
    Image.open("img.png").show()

<img alt="a cat" src="https://cdn.openai.com/API/images/guides/image_generation_simple.webp" width="60%">
<br>

## Embeddings
    import openai_async

    response = await openai_async.embeddings(
        <API_KEY>,
        timeout=2,
        payload={"model": "text-embedding-ada-002", "input": "a cat"},
    )
    print(response.json()["data"][0]["embedding"])
    >>> [-0.019408401,
    -0.009246278,
    -0.014390069,
    -0.012294915,
    -0.0025609178,
    0.021252638,
    ...]

Visit the [official documentation](https://beta.openai.com/docs/api-reference/embeddings) for more info.

# Get an API key
To generate an openAI API key, while in the [openAI website](https://beta.openai.com), click on your username in the top right corner, then go to "View API keys" and create a key.
<br><br>

### Disclaimer

This repository has no connection whatsoever to openAI.
django-universal-uploader-widget 0.2.4
Simple Universal Uploader Widget for Django-Admin
License: MIT
Keywords: django,admin,widget,universal,uploader

# django-universal-uploader-widget

A beautiful image uploader widget for django/django-admin.

![Beautiful image uploader widget](https://raw.githubusercontent.com/inventare/django-universal-uploader-widget/main/docs/static/img/beautiful.gif)

![Multiple behaviours](https://raw.githubusercontent.com/inventare/django-universal-uploader-widget/main/docs/static/img/click.gif)

![Multiple files handling](https://raw.githubusercontent.com/inventare/django-universal-uploader-widget/main/docs/static/img/inline_multiple.gif)

## Documentation

To understand this package and how to use it you can access the package [documentation](https://uuw.institutoinventare.com.br/).

## Installing

Install via pip package manager:

```bash
pip install django-universal-uploader-widget
```

Add to installed apps, in `settings.py`:

```python
INSTALLED_APPS = [
    'my_app.apps.MyAppConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.forms',
    'universal_uploader_widget',
]
```

##  Usage

```python
# forms.py
from django import forms
from universal_uploader_widget.widgets import ImageUploaderWidget

class ExampleForm(forms.ModelForm):
    class Meta:
        widgets = {
            'image': ImageUploaderWidget(),
        }
        fields = '__all__'
```
tonic-reporting 1.5.0
Tools for evaluating fidelity and privacy of synthetic data
License: MIT
Requires Python: >=3.8
Keywords: tonic.ai,tonic

# Overview
This library contains tools for evaluating fidelity and privacy of synthetic data.

## Usage

Import the desired modules from the library:

```
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from tonic_reporting import univariate, multivariate, privacy
```

**Preface**

*Numeric* columns refer to columns *encoded* as numeric. Numerical data types in the schema underlying a model may be encoded as other types.

*Categorical* columns refer to columns *encoded* as categorical.

*source_df* is a Pandas DataFrame of original data from the source database

*synth_df* is a Pandas DataFrame of sampled data from trained models

The source and synthetic DataFrames should be equal in row count and schema.

**Numeric Column Statistics**

`univariate.summarize_numeric(source_df, synth_df, numeric_cols)`

**Categorical Column Statistics**

`univariate.summarize_categorical(source_df, synth_df, categorical_cols)`

**Numeric Column Comparative Histograms**

```
fig, axarr = plt.subplots(1, len(numeric_cols), figsize = (9,12))
axarr = axarr.ravel()

for col, ax in zip(numeric_cols, axarr):
    univariate.plot_histogram(source_df, synth_df, col,ax)
```

**Categorical Column Comparative Frequency Tables**

```
for col in categorical_cols:
    univariate.plot_frequency_table(source_df, synth_df, col, ax)
```

**Numeric Column Aggregates Over Time**

If the data represents time series, we can visualize means and confidence intervals of numeric features
over time:

```
for col in numeric_cols:
    fig, ax = plt.subplots(figsize=(10, 8))
    univariate.plot_events_means(source_df, synth_df, col, order_col, ax=ax)
```

and

```
for col in numeric_cols:
    fig, ax = plt.subplots(figsize=(12, 10))
    univariate.plot_events_confidence_intervals(source_df, synth_df, col, order_col, ax=ax)
```
where `order_col` denotes the time/order column.

**Numeric Column Multivariate Correlations Table**

`multivariate.summarize_correlations(source_df, synth_df, numeric_cols)`

**Numeric Column Multivariate Correlations Heat Map**

```
fig, axarr = plt.subplots(1, 2, figsize=(13, 8))
multivariate.plot_correlations(source_df, synth_df, numeric_cols, axarr=axarr, )
fig.tight_layout()
```

**Distance to Closest Record Comparison**

```
syn_dcr, real_dcr = privacy.compute_dcr(source_df, synth_df, numeric_cols, categorical_cols)

fig, ax = plt.subplots(1,1,figsize=(8,6))
ax.hist(real_dcr,bins=300,label = 'Real vs. real', color='mediumpurple');
ax.hist(syn_dcr,bins=300,label='Synthetic vs. real', color='mediumturquoise');
ax.tick_params(axis='both', which='major', labelsize=14)
ax.set_title('Distances to closest record',fontsize=22)
ax.legend(fontsize=16);
```