ai-parrot 0.5.9__cp311-cp311-manylinux_2_28_x86_64.whl → 0.5.11__cp311-cp311-manylinux_2_28_x86_64.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.

Potentially problematic release.


This version of ai-parrot might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ai-parrot
3
- Version: 0.5.9
3
+ Version: 0.5.11
4
4
  Summary: Live Chatbots based on Langchain chatbots and Agents Integrated into Navigator Framework or used into any aiohttp applications.
5
5
  Home-page: https://github.com/phenobarbital/ai-parrot
6
6
  Author: Jesus Lara
@@ -4,14 +4,14 @@ parrot/exceptions.cpython-311-x86_64-linux-gnu.so,sha256=1tKBneucxl6ShNqI8KS4-pa
4
4
  parrot/manager.py,sha256=E1OdoNnZh1qCqVgZzcp8rdRnE1-xRwyQ6d1nFcOmg3U,6527
5
5
  parrot/models.py,sha256=MT88rYdITenwTuyCfeqHqaNf49rieAKz43R2TibN7G8,14314
6
6
  parrot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- parrot/version.py,sha256=uuGJi_QomqOL8oXXvwTsmEi7k1OjqnC5QmKhiQZmywE,377
7
+ parrot/version.py,sha256=C4CZL3SltVkkn8Nf0SUBHRIqD7QqcJGmj5peRWKjzsM,378
8
8
  parrot/bots/__init__.py,sha256=qD-WOn8n34VUCp7Mq6Mq1lZV8h_cKAeXQxn27UtBDP4,153
9
- parrot/bots/abstract.py,sha256=mmMEs9O_a7VJ9nx_IgvTqS7pMFML0U8sLnGaW5Qst0A,35790
9
+ parrot/bots/abstract.py,sha256=8Oq47Cjt5-TAAdeyS3-JQd9FwPOumT2U6IIFMFXp02k,35886
10
10
  parrot/bots/agent.py,sha256=2v_5hQ3XCvCPpwTne7t-NDUpX3na1LIwXfufT-cK9LU,13432
11
11
  parrot/bots/base.py,sha256=Wl2BXRzxdGsWdHltAi0jalIPPAiM0TkVIHkRc1HQ99I,13422
12
12
  parrot/bots/basic.py,sha256=dg2kT_ynMEtZ3cMTcSovmDwrOo7BhBwL1o-Nn_7I85A,235
13
13
  parrot/bots/bose.py,sha256=gQQzAgt6wxGshihdr5H9_G4ns0lth814IkL7x1Ukjd4,759
14
- parrot/bots/chatbot.py,sha256=uvTCgTSCsbGRz2BZbk0Ueca3Lvzl_tBj4eUfqon0AQQ,10106
14
+ parrot/bots/chatbot.py,sha256=E7pz0duU2-qrbo9QzvwM_Gfw2OtpcWziXvEZmfWfPeo,10201
15
15
  parrot/bots/cody.py,sha256=gPQPRcn7QNJfTF0zWI9i6K-PhyAG6PBVcoCxdvylRdI,616
16
16
  parrot/bots/copilot.py,sha256=PDK1Hj3TmxHgZT0rAplMnbbDkmV51B9tTstWWQjsLFM,2795
17
17
  parrot/bots/dataframe.py,sha256=CfZiLKIwnaku52nl2PNjciqRlH8m2lM4buO6xI7P408,3914
@@ -24,7 +24,7 @@ parrot/bots/prompts/__init__.py,sha256=rm_rAX7ZIxDIpSVOjHVuHRLMI9wS3avsu5fUfwAsd
24
24
  parrot/bots/prompts/agents.py,sha256=nXmzmRG15jiTDnjhmZ8ljSYCB1xU4RwsayZThFSj0Zg,4310
25
25
  parrot/bots/retrievals/__init__.py,sha256=AgI0mTB27tZ0Oyr7RU63G-ZO1VyX-uCJ6lwxgP4baag,45
26
26
  parrot/bots/retrievals/constitutional.py,sha256=x7kFR0KpmkR0Wz6bXNOeU3Hesn_EXc6eOSd4TdXxb8o,600
27
- parrot/bots/retrievals/multi.py,sha256=km1zaE2ialNYYjY5f9CrhNeA44SNeUlJ7wRUCL2yb4w,1790
27
+ parrot/bots/retrievals/multi.py,sha256=gVsGIM6ynqDFdqryrEyQg6yYXIN3uGwAGby9fvacl_w,3667
28
28
  parrot/bots/retrievals/retrieval.py,sha256=wvMM53k76njV5b6t6CCKiYVk2o81JCHzCNmlHBKYFMg,20622
