openaivec 1.0.10__py3-none-any.whl → 1.0.12__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.
@@ -21,7 +21,10 @@ class BatchSizeSuggester:
21
21
  min_batch_size: int = 10
22
22
  min_duration: float = 30.0
23
23
  max_duration: float = 60.0
24
- step_ratio: float = 0.2
24
+ step_ratio_up: float = 0.1
25
+ step_ratio_down: float = 0.2
26
+ max_step: int | None = None
27
+ min_step: int = 1
25
28
  sample_size: int = 4
26
29
  _history: list[PerformanceMetric] = field(default_factory=list)
27
30
  _lock: threading.RLock = field(default_factory=threading.RLock, repr=False)
@@ -34,8 +37,14 @@ class BatchSizeSuggester:
34
37
  raise ValueError("current_batch_size must be >= min_batch_size")
35
38
  if self.sample_size <= 0:
36
39
  raise ValueError("sample_size must be > 0")
37
- if self.step_ratio <= 0:
38
- raise ValueError("step_ratio must be > 0")
40
+ if self.step_ratio_up <= 0:
41
+ raise ValueError("step_ratio_up must be > 0")
42
+ if self.step_ratio_down <= 0:
43
+ raise ValueError("step_ratio_down must be > 0")
44
+ if self.max_step is not None and self.max_step <= 0:
45
+ raise ValueError("max_step must be > 0")
46
+ if self.min_step <= 0:
47
+ raise ValueError("min_step must be > 0")
39
48
  if self.min_duration <= 0 or self.max_duration <= 0:
40
49
  raise ValueError("min_duration and max_duration must be > 0")
41
50
  if self.min_duration >= self.max_duration:
@@ -94,9 +103,15 @@ class BatchSizeSuggester:
94
103
  current_size = self.current_batch_size
95
104
 
96
105
  if average_duration < self.min_duration:
97
- new_batch_size = int(current_size * (1 + self.step_ratio))
106
+ delta = max(self.min_step, int(current_size * self.step_ratio_up))
107
+ if self.max_step is not None:
108
+ delta = min(delta, self.max_step)
109
+ new_batch_size = current_size + delta
98
110
  elif average_duration > self.max_duration:
99
- new_batch_size = int(current_size * (1 - self.step_ratio))
111
+ delta = max(self.min_step, int(current_size * self.step_ratio_down))
112
+ if self.max_step is not None:
113
+ delta = min(delta, self.max_step)
114
+ new_batch_size = current_size - delta
100
115
  else:
101
116
  new_batch_size = current_size
102
117
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openaivec
3
- Version: 1.0.10
3
+ Version: 1.0.12
4
4
  Summary: Generative mutation for tabular calculation
5
5
  Project-URL: Homepage, https://microsoft.github.io/openaivec/
6
6
  Project-URL: Repository, https://github.com/microsoft/openaivec
@@ -63,7 +63,7 @@ print(sentiment.tolist())
63
63
  # Output: ['Positive sentiment', 'Negative sentiment']
64
64
  ```
65
65
 
66
- **Try it live:** https://microsoft.github.io/openaivec/examples/pandas/
66
+ **Pandas tutorial (GitHub Pages):** https://microsoft.github.io/openaivec/examples/pandas/
67
67
 
68
68
  ## Benchmarks
69
69
 
@@ -82,6 +82,7 @@ Batching alone removes most HTTP overhead, and letting batching overlap with con
82
82
  ## Contents
83
83
 
84
84
  - [Why openaivec?](#why-openaivec)
85
+ - [Overview](#overview)
85
86
  - [Core Workflows](#core-workflows)
86
87
  - [Using with Apache Spark UDFs](#using-with-apache-spark-udfs)
87
88
  - [Building Prompts](#building-prompts)
@@ -93,14 +94,13 @@ Batching alone removes most HTTP overhead, and letting batching overlap with con
93
94
  ## Why openaivec?
94
95
 
95
96
  - Drop-in `.ai` and `.aio` accessors keep pandas analysts in familiar tooling.
96
- - OpenAI batch-optimized: `BatchingMapProxy`/`AsyncBatchingMapProxy` coalesce requests, dedupe prompts, and keep column order stable.
97
- - Smart batching (`BatchingMapProxy`/`AsyncBatchingMapProxy`) dedupes prompts, preserves order, and releases waiters on failure.
97
+ - OpenAI batch-optimized: `BatchingMapProxy`/`AsyncBatchingMapProxy` coalesce requests, dedupe prompts, preserve order, and release waiters on failure.
98
98
  - Reasoning support mirrors the OpenAI SDK; structured outputs accept Pydantic `response_format`.
99
99
  - Built-in caches and retries remove boilerplate; helpers reuse caches across pandas, Spark, and async flows.
100
100
  - Spark UDFs and Microsoft Fabric guides move notebooks into production-scale ETL.
101
101
  - Prompt tooling (`FewShotPromptBuilder`, `improve`) and the task library ship curated prompts with validated outputs.
102
102
 
103
- # Overview
103
+ ## Overview
104
104
 
105
105
  Vectorized OpenAI batch processing so you handle many inputs per call instead of one-by-one. Batching proxies dedupe inputs, enforce ordered outputs, and unblock waiters even on upstream errors. Cache helpers (`responses_with_cache`, Spark UDF builders) plug into the same layer so expensive prompts are reused across pandas, Spark, and async flows. Reasoning models honor SDK semantics. Requires Python 3.10+.
106
106
 
@@ -186,7 +186,7 @@ result = df.assign(
186
186
 
187
187
  ### Using with reasoning models
188
188
 
189
- Reasoning models (o1-preview, o1-mini, o3-mini, etc.) work without special flags. `reasoning` mirrors the OpenAI SDK.
189
+ Reasoning models (o1-preview, o1-mini, o3-mini, etc.) follow OpenAI SDK semantics. Pass `reasoning` when you want to override model defaults.
190
190
 
191
191
  ```python
