You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clients/python/llmengine/completion.py
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@
10
10
CreateBatchCompletionsRequest,
11
11
CreateBatchCompletionsRequestContent,
12
12
CreateBatchCompletionsResponse,
13
+
ToolConfig,
13
14
)
14
15
15
16
COMPLETION_TIMEOUT=300
@@ -412,6 +413,7 @@ def batch_create(
412
413
input_data_path: Optional[str] =None,
413
414
data_parallelism: int=1,
414
415
max_runtime_sec: int=24*3600,
416
+
tool_config: Optional[ToolConfig] =None,
415
417
) ->CreateBatchCompletionsResponse:
416
418
"""
417
419
Creates a batch completion for the provided input data. The job runs offline and does not depend on an existing model endpoint.
@@ -437,6 +439,13 @@ def batch_create(
437
439
max_runtime_sec (int):
438
440
The maximum runtime of the batch completion in seconds. Defaults to 24 hours.
439
441
442
+
tool_config (Optional[ToolConfig]):
443
+
Configuration for tool use.
444
+
NOTE: this config is highly experimental and signature will change significantly in future iterations.
445
+
Currently only Python code evaluator is supported.
446
+
Python code context starts with "\`\`\`python\\n" and ends with "\\n>>>\\n", data before "\\n\`\`\`\\n" and content end will be replaced by the Python execution results.
447
+
Please format prompts accordingly and provide examples so LLMs could properly generate Python code.
448
+
440
449
Returns:
441
450
response (CreateBatchCompletionsResponse): The response containing the job id.
442
451
@@ -480,6 +489,29 @@ def batch_create(
480
489
)
481
490
print(response.json())
482
491
```
492
+
493
+
=== "Batch completions with prompts and use tool"
494
+
```python
495
+
from llmengine import Completion
496
+
from llmengine.data_types import CreateBatchCompletionsModelConfig, CreateBatchCompletionsRequestContent, ToolConfig
497
+
498
+
# Store CreateBatchCompletionsRequestContent data into input file "s3://my-input-path"
Copy file name to clipboardExpand all lines: docs/guides/completions.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ asyncio.run(main())
122
122
123
123
## Batch completions
124
124
125
-
The Python client also supports batch completions. Batch completions supports distributing data to multiple workers to accelerate inference. It also tries to maximize throughput so the completions should finish quite a bit faster than hitting models through HTTP. Use [Completion.batch_complete](../../api/python_client/#llmengine.completion.Completion.batch_complete) to utilize batch completions.
125
+
The Python client also supports batch completions. Batch completions supports distributing data to multiple workers to accelerate inference. It also tries to maximize throughput so the completions should finish quite a bit faster than hitting models through HTTP. Use [Completion.batch_create](../../api/python_client/#llmengine.Completion.batch_create) to utilize batch completions.
0 commit comments