openaivec 1.0.4__tar.gz → 1.0.5__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.
Files changed (90) hide show
  1. {openaivec-1.0.4 → openaivec-1.0.5}/PKG-INFO +9 -3
  2. {openaivec-1.0.4 → openaivec-1.0.5}/README.md +8 -2
  3. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_model.py +3 -10
  4. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_responses.py +11 -3
  5. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_schema/infer.py +0 -1
  6. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/pandas_ext.py +45 -26
  7. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/spark.py +4 -7
  8. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/customer_sentiment.py +3 -4
  9. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/inquiry_classification.py +2 -5
  10. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/inquiry_summary.py +2 -5
  11. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/intent_analysis.py +6 -8
  12. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/response_suggestion.py +2 -5
  13. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/urgency_analysis.py +2 -5
  14. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/dependency_parsing.py +3 -4
  15. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/keyword_extraction.py +3 -4
  16. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/morphological_analysis.py +3 -4
  17. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/named_entity_recognition.py +3 -4
  18. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/sentiment_analysis.py +3 -4
  19. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/translation.py +3 -5
  20. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/table/fillna.py +2 -7
  21. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_pandas_ext.py +24 -14
  22. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_spark.py +2 -4
  23. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_task.py +2 -45
  24. {openaivec-1.0.4 → openaivec-1.0.5}/.env.example +0 -0
  25. {openaivec-1.0.4 → openaivec-1.0.5}/.github/copilot-instructions.md +0 -0
  26. {openaivec-1.0.4 → openaivec-1.0.5}/.github/dependabot.yml +0 -0
  27. {openaivec-1.0.4 → openaivec-1.0.5}/.github/workflows/docs.yml +0 -0
  28. {openaivec-1.0.4 → openaivec-1.0.5}/.github/workflows/publish.yml +0 -0
  29. {openaivec-1.0.4 → openaivec-1.0.5}/.github/workflows/test.yml +0 -0
  30. {openaivec-1.0.4 → openaivec-1.0.5}/.gitignore +0 -0
  31. {openaivec-1.0.4 → openaivec-1.0.5}/AGENTS.md +0 -0
  32. {openaivec-1.0.4 → openaivec-1.0.5}/CODE_OF_CONDUCT.md +0 -0
  33. {openaivec-1.0.4 → openaivec-1.0.5}/LICENSE +0 -0
  34. {openaivec-1.0.4 → openaivec-1.0.5}/SECURITY.md +0 -0
  35. {openaivec-1.0.4 → openaivec-1.0.5}/SUPPORT.md +0 -0
  36. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/main.md +0 -0
  37. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/pandas_ext.md +0 -0
  38. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/spark.md +0 -0
  39. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/task.md +0 -0
  40. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/customer_sentiment.md +0 -0
  41. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/inquiry_classification.md +0 -0
  42. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/inquiry_summary.md +0 -0
  43. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/intent_analysis.md +0 -0
  44. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/response_suggestion.md +0 -0
  45. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/customer_support/urgency_analysis.md +0 -0
  46. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/dependency_parsing.md +0 -0
  47. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/keyword_extraction.md +0 -0
  48. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/morphological_analysis.md +0 -0
  49. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/named_entity_recognition.md +0 -0
  50. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/sentiment_analysis.md +0 -0
  51. {openaivec-1.0.4 → openaivec-1.0.5}/docs/api/tasks/nlp/translation.md +0 -0
  52. {openaivec-1.0.4 → openaivec-1.0.5}/docs/contributor-guide.md +0 -0
  53. {openaivec-1.0.4 → openaivec-1.0.5}/docs/index.md +0 -0
  54. {openaivec-1.0.4 → openaivec-1.0.5}/docs/robots.txt +0 -0
  55. {openaivec-1.0.4 → openaivec-1.0.5}/mkdocs.yml +0 -0
  56. {openaivec-1.0.4 → openaivec-1.0.5}/pyproject.toml +0 -0
  57. {openaivec-1.0.4 → openaivec-1.0.5}/pytest.ini +0 -0
  58. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/__init__.py +0 -0
  59. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_cache/__init__.py +0 -0
  60. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_cache/optimize.py +0 -0
  61. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_cache/proxy.py +0 -0
  62. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_di.py +0 -0
  63. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_embeddings.py +0 -0
  64. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_log.py +0 -0
  65. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_prompt.py +0 -0
  66. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_provider.py +0 -0
  67. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_schema/__init__.py +0 -0
  68. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_schema/spec.py +0 -0
  69. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_serialize.py +0 -0
  70. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/_util.py +0 -0
  71. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/__init__.py +0 -0
  72. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/customer_support/__init__.py +0 -0
  73. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/nlp/__init__.py +0 -0
  74. {openaivec-1.0.4 → openaivec-1.0.5}/src/openaivec/task/table/__init__.py +0 -0
  75. {openaivec-1.0.4 → openaivec-1.0.5}/tests/__init__.py +0 -0
  76. {openaivec-1.0.4 → openaivec-1.0.5}/tests/_cache/test_optimize.py +0 -0
  77. {openaivec-1.0.4 → openaivec-1.0.5}/tests/_cache/test_proxy.py +0 -0
  78. {openaivec-1.0.4 → openaivec-1.0.5}/tests/_cache/test_proxy_suggester.py +0 -0
  79. {openaivec-1.0.4 → openaivec-1.0.5}/tests/_schema/test_infer.py +0 -0
  80. {openaivec-1.0.4 → openaivec-1.0.5}/tests/_schema/test_spec.py +0 -0
  81. {openaivec-1.0.4 → openaivec-1.0.5}/tests/conftest.py +0 -0
  82. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_di.py +0 -0
  83. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_embeddings.py +0 -0
  84. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_prompt.py +0 -0
  85. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_provider.py +0 -0
  86. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_responses.py +0 -0
  87. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_serialize.py +0 -0
  88. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_serialize_pydantic_v2_compliance.py +0 -0
  89. {openaivec-1.0.4 → openaivec-1.0.5}/tests/test_util.py +0 -0
  90. {openaivec-1.0.4 → openaivec-1.0.5}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openaivec
3
- Version: 1.0.4
3
+ Version: 1.0.5
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
@@ -215,8 +215,14 @@ text_df = pd.DataFrame({
215
215
  })
216
216
 
217
217
  results = text_df.assign(
218
- sentiment=lambda df: df.text.ai.task(nlp.SENTIMENT_ANALYSIS),
219
- intent=lambda df: df.text.ai.task(customer_support.INTENT_ANALYSIS),
218
+ sentiment=lambda df: df.text.ai.task(
219
+ nlp.SENTIMENT_ANALYSIS,
220
+ reasoning={"effort": "none"},
221
+ ),
222
+ intent=lambda df: df.text.ai.task(
223
+ customer_support.INTENT_ANALYSIS,
224
+ reasoning={"effort": "none"},
225
+ ),
220
226
  )
