beekeeper-ai 0.6.5__py3-none-any.whl → 1.0.0__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.
Files changed (41) hide show
  1. beekeeper/_bundle/__init__.py +0 -0
  2. beekeeper_ai-1.0.0.dist-info/METADATA +41 -0
  3. beekeeper_ai-1.0.0.dist-info/RECORD +5 -0
  4. {beekeeper_ai-0.6.5.dist-info → beekeeper_ai-1.0.0.dist-info}/WHEEL +1 -1
  5. beekeeper_ai-1.0.0.dist-info/licenses/LICENSE +176 -0
  6. beekeeper/__init__.py +0 -1
  7. beekeeper/core/document/__init__.py +0 -6
  8. beekeeper/core/document/schema.py +0 -97
  9. beekeeper/core/document_loaders/__init__.py +0 -5
  10. beekeeper/core/document_loaders/base.py +0 -24
  11. beekeeper/core/embeddings/__init__.py +0 -6
  12. beekeeper/core/embeddings/base.py +0 -44
  13. beekeeper/core/text_splitters/utils.py +0 -142
  14. beekeeper/core/utils/pairwise.py +0 -20
  15. beekeeper/document_loaders/__init__.py +0 -17
  16. beekeeper/document_loaders/directory.py +0 -65
  17. beekeeper/document_loaders/docx.py +0 -31
  18. beekeeper/document_loaders/html.py +0 -77
  19. beekeeper/document_loaders/json.py +0 -53
  20. beekeeper/document_loaders/pdf.py +0 -38
  21. beekeeper/document_loaders/s3.py +0 -72
  22. beekeeper/document_loaders/watson_discovery.py +0 -121
  23. beekeeper/embeddings/__init__.py +0 -7
  24. beekeeper/embeddings/huggingface.py +0 -66
  25. beekeeper/embeddings/watsonx.py +0 -100
  26. beekeeper/evaluation/__init__.py +0 -5
  27. beekeeper/evaluation/knowledge_base_coverage.py +0 -62
  28. beekeeper/monitor/__init__.py +0 -11
  29. beekeeper/monitor/watsonx.py +0 -843
  30. beekeeper/retrievers/__init__.py +0 -5
  31. beekeeper/retrievers/watson_discovery.py +0 -121
  32. beekeeper/text_splitters/__init__.py +0 -9
  33. beekeeper/text_splitters/semantic.py +0 -139
  34. beekeeper/text_splitters/sentence.py +0 -107
  35. beekeeper/text_splitters/token.py +0 -101
  36. beekeeper/vector_stores/__init__.py +0 -7
  37. beekeeper/vector_stores/chroma.py +0 -115
  38. beekeeper/vector_stores/elasticsearch.py +0 -183
  39. beekeeper_ai-0.6.5.dist-info/LICENSE +0 -7
  40. beekeeper_ai-0.6.5.dist-info/METADATA +0 -49
  41. beekeeper_ai-0.6.5.dist-info/RECORD +0 -37
