mb-rag 1.1.8__tar.gz → 1.1.10__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.
- {mb_rag-1.1.8 → mb_rag-1.1.10}/PKG-INFO +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/chatbot/basic.py +54 -7
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/version.py +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag.egg-info/PKG-INFO +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.10}/README.md +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/chatbot/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/chatbot/chains.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/chatbot/prompts.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/rag/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/rag/embeddings.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/utils/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/utils/bounding_box.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag/utils/extra.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag.egg-info/SOURCES.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag.egg-info/dependency_links.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag.egg-info/requires.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/mb_rag.egg-info/top_level.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/pyproject.toml +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/setup.cfg +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.10}/setup.py +0 -0
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
from dotenv import load_dotenv
|
|
3
3
|
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
|
|
4
4
|
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
|
5
|
+
from langchain.document_loaders import TextLoader
|
|
5
6
|
from IPython.display import display, HTML
|
|
6
7
|
from typing import Optional, List, Dict, Any, Union
|
|
7
8
|
from mb_rag.utils.extra import check_package
|
|
@@ -65,7 +66,9 @@ class ModelFactory:
|
|
|
65
66
|
'anthropic': self.create_anthropic,
|
|
66
67
|
'google': self.create_google,
|
|
67
68
|
'ollama': self.create_ollama,
|
|
68
|
-
'groq': self.create_groq
|
|
69
|
+
'groq': self.create_groq,
|
|
70
|
+
'deepseek': self.create_deepseek,
|
|
71
|
+
'qwen' : self.create_qwen,
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
model_data = creators.get(model_type)
|
|
@@ -162,23 +165,67 @@ class ModelFactory:
|
|
|
162
165
|
kwargs["model"] = model_name
|
|
163
166
|
return ChatGroq(**kwargs)
|
|
164
167
|
|
|
165
|
-
|
|
168
|
+
@classmethod
|
|
169
|
+
def create_deepseek(cls, model_name: str = "deepseek-chat", **kwargs) -> Any:
|
|
170
|
+
"""
|
|
171
|
+
Create Deepseek chatbot model
|
|
172
|
+
Args:
|
|
173
|
+
model_name (str): Name of the model
|
|
174
|
+
**kwargs: Additional arguments
|
|
175
|
+
Returns:
|
|
176
|
+
ChatDeepseek: Chatbot model
|
|
177
|
+
"""
|
|
178
|
+
if not check_package("langchain_deepseek"):
|
|
179
|
+
raise ImportError("Langchain Deepseek package not found. Please install it using: pip install langchain-deepseek")
|
|
180
|
+
|
|
181
|
+
from langchain_deepseek import ChatDeepSeek
|
|
182
|
+
kwargs["model"] = model_name
|
|
183
|
+
return ChatDeepSeek(**kwargs)
|
|
184
|
+
|
|
185
|
+
@classmethod
|
|
186
|
+
def create_qwen(cls, model_name: str = "qwen", **kwargs) -> Any:
|
|
187
|
+
"""
|
|
188
|
+
Create Qwen chatbot model
|
|
189
|
+
Args:
|
|
190
|
+
model_name (str): Name of the model
|
|
191
|
+
**kwargs: Additional arguments
|
|
192
|
+
Returns:
|
|
193
|
+
ChatQwen: Chatbot model
|
|
194
|
+
"""
|
|
195
|
+
if not check_package("langchain_community"):
|
|
196
|
+
raise ImportError("Langchain Qwen package not found. Please install it using: pip install langchain_community")
|
|
197
|
+
|
|
198
|
+
from langchain_community.chat_models.tongyi import ChatTongyi
|
|
199
|
+
kwargs["model"] = model_name
|
|
200
|
+
return ChatTongyi(streaming=True,**kwargs)
|
|
201
|
+
|
|
202
|
+
def _reset_model(self):
|
|
203
|
+
"""Reset the model"""
|
|
204
|
+
self.model = self.model.reset()
|
|
205
|
+
|
|
206
|
+
def invoke_query(self,query: str,file_path: str = None,get_content_only: bool = True,images: list = None,pydantic_model = None) -> str:
|
|
166
207
|
"""
|
|
167
208
|
Invoke the model
|
|
168
209
|
Args:
|
|
169
210
|
query (str): Query to send to the model
|
|
211
|
+
file_path (str): Path to text file to load. Default is None
|
|
170
212
|
get_content_only (bool): Whether to return only content
|
|
171
213
|
images (list): List of images to send to the model
|
|
172
214
|
pydantic_model: Pydantic model for structured output
|
|
173
215
|
Returns:
|
|
174
216
|
str: Response from the model
|
|
175
217
|
"""
|
|
176
|
-
|
|
218
|
+
if file_path:
|
|
219
|
+
loader = TextLoader(file_path)
|
|
220
|
+
document = loader.load()
|
|
221
|
+
query = document.content
|
|
222
|
+
|
|
177
223
|
if pydantic_model is not None:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
224
|
+
if hasattr(self.model, 'with_structured_output'):
|
|
225
|
+
try:
|
|
226
|
+
self.model = self.model.with_structured_output(pydantic_model)
|
|
227
|
+
except Exception as e:
|
|
228
|
+
raise ValueError(f"Error with pydantic_model: {e}")
|
|
182
229
|
if images:
|
|
183
230
|
res = self._model_invoke_images(images=images,prompt=query,pydantic_model=pydantic_model)
|
|
184
231
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|