221
227
 
222
228
  # Extract structured results into separate columns
@@ -189,8 +189,14 @@ text_df = pd.DataFrame({
189
189
  })
190
190
 
191
191
  results = text_df.assign(
192
- sentiment=lambda df: df.text.ai.task(nlp.SENTIMENT_ANALYSIS),
193
- intent=lambda df: df.text.ai.task(customer_support.INTENT_ANALYSIS),
192
+ sentiment=lambda df: df.text.ai.task(
193
+ nlp.SENTIMENT_ANALYSIS,
194
+ reasoning={"effort": "none"},
195
+ ),
196
+ intent=lambda df: df.text.ai.task(
197
+ customer_support.INTENT_ANALYSIS,
198
+ reasoning={"effort": "none"},
199
+ ),
194
200
  )
195
201
 
196
202
  # Extract structured results into separate columns
@@ -1,4 +1,4 @@
1
- from dataclasses import dataclass, field
1
+ from dataclasses import dataclass
2
2
  from typing import Generic, TypeVar
3
3
 
4
4
  __all__ = [
@@ -12,19 +12,14 @@ ResponseFormat = TypeVar("ResponseFormat")
12
12
  class PreparedTask(Generic[ResponseFormat]):
13
13
  """A data class representing a complete task configuration for OpenAI API calls.
14
14
 
15
- This class encapsulates all the necessary parameters for executing a task,
16
- including the instructions to be sent to the model, the expected response
17
- format using Pydantic models, and API parameters for controlling
18
- the model's output behavior.
15
+ This class encapsulates the instructions and expected response format for
16
+ executing a task against the OpenAI Responses API.
19
17
 
20
18
  Attributes:
21
19
  instructions (str): The prompt or instructions to send to the OpenAI model.
22
20
  This should contain clear, specific directions for the task.
23
21
  response_format (type[ResponseFormat]): A Pydantic model class or str type that defines the expected
24
22
  structure of the response. Can be either a BaseModel subclass or str.
25
- api_kwargs (dict[str, int | float | str | bool]): Additional OpenAI API parameters
26
- such as temperature, top_p, frequency_penalty, presence_penalty, seed, etc.
27
- Defaults to an empty dict.
28
23
 
29
24
  Example:
30
25
  Creating a custom task:
@@ -40,7 +35,6 @@ class PreparedTask(Generic[ResponseFormat]):
40
35
  custom_task = PreparedTask(
41
36
  instructions="Translate the following text to French:",
42
37
  response_format=TranslationResponse,
43
- api_kwargs={"temperature": 0.1, "top_p": 0.9}
44
38
  )
45
39
  ```
46
40
 
@@ -51,7 +45,6 @@ class PreparedTask(Generic[ResponseFormat]):
51
45
 
52
46
  instructions: str
53
47
  response_format: type[ResponseFormat]
54
- api_kwargs: dict[str, int | float | str | bool] = field(default_factory=dict)
55
48
 
56
49
 
57
50
  @dataclass(frozen=True)
@@ -202,7 +202,12 @@ class BatchResponses(Generic[ResponseFormat]):
202
202
 
203
203
  @classmethod
204
204
  def of_task(
205
- cls, client: OpenAI, model_name: str, task: PreparedTask[ResponseFormat], batch_size: int | None = None
205
+ cls,
206
+ client: OpenAI,
207
+ model_name: str,
208
+ task: PreparedTask[ResponseFormat],
209
+ batch_size: int | None = None,
210
+ **api_kwargs,
206
211
  ) -> "BatchResponses":
207
212
  """Factory from a PreparedTask.
208
213
 
@@ -212,6 +217,7 @@ class BatchResponses(Generic[ResponseFormat]):
212
217
  task (PreparedTask): Prepared task with instructions and response format.
213
218
  batch_size (int | None, optional): Max unique prompts per API call. Defaults to None
214
219
  (automatic batch size optimization). Set to a positive integer for fixed batch size.
220
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
215
221
 
216
222
  Returns:
217
223
  BatchResponses: Configured instance backed by a batching proxy.
@@ -222,7 +228,7 @@ class BatchResponses(Generic[ResponseFormat]):
222
228
  system_message=task.instructions,
223
229
  response_format=task.response_format,
224
230
  cache=BatchingMapProxy(batch_size=batch_size),
225
- api_kwargs=task.api_kwargs,
231
+ api_kwargs=api_kwargs,
226
232
  )
227
233
 
228
234
  def __post_init__(self):
@@ -403,6 +409,7 @@ class AsyncBatchResponses(Generic[ResponseFormat]):
403
409
  task: PreparedTask[ResponseFormat],
404
410
  batch_size: int | None = None,
405
411
  max_concurrency: int = 8,
412
+ **api_kwargs,
406
413
  ) -> "AsyncBatchResponses":
407
414
  """Factory from a PreparedTask.
408
415
 
@@ -413,6 +420,7 @@ class AsyncBatchResponses(Generic[ResponseFormat]):
413
420
  batch_size (int | None, optional): Max unique prompts per API call. Defaults to None
414
421
  (automatic batch size optimization). Set to a positive integer for fixed batch size.
415
422
  max_concurrency (int, optional): Max concurrent API calls. Defaults to 8.
423
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
416
424
 
417
425
  Returns:
418
426
  AsyncBatchResponses: Configured instance backed by an async batching proxy.
@@ -423,7 +431,7 @@ class AsyncBatchResponses(Generic[ResponseFormat]):
423
431
  system_message=task.instructions,
424
432
  response_format=task.response_format,
425
433
  cache=AsyncBatchingMapProxy(batch_size=batch_size, max_concurrency=max_concurrency),
426
- api_kwargs=task.api_kwargs,
434
+ api_kwargs=api_kwargs,
427
435
  )
428
436
 
429
437
  def __post_init__(self):
@@ -156,7 +156,6 @@ class SchemaInferenceOutput(BaseModel):
156
156
  return PreparedTask(
157
157
  instructions=self.inference_prompt,
158
158
  response_format=self.model,
159
- api_kwargs={"top_p": None, "temperature": None},
160
159
  )
161
160
 
162
161
  def build_model(self) -> type[BaseModel]:
@@ -378,12 +378,13 @@ class OpenAIVecSeriesAccessor:
378
378
  self,
379
379
  task: PreparedTask[ResponseFormat],
380
380
  cache: BatchingMapProxy[str, ResponseFormat],
381
+ **api_kwargs,
381
382
  ) -> pd.Series:
382
383
  """Execute a prepared task on every Series element using a provided cache.