@@ -1,183 +0,0 @@
1
- import uuid
2
- from logging import getLogger
3
- from typing import List, Literal
4
-
5
- from beekeeper.core.document import Document, DocumentWithScore
6
- from beekeeper.core.embeddings import BaseEmbedding
7
-
8
- logger = getLogger(__name__)
9
-
10
-
11
- class ElasticsearchVectorStore:
12
- """Provides functionality to interact with Elasticsearch for storing and querying document embeddings.
13
-
14
- Args:
15
- index_name (str): Name of the Elasticsearch index.
16
- url (str): Elasticsearch instance url.
17
- user (str): Elasticsearch username.
18
- password (str): Elasticsearch password.
19
- dims_length (int): Length of the embedding dimensions.
20
- embed_model (BaseEmbedding):
21
- batch_size (int, optional): Batch size for bulk operations. Defaults to ``200``.
22
- ssl (bool, optional): Whether to use SSL. Defaults to ``False``.
23
- distance_strategy (str, optional): Distance strategy for similarity search. Currently supports "cosine", "dot_product" and "l2_norm". Defaults to ``cosine``.
24
- text_field (str, optional): Name of the field containing text. Defaults to ``text``.
25
- vector_field (str, optional): Name of the field containing vector embeddings. Defaults to ``embedding``.
26
- """
27
-
28
- def __init__(self,
29
- index_name: str,
30
- url: str,
31
- user: str,
32
- password: str,
33
- dims_length: int,
34
- embed_model: BaseEmbedding,
35
- batch_size: int = 200,
36
- ssl: bool = False,
37
- distance_strategy: Literal["cosine", "dot_product", "l2_norm"] = "cosine",
38
- text_field: str = "text",
39
- vector_field: str = "embedding",
40
- ) -> None:
41
- try:
42
- from elasticsearch import Elasticsearch
43
- from elasticsearch.helpers import bulk
44
-
45
- self._es_bulk = bulk
46
- except ImportError:
47
- raise ImportError("elasticsearch package not found, please install it with `pip install elasticsearch`")
48
-
49
- # TO-DO: Add connections types e.g: cloud
50
- self._embed_model = embed_model
51
- self.index_name = index_name
52
- self.batch_size = batch_size
53
- self.dims_length = dims_length
54
- self.distance_strategy = distance_strategy
55
- self.vector_field = vector_field
56
- self.text_field = text_field
57
-
58
- self._client = Elasticsearch(
59
- hosts=[url],
60
- basic_auth=(
61
- user,
62
- password
63
- ),
64
- verify_certs=ssl,
65
- ssl_show_warn=False
66
- )
67
-
68
- try:
69
- self._client.info()
70
- except Exception as e:
71
- logger.error(f"Error connecting to Elasticsearch: {e}")
72
- raise
73
-
74
- def _create_index_if_not_exists(self) -> None:
75
- """Creates the Elasticsearch index if it doesn't already exist."""
76
- if self._client.indices.exists(index=self.index_name):
77
- logger.info(f"Index {self.index_name} already exists. Skipping creation.")
78
-
79
- else:
80
- if self.dims_length is None:
81
- raise ValueError(
82
- "Cannot create index without specifying dims_length. "
83
- "When the index doesn't already exist."
84
- )
85
-
86
- index_mappings = {
87
- "properties": {
88
- self.text_field: {"type": "text"},
89
- self.vector_field: {
90
- "type": "dense_vector",
91
- "dims": self.dims_length,
92
- "index": True,
93
- "similarity": self.distance_strategy,
94
- },
95
- "metadata": {
96
- "properties": {
97
- "creation_date": {"type": "keyword"},
98
- "filename": {"type": "keyword"},
99
- "file_type": {"type": "keyword"},
100
- "page": {"type": "keyword"},
101
- }
102
- }
103
- }
104
- }
105
-
106
- print(f"Creating index {self.index_name}")
107
-
108
- self._client.indices.create(index=self.index_name, mappings=index_mappings)
109
-
110
- def add_documents(self, documents: List[Document], create_index_if_not_exists: bool = True) -> None:
111
- """Add documents to the Elasticsearch index.
112
-
113
- Args:
114
- documents (List[Document]): List of `Document` objects to add to the index.
115
- create_index_if_not_exists (bool, optional): Whether to create the index if it doesn't exist. Defaults to ``True``.
116
- """
117
- if create_index_if_not_exists:
118
- self._create_index_if_not_exists()
119
-
120
- vector_store_data = []
121
- for doc in documents:
122
- _id = doc.doc_id if doc.doc_id else str(uuid.uuid4())
123
- _metadata = doc.get_metadata()
124
- vector_store_data.append({
125
- "_index": self.index_name,
126
- "_id": _id,
127
- self.text_field: doc.get_content(),
128
- self.vector_field: self._embed_model.get_query_embedding(doc.get_content()),
129
- "metadata": _metadata,
130
- "metadata.creation_date": _metadata["creation_date"] if _metadata["creation_date"] else None,
131
- "metadata.filename": _metadata["filename"] if _metadata["filename"] else None,
132
- "metadata.file_type": _metadata["file_type"] if _metadata["file_type"] else None,
133
- "metadata.page": _metadata["page"] if _metadata["page"] else None,
134
- })
135
-
136
- self._es_bulk(self._client, vector_store_data, chunk_size=self.batch_size, refresh=True)
137
- print(f"Added {len(vector_store_data)} documents to `{self.index_name}`")
138
-
139
- def query(self, query: str, top_k: int = 4) -> List[DocumentWithScore]:
140
- """Performs a similarity search for top-k most similar documents.
141
-
142
- Args:
143
- query (str): Query text.
144
- top_k (int, optional): Number of top results to return. Defaults to ``4``.
145
- """
146
- query_embedding = self._embed_model.get_query_embedding(query)
147
- # TO-DO: Add elasticsearch `filter` option
148
- es_query = {"knn": {
149
- # "filter": filter,
150
- "field": self.vector_field,
151
- "query_vector": query_embedding,
152
- "k": top_k,
153
- "num_candidates": top_k * 10,
154
- }}
155
-
156
- results = self._client.search(index=self.index_name,
157
- **es_query,
158
- size=top_k,
159
- _source={"excludes": [self.vector_field]})
160
-
161
- hits = results["hits"]["hits"]
162
-
163
- return [DocumentWithScore(
164
- document=Document(
165
- doc_id=hit["_id"],
166
- text=hit["_source"]["text"],
167
- metadata=hit["_source"]["metadata"],
168
- ),
169
- score=hit["_score"])
170
- for hit in hits
171
- ]
172
-
173
- def delete_documents(self, ids: List[str] = None) -> None:
174
- """Delete documents from the Elasticsearch index.
175
-
176
- Args:
177
- ids (List[str]): List of `Document` IDs to delete.
178
- """
179
- if not ids:
180
- raise ValueError("No ids provided to delete.")
181
-
182
- for id in ids:
183
- self._client.delete(index=self.index_name, id=id)
@@ -1,7 +0,0 @@
1
- Copyright 2024 Leonardo Furnielis
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,49 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: beekeeper-ai
3
- Version: 0.6.5
4
- Summary: Load any data in one line of code and connect with AI applications
5
- Home-page: https://github.com/leonardofurnielis/beekeeper
6
- License: MIT
7
- Keywords: AI,LLM,QA,RAG,data,monitor,retrieval,semantic-search
8
- Author: Leonardo Furnielis
9
- Author-email: leonardofurnielis@outlook.com
10
- Requires-Python: >=3.10,<4.0
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.10
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 :: Application Frameworks
20
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Requires-Dist: nltk (>=3.8.1,<4.0.0)
22
- Requires-Dist: numpy (>=1.26.4,<2.0.0)
23
- Requires-Dist: pydantic (>=2.7.1,<3.0.0)
24
- Requires-Dist: sentence-transformers (>=2.7.0,<3.0.0)
25
- Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
26
- Requires-Dist: torch (==2.1.0)
27
- Project-URL: Documentation, https://leonardofurnielis.github.io/beekeeper
28
- Project-URL: Repository, https://github.com/leonardofurnielis/beekeeper
29
- Description-Content-Type: text/markdown
30
-
31
- # Beekeeper
32
-
33
- ![PyPI - Version](https://img.shields.io/pypi/v/beekeeper-ai)
34
- [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
35
- ![PyPI - Downloads](https://img.shields.io/pypi/dm/beekeeper-ai)
36
- ![PyPI - License](https://img.shields.io/pypi/l/beekeeper-ai)
37
-
38
- ## Installation
39
-
40
- ```bash
41
- pip install beekeeper-ai
42
- ```
43
-
44
- ## 📄 Documentation
45
-
46
- The documentation can be found Click [here](https://leonardofurnielis.github.io/beekeeper)!
47
-
48
- Please check it out for overview of the interfaces, components, integrations and other resources!
49
-
@@ -1,37 +0,0 @@
1
- beekeeper/__init__.py,sha256=KDgkBrBsBSUzbLgrOZ89YsNN06fU4j5bmcuEwo6q5pg,22
2
- beekeeper/core/document/__init__.py,sha256=6l28uskkwzxQhnX_Ov9NmXQ3JAF5vXJk6cuQR3zRqwg,126
3
- beekeeper/core/document/schema.py,sha256=72jWAkBAU8DtRA90jYdhbUqax1a0Yx76NgAYxQj6UFU,2534
4
- beekeeper/core/document_loaders/__init__.py,sha256=OH0Y6Nf66bdi8vv_o-dldndHhmfM74y8s9ilgvG_Crk,93
5
- beekeeper/core/document_loaders/base.py,sha256=ojJ4cC2H47hJUbDPwfAK-QXihrjjBjBUq4N0vTHwaZM,581
6
- beekeeper/core/embeddings/__init__.py,sha256=y5mtk3vSn4toM9z-zYRtagYHJiiTcNUdxuT6EBuoYto,121
7
- beekeeper/core/embeddings/base.py,sha256=JjtSs_RyGMZgSLwKUYlLt5snBrE3gNIqvwjC8ySGb9w,1326
8
- beekeeper/core/text_splitters/utils.py,sha256=5bDbTr_NLeTyJBIUjnsd4Jm9DkAbzR3EjvK3dF0R3iQ,4544
9
- beekeeper/core/utils/pairwise.py,sha256=G4ud6yGtDIuwVeQ9uv9tX8kISXYbPV73_DOjko8TdX4,542
10
- beekeeper/document_loaders/__init__.py,sha256=VOQI6bSNNw76y_wOrw7v8wu424w1Rya6ld_fPJDOuIk,566
11
- beekeeper/document_loaders/directory.py,sha256=wp8XhrlzyaPZGH3JUIgD0wgtprsI4RDFkli3vOw6A2M,2245
12
- beekeeper/document_loaders/docx.py,sha256=EQ9WLdhUnxsqnztMJVTYO6MtyoJx5z_pRO4VL9a294I,990
13
- beekeeper/document_loaders/html.py,sha256=JpYQFrjl7nGLLaypPfhQNmDYwB1I-m7rfqTqf90V8Eo,2408
14
- beekeeper/document_loaders/json.py,sha256=r4qprhL66UFA8dN_NbSa7y5jxXEs7ULvfxfVhAf0aYQ,1672
15
- beekeeper/document_loaders/pdf.py,sha256=A6fuSieakWiVA5RjSUsTqJ8FMllMNujSrSlIPLWH7CU,1194
16
- beekeeper/document_loaders/s3.py,sha256=iTdjPIxP8nF3Zeehtqq7xplQfB8CmF8TDD56pv5E-pQ,2545
17
- beekeeper/document_loaders/watson_discovery.py,sha256=eIR4mYARMck3S9q-mMOPX1X5BYqEL7ePH-50emz6HE0,4880
18
- beekeeper/embeddings/__init__.py,sha256=enRONiVzIgDSpxcQshBKrqNQD8tQ7JACzHzowcL_N1w,190
19
- beekeeper/embeddings/huggingface.py,sha256=wmKnEyTzLlf_MtmKjUFiULZjxRk5RJ_W-_4YC6ifcAQ,2176
20
- beekeeper/embeddings/watsonx.py,sha256=w7Fbz74B_XDLu7aE9_haXI77oCUyFLhrSFgHuMCZ3qg,3605
21
- beekeeper/evaluation/__init__.py,sha256=SzRQHkUqgzRoiccHknu0juMutSyF1dI_-AeuBZOCe_E,123
22
- beekeeper/evaluation/knowledge_base_coverage.py,sha256=YkjrqQAmUU7ul0ZVcO7MN62EIkk-nMKQCRF-HD19WmU,2268
23
- beekeeper/monitor/__init__.py,sha256=Zgx2OaGiid3pnNnBrI-YjCNE0KdWX3g3sOhbCEhhYY8,258
24
- beekeeper/monitor/watsonx.py,sha256=LG16TpKVNV5N5gCKNMQZKZZqaqNdFJTHitrEXGB_W0g,42567
25
- beekeeper/retrievers/__init__.py,sha256=Py1X7DfxNyMozQX1LBl0jSZyft05OD04yglqBVpP3mQ,122
26
- beekeeper/retrievers/watson_discovery.py,sha256=evn9MGBUE2WkL7r_mg1zlSNZpp7XuxfG0HgeDiSeUyU,5121
27
- beekeeper/text_splitters/__init__.py,sha256=HkRHuwi-v5Xtwnr3ELkf_eG9WfXtuq3FFf_Zn8QUOuE,275
28
- beekeeper/text_splitters/semantic.py,sha256=4dK5cY5ZI4uXJhr9xcc6njPnytMlEWs9GvFEEBErGGk,5292
29
- beekeeper/text_splitters/sentence.py,sha256=F4PhqN_Q4MdNF-CDmS03Q4I9OuecTLhMOnFvqA8dzR8,3399
30
- beekeeper/text_splitters/token.py,sha256=HgGf7V_RHvkl0C_Jmjr0pgdAqmcI9qKBeVqDEb-6SXc,3138
31
- beekeeper/vector_stores/__init__.py,sha256=sH7pUh-3ln9EzZOJm4mz2z1BJFqJStsuogl-XvuatvQ,208
32
- beekeeper/vector_stores/chroma.py,sha256=89ebsNs4JYCpM6SYY6pYy2nuH5gv4TxjxMrz729XE1w,3997
33
- beekeeper/vector_stores/elasticsearch.py,sha256=GTLCvxv8ne-S3fEG8HcONlpagJ1o5PJxtdE_JoM4aTs,7318
34
- beekeeper_ai-0.6.5.dist-info/LICENSE,sha256=TC5Fo1FSsyuLJTlNFbY0zCa08wcY5OmMW3RdKOId37s,1071
35
- beekeeper_ai-0.6.5.dist-info/METADATA,sha256=pXUun_4zd5L9JoFqkam-YtBBF1oWPy7Qmf-oTpE0kZY,1962
36
- beekeeper_ai-0.6.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
37
- beekeeper_ai-0.6.5.dist-info/RECORD,,