29
29
  parrot/chatbots/__init__.py,sha256=ypskCnME0xUv6psBEGCEyXCrD0J0ULHSllpVmSxqb4A,200
30
30
  parrot/chatbots/abstract.py,sha256=CmDn3k4r9uKImOZRN4L9zxLbCdC-1MPUAorDlfZT-kA,26421
@@ -101,12 +101,12 @@ parrot/loaders/handlers/data.py,sha256=olZ2p-wyUMGoazah7tgHY7V9buGX1FOeJ-cv2vGEo
101
101
  parrot/loaders/utils/__init__.py,sha256=SkDyK3MuPGhp0NM6kHvaxQDe97Gcl3n9t5A741OVh1c,28
102
102
  parrot/loaders/utils/models.py,sha256=BHcnFzS7oOKUGG-vPy_TlqeFNAC8puRgsIMX2mSgKxY,1059
103
103
  parrot/stores/__init__.py,sha256=W7Ggvvxw4Dn13IWbuXaT0KTTJJORpvLtTKuaajNUxNA,264
104
- parrot/stores/abstract.py,sha256=1ixPyClc8gaiafl3ZW7KtmwZTgVACFleF73DwzFsamk,7186
104
+ parrot/stores/abstract.py,sha256=esoNpgcA_07RS3z2Qm7RtQd7pfKbhLoJMztoDwC_c1k,7387
105
105
  parrot/stores/chroma.py,sha256=UbPNs6P1o8BnUA0B_IwQ6n89VuZt7H2j0FpNmK22Ids,5932
106
106
  parrot/stores/duck.py,sha256=FTDV2HJb580ojVNBdUrC1ukuDUTyk4qUwF-LaN-IbWA,4740
107
107
  parrot/stores/empty.py,sha256=bCQJt54YPpR_pN9uHA2VA95GPPp04daMBJHbHQsRY0Q,234
108
108
  parrot/stores/faiss.py,sha256=tbur-YM7ictMh9S65Tc6WGK88JBkunQqES98w27CBtE,5694
109
- parrot/stores/milvus.py,sha256=Bi2geRA8yT0ux_DeYo436U38qth-Obpp_HN_NmPWRZ8,13209
109
+ parrot/stores/milvus.py,sha256=rRM-oODKsTIEKiFBcygchqxpC94am2TLgbE0gw0NfJg,13275
110
110
  parrot/stores/postgres.py,sha256=7mZ4l8EKcTMegWw6ooI9nfIUCdlutMCzJfQ0ULQFh6k,24908
111
111
  parrot/stores/qdrant.py,sha256=u07DUoFHWDf-IU5tHbhinhMjPGWFgUbzaBhT_lWrvCA,6003
112
112
  parrot/stores/embeddings/__init__.py,sha256=ZQPpLBhiBx27Q5FhB_v-Vibcq3rHEP7x9GXfn_LGFOc,283
@@ -144,8 +144,8 @@ resources/users/handlers.py,sha256=BGzqBvPY_OaIF_nONWX4b_B5OyyBrdGuSihIsdlFwjk,2
144
144
  resources/users/models.py,sha256=glk7Emv7QCi6i32xRFDrGc8UwK23_LPg0XUOJoHnwRU,6799
145
145
  settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
146
  settings/settings.py,sha256=9ueEvyLNurUX-AaIeRPV8GKX1c4YjDLbksUAeqEq6Ck,1854
147
- ai_parrot-0.5.9.dist-info/LICENSE,sha256=vRKOoa7onTsLNvSzJtGtMaNhWWh8B3YAT733Tlu6M4o,1070
148
- ai_parrot-0.5.9.dist-info/METADATA,sha256=kyo9XvvUMJ8Nhi8w-nD4P-Q2TFseOPbmjs9H9PxEx5g,9715
149
- ai_parrot-0.5.9.dist-info/WHEEL,sha256=lNWVJ6q28SO2kTKDIyc1kQ-4wE2w5snxBQXSv06oiUw,113
150
- ai_parrot-0.5.9.dist-info/top_level.txt,sha256=VCLpdIu_5wkShgIQjK85jFzL9HEVVjAqlQa_gupLekI,17
151
- ai_parrot-0.5.9.dist-info/RECORD,,
147
+ ai_parrot-0.5.11.dist-info/LICENSE,sha256=vRKOoa7onTsLNvSzJtGtMaNhWWh8B3YAT733Tlu6M4o,1070
148
+ ai_parrot-0.5.11.dist-info/METADATA,sha256=3cT8zN64WE4sXyaO5CwVAe5WkLs7-UHsrojIY7jy3bU,9716
149
+ ai_parrot-0.5.11.dist-info/WHEEL,sha256=lNWVJ6q28SO2kTKDIyc1kQ-4wE2w5snxBQXSv06oiUw,113
150
+ ai_parrot-0.5.11.dist-info/top_level.txt,sha256=VCLpdIu_5wkShgIQjK85jFzL9HEVVjAqlQa_gupLekI,17
151
+ ai_parrot-0.5.11.dist-info/RECORD,,
parrot/bots/abstract.py CHANGED
@@ -466,6 +466,7 @@ class AbstractBot(DBInterface, ABC):
466
466
 