383
384
 
384
- This mirrors ``responses_with_cache`` but uses the task's stored instructions,
385
- response format, and API parameters. A supplied ``BatchingMapProxy`` enables
386
- cross‑operation deduplicated reuse and external batch size / progress control.
385
+ This mirrors ``responses_with_cache`` but uses the task's stored instructions
386
+ and response format. A supplied ``BatchingMapProxy`` enables cross‑operation
387
+ deduplicated reuse and external batch size / progress control.
387
388
 
388
389
  Example:
389
390
  ```python
@@ -393,12 +394,13 @@ class OpenAIVecSeriesAccessor:
393
394
  ```
394
395
 
395
396
  Args:
396
- task (PreparedTask): Prepared task (instructions + response_format + sampling params).
397
+ task (PreparedTask): Prepared task (instructions + response_format).
397
398
  cache (BatchingMapProxy[str, ResponseFormat]): Pre‑configured cache instance.
399
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
398
400
 
399
401
  Note:
400
- The task's stored API parameters are used. Core routing keys (``model``, system
401
- instructions, user input) are managed internally and cannot be overridden.
402
+ Core routing keys (``model``, system instructions, user input) are managed
403
+ internally and cannot be overridden.
402
404
 
403
405
  Returns:
404
406
  pandas.Series: Task results aligned with the original Series index.
@@ -409,7 +411,7 @@ class OpenAIVecSeriesAccessor:
409
411
  system_message=task.instructions,
410
412
  response_format=task.response_format,
411
413
  cache=cache,
412
- api_kwargs=task.api_kwargs,
414
+ api_kwargs=api_kwargs,
413
415
  )
414
416
  return pd.Series(client.parse(self._obj.tolist()), index=self._obj.index, name=self._obj.name)
415
417
 
@@ -418,6 +420,7 @@ class OpenAIVecSeriesAccessor:
418
420
  task: PreparedTask,
419
421
  batch_size: int | None = None,
420
422
  show_progress: bool = True,
423
+ **api_kwargs,
421
424
  ) -> pd.Series:
422
425
  """Execute a prepared task on every Series element.
423
426
 
@@ -443,16 +446,16 @@ class OpenAIVecSeriesAccessor:
443
446
 
444
447
  Args:
445
448
  task (PreparedTask): A pre-configured task containing instructions,
446
- response format, and other parameters for processing the inputs.
449
+ response format for processing the inputs.
447
450
  batch_size (int | None, optional): Number of prompts grouped into a single
448
451
  request to optimize API usage. Defaults to ``None`` (automatic batch size
449
452
  optimization based on execution time). Set to a positive integer for fixed batch size.
450
453
  show_progress (bool, optional): Show progress bar in Jupyter notebooks. Defaults to ``True``.
454
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
451
455
 
452
456
  Note:
453
- The task's stored API parameters are used. Core batching / routing keys
454
- (``model``, ``instructions`` / system message, user ``input``) are managed by the
455
- library and cannot be overridden.
457
+ Core batching / routing keys (``model``, ``instructions`` / system message,
458
+ user ``input``) are managed by the library and cannot be overridden.
456
459
 
457
460
  Returns:
458
461
  pandas.Series: Series whose values are instances of the task's response format.
@@ -460,6 +463,7 @@ class OpenAIVecSeriesAccessor:
460
463
  return self.task_with_cache(
461
464
  task=task,
462
465
  cache=BatchingMapProxy(batch_size=batch_size, show_progress=show_progress),
466
+ **api_kwargs,
463
467
  )
464
468
 
465
469
  def parse_with_cache(
@@ -818,15 +822,17 @@ class OpenAIVecDataFrameAccessor:
818
822
  self,
819
823
  task: PreparedTask[ResponseFormat],
820
824
  cache: BatchingMapProxy[str, ResponseFormat],
825
+ **api_kwargs,
821
826
  ) -> pd.Series:
822
827
  """Execute a prepared task on each DataFrame row after serializing it to JSON using a provided cache.
823
828
 
824
829
  Args:
825
- task (PreparedTask): Prepared task (instructions + response_format + sampling params).
830
+ task (PreparedTask): Prepared task (instructions + response_format).
826
831
  cache (BatchingMapProxy[str, ResponseFormat]): Pre‑configured cache instance.
832
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
827
833
 
828
834
  Note:
829
- The task's stored API parameters are used. Core routing keys are managed internally.
835
+ Core routing keys are managed internally.
830
836
 
831
837
  Returns:
832
838
  pandas.Series: Task results aligned with the DataFrame's original index.
@@ -834,6 +840,7 @@ class OpenAIVecDataFrameAccessor:
834
840
  return _df_rows_to_json_series(self._obj).ai.task_with_cache(
835
841
  task=task,
836
842
  cache=cache,
843
+ **api_kwargs,
837
844
  )
838
845
 
839
846
  def task(
@@ -841,6 +848,7 @@ class OpenAIVecDataFrameAccessor:
841
848
  task: PreparedTask,
842
849
  batch_size: int | None = None,
843
850
  show_progress: bool = True,
851
+ **api_kwargs,
844
852
  ) -> pd.Series:
845
853
  """Execute a prepared task on each DataFrame row after serializing it to JSON.
846
854
 
@@ -870,16 +878,16 @@ class OpenAIVecDataFrameAccessor:
870
878
 
871
879
  Args:
872
880
  task (PreparedTask): A pre-configured task containing instructions,
873
- response format, and other parameters for processing the inputs.
881
+ response format for processing the inputs.
874
882
  batch_size (int | None, optional): Number of requests sent in one batch
875
883
  to optimize API usage. Defaults to ``None`` (automatic batch size
876
884
  optimization based on execution time). Set to a positive integer for fixed batch size.
877
885
  show_progress (bool, optional): Show progress bar in Jupyter notebooks. Defaults to ``True``.
886
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
878
887
 
879
888
  Note:
880
- The task's stored API parameters are used. Core batching / routing
881
- keys (``model``, ``instructions`` / system message, user ``input``) are managed by the
882
- library and cannot be overridden.
889
+ Core batching / routing keys (``model``, ``instructions`` / system message, user ``input``)
890
+ are managed by the library and cannot be overridden.
883
891
 
884
892
  Returns:
885
893
  pandas.Series: Series whose values are instances of the task's
@@ -889,6 +897,7 @@ class OpenAIVecDataFrameAccessor:
889
897
  task=task,
890
898
  batch_size=batch_size,
891
899
  show_progress=show_progress,
900
+ **api_kwargs,
892
901
  )
893
902
 
894
903
  def parse_with_cache(
@@ -1406,6 +1415,7 @@ class AsyncOpenAIVecSeriesAccessor:
1406
1415
  self,
1407
1416
  task: PreparedTask[ResponseFormat],
1408
1417
  cache: AsyncBatchingMapProxy[str, ResponseFormat],
1418
+ **api_kwargs,
1409
1419
  ) -> pd.Series:
1410
1420
  """Execute a prepared task on every Series element using a provided cache (asynchronously).
