diff --git a/docs/modules/llms/integrations/promptlayer_openai.ipynb b/docs/modules/llms/integrations/promptlayer_openai.ipynb index b18b9ebd..a50d6670 100644 --- a/docs/modules/llms/integrations/promptlayer_openai.ipynb +++ b/docs/modules/llms/integrations/promptlayer_openai.ipynb @@ -11,6 +11,82 @@ "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, @@ -29,26 +105,23 @@ } ], "source": [ - "from langchain.llms import PromptLayerOpenAI\n", - "import promptlayer\n", - "import os\n", - "\n", - "# Set up API keys, you can get a promptlayer api key here: https://promptlayer.com/\n", - "os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPENAI_API_KEY\"\n", - "promptlayer.api_key = \"YOUR_PROMPTLAYER_API_KEY\"\n", - "\n", - "# Optionally pass in pl_tags to track your requests\n", "llm = PromptLayerOpenAI(pl_tags=[\"langchain\"])\n", - "\n", "llm(\"I am a cat and I want\")" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "ae4559c7", + "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": {}, - "outputs": [], "source": [] } ], @@ -68,7 +141,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.8" + "version": "3.8.8 (default, Apr 13 2021, 12:59:45) \n[Clang 10.0.0 ]" }, "vscode": { "interpreter": {