|
15 | 15 | }, |
16 | 16 | { |
17 | 17 | "cell_type": "code", |
18 | | - "execution_count": null, |
| 18 | + "execution_count": 1, |
19 | 19 | "id": "020c8f6a", |
20 | 20 | "metadata": {}, |
21 | | - "outputs": [], |
| 21 | + "outputs": [ |
| 22 | + { |
| 23 | + "name": "stdout", |
| 24 | + "output_type": "stream", |
| 25 | + "text": [ |
| 26 | + "Requirement already satisfied: openlayer in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (0.1.0a19)\n", |
| 27 | + "Requirement already satisfied: urllib3>=1.26.14 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (1.26.18)\n", |
| 28 | + "Requirement already satisfied: pybars3 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (0.9.7)\n", |
| 29 | + "Requirement already satisfied: pandas in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (1.5.3)\n", |
| 30 | + "Requirement already satisfied: openai>=1.0.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (1.3.7)\n", |
| 31 | + "Requirement already satisfied: tqdm in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (4.64.1)\n", |
| 32 | + "Requirement already satisfied: marshmallow in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (3.20.1)\n", |
| 33 | + "Requirement already satisfied: requests-toolbelt in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (1.0.0)\n", |
| 34 | + "Requirement already satisfied: tabulate in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (0.9.0)\n", |
| 35 | + "Requirement already satisfied: marshmallow-oneofschema in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (3.0.1)\n", |
| 36 | + "Requirement already satisfied: anthropic in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (0.7.2)\n", |
| 37 | + "Requirement already satisfied: google-generativeai in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (0.1.0rc1)\n", |
| 38 | + "Requirement already satisfied: requests>=2.28.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (2.31.0)\n", |
| 39 | + "Requirement already satisfied: cohere in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openlayer) (4.35)\n", |
| 40 | + "Requirement already satisfied: httpx<1,>=0.23.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (0.25.1)\n", |
| 41 | + "Requirement already satisfied: pydantic<3,>=1.9.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (1.10.5)\n", |
| 42 | + "Requirement already satisfied: distro<2,>=1.7.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (1.8.0)\n", |
| 43 | + "Requirement already satisfied: typing-extensions<5,>=4.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (4.5.0)\n", |
| 44 | + "Requirement already satisfied: anyio<4,>=3.5.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (3.6.2)\n", |
| 45 | + "Requirement already satisfied: sniffio in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from openai>=1.0.0->openlayer) (1.3.0)\n", |
| 46 | + "Requirement already satisfied: idna<4,>=2.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from requests>=2.28.2->openlayer) (3.4)\n", |
| 47 | + "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from requests>=2.28.2->openlayer) (3.0.1)\n", |
| 48 | + "Requirement already satisfied: certifi>=2017.4.17 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from requests>=2.28.2->openlayer) (2022.12.7)\n", |
| 49 | + "Requirement already satisfied: tokenizers>=0.13.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from anthropic->openlayer) (0.15.0)\n", |
| 50 | + "Requirement already satisfied: importlib_metadata<7.0,>=6.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from cohere->openlayer) (6.8.0)\n", |
| 51 | + "Requirement already satisfied: backoff<3.0,>=2.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from cohere->openlayer) (2.2.1)\n", |
| 52 | + "Requirement already satisfied: aiohttp<4.0,>=3.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from cohere->openlayer) (3.9.1)\n", |
| 53 | + "Requirement already satisfied: fastavro==1.8.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from cohere->openlayer) (1.8.2)\n", |
| 54 | + "Requirement already satisfied: google-ai-generativelanguage==0.1.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-generativeai->openlayer) (0.1.0)\n", |
| 55 | + "Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (3.20.3)\n", |
| 56 | + "Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (1.22.2)\n", |
| 57 | + "Requirement already satisfied: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (1.34.0)\n", |
| 58 | + "Requirement already satisfied: packaging>=17.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from marshmallow->openlayer) (23.0)\n", |
| 59 | + "Requirement already satisfied: pytz>=2020.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from pandas->openlayer) (2022.7.1)\n", |
| 60 | + "Requirement already satisfied: numpy>=1.20.3 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from pandas->openlayer) (1.22.4)\n", |
| 61 | + "Requirement already satisfied: python-dateutil>=2.8.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from pandas->openlayer) (2.8.2)\n", |
| 62 | + "Requirement already satisfied: PyMeta3>=0.5.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from pybars3->openlayer) (0.5.1)\n", |
| 63 | + "Requirement already satisfied: attrs>=17.3.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (22.2.0)\n", |
| 64 | + "Requirement already satisfied: frozenlist>=1.1.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (1.3.3)\n", |
| 65 | + "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (1.8.2)\n", |
| 66 | + "Requirement already satisfied: async-timeout<5.0,>=4.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (4.0.2)\n", |
| 67 | + "Requirement already satisfied: aiosignal>=1.1.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (1.3.1)\n", |
| 68 | + "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from aiohttp<4.0,>=3.0->cohere->openlayer) (6.0.4)\n", |
| 69 | + "Requirement already satisfied: httpcore in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from httpx<1,>=0.23.0->openai>=1.0.0->openlayer) (1.0.2)\n", |
| 70 | + "Requirement already satisfied: zipp>=0.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from importlib_metadata<7.0,>=6.0->cohere->openlayer) (3.15.0)\n", |
| 71 | + "Requirement already satisfied: six>=1.5 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from python-dateutil>=2.8.1->pandas->openlayer) (1.16.0)\n", |
| 72 | + "Requirement already satisfied: huggingface_hub<1.0,>=0.16.4 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from tokenizers>=0.13.0->anthropic->openlayer) (0.19.4)\n", |
| 73 | + "Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.56.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (1.58.0)\n", |
| 74 | + "Requirement already satisfied: google-auth<3.0dev,>=1.25.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (2.16.1)\n", |
| 75 | + "Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (1.51.3)\n", |
| 76 | + "Requirement already satisfied: grpcio-status<2.0dev,>=1.33.2 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (1.48.2)\n" |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "name": "stdout", |
| 81 | + "output_type": "stream", |
| 82 | + "text": [ |
| 83 | + "Requirement already satisfied: filelock in /Users/rishabramanathan/.local/lib/python3.8/site-packages (from huggingface_hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic->openlayer) (3.6.0)\n", |
| 84 | + "Requirement already satisfied: pyyaml>=5.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from huggingface_hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic->openlayer) (6.0)\n", |
| 85 | + "Requirement already satisfied: fsspec>=2023.5.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from huggingface_hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic->openlayer) (2023.10.0)\n", |
| 86 | + "Requirement already satisfied: h11<0.15,>=0.13 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from httpcore->httpx<1,>=0.23.0->openai>=1.0.0->openlayer) (0.14.0)\n", |
| 87 | + "Requirement already satisfied: rsa<5,>=3.1.4 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-auth<3.0dev,>=1.25.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (4.9)\n", |
| 88 | + "Requirement already satisfied: pyasn1-modules>=0.2.1 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-auth<3.0dev,>=1.25.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (0.2.8)\n", |
| 89 | + "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from google-auth<3.0dev,>=1.25.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (5.3.0)\n", |
| 90 | + "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /Users/rishabramanathan/opt/miniconda3/envs/old/lib/python3.8/site-packages (from pyasn1-modules>=0.2.1->google-auth<3.0dev,>=1.25.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-ai-generativelanguage==0.1.0->google-generativeai->openlayer) (0.4.8)\n" |
| 91 | + ] |
| 92 | + } |
| 93 | + ], |
22 | 94 | "source": [ |
23 | 95 | "!pip install openlayer" |
24 | 96 | ] |
|
33 | 105 | }, |
34 | 106 | { |
35 | 107 | "cell_type": "code", |
36 | | - "execution_count": null, |
| 108 | + "execution_count": 2, |
37 | 109 | "id": "f3f4fa13", |
38 | 110 | "metadata": {}, |
39 | 111 | "outputs": [], |
|
42 | 114 | "import openai\n", |
43 | 115 | "\n", |
44 | 116 | "# OpenAI env variable\n", |
45 | | - "os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPENAI_API_KEY_HERE\"\n", |
| 117 | + "os.environ[\"OPENAI_API_KEY\"] = \"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\"\n", |
46 | 118 | "\n", |
47 | 119 | "# Openlayer env variables\n", |
48 | | - "os.environ[\"OPENLAYER_API_KEY\"] = \"YOUR_OPENLAYER_API_KEY_HERE\"\n", |
49 | | - "os.environ[\"OPENLAYER_PROJECT_NAME\"] = \"Your Openlayer Project Name Here\" " |
| 120 | + "os.environ[\"OPENLAYER_API_KEY\"] = \"-QfWTgH1NcHyBofvHr_Cm5huswkowJpJ\"\n", |
| 121 | + "os.environ[\"OPENLAYER_PROJECT_NAME\"] = \"test1\" " |
50 | 122 | ] |
51 | 123 | }, |
52 | 124 | { |
|
59 | 131 | }, |
60 | 132 | { |
61 | 133 | "cell_type": "code", |
62 | | - "execution_count": null, |
| 134 | + "execution_count": 3, |
63 | 135 | "id": "e60584fa", |
64 | 136 | "metadata": {}, |
65 | 137 | "outputs": [], |
66 | 138 | "source": [ |
| 139 | + "import openlayer\n", |
| 140 | + "\n", |
| 141 | + "openlayer.api.STORAGE = openlayer.api.StorageType.ONPREM\n", |
| 142 | + "openlayer.api.OPENLAYER_ENDPOINT = \"http://localhost:8080/v1\"\n", |
| 143 | + "\n", |
67 | 144 | "from openlayer import llm_monitors\n", |
68 | 145 | "\n", |
69 | 146 | "openai_client = openai.OpenAI()\n", |
|
80 | 157 | }, |
81 | 158 | { |
82 | 159 | "cell_type": "code", |
83 | | - "execution_count": null, |
| 160 | + "execution_count": 7, |
84 | 161 | "id": "2cb5ce9b", |
85 | 162 | "metadata": {}, |
86 | | - "outputs": [], |
| 163 | + "outputs": [ |
| 164 | + { |
| 165 | + "name": "stdout", |
| 166 | + "output_type": "stream", |
| 167 | + "text": [ |
| 168 | + "All the calls to OpenAI models are now being monitored!\n", |
| 169 | + "Furthermore, since `publish` was set to True, the data is being published to your 'test1' Openlayer project.\n", |
| 170 | + "To stop monitoring, call the `stop_monitoring` method.\n" |
| 171 | + ] |
| 172 | + } |
| 173 | + ], |
87 | 174 | "source": [ |
88 | 175 | "openai_monitor.start_monitoring()" |
89 | 176 | ] |
|
98 | 185 | }, |
99 | 186 | { |
100 | 187 | "cell_type": "code", |
101 | | - "execution_count": null, |
| 188 | + "execution_count": 8, |
102 | 189 | "id": "e00c1c79", |
103 | 190 | "metadata": {}, |
104 | 191 | "outputs": [], |
|
107 | 194 | " model=\"gpt-3.5-turbo\",\n", |
108 | 195 | " messages=[\n", |
109 | 196 | " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n", |
110 | | - " {\"role\": \"user\", \"content\": \"How are you doing today?\"}\n", |
| 197 | + " {\"role\": \"user\", \"content\": \"How are you doing today?\"},\n", |
| 198 | + " {\"role\": \"assistant\", \"content\": \"Pretty well! How about you?\"},\n", |
| 199 | + " {\"role\": \"user\", \"content\": \"I am doing well, but would like some words of encouragement.\"},\n", |
111 | 200 | " ]\n", |
112 | 201 | ")" |
113 | 202 | ] |
114 | 203 | }, |
115 | 204 | { |
116 | 205 | "cell_type": "code", |
117 | | - "execution_count": null, |
| 206 | + "execution_count": 6, |
118 | 207 | "id": "f9139f2b", |
119 | 208 | "metadata": {}, |
120 | | - "outputs": [], |
| 209 | + "outputs": [ |
| 210 | + { |
| 211 | + "name": "stdout", |
| 212 | + "output_type": "stream", |
| 213 | + "text": [ |
| 214 | + "Monitoring stopped.\n" |
| 215 | + ] |
| 216 | + } |
| 217 | + ], |
121 | 218 | "source": [ |
122 | 219 | "openai_monitor.stop_monitoring()" |
123 | 220 | ] |
|
147 | 244 | "name": "python", |
148 | 245 | "nbconvert_exporter": "python", |
149 | 246 | "pygments_lexer": "ipython3", |
150 | | - "version": "3.8.13" |
| 247 | + "version": "3.8.12" |
151 | 248 | } |
152 | 249 | }, |
153 | 250 | "nbformat": 4, |
|
0 commit comments