1411
1421
 
@@ -1416,10 +1426,11 @@ class AsyncOpenAIVecSeriesAccessor:
1416
1426
 
1417
1427
  Args:
1418
1428
  task (PreparedTask): A pre-configured task containing instructions,
1419
- response format, and other parameters for processing the inputs.
1429
+ response format for processing the inputs.
1420
1430
  cache (AsyncBatchingMapProxy[str, ResponseFormat]): Pre-configured cache
1421
1431
  instance for managing API call batching and deduplication.
1422
1432
  Set cache.batch_size=None to enable automatic batch size optimization.
1433
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
1423
1434
 
1424
1435
  Example:
1425
1436
  ```python
@@ -1456,7 +1467,7 @@ class AsyncOpenAIVecSeriesAccessor:
1456
1467
  system_message=task.instructions,
1457
1468
  response_format=task.response_format,
1458
1469
  cache=cache,
1459
- api_kwargs=task.api_kwargs,
1470
+ api_kwargs=api_kwargs,
1460
1471
  )
1461
1472
  results = await client.parse(self._obj.tolist())
1462
1473
 
@@ -1468,6 +1479,7 @@ class AsyncOpenAIVecSeriesAccessor:
1468
1479
  batch_size: int | None = None,
1469
1480
  max_concurrency: int = 8,
1470
1481
  show_progress: bool = True,
1482
+ **api_kwargs,
1471
1483
  ) -> pd.Series:
1472
1484
  """Execute a prepared task on every Series element (asynchronously).
1473
1485
 
@@ -1494,13 +1506,14 @@ class AsyncOpenAIVecSeriesAccessor:
1494
1506
 
1495
1507
  Args:
1496
1508
  task (PreparedTask): A pre-configured task containing instructions,
1497
- response format, and other parameters for processing the inputs.
1509
+ response format for processing the inputs.
1498
1510
  batch_size (int | None, optional): Number of prompts grouped into a single
1499
1511
  request to optimize API usage. Defaults to ``None`` (automatic batch size
1500
1512
  optimization based on execution time). Set to a positive integer for fixed batch size.
1501
1513
  max_concurrency (int, optional): Maximum number of concurrent
1502
1514
  requests. Defaults to 8.
1503
1515
  show_progress (bool, optional): Show progress bar in Jupyter notebooks. Defaults to ``True``.
1516
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
1504
1517
 
1505
1518
  Note:
1506
1519
  The task's stored API parameters are used. Core batching / routing
@@ -1519,6 +1532,7 @@ class AsyncOpenAIVecSeriesAccessor:
1519
1532
  cache=AsyncBatchingMapProxy(
1520
1533
  batch_size=batch_size, max_concurrency=max_concurrency, show_progress=show_progress
1521
1534
  ),
1535
+ **api_kwargs,
1522
1536
  )
1523
1537
 
1524
1538
  async def parse_with_cache(
@@ -1752,17 +1766,19 @@ class AsyncOpenAIVecDataFrameAccessor:
1752
1766
  self,
1753
1767
  task: PreparedTask[ResponseFormat],
1754
1768
  cache: AsyncBatchingMapProxy[str, ResponseFormat],
1769
+ **api_kwargs,
1755
1770
  ) -> pd.Series:
1756
1771
  """Execute a prepared task on each DataFrame row using a provided cache (asynchronously).
1757
1772
 
1758
1773
  After serializing each row to JSON, this method executes the prepared task.
1759
1774
 
1760
1775
  Args:
1761
- task (PreparedTask): Prepared task (instructions + response_format + sampling params).
1776
+ task (PreparedTask): Prepared task (instructions + response_format).
1762
1777
  cache (AsyncBatchingMapProxy[str, ResponseFormat]): Pre‑configured async cache instance.
1778
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
1763
1779
 
1764
1780
  Note:
1765
- The task's stored API parameters are used. Core routing keys are managed internally.
1781
+ Core routing keys are managed internally.
1766
1782
 
1767
1783
  Returns:
1768
1784
  pandas.Series: Task results aligned with the DataFrame's original index.
@@ -1773,6 +1789,7 @@ class AsyncOpenAIVecDataFrameAccessor:
1773
1789
  return await _df_rows_to_json_series(self._obj).aio.task_with_cache(
1774
1790
  task=task,
1775
1791
  cache=cache,
1792
+ **api_kwargs,
1776
1793
  )
1777
1794
 
1778
1795
  async def task(
@@ -1781,6 +1798,7 @@ class AsyncOpenAIVecDataFrameAccessor:
1781
1798
  batch_size: int | None = None,
1782
1799
  max_concurrency: int = 8,
1783
1800
  show_progress: bool = True,
1801
+ **api_kwargs,
1784
1802
  ) -> pd.Series:
1785
1803
  """Execute a prepared task on each DataFrame row after serializing it to JSON (asynchronously).
1786
1804
 
@@ -1811,18 +1829,18 @@ class AsyncOpenAIVecDataFrameAccessor:
1811
1829
 
1812
1830
  Args:
1813
1831
  task (PreparedTask): A pre-configured task containing instructions,
1814
- response format, and other parameters for processing the inputs.
1832
+ response format for processing the inputs.
1815
1833
  batch_size (int | None, optional): Number of requests sent in one batch
1816
1834
  to optimize API usage. Defaults to ``None`` (automatic batch size
1817
1835
  optimization based on execution time). Set to a positive integer for fixed batch size.
1818
1836
  max_concurrency (int, optional): Maximum number of concurrent
1819
1837
  requests. Defaults to 8.
1820
1838
  show_progress (bool, optional): Show progress bar in Jupyter notebooks. Defaults to ``True``.
1839
+ **api_kwargs: Additional OpenAI API parameters forwarded to the Responses API.
1821
1840
 
1822
1841
  Note:
1823
- The task's stored API parameters are used. Core batching / routing
1824
- keys (``model``, ``instructions`` / system message, user ``input``) are managed by the
1825
- library and cannot be overridden.
1842
+ Core batching / routing keys (``model``, ``instructions`` / system message, user ``input``)
1843
+ are managed by the library and cannot be overridden.
1826
1844
 
1827
1845
  Returns:
1828
1846
  pandas.Series: Series whose values are instances of the task's
@@ -1837,6 +1855,7 @@ class AsyncOpenAIVecDataFrameAccessor:
1837
1855
  batch_size=batch_size,
1838
1856
  max_concurrency=max_concurrency,
1839
1857
  show_progress=show_progress,
1858
+ **api_kwargs,
1840
1859
  )
1841
1860
 
1842
1861
  async def parse_with_cache(
@@ -503,8 +503,8 @@ def task_udf(
503
503
  datasets with overlapping content.
504
504
 
505
505
  Args:
506
- task (PreparedTask): A predefined task configuration containing instructions,
507
- response format, and API parameters.
506
+ task (PreparedTask): A predefined task configuration containing instructions
507
+ and response format.
508
508
  model_name (str | None): For Azure OpenAI, use your deployment name (e.g., "my-gpt4-deployment").
509
509
  For OpenAI, use the model name (e.g., "gpt-4.1-mini"). Defaults to configured model in DI container
510
510
  via ResponsesModelName if not provided.
@@ -522,7 +522,7 @@ def task_udf(
522
522
  Arbitrary OpenAI Responses API parameters (e.g. ``temperature``, ``top_p``,
523
523
  ``frequency_penalty``, ``presence_penalty``, ``seed``, ``max_output_tokens``, etc.)
524
524
  are forwarded verbatim to the underlying API calls. These parameters are applied to
525
- all API requests made by the UDF and override any parameters set in the task configuration.
525
+ all API requests made by the UDF.
526
526
 
527
527
  Returns:
528
528
  UserDefinedFunction: A Spark pandas UDF configured to execute the specified task
@@ -543,16 +543,13 @@ def task_udf(
543
543
  **Automatic Caching**: Duplicate inputs within each partition are cached,
544
544
  reducing API calls and costs significantly on datasets with repeated content.
545
545
  """
546
- # Merge task's api_kwargs with caller's api_kwargs (caller takes precedence)
547
- merged_kwargs = {**task.api_kwargs, **api_kwargs}
548
-
549
546
  return responses_udf(
550
547
  instructions=task.instructions,
551
548
  response_format=task.response_format,
552
549
  model_name=model_name,
553
550
  batch_size=batch_size,
554
551
  max_concurrency=max_concurrency,
555
- **merged_kwargs,
552
+ **api_kwargs,
556
553
  )
557
554
 
558
555
 
@@ -95,12 +95,11 @@ class CustomerSentiment(BaseModel):
95
95
  )
96
96
 
97
97
 
98
- def customer_sentiment(business_context: str = "general customer support", **api_kwargs) -> PreparedTask:
98
+ def customer_sentiment(business_context: str = "general customer support") -> PreparedTask:
99
99
  """Create a configurable customer sentiment analysis task.
100
100
 
101
101
  Args:
102
102
  business_context (str): Business context for sentiment analysis.
103
- **api_kwargs: Additional OpenAI API parameters (temperature, top_p, etc.).
104
103
 
105
104
  Returns:
106
105
  PreparedTask configured for customer sentiment analysis.
@@ -166,8 +165,8 @@ values like "positive" for sentiment.
166
165
 
167
166
  Provide comprehensive sentiment analysis with business context and recommended response strategy."""
168
167
 
169
- return PreparedTask(instructions=instructions, response_format=CustomerSentiment, api_kwargs=api_kwargs)
168
+ return PreparedTask(instructions=instructions, response_format=CustomerSentiment)
170
169
 
171
170
 
172
171
  # Backward compatibility - default configuration
173
- CUSTOMER_SENTIMENT = customer_sentiment(temperature=0.0, top_p=1.0)
172
+ CUSTOMER_SENTIMENT = customer_sentiment()
@@ -119,7 +119,6 @@ def inquiry_classification(
119
119
  priority_rules: Dict[str, str] | None = None,
120
120
  business_context: str = "general customer support",
121
121
  custom_keywords: Dict[str, list[str]] | None = None,
122
- **api_kwargs,
123
122
  ) -> PreparedTask:
124
123
  """Create a configurable inquiry classification task.
125
124
 
@@ -132,8 +131,6 @@ def inquiry_classification(
132
131
  Default uses standard priority indicators.
133
132
  business_context (str): Description of the business context to help with classification.
134
133
  custom_keywords (dict[str, list[str]] | None): Dictionary mapping categories to relevant keywords.
135
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
136
- such as temperature, top_p, etc.
137
134
 
138
135
  Returns:
139
136
  PreparedTask configured for inquiry classification.
@@ -253,8 +250,8 @@ language where appropriate, but priority must use English values like "high".
253
250
 
254
251
  Provide accurate classification with detailed reasoning."""
255
252
 
256
- return PreparedTask(instructions=instructions, response_format=InquiryClassification, api_kwargs=api_kwargs)
253
+ return PreparedTask(instructions=instructions, response_format=InquiryClassification)
257
254
 
258
255
 
259
256
  # Backward compatibility - default configuration
260
- INQUIRY_CLASSIFICATION = inquiry_classification(temperature=0.0, top_p=1.0)
257
+ INQUIRY_CLASSIFICATION = inquiry_classification()
@@ -87,15 +87,12 @@ class InquirySummary(BaseModel):
87
87
  def inquiry_summary(
88
88
  summary_length: str = "concise",
89
89
  business_context: str = "general customer support",
90
- **api_kwargs,
91
90
  ) -> PreparedTask:
92
91
  """Create a configurable inquiry summary task.
93
92
 
94
93
  Args:
95
94
  summary_length (str): Length of summary (concise, detailed, bullet_points).
96
95
  business_context (str): Business context for summary.
97
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
98
- such as temperature, top_p, etc.
99
96
 
100
97
  Returns:
101
98
  PreparedTask configured for inquiry summarization.
@@ -162,8 +159,8 @@ input is in German, provide all summary content in German, but use English value
162
159
 
163
160
  Provide accurate, actionable summary that enables efficient support resolution."""
164
161
 
165
- return PreparedTask(instructions=instructions, response_format=InquirySummary, api_kwargs=api_kwargs)
162
+ return PreparedTask(instructions=instructions, response_format=InquirySummary)
166
163
 
167
164
 
168
165
  # Backward compatibility - default configuration
169
- INQUIRY_SUMMARY = inquiry_summary(temperature=0.0, top_p=1.0)
166
+ INQUIRY_SUMMARY = inquiry_summary()
@@ -52,9 +52,9 @@ Example:
52
52
  ```
