docs: Infino example fix (#9888)

- Fixed a broken link in the `integrations/providers/infino.mdx`
- Fixed a title in the `integration/collbacks/infino.ipynb` example
- Updated text format in this example.
This commit is contained in:
Leonid Ganeline 2023-08-28 17:42:11 -07:00 committed by GitHub
parent fe1b9ee6b8
commit cf122b6269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 56 deletions

View File

@ -1,86 +1,73 @@
{ {
"cells": [ "cells": [
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "8d10861f-a550-4443-bc63-4ce2ae13b841", "id": "8d10861f-a550-4443-bc63-4ce2ae13b841",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Infino - LangChain LLM Monitoring Example\n", "# Infino\n",
"\n", "\n",
"This example shows how one can track the following while calling OpenAI models via LangChain and [Infino](https://github.com/infinohq/infino):\n", "This example shows how one can track the following while calling OpenAI models via `LangChain` and [Infino](https://github.com/infinohq/infino):\n",
"\n", "\n",
"* prompt input,\n", "* prompt input,\n",
"* response from chatgpt or any other LangChain model,\n", "* response from `ChatGPT` or any other `LangChain` model,\n",
"* latency,\n", "* latency,\n",
"* errors,\n", "* errors,\n",
"* number of tokens consumed" "* number of tokens consumed"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": 9, "id": "64d14c88-b71c-4524-ab1b-4250a7dbb62b",
"id": "3a5a0976-9953-41d8-880c-eb3f2992e936",
"metadata": {}, "metadata": {},
"outputs": [ "source": [
{ "## Initializing"
"name": "stdout", ]
"output_type": "stream", },
"text": [ {
"Requirement already satisfied: matplotlib in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (3.7.1)\n", "cell_type": "code",
"Requirement already satisfied: contourpy>=1.0.1 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (1.0.7)\n", "execution_count": null,
"Requirement already satisfied: cycler>=0.10 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (0.11.0)\n", "id": "ed46c894-caa6-49b2-85d1-f275374fa308",
"Requirement already satisfied: fonttools>=4.22.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (4.39.4)\n", "metadata": {},
"Requirement already satisfied: kiwisolver>=1.0.1 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (1.4.4)\n", "outputs": [],
"Requirement already satisfied: numpy>=1.20 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (1.24.3)\n",
"Requirement already satisfied: packaging>=20.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (23.1)\n",
"Requirement already satisfied: pillow>=6.2.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (9.5.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (3.0.9)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from matplotlib) (2.8.2)\n",
"Requirement already satisfied: six>=1.5 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n",
"Requirement already satisfied: infinopy in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (0.0.1)\n",
"Requirement already satisfied: docker in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from infinopy) (6.1.3)\n",
"Requirement already satisfied: requests in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from infinopy) (2.31.0)\n",
"Requirement already satisfied: packaging>=14.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from docker->infinopy) (23.1)\n",
"Requirement already satisfied: urllib3>=1.26.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from docker->infinopy) (2.0.2)\n",
"Requirement already satisfied: websocket-client>=0.32.0 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from docker->infinopy) (1.5.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from requests->infinopy) (3.1.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from requests->infinopy) (3.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/vinaykakade/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from requests->infinopy) (2023.5.7)\n"
]
}
],
"source": [ "source": [
"# Install necessary dependencies.\n", "# Install necessary dependencies.\n",
"!pip install infinopy\n", "!pip install infinopy\n",
"!pip install matplotlib\n", "!pip install matplotlib"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3a5a0976-9953-41d8-880c-eb3f2992e936",
"metadata": {},
"outputs": [],
"source": [
"# Remove the (1) import sys and sys.path.append(..) and (2) uncomment `!pip install langchain` after merging the PR for Infino/LangChain integration.\n", "# Remove the (1) import sys and sys.path.append(..) and (2) uncomment `!pip install langchain` after merging the PR for Infino/LangChain integration.\n",
"import sys\n", "import sys\n",
"\n", "\n",
"sys.path.append(\"../../../../../langchain\")\n", "sys.path.append(\"../../../../../langchain\")\n",
"#!pip install langchain\n",
"\n", "\n",
"\n", "\n",
"import datetime as dt\n", "import datetime as dt\n",
"from infinopy import InfinoClient\n",
"import json\n", "import json\n",
"from langchain.llms import OpenAI\n", "from langchain.llms import OpenAI\n",
"from langchain.callbacks import InfinoCallbackHandler\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import matplotlib.dates as md\n", "import matplotlib.dates as md\n",
"import os\n", "import os\n",
"import time\n", "import time\n",
"import sys" "import sys\n",
"\n",
"from infinopy import InfinoClient\n",
"from langchain.callbacks import InfinoCallbackHandler"
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "9f90210d-c805-4a0c-81e4-d5298942afc4", "id": "9f90210d-c805-4a0c-81e4-d5298942afc4",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Start Infino server, initialize the Infino client\n" "## Start Infino server, initialize the Infino client"
] ]
}, },
{ {
@ -106,7 +93,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "b6b81cda-b841-43ee-8c5e-b1576555765f", "id": "b6b81cda-b841-43ee-8c5e-b1576555765f",
"metadata": {}, "metadata": {},
@ -148,7 +134,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "dce1b820-3f1a-4b94-b848-4c6032cadc18", "id": "dce1b820-3f1a-4b94-b848-4c6032cadc18",
"metadata": {}, "metadata": {},
@ -214,7 +199,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "b68ec697-c922-4fd9-aad1-f49c6ac24e8a", "id": "b68ec697-c922-4fd9-aad1-f49c6ac24e8a",
"metadata": {}, "metadata": {},
@ -326,7 +310,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "c3d61822-1781-4bc6-97a2-2abc5c2b2e75", "id": "c3d61822-1781-4bc6-97a2-2abc5c2b2e75",
"metadata": {}, "metadata": {},
@ -364,12 +347,11 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "4b171074-c775-48e0-a4b3-f550e2c8eccb", "id": "4b171074-c775-48e0-a4b3-f550e2c8eccb",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Step 5: Stop infino server" "## Stop infino server"
] ]
}, },
{ {
@ -415,7 +397,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.9.4" "version": "3.10.12"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -2,10 +2,10 @@
>[Infino](https://github.com/infinohq/infino) is an open-source observability platform that stores both metrics and application logs together. >[Infino](https://github.com/infinohq/infino) is an open-source observability platform that stores both metrics and application logs together.
Key features of infino include: Key features of `Infino` include:
- Metrics Tracking: Capture time taken by LLM model to handle request, errors, number of tokens, and costing indication for the particular LLM. - **Metrics Tracking**: Capture time taken by LLM model to handle request, errors, number of tokens, and costing indication for the particular LLM.
- Data Tracking: Log and store prompt, request, and response data for each LangChain interaction. - **Data Tracking**: Log and store prompt, request, and response data for each LangChain interaction.
- Graph Visualization: Generate basic graphs over time, depicting metrics such as request duration, error occurrences, token count, and cost. - **Graph Visualization**: Generate basic graphs over time, depicting metrics such as request duration, error occurrences, token count, and cost.
## Installation and Setup ## Installation and Setup
@ -15,7 +15,7 @@ First, you'll need to install the `infinopy` Python package as follows:
pip install infinopy pip install infinopy
``` ```
If you already have an Infino Server running, then you're good to go; but if If you already have an `Infino Server` running, then you're good to go; but if
you don't, follow the next steps to start it: you don't, follow the next steps to start it:
- Make sure you have Docker installed - Make sure you have Docker installed
@ -28,7 +28,7 @@ you don't, follow the next steps to start it:
## Using Infino ## Using Infino
See a [usage example of `InfinoCallbackHandler`](/docs/modules/callbacks/integrations/infino.html). See a [usage example of `InfinoCallbackHandler`](/docs/integrations/callbacks/infino.html).
```python ```python
from langchain.callbacks import InfinoCallbackHandler from langchain.callbacks import InfinoCallbackHandler