467
467
  def configure_store(self, **kwargs):
468
468
  # TODO: Implement VectorStore Configuration
469
+ print('SELF > ', self._vector_store)
469
470
  if isinstance(self._vector_store, list):
470
471
  # Is a list of vector stores instances:
471
472
  for st in self._vector_store:
@@ -959,6 +960,7 @@ class AbstractBot(DBInterface, ABC):
959
960
  return_messages=True
960
961
  )
961
962
  async with self.store as store: #pylint: disable=E1101
963
+ print('STORES > ', self.stores, store)
962
964
  if self._use_vector:
963
965
  if len(self.stores) > 1:
964
966
  retriever = MultiVectorStoreRetriever(
parrot/bots/chatbot.py CHANGED
@@ -244,6 +244,9 @@ class Chatbot(AbstractBot):
244
244
  vector_db = database.pop('vector_database', None)
245
245
  # configure vector database:
246
246
  if vector_db:
247
+ # Initialize the store:
248
+ self.stores = []
249
+ self.store = None
247
250
  self._use_vector = vector_store
248
251
  self._vector_store = database
249
252
  self.configure_store()
@@ -1,50 +1,102 @@
1
- from typing import List
2
- from collections.abc import Callable
3
- from langchain.schema import Document
1
+ from typing import List, Dict, Any, Optional
2
+ from langchain_core.retrievers import BaseRetriever
3
+ from langchain_core.callbacks import CallbackManagerForRetrieverRun
4
+ from langchain_core.documents import Document
4
5
 
5
- class MultiVectorStoreRetriever:
6
+
7
+ class MultiVectorStoreRetriever(BaseRetriever):
6
8
  """
7
9
  This aggregator retriever queries multiple vector stores
8
10
  and merges the results into a single list.
9
11
  """
10
12
 
13
+ stores: List[Any]
14
+ search_kwargs: Dict[str, Any]
15
+ chain_type: str
16
+ search_type: str
17
+ metric_type: str
18
+
11
19
  def __init__(
12
20
  self,
13
- stores: List[Callable],
21
+ stores: List[Any],
14
22
  metric_type: str = 'COSINE',
15
23
  chain_type: str = 'stuff',
16
24
  search_type: str = 'similarity',
17
- search_kwargs: dict = None,
25
+ search_kwargs: Optional[Dict[str, Any]] = None,
18
26
  ):
19
27
  """
20
- stores: List of AbstractStore or anything that provides an as_retriever() method
21
- search_kwargs: dict to pass on to each store's retrieve method (like 'k' for top_k)
28
+ Initialize the MultiVectorStoreRetriever.
29
+
30
+ Args:
31
+ stores: List of vector stores that provide an as_retriever() method
32
+ metric_type: Similarity metric (COSINE, EUCLIDEAN, DOT_PRODUCT)
33
+ chain_type: Chain type for the retriever
34
+ search_type: Search type (similarity, mmr)
35
+ search_kwargs: Dict to pass to each store's retrieve method (like 'k' for top_k)
22
36
  """
37
+ super().__init__()
23
38
  self.stores = stores
24
39
  self.search_kwargs = search_kwargs or {}
25
40
  self.chain_type = chain_type
26
41
  self.search_type = search_type
27
42
  self.metric_type = metric_type
28
43
 
29
- def get_relevant_documents(self, query: str) -> List[Document]:
44
+ def _get_relevant_documents(
45
+ self, query: str, *, run_manager: CallbackManagerForRetrieverRun
46
+ ) -> List[Document]:
47
+ """
48
+ Get documents relevant to the query.
49
+ Implements the required method from BaseRetriever.
50
+
51
+ Args:
52
+ query: Query string
53
+ run_manager: CallbackManager for the run
54
+
55
+ Returns:
56
+ List of relevant documents
57
+ """
30
58
  all_results = []
31
59
  for store in self.stores:
32
- retriever = store.as_retriever(**self.search_kwargs)
33
- docs = retriever.get_relevant_documents(query)
60
+ retriever = store.as_retriever(
61
+ search_type=self.search_type,
62
+ search_kwargs=self.search_kwargs,
63
+ chain_type=self.chain_type
64
+ )
65
+ # Pass the run_manager to the sub-retrievers if they support it
66
+ if hasattr(retriever, "_get_relevant_documents"):
67
+ callback_manager = run_manager.get_child()
68
+ docs = retriever._get_relevant_documents(query, run_manager=callback_manager)
69
+ else:
70
+ docs = retriever.get_relevant_documents(query)
34
71
  all_results.extend(docs)
35
72
  return all_results
36
73
 
37
- async def aget_relevant_documents(self, query: str) -> List[Document]:
38
- # Async version
74
+ async def _aget_relevant_documents(
75
+ self, query: str, *, run_manager: CallbackManagerForRetrieverRun
76
+ ) -> List[Document]:
77
+ """
78
+ Asynchronously get documents relevant to the query.
79
+ Implements the required async method from BaseRetriever.
80
+
81
+ Args:
82
+ query: Query string
83
+ run_manager: CallbackManager for the run
84
+
85
+ Returns:
86
+ List of relevant documents
87
+ """
39
88
  all_results = []
40
89
  for store in self.stores:
41
- async with store as st:
42
- retriever = st.as_retriever(
43
- search_type=self.search_type,
44
- search_kwargs=self.search_kwargs,
45
- metric_type=self.metric_type,
46
- chain_type=self.chain_type,
47
- )
90
+ retriever = store.as_retriever(
91
+ search_type=self.search_type,
92
+ search_kwargs=self.search_kwargs,
93
+ chain_type=self.chain_type
94
+ )
95
+ # Pass the run_manager to the sub-retrievers if they support it
96
+ if hasattr(retriever, "_aget_relevant_documents"):
97
+ callback_manager = run_manager.get_child()
98
+ docs = await retriever._aget_relevant_documents(query, run_manager=callback_manager)
99
+ else:
48
100
  docs = await retriever.aget_relevant_documents(query)
49
- all_results.extend(docs)
101
+ all_results.extend(docs)
50
102
  return all_results
parrot/stores/abstract.py CHANGED
@@ -230,11 +230,16 @@ class AbstractStore(ABC):
230
230
  def as_retriever(
231
231
  self,
232
232
  metric_type: str = 'COSINE',
233
+ index_type: str = 'IVF_FLAT',
233
234
  search_type: str = 'similarity',
234
235
  chain_type: str = 'stuff',
235
236
  search_kwargs: dict = None
236
237
  ) -> Callable:
237
- vector = self.get_vector(metric_type=metric_type)
238
+ vector = self.get_vector(metric_type=metric_type, index_type=index_type)
239
+ if not vector:
240
+ raise ConfigError(
241
+ "Vector Store is not connected. Check your connection."
242
+ )
238
243
  return VectorStoreRetriever(
239
244
  vectorstore=vector,
240
245
  search_type=search_type,
parrot/stores/milvus.py CHANGED
@@ -251,6 +251,7 @@ class MilvusStore(AbstractStore):
251
251
  self,
252
252
  collection: Union[str, None] = None,
253
253
  metric_type: str = None,
254
+ index_type: str = None,
254
255
  nprobe: int = 32,
255
256
  metadata_field: str = None,
256
257
  consistency_level: str = 'session'
@@ -261,10 +262,11 @@ class MilvusStore(AbstractStore):
261
262
  collection = self.collection_name
262
263
  if not metric_type:
263
264
  metric_type = self._metric_type or 'COSINE'
265
+ _idx = index_type or self._index_type
264
266
  _search = {
265
267
  "search_params": {
266
268
  "metric_type": metric_type,
267
- "index_type": self._index_type,
269
+ "index_type": _idx,
268
270
  "params": {"nprobe": nprobe, "nlist": 1024},
269
271
  }
270
272
  }
parrot/version.py CHANGED
@@ -3,7 +3,7 @@
3
3
  __title__ = "ai-parrot"
4
4
  __description__ = "Live Chatbots based on Langchain chatbots and Agents \
5
5
  Integrated into Navigator Framework or used into any aiohttp applications."
6
- __version__ = "0.5.9"
6
+ __version__ = "0.5.11"
7
7
  __author__ = "Jesus Lara"
8
8
  __author_email__ = "jesuslarag@gmail.com"
9
9
  __license__ = "MIT"