53
53
 
54
54
  Attributes:
55
- INTENT_ANALYSIS (PreparedTask): A prepared task instance
56
- configured for intent analysis with temperature=0.0 and
57
- top_p=1.0 for deterministic output.
55
+ INTENT_ANALYSIS (PreparedTask): A prepared task instance configured for intent
56
+ analysis. Provide ``temperature=0.0`` and ``top_p=1.0`` to your API calls
57
+ for deterministic output.
58
58
  """
59
59
 
60
60
  from typing import Literal
@@ -100,13 +100,11 @@ class IntentAnalysis(BaseModel):
100
100
  )
101
101
 
102
102
 
103
- def intent_analysis(business_context: str = "general customer support", **api_kwargs) -> PreparedTask:
103
+ def intent_analysis(business_context: str = "general customer support") -> PreparedTask:
104
104
  """Create a configurable intent analysis task.
105
105
 
106
106
  Args:
107
107
  business_context (str): Business context for intent analysis.
108
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
109
- such as temperature, top_p, etc.
110
108
 
111
109
  Returns:
112
110
  PreparedTask configured for intent analysis.
@@ -169,8 +167,8 @@ next_steps, and reasoning in Japanese, but use English values like "get_help" fo
169
167
 
170
168
  Provide comprehensive intent analysis with actionable recommendations."""
171
169
 
172
- return PreparedTask(instructions=instructions, response_format=IntentAnalysis, api_kwargs=api_kwargs)
170
+ return PreparedTask(instructions=instructions, response_format=IntentAnalysis)
173
171
 
174
172
 
175
173
  # Backward compatibility - default configuration
176
- INTENT_ANALYSIS = intent_analysis(temperature=0.0, top_p=1.0)
174
+ INTENT_ANALYSIS = intent_analysis()
@@ -92,7 +92,6 @@ def response_suggestion(
92
92
  response_style: str = "professional",
93
93
  company_name: str = "our company",
94
94
  business_context: str = "general customer support",
95
- **api_kwargs,
96
95
  ) -> PreparedTask:
97
96
  """Create a configurable response suggestion task.
