mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
05df480376
This PR updates the usage instructions for PromptLayerOpenAI in Langchain's documentation. The updated instructions provide more detail and conform better to the style of other LLM integration documentation pages. No code changes were made in this PR, only improvements to the documentation. This update will make it easier for users to understand how to use `PromptLayerOpenAI`
155 lines
3.5 KiB
Plaintext
155 lines
3.5 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "959300d4",
|
|
"metadata": {},
|
|
"source": [
|
|
"# PromptLayer OpenAI\n",
|
|
"\n",
|
|
"This example showcases how to connect to [PromptLayer](https://www.promptlayer.com) to start recording your OpenAI requests."
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "6a45943e",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Install PromptLayer\n",
|
|
"The `promptlayer` package is required to use PromptLayer with OpenAI. Install `promptlayer` using pip."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "dbe09bd8",
|
|
"metadata": {
|
|
"vscode": {
|
|
"languageId": "powershell"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"pip install promptlayer"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "536c1dfa",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Imports"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c16da3b5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"from langchain.llms import PromptLayerOpenAI\n",
|
|
"import promptlayer"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "8564ce7d",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Set the Environment API Key\n",
|
|
"You can create a PromptLayer API Key at [wwww.promptlayer.com](https://ww.promptlayer.com) by clicking the settings cog in the navbar.\n",
|
|
"\n",
|
|
"Set it as an environment variable called `PROMPTLAYER_API_KEY`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "46ba25dc",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"os.environ[\"PROMPTLAYER_API_KEY\"] = \"********\""
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "bf0294de",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Use the PromptLayerOpenAI LLM like normal\n",
|
|
"*You can optionally pass in `pl_tags` to track your requests with PromptLayer's tagging feature.*"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "3acf0069",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"' to go outside\\n\\nUnfortunately, cats cannot go outside without being supervised by a human. Going outside can be dangerous for cats, as they may come into contact with cars, other animals, or other dangers. If you want to go outside, ask your human to take you on a supervised walk or to a safe, enclosed outdoor space.'"
|
|
]
|
|
},
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"llm = PromptLayerOpenAI(pl_tags=[\"langchain\"])\n",
|
|
"llm(\"I am a cat and I want\")"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "a2d76826",
|
|
"metadata": {},
|
|
"source": [
|
|
"**The above request should now appear on your [PromptLayer dashboard](https://ww.promptlayer.com).**"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "05e9e2fe",
|
|
"metadata": {},
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "base",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.8.8 (default, Apr 13 2021, 12:59:45) \n[Clang 10.0.0 ]"
|
|
},
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "c4fe2cd85a8d9e8baaec5340ce66faff1c77581a9f43e6c45e85e09b6fced008"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|