Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MagnivOrg/prompt-layer-library
π° PromptLayer - Maintain a log of your prompts and OpenAI API requests. Track, debug, and replay old completions.
https://github.com/MagnivOrg/prompt-layer-library
gpt machine-learning openai prompt prompt-engineering python
Last synced: 5 days ago
JSON representation
π° PromptLayer - Maintain a log of your prompts and OpenAI API requests. Track, debug, and replay old completions.
- Host: GitHub
- URL: https://github.com/MagnivOrg/prompt-layer-library
- Owner: MagnivOrg
- License: apache-2.0
- Created: 2022-12-23T21:18:26.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T12:31:49.000Z (11 days ago)
- Last Synced: 2024-10-31T13:33:13.090Z (11 days ago)
- Topics: gpt, machine-learning, openai, prompt, prompt-engineering, python
- Language: Python
- Homepage: https://www.promptlayer.com
- Size: 492 KB
- Stars: 513
- Watchers: 5
- Forks: 47
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π° PromptLayer
**The first platform built for prompt engineers**
---
[PromptLayer](https://promptlayer.com/) 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
```bash
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](https://promptlayer.com/). Once logged in, click the button to create an API key and save this in a secure location ([Guide to Using Env Vars](https://towardsdatascience.com/the-quick-guide-to-using-environment-variables-in-python-d4ec9291619e)).
Once you have that all set up, [install PromptLayer using](https://pypi.org/project/promptlayer/) `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.
```python
from promptlayer import PromptLayerpromptlayer = PromptLayer(api_key="")
openai = promptlayer.openai
```**You can then use `openai` as you would if you had imported it directly.**
π‘ Your OpenAI API Key is **never** sent to our servers. All OpenAI requests are made locally from your machine, PromptLayer just logs the request.
### 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!*
```python
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:
```jsx
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_",
},
)
```## 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 [[email protected]](mailto:[email protected]).