98
97
 
@@ -100,8 +99,6 @@ def response_suggestion(
100
99
  response_style (str): Style of response (professional, friendly, empathetic, formal).
101
100
  company_name (str): Name of the company for personalization.
102
101
  business_context (str): Business context for responses.
103
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
104
- such as temperature, top_p, etc.
105
102
 
106
103
  Returns:
107
104
  PreparedTask configured for response suggestions.
@@ -189,8 +186,8 @@ but use English values like "empathetic" for tone.
189
186
  Generate helpful, professional response that moves toward resolution while maintaining
190
187
  positive customer relationship."""
191
188
 
192
- return PreparedTask(instructions=instructions, response_format=ResponseSuggestion, api_kwargs=api_kwargs)
189
+ return PreparedTask(instructions=instructions, response_format=ResponseSuggestion)
193
190
 
194
191
 
195
192
  # Backward compatibility - default configuration
196
- RESPONSE_SUGGESTION = response_suggestion(temperature=0.0, top_p=1.0)
193
+ RESPONSE_SUGGESTION = response_suggestion()
@@ -135,7 +135,6 @@ def urgency_analysis(
135
135
  business_context: str = "general customer support",
136
136
  business_hours: str = "24/7 support",
137
137
  sla_rules: Dict[str, str] | None = None,
138
- **api_kwargs,
139
138
  ) -> PreparedTask:
140
139
  """Create a configurable urgency analysis task.
141
140
 
@@ -148,8 +147,6 @@ def urgency_analysis(
148
147
  business_context (str): Description of the business context.
149
148
  business_hours (str): Description of business hours for response time calculation.
150
149
  sla_rules (dict[str, str] | None): Dictionary mapping customer tiers to SLA requirements.
151
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
152
- such as temperature, top_p, etc.
153
150
 
154
151
  Returns:
155
152
  PreparedTask configured for urgency analysis.
@@ -286,8 +283,8 @@ urgency_level.
286
283
 
287
284
  Provide detailed analysis with clear reasoning for urgency level and response time recommendations."""
288
285
 
289
- return PreparedTask(instructions=instructions, response_format=UrgencyAnalysis, api_kwargs=api_kwargs)
286
+ return PreparedTask(instructions=instructions, response_format=UrgencyAnalysis)
290
287
 
291
288
 
292
289
  # Backward compatibility - default configuration
293
- URGENCY_ANALYSIS = urgency_analysis(temperature=0.0, top_p=1.0)
290
+ URGENCY_ANALYSIS = urgency_analysis()
@@ -43,9 +43,9 @@ Example:
43
43
  ```
44
44
 
45
45
  Attributes:
46
- DEPENDENCY_PARSING (PreparedTask): A prepared task instance
47
- configured for dependency parsing with temperature=0.0 and
48
- top_p=1.0 for deterministic output.
46
+ DEPENDENCY_PARSING (PreparedTask): A prepared task instance configured for dependency
47
+ parsing. Provide ``temperature=0.0`` and ``top_p=1.0`` when calling the API for
48
+ deterministic output.
49
49
  """
50
50
 
51
51
  from pydantic import BaseModel, Field
@@ -75,5 +75,4 @@ DEPENDENCY_PARSING = PreparedTask(
75
75
  "relations between words, determine the root word, and provide a tree representation of the "
76
76
  "syntactic structure.",
77
77
  response_format=DependencyParsing,
78
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
79
78
  )
@@ -45,9 +45,9 @@ Example:
45
45
  ```
46
46
 
47
47
  Attributes:
48
- KEYWORD_EXTRACTION (PreparedTask): A prepared task instance
49
- configured for keyword extraction with temperature=0.0 and
50
- top_p=1.0 for deterministic output.
48
+ KEYWORD_EXTRACTION (PreparedTask): A prepared task instance configured for keyword
49
+ extraction. Provide ``temperature=0.0`` and ``top_p=1.0`` when calling the API
50
+ for deterministic output.
51
51
  """
52
52
 
53
53
  from pydantic import BaseModel, Field
@@ -75,5 +75,4 @@ KEYWORD_EXTRACTION = PreparedTask(
75
75
  instructions="Extract important keywords and phrases from the following text. Rank them "
76
76
  "by importance, provide frequency counts, identify main topics, and generate a brief summary.",
77
77
  response_format=KeywordExtraction,
78
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
79
78
  )
@@ -44,9 +44,9 @@ Example:
44
44
  ```
45
45
 
46
46
  Attributes:
47
- MORPHOLOGICAL_ANALYSIS (PreparedTask): A prepared task instance
48
- configured for morphological analysis with temperature=0.0 and
49
- top_p=1.0 for deterministic output.
47
+ MORPHOLOGICAL_ANALYSIS (PreparedTask): A prepared task instance configured
48
+ for morphological analysis. Provide ``temperature=0.0`` and ``top_p=1.0`` to
49
+ API calls for deterministic output.
50
50
  """
51
51
 
52
52
  from pydantic import BaseModel, Field
@@ -70,5 +70,4 @@ MORPHOLOGICAL_ANALYSIS = PreparedTask(
70
70
  "identify part-of-speech tags, provide lemmatized forms, and extract morphological features "
71
71
  "for each token.",
72
72
  response_format=MorphologicalAnalysis,
73
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
74
73
  )
@@ -43,9 +43,9 @@ Example:
43
43
  ```
44
44
 
45
45
  Attributes:
46
- NAMED_ENTITY_RECOGNITION (PreparedTask): A prepared task instance
47
- configured for named entity recognition with temperature=0.0 and
48
- top_p=1.0 for deterministic output.
46
+ NAMED_ENTITY_RECOGNITION (PreparedTask): A prepared task instance configured for named
47
+ entity recognition. Provide ``temperature=0.0`` and ``top_p=1.0`` to API calls for
48
+ deterministic output.
49
49
  """
50
50
 
51
51
  from pydantic import BaseModel, Field
@@ -78,5 +78,4 @@ NAMED_ENTITY_RECOGNITION = PreparedTask(
78
78
  "organizations, locations, dates, money, percentages, and other miscellaneous entities "
79
79
  "with their positions and confidence scores.",
80
80
  response_format=NamedEntityRecognition,
81
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
82
81
  )
@@ -43,9 +43,9 @@ Example:
43
43
  ```
44
44
 
45
45
  Attributes:
46
- SENTIMENT_ANALYSIS (PreparedTask): A prepared task instance
47
- configured for sentiment analysis with temperature=0.0 and
48
- top_p=1.0 for deterministic output.
46
+ SENTIMENT_ANALYSIS (PreparedTask): A prepared task instance configured for sentiment
47
+ analysis. Provide ``temperature=0.0`` and ``top_p=1.0`` to API calls for
48
+ deterministic output.
49
49
  """
50
50
 
51
51
  from typing import Literal
@@ -78,5 +78,4 @@ SENTIMENT_ANALYSIS = PreparedTask(
78
78
  "English values specified (positive/negative/neutral for sentiment, and "
79
79
  "joy/sadness/anger/fear/surprise/disgust for emotions).",
80
80
  response_format=SentimentAnalysis,
81
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
82
81
  )
@@ -49,8 +49,8 @@ Example:
49
49
 
50
50
  Attributes:
51
51
  MULTILINGUAL_TRANSLATION (PreparedTask): A prepared task instance configured
52
- for multilingual translation with temperature=0.0 and top_p=1.0 for
53
- deterministic output.
52
+ for multilingual translation. Provide ``temperature=0.0`` and ``top_p=1.0``
53
+ to the calling API wrapper for deterministic output.
54
54
 
55
55
  Note:
56
56
  The translation covers 58 languages across major language families. All field
@@ -156,6 +156,4 @@ class TranslatedString(BaseModel):
156
156
 
157
157
  instructions = "Translate the following text into multiple languages. "
158
158
 
159
- MULTILINGUAL_TRANSLATION = PreparedTask(
160
- instructions=instructions, response_format=TranslatedString, api_kwargs={"temperature": 0.0, "top_p": 1.0}
161
- )
159
+ MULTILINGUAL_TRANSLATION = PreparedTask(instructions=instructions, response_format=TranslatedString)
@@ -125,7 +125,7 @@ class FillNaResponse(BaseModel):
125
125
  )
126
126
 
127
127
 
128
- def fillna(df: pd.DataFrame, target_column_name: str, max_examples: int = 500, **api_kwargs) -> PreparedTask:
128
+ def fillna(df: pd.DataFrame, target_column_name: str, max_examples: int = 500) -> PreparedTask:
129
129
  """Create a prepared task for filling missing values in a DataFrame column.
130
130
 
131
131
  Analyzes the provided DataFrame to understand data patterns and creates
@@ -141,8 +141,6 @@ def fillna(df: pd.DataFrame, target_column_name: str, max_examples: int = 500, *
141
141
  max_examples (int): Maximum number of example rows to use for few-shot
142
142
  learning. Defaults to 500. Higher values provide more context
143
143
  but increase token usage and processing time.
144
- **api_kwargs: Additional keyword arguments to pass to the OpenAI API,
145
- such as temperature, top_p, etc.
146
144
 
147
145
  Returns:
148
146
  PreparedTask configured for missing value imputation with:
@@ -182,7 +180,4 @@ def fillna(df: pd.DataFrame, target_column_name: str, max_examples: int = 500, *
182
180
  if df[target_column_name].notna().sum() == 0:
183
181
  raise ValueError(f"Column '{target_column_name}' contains no non-null values for training examples.")
184
182
  instructions = get_instructions(df, target_column_name, max_examples)
185
- # Set default values for deterministic results if not provided
186
- if not api_kwargs:
187
- api_kwargs = {"temperature": 0.0, "top_p": 1.0}
188
- return PreparedTask(instructions=instructions, response_format=FillNaResponse, api_kwargs=api_kwargs)
183
+ return PreparedTask(instructions=instructions, response_format=FillNaResponse)
@@ -85,12 +85,10 @@ class TestPandasExt:
85
85
  """Test Series.ai.task method with actual task execution."""
86
86
  from openaivec._model import PreparedTask
87
87
 
88
- task = PreparedTask(
89
- instructions="Translate to French", response_format=str, api_kwargs={"temperature": 0.0, "top_p": 1.0}
90
- )
88
+ task = PreparedTask(instructions="Translate to French", response_format=str)
91
89
 
92
90
  series = pd.Series(["cat", "dog"])
93
- results = series.ai.task(task=task, batch_size=2, show_progress=False)
91
+ results = series.ai.task(task=task, batch_size=2, show_progress=False, temperature=0.0, top_p=1.0)
94
92
 
95
93
  assert len(results) == 2
96
94
  assert results.index.equals(series.index)
@@ -142,12 +140,11 @@ class TestPandasExt:
142
140
  task = PreparedTask(
143
141
  instructions="Extract the animal name from the data",
144
142
  response_format=str,
145
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
146
143
  )
147
144
 
148
145
  df = pd.DataFrame([{"animal": "cat", "legs": 4}, {"animal": "dog", "legs": 4}])
149
146
 
150
- results = df.ai.task(task=task, batch_size=2, show_progress=False)
147
+ results = df.ai.task(task=task, batch_size=2, show_progress=False, temperature=0.0, top_p=1.0)
151
148
 
152
149
  assert len(results) == 2
153
150
  assert results.index.equals(df.index)
@@ -236,12 +233,18 @@ class TestPandasExt:
236
233
  task = PreparedTask(
237
234
  instructions="Classify sentiment as positive or negative",
238
235
  response_format=str,
239
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
240
236
  )
241
237
 
242
238
  series = pd.Series(["I love this!", "This is terrible"])
243
239
 
244
- return await series.aio.task(task=task, batch_size=2, max_concurrency=2, show_progress=False)
240
+ return await series.aio.task(
241
+ task=task,
242
+ batch_size=2,
243
+ max_concurrency=2,
244
+ show_progress=False,
245
+ temperature=0.0,
246
+ top_p=1.0,
247
+ )
245
248
 
246
249
  results = asyncio.run(run_test())
247
250
 
@@ -287,13 +290,18 @@ class TestPandasExt:
287
290
  from openaivec._model import PreparedTask
288
291
 
289
292
  async def run_test():
290
- task = PreparedTask(
291
- instructions="Describe the animal", response_format=str, api_kwargs={"temperature": 0.0, "top_p": 1.0}
292
- )
293
+ task = PreparedTask(instructions="Describe the animal", response_format=str)
293
294
 
294
295
  df = pd.DataFrame([{"name": "fluffy", "type": "cat"}, {"name": "buddy", "type": "dog"}])
295
296
 
296
- return await df.aio.task(task=task, batch_size=2, max_concurrency=2, show_progress=False)
297
+ return await df.aio.task(
298
+ task=task,
299
+ batch_size=2,
300
+ max_concurrency=2,
301
+ show_progress=False,
302
+ temperature=0.0,
303
+ top_p=1.0,
304
+ )
297
305
 
298
306
  results = asyncio.run(run_test())
299
307
 
@@ -627,8 +635,10 @@ class TestPandasExt:
627
635
  task = fillna(df_with_missing, "name")
628
636
 
629
637
  assert task is not None
630
- assert task.api_kwargs.get("temperature") == 0.0
631
- assert task.api_kwargs.get("top_p") == 1.0
638
+ assert isinstance(task.instructions, str)
639
+ assert task.response_format.__name__ == "FillNaResponse"
640
+ with pytest.raises(AttributeError):
641
+ _ = task.api_kwargs
632
642
 
633
643
  def test_fillna_task_validation(self):
634
644
  """Test fillna validation with various edge cases."""
@@ -109,12 +109,11 @@ class TestSparkUDFs:
109
109
  simple_task = PreparedTask(
110
110
  instructions="Repeat the input text twice, separated by a space.",
111
111
  response_format=str,
112
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
113
112
  )
114
113
 
115
114
  self.spark.udf.register(
116
115
  "repeat_text",
117
- task_udf(task=simple_task),
116
+ task_udf(task=simple_task, temperature=0.0, top_p=1.0),
118
117
  )
119
118
 
120
119
  text_data = [("hello",), ("world",), ("test",)]
@@ -141,12 +140,11 @@ class TestSparkUDFs:
141
140
  structured_task = PreparedTask(
142
141
  instructions="Analyze the text and return the original text and its length.",
143
142
  response_format=SimpleResponse,
144
- api_kwargs={"temperature": 0.0, "top_p": 1.0},
145
143
  )
146
144
 
147
145
  self.spark.udf.register(
148
146
  "analyze_text",
149
- task_udf(task=structured_task),
147
+ task_udf(task=structured_task, temperature=0.0, top_p=1.0),
150
148
  )
151
149
 
152
150
  text_data = [("hello",), ("world",), ("testing",)]
@@ -24,19 +24,8 @@ class TestPreparedTask:
24
24
 
25
25
  assert task.instructions == "Test instruction"
26
26
  assert task.response_format == SimpleResponse
27
- assert task.api_kwargs == {}
28
-
29
- def test_prepared_task_creation_with_custom_parameters(self):
30
- """Test creating a PreparedTask with custom parameters."""
31
- task = PreparedTask(
32
- instructions="Custom instruction",
33
- response_format=SimpleResponse,
34
- api_kwargs={"temperature": 0.7, "top_p": 0.9},
35
- )
36
-
37
- assert task.instructions == "Custom instruction"
38
- assert task.response_format == SimpleResponse
39
- assert task.api_kwargs == {"temperature": 0.7, "top_p": 0.9}
27
+ with pytest.raises(AttributeError):
28
+ _ = task.api_kwargs
40
29
 
41
30
  def test_prepared_task_is_frozen(self):
42
31
  """Test that PreparedTask is immutable (frozen)."""
@@ -46,37 +35,6 @@ class TestPreparedTask:
46
35
  with pytest.raises(FrozenInstanceError):
47
36
  task.instructions = "Modified instruction"
48
37
 
49
- with pytest.raises(FrozenInstanceError):
50
- task.api_kwargs = {"temperature": 0.5}
51
-
52
- def test_prepared_task_api_kwargs_temperature_bounds(self):
53
- """Test PreparedTask accepts valid temperature values in api_kwargs."""
54
- # Test minimum temperature
55
- task_min = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"temperature": 0.0})
56
- assert task_min.api_kwargs["temperature"] == 0.0
57
-
58
- # Test maximum temperature
59
- task_max = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"temperature": 1.0})
60
- assert task_max.api_kwargs["temperature"] == 1.0
61
-
62
- # Test intermediate value
63
- task_mid = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"temperature": 0.5})
64
- assert task_mid.api_kwargs["temperature"] == 0.5
65
-
66
- def test_prepared_task_api_kwargs_top_p_bounds(self):
67
- """Test PreparedTask accepts valid top_p values in api_kwargs."""
68
- # Test minimum top_p
69
- task_min = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"top_p": 0.0})
70
- assert task_min.api_kwargs["top_p"] == 0.0
71
-
72
- # Test maximum top_p
73
- task_max = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"top_p": 1.0})
74
- assert task_max.api_kwargs["top_p"] == 1.0
75
-
76
- # Test intermediate value
77
- task_mid = PreparedTask(instructions="Test", response_format=SimpleResponse, api_kwargs={"top_p": 0.5})
78
- assert task_mid.api_kwargs["top_p"] == 0.5
79
-
80
38
  def test_prepared_task_response_format_type(self):
81
39
  """Test that response_format must be a Pydantic BaseModel type."""
82
40
  task = PreparedTask(instructions="Test", response_format=SimpleResponse)
@@ -101,7 +59,6 @@ class TestMultilingualTranslationTask:
101
59
  assert task.instructions is not None
102
60
  assert len(task.instructions) > 0
103
61
  assert task.response_format == TranslatedString
104
- assert task.api_kwargs == {"temperature": 0.0, "top_p": 1.0}
105
62
 
106
63
  def test_multilingual_translation_task_instructions(self):
107
64
  """Test that translation task has appropriate instructions."""
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes