Utilities for running asynchronous IO tasks.
Project description
Async Utils
Utilities for running asynchronous IO tasks.
Authors
- Li Peng-Hsuan (李朋軒) @ ailabs.tw (jacobvsdanniel [at] gmail.com)
Features
- A framework of modularized, customizable data definition, quota management, and task runner
- A barebone math application for demo purposes
- An OpenAI async API application for dynamic, high-throughput, real-time, batched GPT requests
Installation
python -m pip install async_utils
Usage
For more detailed usage, see https://github.com/jacobvsdanniel/async_utils/examples
import json
import asyncio
import tiktoken
from openai import AsyncOpenAI
from async_utils import (
process_batch_data, OpenAITaskDatum, OpenAIQuotaManager, openai_task_runner
)
input_file = "tmp_in.jsonl"
output_file = "tmp_out.jsonl"
api_key = input("API key: ")
OpenAITaskDatum.client = AsyncOpenAI(api_key=api_key)
OpenAITaskDatum.tokenizer = tiktoken.encoding_for_model("gpt-5")
quota_manager = OpenAIQuotaManager(60, 500)
with open(input_file, "w", encoding="utf8") as f:
for i in range(10):
datum = {
"text_in": f"Reverse the word order of the sentence: I have {i + 1} fish.",
"model": "gpt-5.2",
"choices": 1,
}
json.dump(datum, f, ensure_ascii=False)
f.write("\n")
asyncio.run(process_batch_data(
input_file, output_file, OpenAITaskDatum, openai_task_runner, quota_manager,
max_task_runs=3, start_id=None, end_id=None, ignore_and_rewrite_output_file=True,
sleep_interval=0.001,
))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jb_async_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jb_async_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141e30844d0fc08a2e303dfe5b1a8ede254e096cd46876b74a6d979e64aab162
|
|
| MD5 |
08d07e73f5f2171043d2d02341f0aa85
|
|
| BLAKE2b-256 |
9207d738e56999c8c02c278748ecbd20ee3747d36a734be92e341c0d5f2149c5
|