Skip to main content

No project description provided

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-0.1.24.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

vendi-0.1.24-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file vendi-0.1.24.tar.gz.

File metadata

  • Download URL: vendi-0.1.24.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for vendi-0.1.24.tar.gz
Algorithm Hash digest
SHA256 93a3e89b0b7a151ac7aff97af12cf61ed1865cda90a8383acf95bb3fbfe0f9ab
MD5 71602af631245f0058a9c58dbdd6210e
BLAKE2b-256 18e5ad983aee82f94233a562a2bddba46ffeab51f03098a0d25455bfb22af842

See more details on using hashes here.

File details

Details for the file vendi-0.1.24-py3-none-any.whl.

File metadata

  • Download URL: vendi-0.1.24-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for vendi-0.1.24-py3-none-any.whl
Algorithm Hash digest
SHA256 3c754d28875a9e0719517e5f20ff703e2bbe704342ce114f38ea755a10ed355e
MD5 ab9ef9c8b4190adc853741cebb8566dd
BLAKE2b-256 750934856057c1ab5e740a258f3d989d7fe34bb77aa7eb26482ff3b1e559ce78

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