192
192
  pandas_ext.set_responses_model("o1-mini") # Set your reasoning model
@@ -194,7 +194,7 @@ pandas_ext.set_responses_model("o1-mini") # Set your reasoning model
194
194
  result = df.assign(
195
195
  analysis=lambda df: df.text.ai.responses(
196
196
  "Analyze this text step by step",
197
- reasoning={"effort": "none"} # Optional: mirrors the OpenAI SDK argument
197
+ reasoning={"effort": "none"}, # Optional: mirrors the OpenAI SDK argument
198
198
  )
199
199
  )
200
200
  ```
@@ -254,7 +254,7 @@ df = pd.DataFrame({"text": [
254
254
  async def process_data():
255
255
  return await df["text"].aio.responses(
256
256
  "Analyze sentiment and classify as positive/negative/neutral",
257
- reasoning={"effort": "none"}, # Required for gpt-5.1
257
+ reasoning={"effort": "none"}, # Recommended for reasoning models
258
258
  max_concurrency=12 # Allow up to 12 concurrent requests
259
259
  )
260
260
 
@@ -11,7 +11,7 @@ openaivec/_util.py,sha256=XfueAycVCQvgRLS7wF7e306b53lebORvZOBzbQjy4vE,6438
11
11
  openaivec/pandas_ext.py,sha256=_y48qlG-npZsCCJJL1yev-yEU1YBZT83EiVl-lH0__o,87305
12
12
  openaivec/spark.py,sha256=XosDAcbzhnaIGyHBJ-p_ZBVJALroOXOFTjWWNRpSG3o,35022
13
13
  openaivec/_cache/__init__.py,sha256=IYUH5GKsJXuCX-k3XtT259rEz49EZm9KW2TIOTGW4uQ,314
14
- openaivec/_cache/optimize.py,sha256=3nS8VehbS7iGC1tPDDQh-iAgyKHbVYmMbCRBWM77U_U,3827
14
+ openaivec/_cache/optimize.py,sha256=9JKU7HYABx-sYzp9SqoHVljG0aRqzmCY5_KCJc_Uq3M,4545
15
15
  openaivec/_cache/proxy.py,sha256=aVjH_hmJIIso6SetV_-Ct3VaOSG-n9Dpil7TttnbYkE,30556
16
16
  openaivec/_schema/__init__.py,sha256=XUj3Jv6ZVDjyYzSmH6Q5lmDj-hBMfUg_eBNeZACXR6Q,368
17
17
  openaivec/_schema/infer.py,sha256=VyvORgmpkcPa8pITClOJYjNzF4VzgSWe_n-9kFJVUjE,15644
@@ -33,7 +33,7 @@ openaivec/task/nlp/sentiment_analysis.py,sha256=P1AFazqmlE9Dy0OShNOXcY8X5rvsGg7X
33
33
  openaivec/task/nlp/translation.py,sha256=IgTy0PQZVF_Q6qis60STim7Vd7rYPVTfTfwP_U1kAKk,6603
34
34
  openaivec/task/table/__init__.py,sha256=kJz15WDJXjyC7UIHKBvlTRhCf347PCDMH5T5fONV2sU,83
35
35
  openaivec/task/table/fillna.py,sha256=nMlXvlUvyWgM9DxJDeRX3M37jxlqg0MgRet1Ds3ni5Y,6571
36
- openaivec-1.0.10.dist-info/METADATA,sha256=xJPQaqzzlN7rkL519vee4l8ZQRQfVwl9UxkXyzXGToM,14195
37
- openaivec-1.0.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
- openaivec-1.0.10.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
39
- openaivec-1.0.10.dist-info/RECORD,,
36
+ openaivec-1.0.12.dist-info/METADATA,sha256=D5-CBm8n5ReO2vYO5Fpbqby9C2S8xT6IFVOmV-2PjQY,14165
37
+ openaivec-1.0.12.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
+ openaivec-1.0.12.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
39
+ openaivec-1.0.12.dist-info/RECORD,,