ragxo 0.1.9__tar.gz → 0.1.11__tar.gz
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.
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ragxo
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.11
|
4
4
|
Summary: A RAG (Retrieval-Augmented Generation) toolkit with Milvus integration
|
5
5
|
Home-page: https://github.com/yourusername/ragx
|
6
6
|
License: MIT
|
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
18
18
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Requires-Dist: alive-progress (>=3.1.1,<4.0.0)
|
20
21
|
Requires-Dist: boto3 (>=1.36.14,<2.0.0)
|
21
22
|
Requires-Dist: dill (>=0.3.9,<0.4.0)
|
22
23
|
Requires-Dist: milvus (>=2.3.9,<3.0.0)
|
@@ -30,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
30
31
|
|
31
32
|
# RagXO
|
32
33
|
|
33
|
-
Export, version and reuse your RAG pipeline everywhere 🚀
|
34
|
+
Export, version and reuse your E2E RAG pipeline everywhere 🚀
|
34
35
|
|
35
36
|
[](https://badge.fury.io/py/ragxo)
|
36
37
|
[](https://opensource.org/licenses/MIT)
|
@@ -57,20 +58,26 @@ pip install ragxo
|
|
57
58
|
|
58
59
|
### Build a RAG pipeline
|
59
60
|
|
61
|
+
```bash
|
62
|
+
export OPENAI_API_KEY=<openai_key>
|
63
|
+
```
|
64
|
+
|
60
65
|
```python
|
61
66
|
from ragxo import Ragxo, Document
|
62
67
|
|
63
|
-
|
64
|
-
|
68
|
+
|
69
|
+
|
70
|
+
ragxo_client = Ragxo(dimension=1536)
|
65
71
|
|
66
72
|
def preprocess_text_remove_special_chars(text: str) -> str:
|
67
73
|
return re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
68
74
|
|
75
|
+
def preprocess_text_lower(text: str) -> str:
|
76
|
+
return text.lower()
|
77
|
+
|
69
78
|
def get_embeddings(text: str) -> list[float]:
|
70
79
|
return openai.embeddings.create(input=text, model="text-embedding-ada-002").data[0].embedding
|
71
80
|
|
72
|
-
ragxo_client = Ragxo(dimension=768)
|
73
|
-
|
74
81
|
ragxo_client.add_preprocess(preprocess_text_lower)
|
75
82
|
ragxo_client.add_preprocess(preprocess_text_remove_special_chars)
|
76
83
|
ragxo_client.add_embedding_fn(get_embeddings)
|
@@ -94,6 +101,9 @@ ragxo_client.index([
|
|
94
101
|
|
95
102
|
ragxo_client.export("my_rag_v1.0.0")
|
96
103
|
|
104
|
+
# or export to s3
|
105
|
+
ragxo_client.export("my_rag_v1.0.0", s3_bucket="my_bucket")
|
106
|
+
|
97
107
|
```
|
98
108
|
|
99
109
|
|
@@ -107,6 +117,7 @@ vector_search_results = loaded_ragxo_client.query("What is the capital of France
|
|
107
117
|
llm_response = loaded_ragxo_client.generate_llm_response(
|
108
118
|
"What is the capital of France?")
|
109
119
|
|
120
|
+
print(llm_response.choices[0].message.content)
|
110
121
|
```
|
111
122
|
|
112
123
|
|
@@ -226,3 +237,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
226
237
|
## Contributing 🤝
|
227
238
|
|
228
239
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
240
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# RagXO
|
2
2
|
|
3
|
-
Export, version and reuse your RAG pipeline everywhere 🚀
|
3
|
+
Export, version and reuse your E2E RAG pipeline everywhere 🚀
|
4
4
|
|
5
5
|
[](https://badge.fury.io/py/ragxo)
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
@@ -27,20 +27,26 @@ pip install ragxo
|
|
27
27
|
|
28
28
|
### Build a RAG pipeline
|
29
29
|
|
30
|
+
```bash
|
31
|
+
export OPENAI_API_KEY=<openai_key>
|
32
|
+
```
|
33
|
+
|
30
34
|
```python
|
31
35
|
from ragxo import Ragxo, Document
|
32
36
|
|
33
|
-
|
34
|
-
|
37
|
+
|
38
|
+
|
39
|
+
ragxo_client = Ragxo(dimension=1536)
|
35
40
|
|
36
41
|
def preprocess_text_remove_special_chars(text: str) -> str:
|
37
42
|
return re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
38
43
|
|
44
|
+
def preprocess_text_lower(text: str) -> str:
|
45
|
+
return text.lower()
|
46
|
+
|
39
47
|
def get_embeddings(text: str) -> list[float]:
|
40
48
|
return openai.embeddings.create(input=text, model="text-embedding-ada-002").data[0].embedding
|
41
49
|
|
42
|
-
ragxo_client = Ragxo(dimension=768)
|
43
|
-
|
44
50
|
ragxo_client.add_preprocess(preprocess_text_lower)
|
45
51
|
ragxo_client.add_preprocess(preprocess_text_remove_special_chars)
|
46
52
|
ragxo_client.add_embedding_fn(get_embeddings)
|
@@ -64,6 +70,9 @@ ragxo_client.index([
|
|
64
70
|
|
65
71
|
ragxo_client.export("my_rag_v1.0.0")
|
66
72
|
|
73
|
+
# or export to s3
|
74
|
+
ragxo_client.export("my_rag_v1.0.0", s3_bucket="my_bucket")
|
75
|
+
|
67
76
|
```
|
68
77
|
|
69
78
|
|
@@ -77,6 +86,7 @@ vector_search_results = loaded_ragxo_client.query("What is the capital of France
|
|
77
86
|
llm_response = loaded_ragxo_client.generate_llm_response(
|
78
87
|
"What is the capital of France?")
|
79
88
|
|
89
|
+
print(llm_response.choices[0].message.content)
|
80
90
|
```
|
81
91
|
|
82
92
|
|
@@ -195,4 +205,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
195
205
|
|
196
206
|
## Contributing 🤝
|
197
207
|
|
198
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
208
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "ragxo"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.11"
|
4
4
|
description = "A RAG (Retrieval-Augmented Generation) toolkit with Milvus integration"
|
5
5
|
authors = ["Mohamed Sadek <mohamedfawzydes@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -28,6 +28,7 @@ openai = "^1.61.1"
|
|
28
28
|
boto3 = "^1.36.14"
|
29
29
|
pytest-mock = "^3.14.0"
|
30
30
|
mocker = "^1.1.1"
|
31
|
+
alive-progress = "^3.1.1"
|
31
32
|
|
32
33
|
[tool.poetry.group.dev.dependencies]
|
33
34
|
pytest = "^8.3.4"
|
@@ -11,6 +11,7 @@ import tempfile
|
|
11
11
|
from botocore.exceptions import ClientError
|
12
12
|
import openai
|
13
13
|
from openai import ChatCompletion
|
14
|
+
from ragxo.utils import with_loading
|
14
15
|
|
15
16
|
logger = logging.getLogger(__name__)
|
16
17
|
|
@@ -140,6 +141,7 @@ class Ragxo:
|
|
140
141
|
self.presence_penalty = presence_penalty
|
141
142
|
return self
|
142
143
|
|
144
|
+
@with_loading("Indexing documents")
|
143
145
|
def index(self, data: list[Document]) -> Self:
|
144
146
|
"""
|
145
147
|
Index documents into the vector database.
|
@@ -210,6 +212,7 @@ class Ragxo:
|
|
210
212
|
output_fields=output_fields
|
211
213
|
)
|
212
214
|
|
215
|
+
@with_loading("Exporting Ragxo instance")
|
213
216
|
def export(self, destination: str, s3_bucket: str = None) -> Self:
|
214
217
|
"""
|
215
218
|
Export the Ragx instance to either local filesystem or S3.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import functools
|
2
|
+
from alive_progress import alive_bar
|
3
|
+
|
4
|
+
|
5
|
+
def with_loading(title: str):
|
6
|
+
"""
|
7
|
+
Decorator to add loading animation to methods.
|
8
|
+
|
9
|
+
Args:
|
10
|
+
title (str): Title to display during loading
|
11
|
+
"""
|
12
|
+
|
13
|
+
def decorator(func):
|
14
|
+
@functools.wraps(func)
|
15
|
+
def wrapper(self, *args, **kwargs):
|
16
|
+
with alive_bar(title=title, bar=None, stats=False) as bar:
|
17
|
+
result = func(self, *args, **kwargs)
|
18
|
+
bar()
|
19
|
+
return result
|
20
|
+
return wrapper
|
21
|
+
return decorator
|
File without changes
|