ragxo 0.1.2__py3-none-any.whl → 0.1.3__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.
ragxo/ragx.py CHANGED
@@ -126,7 +126,11 @@ class Ragxo:
126
126
  logger.error(f"Error in load: {e}")
127
127
  raise
128
128
 
129
- def generate_llm_response(self, query: str) -> ChatCompletion:
129
+ def generate_llm_response(self, query: str, data: list[dict] = None) -> ChatCompletion:
130
+
131
+ if data is None:
132
+ data = self.query(query)[0]
133
+
130
134
  if not self.system_prompt:
131
135
  raise ValueError("System prompt not set. Please call add_system_prompt first.")
132
136
 
@@ -134,7 +138,7 @@ class Ragxo:
134
138
  model=self.model,
135
139
  messages=[
136
140
  {"role": "system", "content": self.system_prompt},
137
- {"role": "user", "content": query}
141
+ {"role": "user", "content": "query: {} data: {}".format(query, data)}
138
142
  ]
139
143
  )
140
144
 
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.1
2
+ Name: ragxo
3
+ Version: 0.1.3
4
+ Summary: A RAG (Retrieval-Augmented Generation) toolkit with Milvus integration
5
+ Home-page: https://github.com/yourusername/ragx
6
+ License: MIT
7
+ Keywords: rag,milvus,nlp,embeddings,openai
8
+ Author: Mohamed Sadek
9
+ Author-email: mohamedfawzydes@gmail.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Dist: dill (>=0.3.9,<0.4.0)
21
+ Requires-Dist: milvus (>=2.3.9,<3.0.0)
22
+ Requires-Dist: openai (>=1.61.1,<2.0.0)
23
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
24
+ Requires-Dist: pymilvus (>=2.5.4,<3.0.0)
25
+ Project-URL: Repository, https://github.com/yourusername/ragx
26
+ Description-Content-Type: text/markdown
27
+
28
+ # RagXO 🚀
29
+
30
+ [![PyPI version](https://badge.fury.io/py/ragxo.svg)](https://badge.fury.io/py/ragxo)
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
32
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)
33
+
34
+ RagXO extends the capabilities of traditional RAG (Retrieval-Augmented Generation) systems by providing a unified way to package, version, and deploy your entire RAG pipeline with LLM integration. Export your complete system—including embedding functions, preprocessing steps, vector store, and LLM configurations—into a single, portable artifact.
35
+
36
+ ## Features ✨
37
+
38
+ - **Complete RAG Pipeline**: Package your entire RAG system into a versioned artifact
39
+ - **LLM Integration**: Built-in support for OpenAI models
40
+ - **Flexible Embedding**: Compatible with any embedding function (Sentence Transformers, OpenAI, etc.)
41
+ - **Custom Preprocessing**: Chain multiple preprocessing steps
42
+ - **Vector Store Integration**: Built-in Milvus support
43
+ - **System Prompts**: Include and version your system prompts
44
+
45
+ ## Installation 🛠️
46
+
47
+ ```bash
48
+ pip install ragxo
49
+ ```
50
+
51
+ ## Quick Start 🚀
52
+
53
+ ```python
54
+ from ragxo import Ragxo, Document
55
+ from openai import OpenAI
56
+ client = OpenAI()
57
+
58
+ def get_openai_embeddings(text: str) -> list[float]:
59
+ response = client.embeddings.create(
60
+ input=text,
61
+ model="text-embedding-ada-002"
62
+ )
63
+ return response.data[0].embedding
64
+
65
+ def preprocess_text(text: str) -> str:
66
+ return text.lower()
67
+
68
+ # Initialize and configure RagXO
69
+ ragxo = Ragxo(dimension=384)
70
+ ragxo.add_preprocess(preprocess_text)
71
+ ragxo.add_embedding_fn(get_openai_embeddings)
72
+
73
+ # Add system prompt and model
74
+ ragxo.add_system_prompt("You are a helpful assistant.")
75
+ ragxo.add_model("gpt-4o-mini")
76
+
77
+ # Create and index documents
78
+ documents = [
79
+ Document(
80
+ text="Sample document for indexing",
81
+ metadata={"source": "example"},
82
+ id=1
83
+ )
84
+ ]
85
+ ragxo.index(documents)
86
+
87
+ # Export the pipeline
88
+ ragxo.export("my_rag_v1")
89
+
90
+ # Load and use elsewhere
91
+ loaded_ragxo = Ragxo.load("my_rag_v1")
92
+
93
+ # Query and generate response
94
+ similar_docs = loaded_ragxo.query("sample query")
95
+ llm_response = loaded_ragxo.generate_llm_response("What can you tell me about the sample?")
96
+ ```
97
+
98
+ ## Usage Guide 📚
99
+
100
+ ### Creating Documents
101
+
102
+ ```python
103
+ from ragxo import Document
104
+
105
+ doc = Document(
106
+ text="Your document content here",
107
+ metadata={"source": "wiki", "category": "science"},
108
+ id=1
109
+ )
110
+ ```
111
+
112
+ ### Adding Preprocessing Steps
113
+
114
+ ```python
115
+ import re
116
+
117
+ def remove_special_chars(text: str) -> str:
118
+ return re.sub(r'[^a-zA-Z0-9\s]', '', text)
119
+
120
+ def lowercase(text: str) -> str:
121
+ return text.lower()
122
+
123
+ ragxo.add_preprocess(remove_special_chars)
124
+ ragxo.add_preprocess(lowercase)
125
+ ```
126
+
127
+ ### Custom Embedding Functions
128
+
129
+ ```python
130
+ # Using SentenceTransformers
131
+ from sentence_transformers import SentenceTransformer
132
+ model = SentenceTransformer('all-MiniLM-L6-v2')
133
+
134
+ def get_embeddings(text: str) -> list[float]:
135
+ return model.encode(text).tolist()
136
+
137
+ ragxo.add_embedding_fn(get_embeddings)
138
+
139
+ # Or using OpenAI
140
+ from openai import OpenAI
141
+ client = OpenAI()
142
+
143
+ def get_openai_embeddings(text: str) -> list[float]:
144
+ response = client.embeddings.create(
145
+ input=text,
146
+ model="text-embedding-ada-002"
147
+ )
148
+ return response.data[0].embedding
149
+
150
+ ragxo.add_embedding_fn(get_openai_embeddings)
151
+ ```
152
+
153
+ ### LLM Configuration
154
+
155
+ ```python
156
+ # Set system prompt
157
+ ragxo.add_system_prompt("""
158
+ You are a helpful assistant. Use the provided context to answer questions accurately.
159
+ If you're unsure about something, please say so.
160
+ """)
161
+
162
+ # Set LLM model
163
+ ragxo.add_model("gpt-4")
164
+ ```
165
+
166
+ ### Export and Load
167
+
168
+ ```python
169
+ # Export your RAG pipeline
170
+ ragxo.export("rag_pipeline_v1")
171
+
172
+ # Load it elsewhere
173
+ loaded_ragxo = Ragxo.load("rag_pipeline_v1")
174
+ ```
175
+
176
+ ## Best Practices 💡
177
+
178
+ 1. **Version Your Exports**: Use semantic versioning for your exports:
179
+ ```python
180
+ ragxo.export("my_rag_v1.0.0")
181
+ ```
182
+
183
+ 2. **Validate After Loading**: Always test your loaded pipeline:
184
+ ```python
185
+ loaded_ragxo = Ragxo.load("my_rag")
186
+ try:
187
+ # Test similarity search
188
+ similar_docs = loaded_ragxo.query("test query")
189
+ # Test LLM generation
190
+ llm_response = loaded_ragxo.generate_llm_response("test question")
191
+ print("Pipeline loaded successfully!")
192
+ except Exception as e:
193
+ print(f"Error loading pipeline: {e}")
194
+ ```
195
+
196
+ 3. **Document Your Pipeline Configuration**: Keep track of your setup:
197
+ ```python
198
+ pipeline_config = {
199
+ "preprocessing_steps": ["remove_special_chars", "lowercase"],
200
+ "embedding_model": "all-MiniLM-L6-v2",
201
+ "llm_model": "gpt-4",
202
+ "dimension": 384
203
+ }
204
+ ```
205
+
206
+ ## License 📝
207
+
208
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
209
+
210
+ ## Contributing 🤝
211
+
212
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,5 @@
1
+ ragxo/__init__.py,sha256=jI_6iulTUQk9JUDft-jM6NHESpZSmJVPIaVOmd4-jWw,65
2
+ ragxo/ragx.py,sha256=_HQCTth_iR2rxV9amMyA6qlOpdGji5_-rSDB5WWG2u4,4537
3
+ ragxo-0.1.3.dist-info/METADATA,sha256=FZmy-PL_SZMf9NuDWcniQUsleZna_GYsz5GLoJRbHcM,5960
4
+ ragxo-0.1.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
5
+ ragxo-0.1.3.dist-info/RECORD,,
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ragxo
3
- Version: 0.1.2
4
- Summary: A RAG (Retrieval-Augmented Generation) toolkit with Milvus integration
5
- Home-page: https://github.com/yourusername/ragx
6
- License: MIT
7
- Keywords: rag,milvus,nlp,embeddings,openai
8
- Author: Mohamed Sadek
9
- Author-email: mohamedfawzydes@gmail.com
10
- Requires-Python: >=3.11,<4.0
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Classifier: Programming Language :: Python :: 3.13
18
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Requires-Dist: dill (>=0.3.9,<0.4.0)
21
- Requires-Dist: milvus (>=2.3.9,<3.0.0)
22
- Requires-Dist: openai (>=1.61.1,<2.0.0)
23
- Requires-Dist: pydantic (>=2.10.6,<3.0.0)
24
- Requires-Dist: pymilvus (>=2.5.4,<3.0.0)
25
- Project-URL: Repository, https://github.com/yourusername/ragx
26
- Description-Content-Type: text/markdown
27
-
28
-
@@ -1,5 +0,0 @@
1
- ragxo/__init__.py,sha256=jI_6iulTUQk9JUDft-jM6NHESpZSmJVPIaVOmd4-jWw,65
2
- ragxo/ragx.py,sha256=KotppZuO9U1aQG0CSbvRTVOXBN0BpaKMlS1IrqBmigk,4394
3
- ragxo-0.1.2.dist-info/METADATA,sha256=xZ3DcX6lsLCBLnwcn13J5pufLilNnvjL8nk8ccGlyGo,1111
4
- ragxo-0.1.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
5
- ragxo-0.1.2.dist-info/RECORD,,
File without changes