ontocast.tool.llm_batch¶
Provider Batch API helpers for offline benchmark pre-warming.
OpenAI and Anthropic offer asynchronous batch endpoints (~50% lower cost,
multi-hour latency). This module supports exporting pending LLM prompts to
batch JSONL and importing completed results into the OntoCast disk cache so
subsequent server runs hit :class:~ontocast.tool.llm.LLMTool cache entries.
This is intended for validation / benchmark workflows, not interactive
/process traffic.
import_openai_batch_output_jsonl(output_path, *, shared_cache, llm_config, custom_id_to_cache_key)
¶
Import OpenAI batch result JSONL lines into the LLM disk cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
Path
|
Path to the batch output JSONL from the provider. |
required |
shared_cache
|
Cacher
|
Shared :class: |
required |
llm_config
|
LLMConfig
|
LLM settings used when the batch was submitted. |
required |
custom_id_to_cache_key
|
dict[str, str]
|
Maps each |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of cache entries written. |
Source code in ontocast/tool/llm_batch.py
write_openai_chat_batch_jsonl(requests, output_path)
¶
Write OpenAI Batch API input JSONL (one request object per line).
Each item in requests should include:
- custom_id: stable id (e.g. cache key prefix)
- body: chat completions body with model, messages, etc.