mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
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:
parent
fe1b9ee6b8
commit
cf122b6269
@ -1,86 +1,73 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "8d10861f-a550-4443-bc63-4ce2ae13b841",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Infino - LangChain LLM Monitoring Example\n",
|
||||
"# Infino\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",
|
||||
"* prompt input,\n",
|
||||
"* response from chatgpt or any other LangChain model,\n",
|
||||
"* response from `ChatGPT` or any other `LangChain` model,\n",
|
||||
"* latency,\n",
|
||||
"* errors,\n",
|
||||
"* number of tokens consumed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "3a5a0976-9953-41d8-880c-eb3f2992e936",
|
||||
"cell_type": "markdown",
|
||||
"id": "64d14c88-b71c-4524-ab1b-4250a7dbb62b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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": [
|
||||
"## Initializing"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ed46c894-caa6-49b2-85d1-f275374fa308",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Install necessary dependencies.\n",
|
||||
"!pip install infinopy\n",
|
||||
"!pip install matplotlib\n",
|
||||
"\n",
|
||||
"!pip install matplotlib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"import sys\n",
|
||||
"\n",
|
||||
"sys.path.append(\"../../../../../langchain\")\n",
|
||||
"#!pip install langchain\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"import datetime as dt\n",
|
||||
"from infinopy import InfinoClient\n",
|
||||
"import json\n",
|
||||
"from langchain.llms import OpenAI\n",
|
||||
"from langchain.callbacks import InfinoCallbackHandler\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import matplotlib.dates as md\n",
|
||||
"import os\n",
|
||||
"import time\n",
|
||||
"import sys"
|
||||
"import sys\n",
|
||||
"\n",
|
||||
"from infinopy import InfinoClient\n",
|
||||
"from langchain.callbacks import InfinoCallbackHandler"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "9f90210d-c805-4a0c-81e4-d5298942afc4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Start Infino server, initialize the Infino client\n"
|
||||
"## Start Infino server, initialize the Infino client"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -106,7 +93,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "b6b81cda-b841-43ee-8c5e-b1576555765f",
|
||||
"metadata": {},
|
||||
@ -148,7 +134,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "dce1b820-3f1a-4b94-b848-4c6032cadc18",
|
||||
"metadata": {},
|
||||
@ -214,7 +199,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "b68ec697-c922-4fd9-aad1-f49c6ac24e8a",
|
||||
"metadata": {},
|
||||
@ -326,7 +310,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "c3d61822-1781-4bc6-97a2-2abc5c2b2e75",
|
||||
"metadata": {},
|
||||
@ -364,12 +347,11 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "4b171074-c775-48e0-a4b3-f550e2c8eccb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Step 5: Stop infino server"
|
||||
"## Stop infino server"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -415,7 +397,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.4"
|
||||
"version": "3.10.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
>[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:
|
||||
- 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.
|
||||
- Graph Visualization: Generate basic graphs over time, depicting metrics such as request duration, error occurrences, token count, and cost.
|
||||
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.
|
||||
- **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.
|
||||
|
||||
## Installation and Setup
|
||||
|
||||
@ -15,7 +15,7 @@ First, you'll need to install the `infinopy` Python package as follows:
|
||||
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:
|
||||
|
||||
- Make sure you have Docker installed
|
||||
@ -28,7 +28,7 @@ you don't, follow the next steps to start it:
|
||||
|
||||
## 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
|
||||
from langchain.callbacks import InfinoCallbackHandler
|
||||
|
Loading…
Reference in New Issue
Block a user