projectdavid 1.34.5__py3-none-any.whl → 1.34.7__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.

@@ -45,15 +45,30 @@ class RunsClient(BaseAPIClient):
45
45
  meta_data: Optional[Dict[str, Any]] = None,
46
46
  ) -> ent_validator.Run:
47
47
  """
48
- Create a run. The server expects user_id to be injected explicitly,
49
- which is passed in from the authenticated API key.
50
-
51
- Returns a fully‑populated Run model (read schema).
48
+ Create a run. The server injects user_id from the API key.
49
+ We normalize all timestamp fields to epoch ints (or None).
52
50
  """
51
+
52
+ def _epoch(v):
53
+ # Accept None, int, datetime, or stringified int
54
+ if v is None:
55
+ return None
56
+ if isinstance(v, int):
57
+ return v
58
+ if isinstance(v, float):
59
+ return int(v)
60
+ if hasattr(v, "timestamp"): # datetime / date
61
+ return int(v.timestamp())
62
+ try:
63
+ return int(str(v))
64
+ except Exception:
65
+ return None
66
+
67
+ now = int(time.time())
53
68
  if meta_data is None:
54
69
  meta_data = {}
55
70
 
56
- # Construct the RunCreate payload, including user_id
71
+ # Build the Pydantic payload with epoch-normalized timestamps
57
72
  run_payload = ent_validator.RunCreate(
58
73
  id=UtilsInterface.IdentifierService.generate_run_id(),
59
74
  user_id=None,
@@ -61,11 +76,11 @@ class RunsClient(BaseAPIClient):
61
76
  thread_id=thread_id,
62
77
  instructions=instructions,
63
78
  meta_data=meta_data,
64
- cancelled_at=None,
65
- completed_at=None,
66
- created_at=int(time.time()),
67
- expires_at=int(time.time()) + 3600,
68
- failed_at=None,
79
+ cancelled_at=_epoch(None),
80
+ completed_at=_epoch(None),
81
+ created_at=_epoch(now),
82
+ expires_at=_epoch(now + 3600),
83
+ failed_at=_epoch(None),
69
84
  incomplete_details=None,
70
85
  last_error=None,
71
86
  max_completion_tokens=1000,
@@ -75,14 +90,15 @@ class RunsClient(BaseAPIClient):
75
90
  parallel_tool_calls=False,
76
91
  required_action=None,
77
92
  response_format="text",
78
- started_at=None,
93
+ started_at=_epoch(None),
79
94
  status=StatusEnum.queued,
80
95
  tool_choice="none",
81
96
  tools=[],
82
97
  truncation_strategy={},
83
98
  usage=None,
84
- temperature=0.7,
85
- top_p=0.9,
99
+ # NOTE: your DB columns are Integer; avoid floats here to prevent truncation
100
+ temperature=1, # or None if you prefer to omit
101
+ top_p=1, # or None if you prefer to omit
86
102
  tool_resources={},
87
103
  )
88
104
 
@@ -91,14 +107,15 @@ class RunsClient(BaseAPIClient):
91
107
  assistant_id,
92
108
  thread_id,
93
109
  )
94
-
95
110
  logging_utility.debug("Run payload: %s", run_payload.model_dump())
96
111
 
97
112
  try:
98
- resp = self.client.post("/v1/runs", json=run_payload.model_dump())
113
+ # Exclude None so we don't send unset fields
114
+ resp = self.client.post(
115
+ "/v1/runs", json=run_payload.model_dump(exclude_none=True)
116
+ )
99
117
  resp.raise_for_status()
100
118
 
101
- # Validate response with the *read* schema
102
119
  run_out = ent_validator.Run(**resp.json())
103
120
  logging_utility.info("Run created successfully: %s", run_out.id)
104
121
  return run_out
@@ -148,48 +165,6 @@ class RunsClient(BaseAPIClient):
148
165
  )
149
166
  raise
150
167
 
151
- def update_run(self, run_id: str, metadata: Dict[str, Any]) -> ent_validator.Run:
152
- """
153
- Shallow-merge metadata into a run. Returns the updated Run.
154
-
155
- Server route expects body shaped as:
156
- {"metadata": {...}}
157
-
158
- Args:
159
- run_id: The run ID (e.g., "run_abc123").
160
- metadata: Dict to merge into run.meta_data.
161
-
162
- Raises:
163
- ValueError: if metadata is not a dict or validation fails.
164
- httpx.HTTPStatusError: on non-2xx response.
165
- Exception: on unexpected errors.
166
- """
167
- logging_utility.info("Updating metadata for run_id: %s", run_id)
168
-
169
- # Basic input validation (fail fast with clear error)
170
- if not isinstance(metadata, dict):
171
- raise ValueError("`metadata` must be a dict")
172
-
173
- try:
174
- resp = self.client.put(
175
- f"/v1/runs/{run_id}/metadata",
176
- json={"metadata": metadata}, # <-- wrap to match router param
177
- )
178
- resp.raise_for_status()
179
-
180
- # Validate server response to the shared model
181
- return ent_validator.Run(**resp.json())
182
-
183
- except ValidationError as e:
184
- logging_utility.error("Validation error: %s", e.json())
185
- raise ValueError(f"Validation error: {e}")
186
- except httpx.HTTPStatusError as e:
187
- logging_utility.error("HTTP error updating run metadata: %s", str(e))
188
- raise
189
- except Exception as e:
190
- logging_utility.error("Unexpected error updating run metadata: %s", str(e))
191
- raise
192
-
193
168
  def update_run_status(self, run_id: str, new_status: str) -> ent_validator.Run:
194
169
  """
195
170
  Update the status of a run.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: projectdavid
3
- Version: 1.34.5
3
+ Version: 1.34.7
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.13
23
+ Requires-Dist: projectdavid_common==0.17.14
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=xXht0tq-nnpuajy_D52STXBvpOdPanaiC5hQZ8cV7zo,27484
18
+ projectdavid/clients/runs.py,sha256=Z3IbuEx6PBRtsEeXDWBTnqzjD0w4JS8cyxV7Kq-aGOI,26574
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.34.5.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
41
- projectdavid-1.34.5.dist-info/METADATA,sha256=ojM3YNfuQSBRm0EqQ-BoSDQvp6sgxaskcktX4EMJ-5g,11555
42
- projectdavid-1.34.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- projectdavid-1.34.5.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
44
- projectdavid-1.34.5.dist-info/RECORD,,
40
+ projectdavid-1.34.7.dist-info/licenses/LICENSE,sha256=_8yjiEGttpS284BkfhXxfERqTRZW_tUaHiBB0GTJTMg,4563
41
+ projectdavid-1.34.7.dist-info/METADATA,sha256=8XtSh-9H3x03EPAXlBpSkn1cdGJmu_rXkaJyHbQkBoc,11555
42
+ projectdavid-1.34.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ projectdavid-1.34.7.dist-info/top_level.txt,sha256=kil8GU4s7qYRfNnzGnFHhZnSNRSxgNG-J4HLgQMmMtw,13
44
+ projectdavid-1.34.7.dist-info/RECORD,,