discovery-engine-api 0.2.91__tar.gz → 0.2.93__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: discovery-engine-api
3
- Version: 0.2.91
3
+ Version: 0.2.93
4
4
  Summary: Python SDK for Disco API
5
5
  Project-URL: Homepage, https://www.leap-labs.com
6
6
  Project-URL: Documentation, https://disco.leap-labs.com/llms-full.txt
@@ -213,8 +213,7 @@ print(f"Explore: {result.report_url}")
213
213
  ## Credits and Pricing
214
214
 
215
215
  - **Public runs**: Free. Results published to public gallery.
216
- - **Private runs**: 1 credit per MB per depth iteration. $1.00 per credit.
217
- - **Formula**: `credits = max(1, ceil(file_size_mb * analysis_depth))`
216
+ - **Private runs**: Credits scale with file size, depth, and run configuration. $0.10 per credit. Use `engine.estimate()` to check cost before running.
218
217
 
219
218
  ```python
220
219
  # Estimate cost before running
@@ -225,7 +224,6 @@ estimate = await engine.estimate(
225
224
  visibility="private",
226
225
  )
227
226
  # estimate["cost"]["credits"] -> 21
228
- # estimate["cost"]["free_alternative"] -> True
229
227
  # estimate["account"]["sufficient"] -> True/False
230
228
  ```
231
229
 
@@ -176,8 +176,7 @@ print(f"Explore: {result.report_url}")
176
176
  ## Credits and Pricing
177
177
 
178
178
  - **Public runs**: Free. Results published to public gallery.
179
- - **Private runs**: 1 credit per MB per depth iteration. $1.00 per credit.
180
- - **Formula**: `credits = max(1, ceil(file_size_mb * analysis_depth))`
179
+ - **Private runs**: Credits scale with file size, depth, and run configuration. $0.10 per credit. Use `engine.estimate()` to check cost before running.
181
180
 
182
181
  ```python
183
182
  # Estimate cost before running
@@ -188,7 +187,6 @@ estimate = await engine.estimate(
188
187
  visibility="private",
189
188
  )
190
189
  # estimate["cost"]["credits"] -> 21
191
- # estimate["cost"]["free_alternative"] -> True
192
190
  # estimate["account"]["sufficient"] -> True/False
193
191
  ```
194
192
 
@@ -1,6 +1,6 @@
1
1
  """Disco Python SDK."""
2
2
 
3
- __version__ = "0.2.91"
3
+ __version__ = "0.2.93"
4
4
 
5
5
  from discovery.client import Engine
6
6
  from discovery.types import (
@@ -211,6 +211,57 @@ class Engine:
211
211
  )
212
212
  return engine
213
213
 
214
+ @classmethod
215
+ async def login(
216
+ cls,
217
+ email: str,
218
+ *,
219
+ quiet: bool = False,
220
+ ) -> "Engine":
221
+ """Get a new API key for an existing account.
222
+
223
+ Sends a 6-digit verification code to the email address. Prompts for
224
+ the code interactively, then returns a configured Engine with a fresh
225
+ ``disco_`` API key.
226
+
227
+ Use this when you need an API key for an account that already exists
228
+ (e.g. the key was lost or this is a new agent session).
229
+
230
+ Args:
231
+ email: Email address of the existing account.
232
+ quiet: If True, suppress status output.
233
+
234
+ Returns:
235
+ A configured Engine instance with the new API key.
236
+
237
+ Raises:
238
+ ValueError: If no account exists with this email (404).
239
+ """
240
+ async with cls._make_anon_client() as client:
241
+ response = await client.post("/api/login", json={"email": email})
242
+ cls._raise_for_status(response)
243
+ data = response.json()
244
+
245
+ if data.get("status") != "verification_required":
246
+ raise ValueError(f"Unexpected login response: {data}")
247
+
248
+ if not quiet:
249
+ print(f"A verification code has been sent to {email}.")
250
+ code = input("Enter verification code: ").strip()
251
+
252
+ async with cls._make_anon_client() as client:
253
+ verify_response = await client.post(
254
+ "/api/login/verify",
255
+ json={"email": email, "code": code},
256
+ )
257
+ cls._raise_for_status(verify_response)
258
+ key_data = verify_response.json()
259
+
260
+ engine = cls(api_key=key_data["key"], quiet=quiet)
261
+ if not quiet:
262
+ print(f"Logged in. Tier: {key_data.get('tier', 'free_tier')}")
263
+ return engine
264
+
214
265
  # ------------------------------------------------------------------
215
266
  # discover() — the primary method for agents
216
267
  # ------------------------------------------------------------------
@@ -225,6 +276,7 @@ class Engine:
225
276
  description: Optional[str] = None,
226
277
  column_descriptions: Optional[Dict[str, str]] = None,
227
278
  excluded_columns: Optional[List[str]] = None,
279
+ use_llms: bool = False,
228
280
  timeout: float = 1800,
229
281
  **kwargs,
230
282
  ) -> EngineResult:
@@ -244,6 +296,10 @@ class Engine:
244
296
  column_descriptions: Dict mapping column names to descriptions.
245
297
  Significantly improves pattern explanations for non-obvious column names.
246
298
  excluded_columns: Columns to exclude from analysis.
