projectdavid 1.33.33__py3-none-any.whl → 1.34.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.

Potentially problematic release.


This version of projectdavid might be problematic. Click here for more details.

@@ -2,7 +2,7 @@ import json
2
2
  import threading
3
3
  import time
4
4
  from enum import Enum
5
- from typing import Any, Callable, Dict, List, Optional
5
+ from typing import Any, Callable, Dict, List, Optional, Tuple
6
6
 
7
7
  import httpx
8
8
  import requests
@@ -190,36 +190,6 @@ class RunsClient(BaseAPIClient):
190
190
  )
191
191
  raise
192
192
 
193
- def list_runs(self, limit: int = 20, order: str = "asc") -> List[ent_validator.Run]:
194
- """
195
- List runs with the given limit and order.
196
-
197
- Args:
198
- limit (int): Maximum number of runs to retrieve.
199
- order (str): 'asc' or 'desc' for ordering.
200
-
201
- Returns:
202
- List[Run]: A list of runs.
203
- """
204
- logging_utility.info("Listing runs with limit: %d, order: %s", limit, order)
205
- params = {"limit": limit, "order": order}
206
- try:
207
- response = self.client.get("/v1/runs", params=params)
208
- response.raise_for_status()
209
- runs = response.json()
210
- validated_runs = [ent_validator.Run(**run) for run in runs]
211
- logging_utility.info("Retrieved %d runs", len(validated_runs))
212
- return validated_runs
213
- except ValidationError as e:
214
- logging_utility.error("Validation error: %s", e.json())
215
- raise ValueError(f"Validation error: {e}")
216
- except httpx.HTTPStatusError as e:
217
- logging_utility.error("HTTP error occurred while listing runs: %s", str(e))
218
- raise
219
- except Exception as e:
220
- logging_utility.error("An error occurred while listing runs: %s", str(e))
221
- raise
222
-
223
193
  def delete_run(self, run_id: str) -> Dict[str, Any]:
