projectdavid 1.29.9__py3-none-any.whl → 1.38.1__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.
@@ -0,0 +1,64 @@
1
+ # decorators.py
2
+
3
+ import functools
4
+ import warnings
5
+ from typing import Optional
6
+
7
+
8
+ class ExperimentalWarning(UserWarning):
9
+ """
10
+ API is experimental, may be incomplete (and possibly not fully functional),
11
+ and may change or be removed without notice.
12
+ """
13
+
14
+
15
+ class InternalWarning(UserWarning):
16
+ """
17
+ API is internal/admin-only. Intended for framework authors and
18
+ superusers—will likely change or go away without notice.
19
+ """
20
+
21
+
22
+ def experimental(func):
23
+ """
24
+ Decorator to mark methods as experimental.
25
+ Emits an ExperimentalWarning on first call.
26
+ """
27
+
28
+ @functools.wraps(func)
29
+ def wrapper(*args, **kwargs):
30
+ warnings.warn(
31
+ f"{func.__name__} is experimental, may be incomplete, and may change in a future release",
32
+ ExperimentalWarning,
33
+ stacklevel=2,
34
+ )
35
+ return func(*args, **kwargs)
36
+
37
+ wrapper.__experimental__ = True
38
+ return wrapper
39
+
40
+
41
+ def internal(func):
42
+ """
43
+ Decorator to mark a method as internal/admin-only.
44
+ Raises PermissionError if self.is_admin is False or missing.
45
+ Emits an InternalWarning on use.
46
+ """
47
+
48
+ @functools.wraps(func)
49
+ def wrapper(self, *args, **kwargs):
50
+ # 1️⃣ Enforce admin
51
+ if not getattr(self, "is_admin", False):
52
+ raise PermissionError(
53
+ f"{func.__name__} is for admin use only; your client.is_admin is False."
54
+ )
55
+ # 2️⃣ Warn about internal usage
56
+ warnings.warn(
57
+ f"{func.__name__} is internal/admin-only and may change without notice",
58
+ InternalWarning,
59
+ stacklevel=2,
60
+ )
61
+ return func(self, *args, **kwargs)
62
+
63
+ wrapper.__internal__ = True
64
+ return wrapper
projectdavid/entity.py CHANGED
@@ -18,27 +18,44 @@ from .clients.users_client import UsersClient
18
18
  from .clients.vectors import VectorStoreClient
19
19
  from .utils.run_monitor import HttpRunMonitor
20
20
 
21
- # Load environment variables from .env file.
22
- load_dotenv()
23
-
24
21
  # Initialize logging utility.
25
22
  logging_utility = UtilsInterface.LoggingUtility()
26
23
 
27
24
 
25
+ class MissingAPIKeyError(ValueError):
26
+ """Raised when no API key is provided via arg or ENTITIES_API_KEY env var."""
27
+
28
+
28
29
  class Entity:
29
30
  def __init__(
30
31
  self,
31
32
  base_url: Optional[str] = None,
32
33
  api_key: Optional[str] = None,
34
+ file_processor_kwargs: Optional[dict] = None,
33
35
  ):
34
36
  """
35
37
  Initialize the main client with configuration.
36
38
  Optionally, a configuration object can be injected to decouple from environment variables.
37
39
  """
40
+
41
+ self.file_processor_kwargs = file_processor_kwargs
42
+
43
+ # -------- 1. Resolve key -------------------------------------------------
44
+ self.api_key = (
45
+ api_key
46
+ or os.getenv("ENTITIES_API_KEY") # new variable name
47
+ or os.getenv("API_KEY") # legacy support, if you like
48
+ )
49
+
50
+ if not self.api_key:
51
+ raise MissingAPIKeyError(
52
+ "No API key supplied. Set ENTITIES_API_KEY in your environment "
53
+ "or pass api_key='sk-...' when creating the client."
54
+ )
55
+
38
56
  self.base_url = base_url or os.getenv(
39
57
  "ENTITIES_BASE_URL", "http://localhost:9000/"
40
58
  )
41
- self.api_key = api_key or os.getenv("API_KEY", "your_api_key")
42
59
 
43
60
  logging_utility.info("Entity initialized with base_url: %s", self.base_url)
44
61
 
@@ -145,7 +162,9 @@ class Entity:
145
162
  def vectors(self) -> VectorStoreClient:
146
163
  if self._vectors_client is None:
