Skip to main content

Vendi SDK

Project description

Tests Pypi version Pypi downloads


Documentation 📖: https://docs.vendi-ai.com

Source Code 💻 : https://github.com/vendi-ai/vendi-python


Vendi Python API Library

The Vendi python library provides convenient access to the Vendi REST API from any Python 3.7+ application. The library includes all access to the Vendi API, including the ability to create, update, and delete resources.

Installation

Install the latest version of the library with pip:

pip install vendi

Usage

The library needs to be configured with your account's API key which is available in the Vendi web interface.

from vendi import Vendi

client = Vendi(api_key="YOUR_API_KEY") 

Or you can set the VENDI_API_KEY environment variable and the library will automatically use it:

export VENDI_API_KEY="YOUR_API_KEY"

Inference

The library provides a convenient way to make inference requests to your models.

from vendi import Vendi

client = Vendi(api_key="YOUR_API_KEY")

chat_completion = client.completions.create(
    model_id="vendi/mistral-7b-instruct-v2",
    messages=[
        {
            "role": "user",
            "content": "Hello, I'm looking for a new job. Write me a resume."
        }
    ],
    max_tokens=5,
    temperature=0.5,
    top_p=1,
    frequency_penalty=0.5,
    presence_penalty=0.5,
    stop=["\n"]
)

print(chat_completion.provider_response.choices[0].text)

The inference endpoints are OpenAI compatible, so you can use the same parameters as the OpenAI API or even the OpenAI Python library.

Datasets

The library provides a convenient way to upload and download datasets from your account.

from vendi import Vendi

client = Vendi(api_key="YOUR_API_KEY")

dataset = client.datasets.upload(
    name="My Dataset",
    data=[
        {
            "input": "The bill is $5.",
            "output": "5$"
        },
        {
            "name": "They gave us a nice $10 bill.",
            "output": "10$"
        }
    ]
)

You can also download datasets from your account.

from vendi import Vendi

client = Vendi(api_key="YOUR_API_KEY")

dataset = client.datasets.get("YOUR_DATASET_ID")

data = dataset.load_data()

Finetune

The library provides a convenient way to finetune models from your account.

from vendi import Vendi

client = Vendi(
    api_key="my-api-key"
)

dataset = client.datasets.upload(
    name="my-dataset",
    data_path="conversation.jsonl"
)

finetune_job = client.finetune.run(
    run_name="my-first-finetune",
    model_description="My first finetune",
    model_name="vendi/mistralai/Mistral-7B-Instruct-v0.2",
    dataset_id=dataset.id
)

print(finetune_job)

The example above will create a finetune job that will run on the Vendi platform. You can monitor the progress of the finetune job in the Vendi web interface.

To finetune other models rather than mistralai, you can use the client.finetune.available_models() method.

Models

The models are the finetuned models created out of the finetune jobs. You can list all the models in your account with the client.models.list() method.

from vendi import Vendi

client = Vendi(
    api_key="my-api-key"
)

client.models.list()

Inference on finetuned model

Every finetuned model can be used for inference. You can use the client.completions.create() method to make inference requests to your models just like any other pre-trained models.

from vendi import Vendi

client = Vendi(
    api_key="my-api-key"
)

client.completions.create(
    model_id="<account-name>/<finetuned-model-name>",
    messages=[
        {
            "role": "user",
            "content": "Hello, I'm looking for a new job. Write me a resume."
        }
    ],
    max_tokens=256,
    temperature=0.5,
    top_p=1,
    frequency_penalty=0.5,
    presence_penalty=0.5,
    stop=["\n"]
)

📚 For a thorough introduction, features, and best practices, explore our official documentation and quickstart.

Contributing 💼

Join our mission to make declarative AI even better together! We welcome contributions from everyone. Please read our contributing guide to get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vendi_sdk-0.2.3.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

vendi_sdk-0.2.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file vendi_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: vendi_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for vendi_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 29e380546172bc8583661a6f9019155162105f6c4e07d49b87f69c9fbda46130
MD5 2054298fb60d0400ac1f6004d1270326
BLAKE2b-256 883507f134e78b1664bea6e30d80d4fe4f6f2587561c9b707ef8590f9cb3a90d

See more details on using hashes here.

File details

Details for the file vendi_sdk-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: vendi_sdk-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for vendi_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0543c740dfa250fc80d9e413d5ca0910defb50b3629a27bf0f752da2030cfd71
MD5 537ddb9b1d7ff9631a9173c333ab4aee
BLAKE2b-256 509972434537689ee507c7860582ec44595b8388092de20ccf95a3d9ef7f86d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page