mb-rag 1.1.8__tar.gz → 1.1.9__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.
Potentially problematic release.
This version of mb-rag might be problematic. Click here for more details.
- {mb_rag-1.1.8 → mb_rag-1.1.9}/PKG-INFO +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/chatbot/basic.py +17 -6
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/version.py +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag.egg-info/PKG-INFO +1 -1
- {mb_rag-1.1.8 → mb_rag-1.1.9}/README.md +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/chatbot/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/chatbot/chains.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/chatbot/prompts.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/rag/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/rag/embeddings.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/utils/__init__.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/utils/bounding_box.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag/utils/extra.py +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag.egg-info/SOURCES.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag.egg-info/dependency_links.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag.egg-info/requires.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/mb_rag.egg-info/top_level.txt +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/pyproject.toml +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/setup.cfg +0 -0
- {mb_rag-1.1.8 → mb_rag-1.1.9}/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
|
|
@@ -162,23 +163,33 @@ class ModelFactory:
|
|
|
162
163
|
kwargs["model"] = model_name
|
|
163
164
|
return ChatGroq(**kwargs)
|
|
164
165
|
|
|
165
|
-
def
|
|
166
|
+
def _reset_model(self):
|
|
167
|
+
"""Reset the model"""
|
|
168
|
+
self.model = self.model.reset()
|
|
169
|
+
|
|
170
|
+
def invoke_query(self,query: str,file_path: str = None,get_content_only: bool = True,images: list = None,pydantic_model = None) -> str:
|
|
166
171
|
"""
|
|
167
172
|
Invoke the model
|
|
168
173
|
Args:
|
|
169
174
|
query (str): Query to send to the model
|
|
175
|
+
file_path (str): Path to text file to load. Default is None
|
|
170
176
|
get_content_only (bool): Whether to return only content
|
|
171
177
|
images (list): List of images to send to the model
|
|
172
178
|
pydantic_model: Pydantic model for structured output
|
|
173
179
|
Returns:
|
|
174
180
|
str: Response from the model
|
|
175
181
|
"""
|
|
176
|
-
|
|
182
|
+
if file_path:
|
|
183
|
+
loader = TextLoader(file_path)
|
|
184
|
+
document = loader.load()
|
|
185
|
+
query = document.content
|
|
186
|
+
|
|
177
187
|
if pydantic_model is not None:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
if hasattr(self.model, 'with_structured_output'):
|
|
189
|
+
try:
|
|
190
|
+
self.model = self.model.with_structured_output(pydantic_model)
|
|
191
|
+
except Exception as e:
|
|
192
|
+
raise ValueError(f"Error with pydantic_model: {e}")
|
|
182
193
|
if images:
|
|
183
194
|
res = self._model_invoke_images(images=images,prompt=query,pydantic_model=pydantic_model)
|
|
184
195
|
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
|