refactor: update batch_03_prompts.py to use openai>=1.0.0 client instantiation and method calls

Co-authored-by: aider (o3) <aider@aider.chat>
This commit is contained in:
Mark Eaton
2025-09-17 15:38:21 -04:00
co-authored by aider
parent 4cc23871bb
commit 01d73672e0
+5 -2
View File
@@ -20,10 +20,13 @@ from pathlib import Path
from typing import Any, Dict from typing import Any, Dict
from dotenv import load_dotenv from dotenv import load_dotenv
import openai from openai import OpenAI
MODEL = "o3" MODEL = "o3"
# instantiate the v1 OpenAI client (api_key read from environment/.env)
client = OpenAI()
def load_template(path: Path) -> str: def load_template(path: Path) -> str:
with path.open(encoding="utf-8") as fh: with path.open(encoding="utf-8") as fh:
@@ -43,7 +46,7 @@ def write_output(path: Path, record: Dict[str, Any]) -> None:
def call_o3(prompt: str) -> str: def call_o3(prompt: str) -> str:
response = openai.Completion.create( response = client.completions.create(
model=MODEL, model=MODEL,
prompt=prompt, prompt=prompt,
max_tokens=1024, max_tokens=1024,