Skip to main content

No project description provided

Project description

Vellum Python Library

pypi license badge fern shield

The Vellum Python SDK provides access to the Vellum API from python.

API Docs

You can find Vellum's complete API docs at docs.vellum.ai.

Installation

pip install --upgrade vellum-ai

Usage

Below is how you would invoke a deployed Prompt from the Vellum API. For a complete list of all APIs that Vellum supports, check out our API Reference.

from vellum import (
    StringInputRequest,
)
from vellum.client import Vellum

client = Vellum(
    api_key="YOUR_API_KEY",
)

def execute() -> str:
    result = client.execute_prompt(
        prompt_deployment_name="<example-deployment-name>>",
        release_tag="LATEST",
        inputs=[
            StringInputRequest(
                name="input_a",
                type="STRING",
                value="Hello, world!",
            )
        ],
    )
    
    if result.state == "REJECTED":
        raise Exception(result.error.message)

    return result.outputs[0].value

if __name__ == "__main__":
    print(execute())

[!TIP] You can set a system environment variable VELLUM_API_KEY to avoid writing your api key within your code. To do so, add export VELLUM_API_KEY=<your-api-token> to your ~/.zshrc or ~/.bashrc, open a new terminal, and then any code calling vellum.Vellum() will read this key.

Async Client

This SDK has an async version. Here's how to use it:

import asyncio

import vellum
from vellum.client import AsyncVellum

client = AsyncVellum(api_key="YOUR_API_KEY")

async def execute() -> str:
    result = await client.execute_prompt(
        prompt_deployment_name="<example-deployment-name>>",
        release_tag="LATEST",
        inputs=[
            vellum.StringInputRequest(
                name="input_a",
                value="Hello, world!",
            )
        ],
    )

    if result.state == "REJECTED":
        raise Exception(result.error.message)
    
    return result.outputs[0].value

if __name__ == "__main__":
    print(asyncio.run(execute()))

Contributing

While we value open-source contributions to this SDK, most of this library is generated programmatically.

Please feel free to make contributions to any of the directories or files below:

examples/*
src/vellum/lib/*
tests/*
README.md

Any additions made to files beyond those directories and files above would have to be moved over to our generation code (found in the separate vellum-client-generator repo), otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

vellum_ai-0.8.14.tar.gz (141.1 kB view details)

Uploaded Source

Built Distribution

vellum_ai-0.8.14-py3-none-any.whl (375.3 kB view details)

Uploaded Python 3

File details

Details for the file vellum_ai-0.8.14.tar.gz.

File metadata

  • Download URL: vellum_ai-0.8.14.tar.gz
  • Upload date:
  • Size: 141.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1071-azure

File hashes

Hashes for vellum_ai-0.8.14.tar.gz
Algorithm Hash digest
SHA256 d946ff7dc3017f2371ece9c0c7566eaa377d34c50f21a0c0615ab3b3ce40f94d
MD5 5bae59e045186eeb0a32cb9711f40d6c
BLAKE2b-256 bc18dc73edaab1c2011c0efe0ed39c9461d690bdd4505dc82dda3749f8db2acd

See more details on using hashes here.

Provenance

File details

Details for the file vellum_ai-0.8.14-py3-none-any.whl.

File metadata

  • Download URL: vellum_ai-0.8.14-py3-none-any.whl
  • Upload date:
  • Size: 375.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1071-azure

File hashes

Hashes for vellum_ai-0.8.14-py3-none-any.whl
Algorithm Hash digest
SHA256 3583a2389513ab6d22a3ef08da5b8ea3af9400d56154a4c23d7621eaead15aa2
MD5 591220f4fa6e6e13e07286bb24e084d5
BLAKE2b-256 c0742af81230d23d8e8012c8b8c7157065ae80cfe36f64619d4647e46a71abe4

See more details on using hashes here.

Provenance

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