|
20 | 20 | }, |
21 | 21 | { |
22 | 22 | "cell_type": "code", |
23 | | - "execution_count": 1, |
| 23 | + "execution_count": null, |
24 | 24 | "metadata": {}, |
25 | 25 | "outputs": [], |
26 | 26 | "source": [ |
27 | | - "import openai\n", |
28 | | - "!pip install guardrails-ai\n", |
29 | | - "!pip install langchain" |
| 27 | + "!pip install guardrails-ai langchain openai>=1" |
30 | 28 | ] |
31 | 29 | }, |
32 | 30 | { |
|
38 | 36 | }, |
39 | 37 | { |
40 | 38 | "cell_type": "code", |
41 | | - "execution_count": 2, |
42 | | - "metadata": { |
43 | | - "ExecuteTime": { |
44 | | - "end_time": "2023-06-21T16:39:44.813776Z", |
45 | | - "start_time": "2023-06-21T16:39:44.801522Z" |
46 | | - } |
47 | | - }, |
| 39 | + "execution_count": null, |
| 40 | + "metadata": {}, |
48 | 41 | "outputs": [], |
49 | 42 | "source": [ |
50 | 43 | "rail_spec = \"\"\"\n", |
|
79 | 72 | }, |
80 | 73 | { |
81 | 74 | "cell_type": "code", |
82 | | - "execution_count": 3, |
83 | | - "metadata": { |
84 | | - "ExecuteTime": { |
85 | | - "end_time": "2023-06-21T16:39:46.123745Z", |
86 | | - "start_time": "2023-06-21T16:39:46.111378Z" |
87 | | - } |
88 | | - }, |
| 75 | + "execution_count": null, |
| 76 | + "metadata": {}, |
89 | 77 | "outputs": [], |
90 | 78 | "source": [ |
| 79 | + "import openai\n", |
91 | 80 | "from rich import print\n", |
92 | 81 | "\n", |
93 | 82 | "from langchain.output_parsers import GuardrailsOutputParser\n", |
|
98 | 87 | }, |
99 | 88 | { |
100 | 89 | "cell_type": "code", |
101 | | - "execution_count": 4, |
102 | | - "metadata": { |
103 | | - "ExecuteTime": { |
104 | | - "end_time": "2023-06-21T16:39:47.843397Z", |
105 | | - "start_time": "2023-06-21T16:39:47.704763Z" |
106 | | - } |
107 | | - }, |
| 90 | + "execution_count": null, |
| 91 | + "metadata": {}, |
108 | 92 | "outputs": [], |
109 | 93 | "source": [ |
110 | | - "output_parser = GuardrailsOutputParser.from_rail_string(rail_spec, api=openai.ChatCompletion.create)" |
| 94 | + "output_parser = GuardrailsOutputParser.from_rail_string(rail_spec, api=openai.chat.completions.create)" |
111 | 95 | ] |
112 | 96 | }, |
113 | 97 | { |
|
119 | 103 | }, |
120 | 104 | { |
121 | 105 | "cell_type": "code", |
122 | | - "execution_count": 6, |
123 | | - "metadata": { |
124 | | - "ExecuteTime": { |
125 | | - "end_time": "2023-06-21T16:39:49.828250Z", |
126 | | - "start_time": "2023-06-21T16:39:49.823999Z" |
127 | | - } |
128 | | - }, |
| 106 | + "execution_count": null, |
| 107 | + "metadata": {}, |
129 | 108 | "outputs": [ |
130 | 109 | { |
131 | 110 | "data": { |
|
221 | 200 | }, |
222 | 201 | { |
223 | 202 | "cell_type": "code", |
224 | | - "execution_count": 5, |
225 | | - "metadata": { |
226 | | - "ExecuteTime": { |
227 | | - "end_time": "2023-06-21T16:39:54.395309Z", |
228 | | - "start_time": "2023-06-21T16:39:54.378412Z" |
229 | | - } |
230 | | - }, |
| 203 | + "execution_count": null, |
| 204 | + "metadata": {}, |
231 | 205 | "outputs": [], |
232 | 206 | "source": [ |
233 | 207 | "prompt = PromptTemplate(\n", |
|
245 | 219 | }, |
246 | 220 | { |
247 | 221 | "cell_type": "code", |
248 | | - "execution_count": 7, |
249 | | - "metadata": { |
250 | | - "ExecuteTime": { |
251 | | - "end_time": "2023-06-21T16:39:57.246325Z", |
252 | | - "start_time": "2023-06-21T16:39:56.882944Z" |
253 | | - } |
254 | | - }, |
| 222 | + "execution_count": null, |
| 223 | + "metadata": {}, |
255 | 224 | "outputs": [], |
256 | 225 | "source": [ |
257 | 226 | "model = OpenAI(temperature=0)\n", |
|
266 | 235 | }, |
267 | 236 | { |
268 | 237 | "cell_type": "code", |
269 | | - "execution_count": 8, |
| 238 | + "execution_count": null, |
270 | 239 | "metadata": {}, |
271 | 240 | "outputs": [ |
272 | | - { |
273 | | - "name": "stderr", |
274 | | - "output_type": "stream", |
275 | | - "text": [ |
276 | | - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" |
277 | | - ] |
278 | | - }, |
279 | 241 | { |
280 | 242 | "data": { |
281 | 243 | "text/html": [ |
|
322 | 284 | "mimetype": "text/x-python", |
323 | 285 | "name": "python", |
324 | 286 | "nbconvert_exporter": "python", |
325 | | - "pygments_lexer": "ipython3", |
326 | | - "version": "3.11.4" |
| 287 | + "pygments_lexer": "ipython3" |
327 | 288 | } |
328 | 289 | }, |
329 | 290 | "nbformat": 4, |
330 | | - "nbformat_minor": 2 |
| 291 | + "nbformat_minor": 4 |
331 | 292 | } |
0 commit comments