fix: update call_o3 to use chat.completions for OpenAI API ≥ 1.0.0

Co-authored-by: aider (o3) <aider@aider.chat>
This commit is contained in:
Mark Eaton
2025-09-17 15:44:10 -04:00
co-authored by aider
parent 01d73672e0
commit ea0e6bb5b6
+9 -3
View File
@@ -46,13 +46,19 @@ def write_output(path: Path, record: Dict[str, Any]) -> None:
def call_o3(prompt: str) -> str: def call_o3(prompt: str) -> str:
response = client.completions.create( """
Send the prompt to the chat-completions endpoint (OpenAI ≥ 1.0.0).
The prompt is wrapped in a single user message so the new API remains
compatible with the existing template-based workflow.
"""
response = client.chat.completions.create(
model=MODEL, model=MODEL,
prompt=prompt, messages=[{"role": "user", "content": prompt}],
max_tokens=1024, max_tokens=1024,
temperature=0.7, temperature=0.7,
) )
return response.choices[0].text.strip() return response.choices[0].message.content.strip()
def main(argv: list[str] | None = None) -> None: def main(argv: list[str] | None = None) -> None: