1
1
# Tutorial
2
2
3
- The ` whyhow ` package helps create customized RAG pipelines. It is built on top
3
+ The ` whyhow_rbr ` package helps create customized RAG pipelines. It is built on top
4
4
of the following technologies (and their respective Python SDKs)
5
5
6
6
- ** OpenAI** - text generation
@@ -27,7 +27,7 @@ export PINECONE_API_KEY...
27
27
and then instantiate the client without any arguments.
28
28
29
29
``` python title="getting_started.py"
30
- from whyhow import Client
30
+ from whyhow_rbr import Client
31
31
32
32
client = Client()
33
33
@@ -41,7 +41,7 @@ An alternative approach is to manually pass the keys when the client is
41
41
being constructed
42
42
43
43
``` python title="getting_started.py"
44
- from whyhow import Client
44
+ from whyhow_rbr import Client
45
45
46
46
client = Client(
47
47
openai_api_key = " ..." ,
@@ -56,7 +56,7 @@ python getting_started.py
56
56
57
57
## Vector database operations
58
58
59
- ` whywow ` uses Pinecone for everything related to vector databses.
59
+ ` whyhow_rbr ` uses Pinecone for everything related to vector databses.
60
60
61
61
### Creating an index
62
62
@@ -96,7 +96,7 @@ index = client.create_index(
96
96
```python
97
97
from pinecone import ServerlessSpec
98
98
99
- from whyhow import Client
99
+ from whyhow_rbr import Client
100
100
101
101
client = Client()
102
102
@@ -140,7 +140,7 @@ index = client.create_index(
140
140
```python
141
141
from pinecone import PodSpec
142
142
143
- from whyhow import Client
143
+ from whyhow_rbr import Client
144
144
145
145
client = Client()
146
146
@@ -177,7 +177,7 @@ index = client.get_index("amazing-index")
177
177
```python
178
178
from pinecone import PodSpec
179
179
180
- from whyhow import Client
180
+ from whyhow_rbr import Client
181
181
182
182
client = Client()
183
183
@@ -235,7 +235,7 @@ Example output:
235
235
## Uploading documents
236
236
237
237
After creating an index, we are ready to populate it with documents. In
238
- ` whyhow ` this is done using the ` upload_documents ` method of the ` Client ` .
238
+ ` whyhow_rbr ` this is done using the ` upload_documents ` method of the ` Client ` .
239
239
It performs the following steps under the hood:
240
240
241
241
- ** Preprocessing** : Reading and splitting the provided PDF files into chunks
@@ -261,7 +261,7 @@ client.upload_documents(
261
261
??? note "Full code"
262
262
263
263
```python
264
- from whyhow import Client
264
+ from whyhow_rbr import Client
265
265
266
266
client = Client()
267
267
@@ -302,7 +302,7 @@ client.upload_documents(
302
302
)
303
303
```
304
304
Note that the above affects the root logger, however, you can also
305
- just customize the `whyhow ` logger.
305
+ just customize the `whyhow_rbr ` logger.
306
306
307
307
Navigate to [ upload_documents (API docs)] ( ./api.md#whyhow.rag.Client.upload_documents )
308
308
if you want to get more information on the parameters.
@@ -311,7 +311,7 @@ if you want to get more information on the parameters.
311
311
312
312
While Pinecone does not require each document in an index to have the same schema
313
313
all the document uploaded via the ` upload_documents ` will have a fixed schema.
314
- This schema is defined in [ PineconeDocument (API docs)] ( ./api.md#whyhow .rag.PineconeDocument ) .
314
+ This schema is defined in [ PineconeDocument (API docs)] ( ./api.md#whyhow_rbr .rag.PineconeDocument ) .
315
315
This is done in order to have a predictable set of attributes that
316
316
can be used to perform advanced filtering (via rules).
317
317
@@ -320,13 +320,13 @@ can be used to perform advanced filtering (via rules).
320
320
In previous sections we discussed how to to create an index and
321
321
populate it with documents. Now we can finally move to retrieval augmented generation.
322
322
323
- In ` whyhow ` , it can be done via the ` query ` method.
323
+ In ` whyhow_rbr ` , it can be done via the ` query ` method.
324
324
325
325
1 . Simple example:
326
326
327
327
``` python
328
328
329
- from whyhow import Client, Rule
329
+ from whyhow_rbr import Client, Rule
330
330
331
331
client = Client()
332
332
@@ -394,7 +394,7 @@ print(result["matches"])
394
394
395
395
Note that the number of matches will be in general equal to ` top_k ` which
396
396
can be specified as a parameter. Also, each match has a fixed schema -
397
- it is a dump of [ PineconeMatch (API docs)] ( ./api.md#whyhow .rag.PineconeMatch ) .
397
+ it is a dump of [ PineconeMatch (API docs)] ( ./api.md#whyhow_rbr .rag.PineconeMatch ) .
398
398
399
399
``` python
400
400
print (result[" used_contexts" ])
@@ -409,7 +409,7 @@ The OpenAI model only used the context from the 1st match when answering the que
409
409
??? note "Full code"
410
410
411
411
```python
412
- from whyhow import Client
412
+ from whyhow_rbr import Client
413
413
414
414
client = Client()
415
415
@@ -431,14 +431,14 @@ The OpenAI model only used the context from the 1st match when answering the que
431
431
432
432
```
433
433
434
- Navigate to [ query(API docs)] ( ./api.md#whyhow .rag.Client.query )
434
+ Navigate to [ query(API docs)] ( ./api.md#whyhow_rbr .rag.Client.query )
435
435
if you want to get more information on the parameters.
436
436
437
437
### Rules
438
438
439
439
In the previous example, every single document in our index was considered.
440
440
However, sometimes it might be beneficial to only retrieve documents satisfying some
441
- predefined conditions (e.g. ` filename=harry-potter.pdf ` ). In ` whyhow ` this
441
+ predefined conditions (e.g. ` filename=harry-potter.pdf ` ). In ` whyhow_rbr ` this
442
442
can be done via the ` Rule ` class.
443
443
444
444
A rule can control the following metadata attributes
@@ -453,7 +453,7 @@ A rule can control the following metadata attributes
453
453
``` python
454
454
# Code above omitted 👆
455
455
456
- from whyhow import Rule
456
+ from whyhow_rbr import Rule
457
457
458
458
question = " What is Harry Potter's favourite food?"
459
459
@@ -477,7 +477,7 @@ In this example, the keyword_trigger parameter is set to True, and the rule incl
477
477
??? note "Full code"
478
478
479
479
```python
480
- from whyhow import Client, Rule
480
+ from whyhow_rbr import Client, Rule
481
481
482
482
client = Client()
483
483
@@ -512,7 +512,7 @@ will be evaluated using the `OR` logical operator.
512
512
``` python
513
513
# Code above omitted 👆
514
514
515
- from whyhow import Rule
515
+ from whyhow_rbr import Rule
516
516
517
517
question = " What is Harry Potter's favorite food?"
518
518
@@ -545,7 +545,7 @@ Depending on the number of rules you use in your query, you may return more chun
545
545
??? note "Full code"
546
546
547
547
```python
548
- from whyhow import Client, Rule
548
+ from whyhow_rbr import Client, Rule
549
549
550
550
client = Client()
551
551
@@ -577,5 +577,5 @@ Depending on the number of rules you use in your query, you may return more chun
577
577
print(result["used_contexts"])
578
578
```
579
579
580
- Navigate to [ Rule (API docs)] ( ./api.md#whyhow .rag.Rule )
580
+ Navigate to [ Rule (API docs)] ( ./api.md#whyhow_rbr .rag.Rule )
581
581
if you want to get more information on the parameters.
0 commit comments