299
+ use_llms: Slower and more expensive, but you get smarter pre-processing,
300
+ literature context and novelty assessment. Default False — set to
301
+ True if you want Disco-generated explanations. Public runs always
302
+ use LLMs.
247
303
  timeout: Max seconds to wait for completion (default: 1800).
248
304
  **kwargs: Additional arguments passed to run_async().
249
305
 
@@ -265,6 +321,7 @@ class Engine:
265
321
  description=description,
266
322
  column_descriptions=column_descriptions,
267
323
  excluded_columns=excluded_columns,
324
+ use_llms=use_llms,
268
325
  wait=True,
269
326
  wait_timeout=timeout,
270
327
  **kwargs,
@@ -280,6 +337,7 @@ class Engine:
280
337
  description: Optional[str] = None,
281
338
  column_descriptions: Optional[Dict[str, str]] = None,
282
339
  excluded_columns: Optional[List[str]] = None,
340
+ use_llms: bool = False,
283
341
  timeout: float = 1800,
284
342
  **kwargs,
285
343
  ) -> EngineResult:
@@ -294,6 +352,7 @@ class Engine:
294
352
  description=description,
295
353
  column_descriptions=column_descriptions,
296
354
  excluded_columns=excluded_columns,
355
+ use_llms=use_llms,
297
356
  timeout=timeout,
298
357
  **kwargs,
299
358
  )
@@ -352,12 +411,12 @@ class Engine:
352
411
  return response.json()
353
412
 
354
413
  async def purchase_credits(self, packs: int = 1) -> Dict[str, Any]:
355
- """Purchase credit packs. Each pack is 20 credits for $20.
414
+ """Purchase credit packs. Each pack is 100 credits for $10.
356
415
 
357
416
  Requires a payment method on file.
358
417
 
359
418
  Args:
360
- packs: Number of 20-credit packs to purchase (default: 1).
419
+ packs: Number of 100-credit packs to purchase (default: 1).
361
420
 
362
421
  Returns:
363
422
  Dict with ``purchased_credits``, ``total_credits``, ``charge_amount_usd``.
@@ -384,6 +443,7 @@ class Engine:
384
443
  num_rows: Optional[int] = None,
385
444
  analysis_depth: int = 2,
386
445
  visibility: str = "public",
446
+ use_llms: bool = False,
387
447
  ) -> Dict[str, Any]:
388
448
  """Estimate cost and time for an analysis run.
389
449
 
@@ -396,6 +456,9 @@ class Engine:
396
456
  num_rows: Number of rows (improves time estimate accuracy).
397
457
  analysis_depth: Depth iterations (1=fast, higher=deeper).
398
458
  visibility: "public" (free, results published) or "private" (costs credits).
459
+ use_llms: Slower and more expensive, but you get smarter pre-processing,
460
+ literature context and novelty assessment. Default False. Public runs
461
+ always use LLMs.
399
462
 
400
463
  Returns:
401
464
  Dict with ``cost``, ``time_estimate``, ``limits``, and ``account`` info.
@@ -409,6 +472,7 @@ class Engine:
409
472
  "num_rows": num_rows,
410
473
  "analysis_depth": analysis_depth,
411
474
  "visibility": visibility,
475
+ "use_llms": use_llms,
412
476
  },
413
477
  )
414
478
  self._raise_for_status(response)
@@ -750,6 +814,7 @@ class Engine:
750
814
  target_column_override: Optional[str] = None,
751
815
  author: Optional[str] = None,
752
816
  source_url: Optional[str] = None,
817
+ use_llms: bool = False,
753
818
  wait: bool = False,
754
819
  wait_timeout: Optional[float] = None,
755
820
  upload_result: Optional[Dict[str, Any]] = None,
@@ -770,6 +835,7 @@ class Engine:
770
835
  excluded_columns: Column names to exclude from analysis.
771
836
  task: Task type (auto-detected if None).
772
837
  visibility: "public" (free) or "private" (costs credits).
838
+ use_llms: Slower and more expensive, but you get smarter pre-processing, literature context and novelty assessment. Default False — set to True if you want Disco-generated explanations. Public runs always use LLMs.
773
839
  wait: If True, wait for completion and return full results.
774
840
  wait_timeout: Max seconds to wait (only if wait=True).
775
841
  upload_result: Pre-uploaded file data from ``upload_file()``.
@@ -827,6 +893,7 @@ class Engine:
827
893
  "targetColumn": target_column,
828
894
  "analysisDepth": analysis_depth,
829
895
  "isPublic": visibility == "public",
896
+ "useLlms": use_llms,
830
897
  }
831
898
 
832
899
  if title:
@@ -906,6 +973,7 @@ class Engine:
906
973
  timeseries_groups: Optional[List[Dict[str, Any]]] = None,
907
974
  target_column_override: Optional[str] = None,
908
975
  author: Optional[str] = None,
976
+ use_llms: bool = False,
909
977
  source_url: Optional[str] = None,
910
978
  wait: bool = False,
911
979
  wait_timeout: Optional[float] = None,
@@ -927,6 +995,7 @@ class Engine:
927
995
  target_column_override=target_column_override,
928
996
  author=author,
929
997
  source_url=source_url,
998
+ use_llms=use_llms,
930
999
  wait=wait,
931
1000
  wait_timeout=wait_timeout,
932
1001
  **kwargs,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "discovery-engine-api"
3
- version = "0.2.91"
3
+ version = "0.2.93"
4
4
  description = "Python SDK for Disco API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"