openaivec 0.13.5__tar.gz → 0.13.7__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.
- {openaivec-0.13.5 → openaivec-0.13.7}/.github/copilot-instructions.md +26 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.github/workflows/python-test.yml +3 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/PKG-INFO +9 -9
- {openaivec-0.13.5 → openaivec-0.13.7}/README.md +8 -8
- {openaivec-0.13.5 → openaivec-0.13.7}/pyproject.toml +1 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/__init__.py +7 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/di.py +2 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/embeddings.py +10 -8
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/log.py +1 -1
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/model.py +12 -10
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/optimize.py +4 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/pandas_ext.py +68 -42
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/prompt.py +58 -8
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/provider.py +12 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/proxy.py +84 -65
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/responses.py +35 -18
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/serialize.py +1 -1
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/spark.py +49 -34
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/inquiry_classification.py +9 -9
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/urgency_analysis.py +13 -13
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/keyword_extraction.py +2 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/named_entity_recognition.py +2 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/util.py +4 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_optimize.py +2 -2
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_provider.py +28 -28
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_proxy.py +9 -9
- {openaivec-0.13.5 → openaivec-0.13.7}/uv.lock +24 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.env.example +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.github/workflows/python-mkdocs.yml +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.github/workflows/python-package.yml +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.github/workflows/python-update.yml +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/.gitignore +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/CODE_OF_CONDUCT.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/LICENSE +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/SECURITY.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/SUPPORT.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/di.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/embeddings.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/pandas_ext.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/prompt.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/proxy.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/responses.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/spark.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/task.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/customer_sentiment.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/inquiry_classification.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/inquiry_summary.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/intent_analysis.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/response_suggestion.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/customer_support/urgency_analysis.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/dependency_parsing.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/keyword_extraction.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/morphological_analysis.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/named_entity_recognition.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/sentiment_analysis.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/tasks/nlp/translation.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/api/util.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/index.md +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/docs/robots.txt +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/mkdocs.yml +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/__init__.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/__init__.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/customer_sentiment.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/inquiry_summary.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/intent_analysis.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/customer_support/response_suggestion.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/__init__.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/dependency_parsing.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/morphological_analysis.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/sentiment_analysis.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/nlp/translation.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/table/__init__.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/src/openaivec/task/table/fillna.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/__init__.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_di.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_embeddings.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_pandas_ext.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_prompt.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_proxy_suggester.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_responses.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_serialize.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_spark.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_task.py +0 -0
- {openaivec-0.13.5 → openaivec-0.13.7}/tests/test_util.py +0 -0
|
@@ -138,6 +138,32 @@ Don’t
|
|
|
138
138
|
- Use `asyncio.run` in async tests (mirrors existing tests)
|
|
139
139
|
- Optional integration tests can run with valid API keys; keep unit tests independent of network
|
|
140
140
|
|
|
141
|
+
## Package Visibility Guidelines (`__all__`)
|
|
142
|
+
|
|
143
|
+
### Public API Modules
|
|
144
|
+
These modules are part of the public API and should have comprehensive `__all__` declarations:
|
|
145
|
+
|
|
146
|
+
- `embeddings.py` - Batch embedding processing
|
|
147
|
+
- `model.py` - Task configuration models
|
|
148
|
+
- `prompt.py` - Few-shot prompt building
|
|
149
|
+
- `responses.py` - Batch response processing
|
|
150
|
+
- `spark.py` - Apache Spark UDF builders
|
|
151
|
+
- `pandas_ext.py` - Pandas DataFrame/Series extensions
|
|
152
|
+
- `task/*` - All task modules (NLP, customer support, table operations)
|
|
153
|
+
|
|
154
|
+
### Internal Modules
|
|
155
|
+
These modules are for internal use only and should have `__all__ = []`:
|
|
156
|
+
|
|
157
|
+
- All other modules not listed above (util.py, serialize.py, log.py, provider.py, proxy.py, di.py, optimize.py, etc.)
|
|
158
|
+
|
|
159
|
+
### `__all__` Best Practices
|
|
160
|
+
|
|
161
|
+
1. **Public modules**: Include all classes, functions, and constants intended for external use
|
|
162
|
+
2. **Internal modules**: Use `__all__ = []` to explicitly mark as internal-only
|
|
163
|
+
3. **Task modules**: Each task module should export its main classes/functions
|
|
164
|
+
4. **Package `__init__.py`**: Re-export public API from all public modules
|
|
165
|
+
5. **Consistency**: Maintain alphabetical ordering within `__all__` lists
|
|
166
|
+
|
|
141
167
|
## Documentation (MkDocs)
|
|
142
168
|
|
|
143
169
|
- For new developer-facing APIs, update `docs/api/` and consider a short example under `docs/examples/`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openaivec
|
|
3
|
-
Version: 0.13.
|
|
3
|
+
Version: 0.13.7
|
|
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
|
|
@@ -159,7 +159,7 @@ client = BatchResponses.of(
|
|
|
159
159
|
client=OpenAI(),
|
|
160
160
|
model_name="gpt-4.1-mini",
|
|
161
161
|
system_message="Please answer only with 'xx family' and do not output anything else.",
|
|
162
|
-
batch_size
|
|
162
|
+
# batch_size defaults to None (automatic optimization)
|
|
163
163
|
)
|
|
164
164
|
|
|
165
165
|
result = client.parse(["panda", "rabbit", "koala"])
|
|
@@ -304,7 +304,7 @@ async def process_data():
|
|
|
304
304
|
# Asynchronous processing with fine-tuned concurrency control
|
|
305
305
|
results = await df["text"].aio.responses(
|
|
306
306
|
"Analyze sentiment and classify as positive/negative/neutral",
|
|
307
|
-
|
|
307
|
+
# batch_size defaults to None (automatic optimization)
|
|
308
308
|
max_concurrency=12 # Allow up to 12 concurrent requests
|
|
309
309
|
)
|
|
310
310
|
return results
|
|
@@ -315,7 +315,7 @@ sentiments = asyncio.run(process_data())
|
|
|
315
315
|
|
|
316
316
|
**Key Parameters for Performance Tuning:**
|
|
317
317
|
|
|
318
|
-
- **`batch_size`** (default:
|
|
318
|
+
- **`batch_size`** (default: None): Controls how many inputs are grouped into a single API request. When None (default), automatic batch size optimization adjusts based on execution time. Set to a positive integer for fixed batch size. Higher values reduce API call overhead but increase memory usage and request processing time.
|
|
319
319
|
- **`max_concurrency`** (default: 8): Limits the number of concurrent API requests. Higher values increase throughput but may hit rate limits or overwhelm the API.
|
|
320
320
|
|
|
321
321
|
**Performance Benefits:**
|
|
@@ -460,12 +460,12 @@ When using openaivec with Spark, proper configuration of `batch_size` and `max_c
|
|
|
460
460
|
- **Transparent**: Works automatically without code changes - your existing UDFs become more efficient
|
|
461
461
|
- **Partition-Level**: Each partition maintains its own cache, optimal for distributed processing patterns
|
|
462
462
|
|
|
463
|
-
**`batch_size`** (default:
|
|
463
|
+
**`batch_size`** (default: None):
|
|
464
464
|
|
|
465
465
|
- Controls how many rows are processed together in each API request within a partition
|
|
466
|
-
- **
|
|
467
|
-
- **
|
|
468
|
-
- **Recommendation**: 32-128
|
|
466
|
+
- **Default (None)**: Automatic batch size optimization adjusts based on execution time
|
|
467
|
+
- **Positive integer**: Fixed batch size - larger values reduce API calls but increase memory usage
|
|
468
|
+
- **Recommendation**: Use default automatic optimization, or set 32-128 for fixed batch size
|
|
469
469
|
|
|
470
470
|
**`max_concurrency`** (default: 8):
|
|
471
471
|
|
|
@@ -483,7 +483,7 @@ spark.udf.register(
|
|
|
483
483
|
"analyze_sentiment",
|
|
484
484
|
responses_udf(
|
|
485
485
|
instructions="Analyze sentiment as positive/negative/neutral",
|
|
486
|
-
|
|
486
|
+
# batch_size defaults to None (automatic optimization)
|
|
487
487
|
max_concurrency=8 # 80 total concurrent requests across cluster
|
|
488
488
|
)
|
|
489
489
|
)
|
|
@@ -133,7 +133,7 @@ client = BatchResponses.of(
|
|
|
133
133
|
client=OpenAI(),
|
|
134
134
|
model_name="gpt-4.1-mini",
|
|
135
135
|
system_message="Please answer only with 'xx family' and do not output anything else.",
|
|
136
|
-
batch_size
|
|
136
|
+
# batch_size defaults to None (automatic optimization)
|
|
137
137
|
)
|
|
138
138
|
|
|
139
139
|
result = client.parse(["panda", "rabbit", "koala"])
|
|
@@ -278,7 +278,7 @@ async def process_data():
|
|
|
278
278
|
# Asynchronous processing with fine-tuned concurrency control
|
|
279
279
|
results = await df["text"].aio.responses(
|
|
280
280
|
"Analyze sentiment and classify as positive/negative/neutral",
|
|
281
|
-
|
|
281
|
+
# batch_size defaults to None (automatic optimization)
|
|
282
282
|
max_concurrency=12 # Allow up to 12 concurrent requests
|
|
283
283
|
)
|
|
284
284
|
return results
|
|
@@ -289,7 +289,7 @@ sentiments = asyncio.run(process_data())
|
|
|
289
289
|
|
|
290
290
|
**Key Parameters for Performance Tuning:**
|
|
291
291
|
|
|
292
|
-
- **`batch_size`** (default:
|
|
292
|
+
- **`batch_size`** (default: None): Controls how many inputs are grouped into a single API request. When None (default), automatic batch size optimization adjusts based on execution time. Set to a positive integer for fixed batch size. Higher values reduce API call overhead but increase memory usage and request processing time.
|
|
293
293
|
- **`max_concurrency`** (default: 8): Limits the number of concurrent API requests. Higher values increase throughput but may hit rate limits or overwhelm the API.
|
|
294
294
|
|
|
295
295
|
**Performance Benefits:**
|
|
@@ -434,12 +434,12 @@ When using openaivec with Spark, proper configuration of `batch_size` and `max_c
|
|
|
434
434
|
- **Transparent**: Works automatically without code changes - your existing UDFs become more efficient
|
|
435
435
|
- **Partition-Level**: Each partition maintains its own cache, optimal for distributed processing patterns
|
|
436
436
|
|
|
437
|
-
**`batch_size`** (default:
|
|
437
|
+
**`batch_size`** (default: None):
|
|
438
438
|
|
|
439
439
|
- Controls how many rows are processed together in each API request within a partition
|
|
440
|
-
- **
|
|
441
|
-
- **
|
|
442
|
-
- **Recommendation**: 32-128
|
|
440
|
+
- **Default (None)**: Automatic batch size optimization adjusts based on execution time
|
|
441
|
+
- **Positive integer**: Fixed batch size - larger values reduce API calls but increase memory usage
|
|
442
|
+
- **Recommendation**: Use default automatic optimization, or set 32-128 for fixed batch size
|
|
443
443
|
|
|
444
444
|
**`max_concurrency`** (default: 8):
|
|
445
445
|
|
|
@@ -457,7 +457,7 @@ spark.udf.register(
|
|
|
457
457
|
"analyze_sentiment",
|
|
458
458
|
responses_udf(
|
|
459
459
|
instructions="Analyze sentiment as positive/negative/neutral",
|
|
460
|
-
|
|
460
|
+
# batch_size defaults to None (automatic optimization)
|
|
461
461
|
max_concurrency=8 # 80 total concurrent requests across cluster
|
|
462
462
|
)
|
|
463
463
|
)
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
from .embeddings import AsyncBatchEmbeddings, BatchEmbeddings
|
|
2
|
+
from .model import PreparedTask
|
|
3
|
+
from .prompt import FewShotPrompt, FewShotPromptBuilder
|
|
2
4
|
from .responses import AsyncBatchResponses, BatchResponses
|
|
3
5
|
|
|
4
6
|
__all__ = [
|
|
5
|
-
"
|
|
7
|
+
"AsyncBatchEmbeddings",
|
|
6
8
|
"AsyncBatchResponses",
|
|
7
9
|
"BatchEmbeddings",
|
|
8
|
-
"
|
|
10
|
+
"BatchResponses",
|
|
11
|
+
"FewShotPrompt",
|
|
12
|
+
"FewShotPromptBuilder",
|
|
13
|
+
"PreparedTask",
|
|
9
14
|
]
|
|
@@ -2,6 +2,8 @@ from dataclasses import dataclass, field
|
|
|
2
2
|
from threading import RLock
|
|
3
3
|
from typing import Any, Callable, Dict, Set, Type, TypeVar
|
|
4
4
|
|
|
5
|
+
__all__ = []
|
|
6
|
+
|
|
5
7
|
"""Simple dependency injection container with singleton lifecycle management.
|
|
6
8
|
|
|
7
9
|
This module provides a lightweight dependency injection container that manages
|
|
@@ -31,16 +31,17 @@ class BatchEmbeddings:
|
|
|
31
31
|
|
|
32
32
|
client: OpenAI
|
|
33
33
|
model_name: str
|
|
34
|
-
cache: BatchingMapProxy[str, NDArray[np.float32]] = field(default_factory=lambda: BatchingMapProxy(batch_size=
|
|
34
|
+
cache: BatchingMapProxy[str, NDArray[np.float32]] = field(default_factory=lambda: BatchingMapProxy(batch_size=None))
|
|
35
35
|
|
|
36
36
|
@classmethod
|
|
37
|
-
def of(cls, client: OpenAI, model_name: str, batch_size: int =
|
|
37
|
+
def of(cls, client: OpenAI, model_name: str, batch_size: int | None = None) -> "BatchEmbeddings":
|
|
38
38
|
"""Factory constructor.
|
|
39
39
|
|
|
40
40
|
Args:
|
|
41
41
|
client (OpenAI): OpenAI client.
|
|
42
42
|
model_name (str): For Azure OpenAI, use your deployment name. For OpenAI, use the model name.
|
|
43
|
-
batch_size (int, optional): Max unique inputs per API call. Defaults to
|
|
43
|
+
batch_size (int | None, optional): Max unique inputs per API call. Defaults to None
|
|
44
|
+
(automatic batch size optimization). Set to a positive integer for fixed batch size.
|
|
44
45
|
|
|
45
46
|
Returns:
|
|
46
47
|
BatchEmbeddings: Configured instance backed by a batching proxy.
|
|
@@ -127,7 +128,7 @@ class AsyncBatchEmbeddings:
|
|
|
127
128
|
client: AsyncOpenAI
|
|
128
129
|
model_name: str
|
|
129
130
|
cache: AsyncBatchingMapProxy[str, NDArray[np.float32]] = field(
|
|
130
|
-
default_factory=lambda: AsyncBatchingMapProxy(batch_size=
|
|
131
|
+
default_factory=lambda: AsyncBatchingMapProxy(batch_size=None, max_concurrency=8)
|
|
131
132
|
)
|
|
132
133
|
|
|
133
134
|
@classmethod
|
|
@@ -135,7 +136,7 @@ class AsyncBatchEmbeddings:
|
|
|
135
136
|
cls,
|
|
136
137
|
client: AsyncOpenAI,
|
|
137
138
|
model_name: str,
|
|
138
|
-
batch_size: int =
|
|
139
|
+
batch_size: int | None = None,
|
|
139
140
|
max_concurrency: int = 8,
|
|
140
141
|
) -> "AsyncBatchEmbeddings":
|
|
141
142
|
"""Factory constructor.
|
|
@@ -143,7 +144,8 @@ class AsyncBatchEmbeddings:
|
|
|
143
144
|
Args:
|
|
144
145
|
client (AsyncOpenAI): OpenAI async client.
|
|
145
146
|
model_name (str): For Azure OpenAI, use your deployment name. For OpenAI, use the model name.
|
|
146
|
-
batch_size (int, optional): Max unique inputs per API call. Defaults to
|
|
147
|
+
batch_size (int | None, optional): Max unique inputs per API call. Defaults to None
|
|
148
|
+
(automatic batch size optimization). Set to a positive integer for fixed batch size.
|
|
147
149
|
max_concurrency (int, optional): Max concurrent API calls. Defaults to 8.
|
|
148
150
|
|
|
149
151
|
Returns:
|
|
@@ -155,8 +157,8 @@ class AsyncBatchEmbeddings:
|
|
|
155
157
|
cache=AsyncBatchingMapProxy(batch_size=batch_size, max_concurrency=max_concurrency),
|
|
156
158
|
)
|
|
157
159
|
|
|
158
|
-
@observe(_LOGGER)
|
|
159
160
|
@backoff_async(exceptions=[RateLimitError, InternalServerError], scale=1, max_retries=12)
|
|
161
|
+
@observe(_LOGGER)
|
|
160
162
|
async def _embed_chunk(self, inputs: List[str]) -> List[NDArray[np.float32]]:
|
|
161
163
|
"""Embed one minibatch of strings asynchronously.
|
|
162
164
|
|
|
@@ -186,4 +188,4 @@ class AsyncBatchEmbeddings:
|
|
|
186
188
|
Returns:
|
|
187
189
|
List[NDArray[np.float32]]: Embedding vectors aligned to ``inputs``.
|
|
188
190
|
"""
|
|
189
|
-
return await self.cache.map(inputs, self._embed_chunk)
|
|
191
|
+
return await self.cache.map(inputs, self._embed_chunk) # type: ignore[arg-type]
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import Type, TypeVar
|
|
2
|
+
from typing import Generic, Type, TypeVar
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
__all__ = [
|
|
5
|
+
"PreparedTask",
|
|
6
|
+
]
|
|
5
7
|
|
|
6
|
-
ResponseFormat = TypeVar("ResponseFormat"
|
|
8
|
+
ResponseFormat = TypeVar("ResponseFormat")
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
@dataclass(frozen=True)
|
|
10
|
-
class PreparedTask:
|
|
12
|
+
class PreparedTask(Generic[ResponseFormat]):
|
|
11
13
|
"""A data class representing a complete task configuration for OpenAI API calls.
|
|
12
14
|
|
|
13
15
|
This class encapsulates all the necessary parameters for executing a task,
|
|
@@ -84,10 +86,10 @@ class OpenAIAPIKey:
|
|
|
84
86
|
"""Container for OpenAI API key configuration.
|
|
85
87
|
|
|
86
88
|
Attributes:
|
|
87
|
-
value (str): The API key for OpenAI services.
|
|
89
|
+
value (str | None): The API key for OpenAI services.
|
|
88
90
|
"""
|
|
89
91
|
|
|
90
|
-
value: str
|
|
92
|
+
value: str | None
|
|
91
93
|
|
|
92
94
|
|
|
93
95
|
@dataclass(frozen=True)
|
|
@@ -95,10 +97,10 @@ class AzureOpenAIAPIKey:
|
|
|
95
97
|
"""Container for Azure OpenAI API key configuration.
|
|
96
98
|
|
|
97
99
|
Attributes:
|
|
98
|
-
value (str): The API key for Azure OpenAI services.
|
|
100
|
+
value (str | None): The API key for Azure OpenAI services.
|
|
99
101
|
"""
|
|
100
102
|
|
|
101
|
-
value: str
|
|
103
|
+
value: str | None
|
|
102
104
|
|
|
103
105
|
|
|
104
106
|
@dataclass(frozen=True)
|
|
@@ -106,10 +108,10 @@ class AzureOpenAIBaseURL:
|
|
|
106
108
|
"""Container for Azure OpenAI base URL configuration.
|
|
107
109
|
|
|
108
110
|
Attributes:
|
|
109
|
-
value (str): The base URL for Azure OpenAI services.
|
|
111
|
+
value (str | None): The base URL for Azure OpenAI services.
|
|
110
112
|
"""
|
|
111
113
|
|
|
112
|
-
value: str
|
|
114
|
+
value: str | None
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
@dataclass(frozen=True)
|
|
@@ -5,6 +5,8 @@ from dataclasses import dataclass, field
|
|
|
5
5
|
from datetime import datetime, timezone
|
|
6
6
|
from typing import List
|
|
7
7
|
|
|
8
|
+
__all__ = []
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
@dataclass(frozen=True)
|
|
10
12
|
class PerformanceMetric:
|
|
@@ -20,8 +22,8 @@ class BatchSizeSuggester:
|
|
|
20
22
|
min_batch_size: int = 10
|
|
21
23
|
min_duration: float = 30.0
|
|
22
24
|
max_duration: float = 60.0
|
|
23
|
-
step_ratio: float = 0.
|
|
24
|
-
sample_size: int =
|
|
25
|
+
step_ratio: float = 0.2
|
|
26
|
+
sample_size: int = 4
|
|
25
27
|
_history: List[PerformanceMetric] = field(default_factory=list)
|
|
26
28
|
_lock: threading.RLock = field(default_factory=threading.RLock, repr=False)
|
|
27
29
|
_batch_size_changed_at: datetime | None = field(default=None, init=False)
|