⛔ [DEPRECATED] Active at https://github.com/vellum-ai/vellum-client-python
Vellum Python Library
The Vellum python library provides convenient access to the Vellum Predict API from python applications.
Installation
$ pip install vellum-client
Usage
Setup
You'll need an API key from your Vellum account to use this library. You can create an API key from within your account here. We recommend setting it as an environment variable.
Generating Text
Here's an example of initializing the library with the API key loaded from an environment variable and initiating a generation:
import vellum
vellum.api_key = "<YOUR_API_KEY>"
result = vellum.Generate.run(
deployment_name="my-deployment",
requests=[
vellum.GenerateRequest(
input_values={"question": "Can I get a refund?"}
)
]
)
print(result.text)
Submitting Actuals
Submitting actuals is how you provide feedback to Vellum about the quality of the generated text. This feedback can be used to measure model quality and improve it over time.
import vellum
vellum.api_key = "<YOUR_API_KEY>"
vellum.SubmitCompletionActuals.run(
deployment_name="customer-service-demo",
actuals=[
vellum.CompletionActual(
id="<id-returned-from-generate-endpoint>",
quality=1.0, # 1.0 is good, 0.0 is bad
text="Sorry, we do not offer refunds.",
)
]
)
Note: If you don't want to keep track of the ids that Vellum generates, you can include an externalId key in the initial generate request. You can then include this externalId when submitting actuals. If you use this approach, be sure that the ids you provide truly are unique, or you may get unexpected results.
Uploading Documents to Search Across
Documents can be uploaded to Vellum via either the UI or this API. Once uploaded and indexed, Vellum's Search allows you to perform semantic searches against them. Here is an example of how to upload a document from a local file:
import vellum
vellum.api_key = "<YOUR_API_KEY>"
with open("/path/to/your/file.txt", "rb") as file:
result = vellum.UploadDocument.run(
# File to upload
contents=file,
# Document label
label="Human-friendly label for your document",
# The names of indexes that you'd like this document to be added to.
add_to_index_names=["<your-index-name>"],
# Optionally include a unique ID from your system to this document later.
# Useful if you want to perform updates later
external_id="<your-index-name>",
# Optionally include keywords to associate with the document that can be used in hybrid search
keywords=[],
)
print(result)
Performing a Search
Vellum's Search allows you to upload documents and then perform semantic searches against them. Here is an example of how to perform a search:
import vellum
vellum.api_key = "<YOUR_API_KEY>"
result = vellum.Search.run(
index_name="help-center-docs",
query="What is fine tuning?",
options=vellum.SearchOptions(limit=3),
)
print(result)
Metadata
Release files for vellum-client 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vellum-client-0.0.13.tar.gz | 8.1 kB | Without provenance | Details for vellum-client-0.0.13.tar.gz |
Release files / vellum-client-0.0.13.tar.gz
| Download URL | vellum-client-0.0.13.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8620e3de9414960490bcd430a3ef463c9fd90a0b9c31794e01261076090123fa
|
|
BLAKE2b-256 checksum How to use checksums |
66519542331e1e3898528ba8af50820dd8e4f87ab9ab20c2a1e8c518b50b98c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.7.9
|
Security for vellum-client 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.