224
194
  """
225
195
  Delete a run by its ID.
@@ -637,3 +607,138 @@ class RunsClient(BaseAPIClient):
637
607
  t = threading.Thread(target=_listen_and_handle, daemon=True)
638
608
  t.start()
639
609
  t.join()
610
+
611
+ def list_runs(self, limit: int = 20, order: str = "asc") -> List[ent_validator.Run]:
612
+
613
+ logging_utility.info("Listing runs with limit: %d, order: %s", limit, order)
614
+ params = {"limit": limit, "order": order if order in ("asc", "desc") else "asc"}
615
+ try:
616
+ resp = self.client.get("/v1/runs", params=params)
617
+ resp.raise_for_status()
618
+ payload = resp.json()
619
+
620
+ # Preferred: envelope
621
+ if isinstance(payload, dict) and "data" in payload:
622
+ env = ent_validator.RunListResponse(**payload)
623
+ logging_utility.info("Retrieved %d runs", len(env.data))
624
+ return list(env.data)
625
+
626
+ # Legacy: raw list of dicts
627
+ runs = [ent_validator.Run(**item) for item in payload]
628
+ logging_utility.info("Retrieved %d runs (legacy)", len(runs))
629
+ return runs
630
+
631
+ except ValidationError as e:
632
+ logging_utility.error("Validation error: %s", e.json())
633
+ raise ValueError(f"Validation error: {e}")
634
+ except httpx.HTTPStatusError as e:
635
+ logging_utility.error("HTTP error occurred while listing runs: %s", str(e))
636
+ raise
637
+ except Exception as e:
638
+ logging_utility.error("An error occurred while listing runs: %s", str(e))
639
+ raise
640
+
641
+ def list_runs_with_meta(
642
+ self, limit: int = 20, order: str = "asc"
643
+ ) -> Tuple[List[ent_validator.Run], Optional[str], Optional[str], bool]:
644
+ """
645
+ Returns (runs, first_id, last_id, has_more).
646
+ """
647
+ logging_utility.info("Listing runs (with meta) limit=%d order=%s", limit, order)
648
+ params = {"limit": limit, "order": order if order in ("asc", "desc") else "asc"}
649
+ try:
650
+ resp = self.client.get("/v1/runs", params=params)
651
+ resp.raise_for_status()
652
+ payload = resp.json()
653
+
654
+ if isinstance(payload, dict) and "data" in payload:
655
+ env = ent_validator.RunListResponse(**payload)
656
+ return list(env.data), env.first_id, env.last_id, env.has_more
657
+
658
+ # Legacy fallback: compute minimal meta
659
+ runs = [ent_validator.Run(**item) for item in payload]
660
+ first_id = runs[0].id if runs else None
661
+ last_id = runs[-1].id if runs else None
662
+ return runs, first_id, last_id, False
663
+
664
+ except ValidationError as e:
665
+ logging_utility.error("Validation error: %s", e.json())
666
+ raise ValueError(f"Validation error: {e}")
667
+ except httpx.HTTPStatusError as e:
668
+ logging_utility.error("HTTP error occurred while listing runs: %s", str(e))
669
+ raise
670
+ except Exception as e:
671
+ logging_utility.error("An error occurred while listing runs: %s", str(e))
672
+ raise
673
+
674
+ def list_runs_for_thread(
675
+ self, thread_id: str, limit: int = 20, order: str = "asc"
676
+ ) -> List[ent_validator.Run]:
677
+ logging_utility.info(
678
+ "Listing runs for thread_id=%s (limit=%d, order=%s)",
679
+ thread_id,
680
+ limit,
681
+ order,
682
+ )
683
+ params = {"limit": limit, "order": order if order in ("asc", "desc") else "asc"}
684
+ try:
685
+ resp = self.client.get(f"/v1/threads/{thread_id}/runs", params=params)
686
+ resp.raise_for_status()
687
+ payload = resp.json()
688
+
689
+ if isinstance(payload, dict) and "data" in payload:
690
+ env = ent_validator.RunListResponse(**payload)
691
+ logging_utility.info(
692
+ "Retrieved %d runs for thread %s", len(env.data), thread_id
693
+ )
694
+ return list(env.data)
695
+
696
+ runs = [ent_validator.Run(**item) for item in payload]
697
+ logging_utility.info(
698
+ "Retrieved %d runs (legacy) for thread %s", len(runs), thread_id
699
+ )
700
+ return runs
701
+
702
+ except ValidationError as e:
703
+ logging_utility.error("Validation error: %s", e.json())
704
+ raise ValueError(f"Validation error: {e}")
705
+ except httpx.HTTPStatusError as e:
706
+ logging_utility.error("HTTP error listing runs for thread: %s", str(e))
707
+ raise
708
+ except Exception as e:
709
+ logging_utility.error("Error listing runs for thread: %s", str(e))
710
+ raise
711
+
712
+ def list_runs_for_thread_with_meta(
713
+ self, thread_id: str, limit: int = 20, order: str = "asc"
714
+ ) -> Tuple[List[ent_validator.Run], Optional[str], Optional[str], bool]:
715
+ logging_utility.info(
716
+ "Listing runs for thread_id=%s (with meta) limit=%d order=%s",
717
+ thread_id,
718
+ limit,
719
+ order,
720
+ )
721
+ params = {"limit": limit, "order": order if order in ("asc", "desc") else "asc"}
722
+ try:
723
+ resp = self.client.get(f"/v1/threads/{thread_id}/runs", params=params)
724
+ resp.raise_for_status()
725
+ payload = resp.json()
726
+
727
+ if isinstance(payload, dict) and "data" in payload:
728
+ env = ent_validator.RunListResponse(**payload)
729
+ return list(env.data), env.first_id, env.last_id, env.has_more
730
+
731
+ runs = [ent_validator.Run(**item) for item in payload]
732
+ first_id = runs[0].id if runs else None
733
+ last_id = runs[-1].id if runs else None
734
+ return runs, first_id, last_id, False
735
+
736
+ except ValidationError as e:
737
+ logging_utility.error("Validation error: %s", e.json())
738
+ raise ValueError(f"Validation error: {e}")
739
+ except httpx.HTTPStatusError as e:
740
+ logging_utility.error("HTTP error listing runs for thread: %s", str(e))
741
+ raise
742
+ except Exception as e:
743
+ logging_utility.error("Error listing runs for thread: %s", str(e))
744
+ raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: projectdavid
3
- Version: 1.33.33
3
+ Version: 1.34.0
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,7 +20,7 @@ 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.11
23
+ Requires-Dist: projectdavid_common==0.17.12
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
@@ -15,7 +15,7 @@ projectdavid/clients/file_search.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
15
15
  projectdavid/clients/files_client.py,sha256=XkIDzbQFGDrd88taf0Kouc_4YJOPIYEHiIyWYLKDofI,15581
16
16
  projectdavid/clients/inference_client.py,sha256=xz4ACPv5Tkis604QxO5mJX1inH_TGDfQP-31geETYpE,6609
17
17
  projectdavid/clients/messages_client.py,sha256=-tUubr5f62nLER6BxVY3ihp3vn3pnZH-ceigvQRSlYs,16825
18
- projectdavid/clients/runs.py,sha256=-fXOq5L9w2efDPmZkNxb0s2yjl6oN0XN4_aLXqaeceo,25270
18
+ projectdavid/clients/runs.py,sha256=8VcFGxIcmbps8tU6wU04dUhY1C-H3ANqsCUxvlaek3c,29816
19
19
  projectdavid/clients/synchronous_inference_wrapper.py,sha256=qh94rtNlLqgIxiA_ZbQ1ncOwQTi9aBj5os3sMExLh4E,7070
20
20
  projectdavid/clients/threads_client.py,sha256=9RshJD09kfYxfarTysQz_Bwbv4XxQaHQXhCLRMdaWcI,7392
21
21
  projectdavid/clients/tools_client.py,sha256=GkCVOmwpAoPqVt6aYmH0G1HIFha3iEwR9IIf9teR0j8,11487
@@ -37,8 +37,8 @@ projectdavid/utils/monitor_launcher.py,sha256=3YAgJdeuaUvq3JGvpA4ymqFsAnk29nH5q9
37
37
  projectdavid/utils/peek_gate.py,sha256=5whMRnDOQjATRpThWDJkvY9ScXuJ7Sd_-9rvGgXeTAQ,2532
38
38
  projectdavid/utils/run_monitor.py,sha256=F_WkqIP-qnWH-4llIbileWWLfRj2Q1Cg-ni23SR1rec,3786
39
39
  projectdavid/utils/vector_search_formatter.py,sha256=YTe3HPGec26qGY7uxY8_GS8lc4QaN6aNXMzkl29nZpI,1735
40
- projectdavid-1.33.33.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
41
- projectdavid-1.33.33.dist-info/METADATA,sha256=N2yfT44Bx7pK-A5d3dRcOAAoOmSFEHS4SMMUvEAsuf0,11556
42
- projectdavid-1.33.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- projectdavid-1.33.33.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
44
- projectdavid-1.33.33.dist-info/RECORD,,
40
+ projectdavid-1.34.0.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
41
+ projectdavid-1.34.0.dist-info/METADATA,sha256=VxCflJwsHNlIc18malH4cofc6-Us2lU2Pm9PZ8B7tl4,11555
42
+ projectdavid-1.34.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ projectdavid-1.34.0.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
44
+ projectdavid-1.34.0.dist-info/RECORD,,