PromptLayer is a platform for prompt engineering and tracks your LLM requests.
Project description
🍰 PromptLayer
The first platform built for prompt engineers
PromptLayer is the first platform that allows you to track, manage, and share your GPT prompt engineering. PromptLayer acts a middleware between your code and OpenAI’s python library.
PromptLayer records all your OpenAI API requests, allowing you to search and explore request history in the PromptLayer dashboard.
This repo contains the Python wrapper library for PromptLayer.
Quickstart ⚡
Install PromptLayer
pip install promptlayer
Installing PromptLayer Locally
Use pip install .
to install locally.
Using PromptLayer
To get started, create an account by clicking “Log in” on PromptLayer. Once logged in, click the button to create an API key and save this in a secure location (Guide to Using Env Vars).
Once you have that all set up, install PromptLayer using pip
.
In the Python file where you use OpenAI APIs, add the following. This allows us to keep track of your requests without needing any other code changes.
from promptlayer import PromptLayer
promptlayer = PromptLayer(api_key="<YOUR PromptLayer API KEY pl_xxxxxx>")
openai = promptlayer.openai
You can then use openai
as you would if you had imported it directly.
Adding PromptLayer tags: pl_tags
PromptLayer allows you to add tags through the pl_tags
argument. This allows you to track and group requests in the dashboard.
Tags are not required but we recommend them!
openai.Completion.create(
engine="text-ada-001",
prompt="My name is",
pl_tags=["name-guessing", "pipeline-2"]
)
After making your first few requests, you should be able to see them in the PromptLayer dashboard!
Using the REST API
This Python library is a wrapper over PromptLayer's REST API. If you use another language, like Javascript, just interact directly with the API.
Here is an example request below:
import requests
request_response = requests.post(
"https://api.promptlayer.com/track-request",
json={
"function_name": "openai.Completion.create",
"args": [],
"kwargs": {"engine": "text-ada-001", "prompt": "My name is"},
"tags": ["hello", "world"],
"request_response": {"id": "cmpl-6TEeJCRVlqQSQqhD8CYKd1HdCcFxM", "object": "text_completion", "created": 1672425843, "model": "text-ada-001", "choices": [{"text": " advocacy\"\n\nMy name is advocacy.", "index": 0, "logprobs": None, "finish_reason": "stop"}]},
"request_start_time": 1673987077.463504,
"request_end_time": 1673987077.463504,
"api_key": "pl_<YOUR API KEY>",
},
)
Contributing
We welcome contributions to our open source project, including new features, infrastructure improvements, and better documentation. For more information or any questions, contact us at hello@promptlayer.com.
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
Built Distribution
File details
Details for the file promptlayer-1.0.29.tar.gz
.
File metadata
- Download URL: promptlayer-1.0.29.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c30ee3c9adf81c82b24d8fb7722729af2278268badd7c90a20f905c12c034e3e |
|
MD5 | b361b1e4155b2a3257957efd3a5f728f |
|
BLAKE2b-256 | 39b30f0b29e76c3ea4e8b47f89aede9260c31fb00eff36e098faf020fa2736d5 |
File details
Details for the file promptlayer-1.0.29-py3-none-any.whl
.
File metadata
- Download URL: promptlayer-1.0.29-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e9d96e3fd6b0b5d496dcfb896eea9f662ebb77721c32c97a104a59419821fc1 |
|
MD5 | 4b717d15336c0e9360756b25367199fe |
|
BLAKE2b-256 | d49cd7bace1a5571558a26dc3a29a3f825801bb7b9c1d996205e3d738ea774de |