Skip to content

Conversation

mshsheikh
Copy link
Contributor

Update the translate_file to call the correct OpenAI Python SDK method for generating chat completions.
Both instances of the non‑existent openai_client.responses.create have been replaced with openai_client.chat.completions.create, restoring compatibility with the current SDK and preventing runtime attribute errors.

….create

Update the `translate_file` to call the correct OpenAI Python SDK method for generating chat completions.
Both instances of the non‑existent `openai_client.responses.create` have been replaced with `openai_client.chat.completions.create`, restoring compatibility with the current SDK and preventing runtime attribute errors.
….create

Update the translate_file to call the correct OpenAI Python SDK method for generating chat completions.
Both instances of the non‑existent openai_client.responses.create have been replaced with openai_client.chat.completions.create, restoring compatibility with the current SDK and preventing runtime attribute errors.
…t.completions

**What Changed**

- Replaced all calls to

  ```python
  openai_client.chat.completions.create(
      model=OPENAI_MODEL,
      instructions=instructions,
      input=chunk,
      # …
  )
  ```

with

  ```python
  openai_client.chat.completions.create(
      model=OPENAI_MODEL,
      messages=[
          {"role": "system", "content": instructions},
          {"role": "user",   "content": chunk},
      ],
      # optional temperature override
  )
  ```
* Unified the “o\*” vs. non‑“o\*” branches into a single code path, conditionally adding `temperature=0.0` for non‑o models.
* Switched result extraction from `response.output_text` to `response.choices[0].message.content`.

**Why This Matters**
* Eliminates the type‑checking errors raised by mypy.
* Aligns the code with the current OpenAI chat completion API, improving future compatibility and clarity.
* Simplifies the logic by removing duplicated branches.
@mshsheikh mshsheikh closed this Jul 15, 2025
@mshsheikh mshsheikh reopened this Jul 15, 2025
@mshsheikh mshsheikh closed this Jul 15, 2025
@mshsheikh mshsheikh deleted the patch-14 branch July 15, 2025 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant