ragit 0.8__py3-none-any.whl → 0.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ragit/__init__.py +116 -2
- ragit/assistant.py +577 -0
- ragit/config.py +60 -0
- ragit/core/__init__.py +5 -0
- ragit/core/experiment/__init__.py +22 -0
- ragit/core/experiment/experiment.py +571 -0
- ragit/core/experiment/results.py +131 -0
- ragit/loaders.py +245 -0
- ragit/providers/__init__.py +47 -0
- ragit/providers/base.py +147 -0
- ragit/providers/function_adapter.py +237 -0
- ragit/providers/ollama.py +446 -0
- ragit/providers/sentence_transformers.py +225 -0
- ragit/utils/__init__.py +105 -0
- ragit/version.py +5 -0
- ragit-0.8.2.dist-info/METADATA +166 -0
- ragit-0.8.2.dist-info/RECORD +20 -0
- {ragit-0.8.dist-info → ragit-0.8.2.dist-info}/WHEEL +1 -1
- ragit-0.8.2.dist-info/licenses/LICENSE +201 -0
- {ragit-0.8.dist-info → ragit-0.8.2.dist-info}/top_level.txt +0 -0
- ragit/main.py +0 -354
- ragit-0.8.dist-info/LICENSE +0 -21
- ragit-0.8.dist-info/METADATA +0 -176
- ragit-0.8.dist-info/RECORD +0 -7
ragit-0.8.dist-info/METADATA
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: ragit
|
|
3
|
-
Version: 0.8
|
|
4
|
-
Home-page: https://github.com/stsfaroz/ragit
|
|
5
|
-
Author: Salman Faroz
|
|
6
|
-
License: MIT
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Requires-Dist: sentence-transformers>=3.4.1
|
|
10
|
-
Requires-Dist: pandas>=2.2.3
|
|
11
|
-
Requires-Dist: chromadb>=0.6.3
|
|
12
|
-
Requires-Dist: setuptools>=75.8.0
|
|
13
|
-
Requires-Dist: wheel>=0.45.1
|
|
14
|
-
Requires-Dist: twine>=6.1.0
|
|
15
|
-
Dynamic: author
|
|
16
|
-
Dynamic: description
|
|
17
|
-
Dynamic: description-content-type
|
|
18
|
-
Dynamic: home-page
|
|
19
|
-
Dynamic: license
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Ragit
|
|
24
|
-
🚀 Smart, Fast, Scalable Search 🚀
|
|
25
|
-
|
|
26
|
-
## Installation
|
|
27
|
-
```
|
|
28
|
-
pip install ragit
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**ragit** is a lightweight Python library that simplifies the management of vector databases. With **ragit**, you can easily create, update, query, and manage your vector database, all from CSV files containing text data.
|
|
32
|
-
|
|
33
|
-
## Features
|
|
34
|
-
|
|
35
|
-
- **Create a Vector Database:** Build your database from a CSV file with two required columns: `id` and `text`.
|
|
36
|
-
- **Add New Entries:** Insert additional entries from CSV files or add them individually.
|
|
37
|
-
- **Similarity Search:** Find nearby texts using various distance metrics (e.g., cosine, L2) with similarity scores.
|
|
38
|
-
- **Data Retrieval:** Fetch entries by IDs or exact text matches.
|
|
39
|
-
- **Deletion:** Remove single entries or entire collections when needed.
|
|
40
|
-
|
|
41
|
-
## CSV File Format
|
|
42
|
-
ragit expects your CSV file to have exactly two columns: `id` and `text`. **Note:** Each `id` must be unique.
|
|
43
|
-
|
|
44
|
-
## Example CSV (`data.csv`):
|
|
45
|
-
|
|
46
|
-
```csv
|
|
47
|
-
id,text
|
|
48
|
-
1,The quick brown fox jumps over the lazy dog.
|
|
49
|
-
2,Another sample entry for testing.
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Usage
|
|
53
|
-
Below are some examples that demonstrate how to use `ragit`. The examples cover creating a database, adding entries, performing similarity searches, and more.
|
|
54
|
-
|
|
55
|
-
### 1. Importing and Initializing
|
|
56
|
-
First, import the `VectorDBManager` class from `ragit` and initialize it:
|
|
57
|
-
|
|
58
|
-
```python
|
|
59
|
-
from ragit import VectorDBManager
|
|
60
|
-
|
|
61
|
-
# Initialize the vector database manager with a custom persistence directory and model
|
|
62
|
-
db_manager = VectorDBManager(
|
|
63
|
-
persist_directory="./my_vector_db", # Optional # default : "./vector_db"
|
|
64
|
-
provider="sentence_transformer", # Optional # default : "sentence_transformer"
|
|
65
|
-
model_name="all-mpnet-base-v2" # Optional # default : "all-mpnet-base-v2"
|
|
66
|
-
)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 2. Creating a Database
|
|
70
|
-
Create a new collection (named `my_collection`) using your CSV file. In this example, the `distance_metric` is set to "cosine"(available options: l2, cosine, ip, l1) :
|
|
71
|
-
|
|
72
|
-
```python
|
|
73
|
-
db_manager.create_database(
|
|
74
|
-
csv_path="data.csv",
|
|
75
|
-
collection_name="my_collection",
|
|
76
|
-
distance_metric="cosine" # Optional # default : l2
|
|
77
|
-
)
|
|
78
|
-
```
|
|
79
|
-
### Reloading Your Database
|
|
80
|
-
|
|
81
|
-
To reuse your existing vector database, initialize VectorDBManager with the same parameters that were used when creating the database.
|
|
82
|
-
|
|
83
|
-
```python
|
|
84
|
-
from ragit import VectorDBManager
|
|
85
|
-
|
|
86
|
-
db_manager = VectorDBManager(
|
|
87
|
-
persist_directory="./my_vector_db",
|
|
88
|
-
provider="sentence_transformer",
|
|
89
|
-
model_name="all-mpnet-base-v2"
|
|
90
|
-
)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### 3. Adding a Single Entry
|
|
94
|
-
Add an individual entry to the collection:
|
|
95
|
-
|
|
96
|
-
```python
|
|
97
|
-
db_manager.add_single_row(
|
|
98
|
-
id_="101",
|
|
99
|
-
text="This is a new test entry for the database.",
|
|
100
|
-
collection_name="my_collection"
|
|
101
|
-
)
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 4. Adding Multiple Entries from CSV
|
|
105
|
-
You can also add multiple entries from a CSV file. This function skips any entries that already exist in the collection:
|
|
106
|
-
|
|
107
|
-
```python
|
|
108
|
-
stats = db_manager.add_values_from_csv(
|
|
109
|
-
csv_path="data.csv",
|
|
110
|
-
collection_name="my_collection"
|
|
111
|
-
)
|
|
112
|
-
print(f"Added {stats['new_entries_added']} new entries")
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 5. Retrieving Collection Information
|
|
116
|
-
Fetch and display information about your collection:
|
|
117
|
-
|
|
118
|
-
```python
|
|
119
|
-
info = db_manager.get_collection_info("my_collection")
|
|
120
|
-
print(f"Collection size: {info['count']} entries")
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 6. Performing a Similarity Search
|
|
124
|
-
Find texts that are similar to your query. In this example, the query text is "ai", and the search is filtered using the string "Artificial intelligence". The top 2 results are returned:
|
|
125
|
-
|
|
126
|
-
```python
|
|
127
|
-
results = db_manager.find_nearby_texts(
|
|
128
|
-
text="ai",
|
|
129
|
-
collection_name="my_collection",
|
|
130
|
-
k=2,
|
|
131
|
-
search_string="Artificial intelligence" # Optional
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
print("Results:")
|
|
135
|
-
for item in results:
|
|
136
|
-
print(f"\nID: {item['id']}")
|
|
137
|
-
print(f"Text: {item['text']}")
|
|
138
|
-
print(f"Similarity: {item['similarity']}%")
|
|
139
|
-
print(f"Distance ({item['metric']}): {item['raw_distance']}")
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### 7. Fetching Texts by IDs
|
|
143
|
-
Retrieve text entries for a list of IDs:
|
|
144
|
-
|
|
145
|
-
```python
|
|
146
|
-
ids_to_fetch = ["1", "2", "3"]
|
|
147
|
-
texts = db_manager.get_by_ids(ids_to_fetch, "my_collection")
|
|
148
|
-
print("Texts:", texts)
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### 8. Deleting a Row / Collection
|
|
152
|
-
|
|
153
|
-
Remove an entry from the collection by its ID:
|
|
154
|
-
|
|
155
|
-
```python
|
|
156
|
-
db_manager.delete_entry_by_id(
|
|
157
|
-
id_="1",
|
|
158
|
-
collection_name="my_collection"
|
|
159
|
-
)
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
Delete an entire collection. **Note:** You must pass `confirmation="yes"` to proceed with deletion.
|
|
164
|
-
|
|
165
|
-
```python
|
|
166
|
-
db_manager.delete_collection(
|
|
167
|
-
collection_name="my_collection",
|
|
168
|
-
confirmation="yes"
|
|
169
|
-
)
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Contributing
|
|
173
|
-
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.
|
|
174
|
-
|
|
175
|
-
## License
|
|
176
|
-
This project is licensed under the MIT License. See the `LICENSE` file for details.
|
ragit-0.8.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ragit/__init__.py,sha256=GECJxYFL_0PMy6tbcVFpW9Fhe1JiI2uXH4iJWhUHpKs,48
|
|
2
|
-
ragit/main.py,sha256=f2kDfZPxP26DBvzmP7aF6VhnNAE1hC-ZONU5ZH6RVBM,11774
|
|
3
|
-
ragit-0.8.dist-info/LICENSE,sha256=L8f7hg7lQm80qoZhSCoW1ACAKph-FpJaNaa9MyNDBqo,1069
|
|
4
|
-
ragit-0.8.dist-info/METADATA,sha256=H73xJZU_viExL4wcb-knClT7-BmMvhtlAaeQ07gliXM,5230
|
|
5
|
-
ragit-0.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
6
|
-
ragit-0.8.dist-info/top_level.txt,sha256=pkPbG7yrw61wt9_y_xcLE2vq2a55fzockASD0yq0g4s,6
|
|
7
|
-
ragit-0.8.dist-info/RECORD,,
|