147
164
  self._vectors_client = VectorStoreClient(
148
- base_url=self.base_url, api_key=self.api_key
165
+ base_url=self.base_url,
166
+ api_key=self.api_key,
167
+ file_processor_kwargs=self.file_processor_kwargs,
149
168
  )
150
169
 
151
170
  return self._vectors_client
@@ -1,10 +1,12 @@
1
+ #
1
2
  from typing import Any, Dict, List
2
3
 
3
- from sentence_transformers import CrossEncoder
4
-
5
4
 
6
5
  def rerank(query: str, hits: List[Dict[str, Any]], top_k: int = 10) -> List[Dict]:
7
6
  try:
7
+
8
+ from sentence_transformers import CrossEncoder
9
+
8
10
  cross_encoder = CrossEncoder(
9
11
  "cross-encoder/ms-marco-MiniLM-L-6-v2",
10
12
  max_length=512,
@@ -0,0 +1,40 @@
1
+ # ------------------------------------------------------------------
2
+ # utils.function_call_suppressor (unchanged except for logger)
3
+ # ------------------------------------------------------------------
4
+ import re
5
+
6
+ from projectdavid_common.utilities.logging_service import LoggingUtility
7
+
8
+ LOG = LoggingUtility()
9
+
10
+
11
+ class FunctionCallSuppressor:
12
+ OPEN_RE = re.compile(r"<\s*fc\s*>", re.I)
13
+ CLOSE_RE = re.compile(r"</\s*fc\s*>", re.I)
14
+
15
+ def __init__(self):
16
+ self.in_fc = False
17
+ self.buf = ""
18
+
19
+ def filter_chunk(self, txt: str) -> str:
20
+ self.buf += txt
21
+ out = ""
22
+ while self.buf:
23
+ if not self.in_fc:
24
+ m = self.OPEN_RE.search(self.buf)
25
+ if not m:
26
+ out += self.buf
27
+ self.buf = ""
28
+ break
29
+ out += self.buf[: m.start()]
30
+ LOG.debug("[SUPPRESSOR] <fc> detected")
31
+ self.buf = self.buf[m.end() :]
32
+ self.in_fc = True
33
+ else:
34
+ m = self.CLOSE_RE.search(self.buf)
35
+ if not m:
36
+ break
37
+ LOG.debug("[SUPPRESSOR] </fc> detected — block suppressed")
38
+ self.buf = self.buf[m.end() :]
39
+ self.in_fc = False
40
+ return out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: projectdavid
3
- Version: 1.29.9
3
+ Version: 1.38.1
4
4
  Summary: Python SDK for interacting with the Entities Assistant API.
5
5
  Author-email: Francis Neequaye Armah <francis.neequaye@projectdavid.co.uk>
6
6
  License: PolyForm Noncommercial License 1.0.0
@@ -20,13 +20,15 @@ Requires-Dist: pydantic<3.0,>=2.0
20
20
  Requires-Dist: python-dotenv<2.0,>=1.0.1
21
21
  Requires-Dist: aiofiles<25.0,>=23.2.1
22
22
  Requires-Dist: ollama<0.5.0,>=0.4.4
23
- Requires-Dist: projectdavid_common==0.17.2
23
+ Requires-Dist: projectdavid_common==0.19.0
24
24
  Requires-Dist: qdrant-client<2.0.0,>=1.0.0
25
25
  Requires-Dist: pdfplumber<0.12.0,>=0.11.0
26
26
  Requires-Dist: validators<0.35.0,>=0.29.0
27
27
  Requires-Dist: sentence-transformers<5.0,>=3.4.0
28
28
  Requires-Dist: sseclient-py
29
29
  Requires-Dist: requests
30
+ Requires-Dist: python-docx
31
+ Requires-Dist: python-pptx
30
32
  Provides-Extra: dev
31
33
  Requires-Dist: black>=23.3; extra == "dev"
32
34
  Requires-Dist: isort>=5.12; extra == "dev"
@@ -224,7 +226,7 @@ Would you like a deeper dive into any of these trends?
224
226
 
225
227
 
226
228
 
227
- ## 📚 Documentation
229
+ ## Documentation
228
230
 
229
231
  | Domain | Link |
230
232
  |---------------------|--------------------------------------------------------|
@@ -249,9 +251,9 @@ Would you like a deeper dive into any of these trends?
249
251
 
250
252
  ---
251
253
 
252
- ## 🌍 Related Repositories
254
+ ## Related Repositories
253
255
 
254
- - 🔌 [Entities API](https://github.com/frankie336/entities_api) — containerized API backend
256
+ - [Entities API](https://github.com/frankie336/entities_api) — containerized API backend
255
257
  -
256
- - 📚 [entities_common](https://github.com/frankie336/entities_common) — shared validation, schemas, utilities, and tools.
258
+ - [entities_common](https://github.com/frankie336/entities_common) — shared validation, schemas, utilities, and tools.
257
259
  This package is auto installed as dependency of entities SDK or entities API.
@@ -1,39 +1,43 @@
1
1
  projectdavid/__init__.py,sha256=QKjYL0-e4ifiRWyp05lK_dGm0u_jaxo36fyF-c0qqeI,224
2
2
  projectdavid/_version.py,sha256=_qiy4uXbgWEU-in9CM9h6tk4Ddhzpvv-HnoAYSuiGg0,100
3
- projectdavid/entity.py,sha256=uqRggs1zLWYnKnycPwO5pUhVegOJN8nCC0R9F2RYROI,5634
3
+ projectdavid/decorators.py,sha256=xwjzSNJdg8pOeicdtWEeJeuwAwfrWfM2_cH9tI5O-l0,1730
4
+ projectdavid/entity.py,sha256=gTaNoRbic2MCIqTRR3R1MYGIkMGR7gJyS5WL_SkD1wA,6329
4
5
  projectdavid/events.py,sha256=m_vu5BgphrM6dpBmnkTXK8jczwyYXO1UwXXI9340vjQ,720
5
6
  projectdavid/serializers.py,sha256=OdipJGXGGjRoZBcPkpmHSDgsNptXUg0CMn2TQoCZIOI,1723
6
7
  projectdavid/clients/actions_client.py,sha256=9DVkQzRA3wQ7DIHR1ab6VFQYcIkhExAQz1-EK8MEt2c,17006
7
8
  projectdavid/clients/api_key_client.py,sha256=8O1lkvb97WhB8V9jdPmleJ5jqWVuXJrnlBNB-u3vlwc,12650
8
- projectdavid/clients/assistants_client.py,sha256=SsIGa5wPr7ga9WX0ywam3djUF-uWFdk_hLWJapzVk1w,11337
9
+ projectdavid/clients/assistants_client.py,sha256=Oo8Gu9zfCiIFaGWj2v2I4vfzejro9QXo0BR4wRZsr_I,10990
9
10
  projectdavid/clients/base_client.py,sha256=UWl6nr6sxD1_xC6iyptQDR1tnNdFCOrEx5cEUPCRqJE,3417
10
11
  projectdavid/clients/base_vector_store.py,sha256=jXivmqAW1bgYcLgIeW-hPxOiWZbs2hCsLy4oWzSvpNI,2061
11
12
  projectdavid/clients/event_handler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- projectdavid/clients/file_processor.py,sha256=fR-FfUFye5Ix85Iq1b7Hni8_X4JtJ_miSFVh2-Wh2mM,9942
13
+ projectdavid/clients/file_processor.py,sha256=9JYejhg9htgNbfgblWB7K2xX68BdxmagjqqqhmUwq9I,15629
13
14
  projectdavid/clients/file_search.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
15
  projectdavid/clients/files_client.py,sha256=XkIDzbQFGDrd88taf0Kouc_4YJOPIYEHiIyWYLKDofI,15581
15
16
  projectdavid/clients/inference_client.py,sha256=xz4ACPv5Tkis604QxO5mJX1inH_TGDfQP-31geETYpE,6609
16
- projectdavid/clients/messages_client.py,sha256=467xeIt3VYs6cG8-bl-eDRi_auWOPmfd5tSJDmQSJUI,17232
17
- projectdavid/clients/runs.py,sha256=-fXOq5L9w2efDPmZkNxb0s2yjl6oN0XN4_aLXqaeceo,25270
18
- projectdavid/clients/synchronous_inference_wrapper.py,sha256=25dNSel5DVieu2aFg6G1e4ENo5WWB4EB8_jugIiVzlo,3433
19
- projectdavid/clients/threads_client.py,sha256=ekzU5w14zftmtmFkiec3NC90Of-_KVSUY1qH9cmfSFg,6771
17
+ projectdavid/clients/messages_client.py,sha256=-tUubr5f62nLER6BxVY3ihp3vn3pnZH-ceigvQRSlYs,16825
18
+ projectdavid/clients/runs.py,sha256=-klntZIcpYLphFtPUcOGoxAJtwqHuI-dlDTSNJx8fp8,21728
19
+ projectdavid/clients/synchronous_inference_wrapper.py,sha256=sW0jwTALuwnZeRuB5FtRppLEqEhAImpQ8UeeBIQtFH8,4789
20
+ projectdavid/clients/threads_client.py,sha256=9RshJD09kfYxfarTysQz_Bwbv4XxQaHQXhCLRMdaWcI,7392
20
21
  projectdavid/clients/tools_client.py,sha256=GkCVOmwpAoPqVt6aYmH0G1HIFha3iEwR9IIf9teR0j8,11487
21
22
  projectdavid/clients/users_client.py,sha256=eCuUb9qvyH1GUFhZu6TRL9zdoK-qzHSs8-Vmrk_0mmg,13729
22
- projectdavid/clients/vector_store_manager.py,sha256=lk-sWJjo6Z0EHZzjRoKiHPr0GpEXfE4bJBQzmKV8ezc,11372
23
- projectdavid/clients/vectors.py,sha256=4P1ihCDstyYishLsmGzSKg3kirqM0yqS03xjL5UQaDY,24601
23
+ projectdavid/clients/vector_store_manager.py,sha256=A-L1rhURKwiRs0EDd1HOuIShOtaC9Hb1yHB4He456Zc,15943
24
+ projectdavid/clients/vectors.py,sha256=BSa2dN5MKhn0bqDrDCD1wey5J9hCPGOJZFMbOUENPlo,32096
25
+ projectdavid/clients/vision-file_processor.py,sha256=fyD1JVZXSkibJ1ZwIRGhPmCUBOlozAFlETFefPD22Cw,17214
26
+ projectdavid/clients/vision_vectors.py,sha256=cysPVbUzW3byB82MTqG2X1Iz5ZAe82WTS1JfQcoqVhE,40229
24
27
  projectdavid/constants/platform.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
28
  projectdavid/services/logging_service.py,sha256=jdoRL46E42Ar8JFTDOV-xVD67CulcHSN-xhcEqA5CXQ,2643
26
29
  projectdavid/synthesis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
30
  projectdavid/synthesis/llm_synthesizer.py,sha256=6dlZ4XRCZSsRNuNbyogIeoGwW2dlGg42PtT3Ud5D-gU,3930
28
31
  projectdavid/synthesis/prompt.py,sha256=Jlya6avnWV5ryaJaibt4W29XYxRlJRV6rwHfjgYyh2U,799
29
- projectdavid/synthesis/reranker.py,sha256=aFjdLDoqnhgzxPIoRfs4y_Z_F6T88g5Sg8R5m0HMxdU,868
32
+ projectdavid/synthesis/reranker.py,sha256=F9HaXbB2RW66MdDqXdhrx4UP_vRG8xDG2S4eFSCQ5GM,879
30
33
  projectdavid/synthesis/retriever.py,sha256=8R5HIgPXMKIQxV5KsN8u_gVVP4JY-wsDwJd92A-74-o,2300
31
34
  projectdavid/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ projectdavid/utils/function_call_suppressor.py,sha256=LsDhySVH0kS8nydPBrHrOtT30yhVvwU24QHApGu1P34,1305
32
36
  projectdavid/utils/monitor_launcher.py,sha256=3YAgJdeuaUvq3JGvpA4ymqFsAnk29nH5q93cwStP4hc,2836
33
37
  projectdavid/utils/run_monitor.py,sha256=F_WkqIP-qnWH-4llIbileWWLfRj2Q1Cg-ni23SR1rec,3786
34
38
  projectdavid/utils/vector_search_formatter.py,sha256=YTe3HPGec26qGY7uxY8_GS8lc4QaN6aNXMzkl29nZpI,1735
35
- projectdavid-1.29.9.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
36
- projectdavid-1.29.9.dist-info/METADATA,sha256=CPLdqHYqHv6Ck1ymIuRwOANiy3UFPIgvPh1P1PpChp0,10727
37
- projectdavid-1.29.9.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
38
- projectdavid-1.29.9.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
39
- projectdavid-1.29.9.dist-info/RECORD,,
39
+ projectdavid-1.38.1.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
40
+ projectdavid-1.38.1.dist-info/METADATA,sha256=Ck2oQkKlAHKFfw7DR-5ENmsTFnPDVF8MhWjj72yHh1I,10768
41
+ projectdavid-1.38.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
+ projectdavid-1.38.1.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
43
+ projectdavid-1.38.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5