Skip to content

Migrate to Chat Completions API and update dependencies#479

Merged
Kav-K merged 3 commits intomainfrom
claude/update-openai-discord-deps-F6O99
Feb 6, 2026
Merged

Migrate to Chat Completions API and update dependencies#479
Kav-K merged 3 commits intomainfrom
claude/update-openai-discord-deps-F6O99

Conversation

@Kav-K
Copy link
Copy Markdown
Owner

@Kav-K Kav-K commented Feb 6, 2026

Summary

This PR modernizes the codebase by migrating all OpenAI API requests to use the Chat Completions endpoint, removing deprecated text completion and edit endpoints, and updating Python version support and dependencies.

Key Changes

API Migration

  • Unified Chat Completions: Converted all requests (completions, edits, language detection) to use the /v1/chat/completions endpoint
  • Removed deprecated endpoints: Eliminated usage of /v1/completions and /v1/edits endpoints
  • Simplified response handling: All responses now use the consistent message.content format instead of conditional logic for different response types

Model Updates

  • Removed legacy models: Deleted text-davinci-003, text-curie-001, and text-davinci-edit-001 models
  • Removed versioned snapshots: Cleaned up dated model versions (e.g., gpt-3.5-turbo-0613, gpt-4-0613)
  • Added new models: Introduced gpt-4o-mini, o1, o1-mini, and `o3-mini models
  • Updated defaults: Changed LOW_USAGE_MODEL from CURIE to GPT_4_OMEGA_MINI

Python & Dependencies

  • Python version: Updated minimum from 3.9 to 3.10; added support for 3.11 and 3.12
  • openai: Upgraded from 1.2.0 to 2.17.0
  • py-cord: Updated from 2.4.1 to 2.7.0
  • tiktoken: Upgraded from 0.4.0 to 0.12.0
  • Updated CI/CD matrix to test against Python 3.10, 3.11, and 3.12
  • Updated Docker base image to Python 3.11

Code Simplification

  • Removed conditional logic: Eliminated branching between ChatGPT and non-ChatGPT request handling
  • Streamlined edit requests: Converted edit functionality to use chat completions with system/user message format
  • Cleaned up token mapping: Removed entries for deprecated models
  • Updated tests: Modified test cases to use new chat completions format and current models

Implementation Details

  • Edit requests now use a system prompt instructing the model to apply edits
  • Language detection requests converted to chat format with system/user message structure
  • All response parsing simplified to use response["choices"][0]["message"]["content"]
  • Removed best_of parameter usage (not supported in chat completions)
  • Maintained backward compatibility in function signatures while updating internal implementation

https://claude.ai/code/session_01YTuyKPGRckqE6jkhtGbnBJ

- Update openai from 1.2.0 to 2.17.0 (latest)
- Update py-cord from 2.4.1 to 2.7.0 (latest)
- Update tiktoken from 0.4.0 to 0.12.0 (latest)
- Replace deprecated /v1/completions endpoint with /v1/chat/completions
- Replace removed /v1/edits endpoint with chat completions approach
- Remove deprecated models (text-davinci-003, text-curie-001, text-davinci-edit-001)
- Add new models (gpt-4o-mini, o1, o1-mini, o3-mini)
- Update all response parsing from choices[0]["text"] to choices[0]["message"]["content"]
- Update send_test_request to use chat completions
- Update send_language_detect_request to use chat completions
- Bump minimum Python version from 3.9 to 3.10 (required by py-cord 2.7)
- Update CI matrix to test Python 3.10, 3.11, 3.12
- Update Dockerfile default Python to 3.11
- Update tests to use current models and response format

https://claude.ai/code/session_01YTuyKPGRckqE6jkhtGbnBJ
- Remove @discord.guild_only() from all commands that already have
  guild_ids=ALLOWED_GUILDS, as py-cord 2.7 raises InvalidArgument when
  both are present (guild_only sets contexts/integration_types internally
  which conflicts with guild-scoped commands)
- Fix test fixtures to use pytest tmp_path instead of hardcoded relative
  paths that fail when tests run from the project root

https://claude.ai/code/session_01YTuyKPGRckqE6jkhtGbnBJ
llama-index==0.8.69.post1 requires Python >=3.8.1,<3.12, so Python 3.12
is not supported. Remove it from the CI matrix, pyproject.toml classifiers,
and hatch test matrix.

https://claude.ai/code/session_01YTuyKPGRckqE6jkhtGbnBJ
@Kav-K Kav-K requested a review from cherryroots February 6, 2026 23:25
@Kav-K Kav-K merged commit c412d69 into main Feb 6, 2026
14 of 15 checks passed
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.

2 participants