|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": null, |
| 5 | + "execution_count": 1, |
6 | 6 | "id": "5aaf649f", |
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [], |
|
13 | 13 | "import sys\n", |
14 | 14 | "\n", |
15 | 15 | "import dotenv\n", |
| 16 | + "import litellm\n", |
16 | 17 | "import pydantic\n", |
17 | 18 | "from pydantic import ValidationError, field_validator\n", |
18 | 19 | "from pydantic_core import PydanticCustomError\n", |
19 | 20 | "\n", |
20 | 21 | "from effectful.handlers.llm import Template, Tool\n", |
21 | 22 | "from effectful.handlers.llm.completions import (\n", |
22 | | - " CacheLLMRequestHandler,\n", |
23 | 23 | " LiteLLMProvider,\n", |
24 | 24 | " LLMLoggingHandler,\n", |
25 | 25 | " RetryLLMHandler,\n", |
|
129 | 129 | "output_type": "stream", |
130 | 130 | "text": [ |
131 | 131 | "\n", |
132 | | - "Here is a haiku on the theme of fish:\n", |
133 | | - "\n", |
134 | | - "Silent stream below, \n", |
135 | | - "Golden fins dart through sun's glow, \n", |
136 | | - "Still waters, life flows.\n", |
| 132 | + "Gentle fins flutter, \n", |
| 133 | + "In the depths of clear blue seas, \n", |
| 134 | + "Silent dancers swim.\n", |
137 | 135 | "----------------------------------------\n", |
138 | | - "Here is a haiku on the theme of fish:\n", |
139 | | - "\n", |
140 | | - "Silent stream below, \n", |
141 | | - "Golden fins dart through sun's glow, \n", |
142 | | - "Still waters, life flows.\n", |
| 136 | + "Gentle fins flutter, \n", |
| 137 | + "In the depths of clear blue seas, \n", |
| 138 | + "Silent dancers swim.\n", |
143 | 139 | "\n", |
144 | | - "Swimming silently, \n", |
145 | | - "Scales shimmer in liquid light, \n", |
146 | | - "Depths hold their secrets.\n", |
| 140 | + "Swimming in silence, \n", |
| 141 | + "Beneath the rippling waves' veil, \n", |
| 142 | + "Whispers of the deep.\n", |
147 | 143 | "----------------------------------------\n", |
148 | | - "Swimming silently, \n", |
149 | | - "Scales shimmer in liquid light, \n", |
150 | | - "Depths hold their secrets.\n", |
| 144 | + "Swimming in silence, \n", |
| 145 | + "Beneath the rippling waves' veil, \n", |
| 146 | + "Whispers of the deep.\n", |
151 | 147 | "\n", |
152 | | - "In oceans they glide, \n", |
153 | | - "Silent beneath waves they swim, \n", |
154 | | - "Fish dance with the tides.\n", |
| 148 | + "In the silent pond, \n", |
| 149 | + "Silver scales glint in moonlight, \n", |
| 150 | + "Dreams of deep blue sea. \n", |
155 | 151 | "----------------------------------------\n", |
156 | | - "In oceans they glide, \n", |
157 | | - "Silent beneath waves they swim, \n", |
158 | | - "Fish dance with the tides.\n" |
| 152 | + "Silent ponds shimmer, \n", |
| 153 | + "Fish glide through liquid silver, \n", |
| 154 | + "Nature's quiet dance.\n" |
159 | 155 | ] |
160 | 156 | } |
161 | 157 | ], |
|
180 | 176 | " print(haiku(\"fish\"))\n", |
181 | 177 | "\n", |
182 | 178 | "print()\n", |
183 | | - "cache_handler1 = CacheLLMRequestHandler()\n", |
184 | | - "with handler(provider), handler(cache_handler1):\n", |
| 179 | + "with handler(provider):\n", |
| 180 | + " litellm.enable_cache()\n", |
185 | 181 | " print(haiku_no_cache(\"fish2\"))\n", |
186 | 182 | " print(\"-\" * 40)\n", |
187 | 183 | " print(haiku_no_cache(\"fish2\"))\n", |
| 184 | + " litellm.disable_cache()\n", |
188 | 185 | "\n", |
189 | 186 | "print()\n", |
190 | | - "cache_handler2 = CacheLLMRequestHandler()\n", |
191 | | - "with handler(provider), handler(cache_handler2):\n", |
| 187 | + "with handler(provider):\n", |
192 | 188 | " print(haiku_no_cache(\"fish3\"))\n", |
193 | 189 | " print(\"-\" * 40)\n", |
194 | 190 | " print(haiku_no_cache(\"fish3\"))" |
|
856 | 852 | ], |
857 | 853 | "metadata": { |
858 | 854 | "kernelspec": { |
859 | | - "display_name": ".venv", |
| 855 | + "display_name": "Python 3 (ipykernel)", |
860 | 856 | "language": "python", |
861 | 857 | "name": "python3" |
862 | 858 | }, |
|
870 | 866 | "name": "python", |
871 | 867 | "nbconvert_exporter": "python", |
872 | 868 | "pygments_lexer": "ipython3", |
873 | | - "version": "3.12.11" |
| 869 | + "version": "3.13.9" |
874 | 870 | } |
875 | 871 | }, |
876 | 872 | "nbformat": 4, |
|
0 commit comments