Refactor translator packages for OpenAI Chat Completions

- Renamed `openai` packages to `chat_completions` across translator modules.
- Introduced `openai_responses_handlers` with handlers for `/v1/models` and OpenAI-compatible chat completions endpoints.
- Updated constants and registry identifiers for OpenAI response type.
- Simplified request/response conversions and added detailed retry/error handling.
- Added `golang.org/x/crypto` for additional cryptographic functions.
This commit is contained in:
Luis Pater
2025-09-01 11:00:47 +08:00
parent e0bff9f212
commit e11637dc62
3 changed files with 9 additions and 216 deletions

View File

@@ -31,7 +31,7 @@ import (
)
const (
chatGPTEndpoint = "https://chatgpt.com/backend-api"
chatGPTEndpoint = "https://chatgpt.com/backend-api/codex"
)
// CodexClient implements the Client interface for OpenAI API
@@ -128,7 +128,7 @@ func (c *CodexClient) SendRawMessage(ctx context.Context, modelName string, rawJ
handlerType := handler.HandlerType()
rawJSON = translator.Request(handlerType, c.Type(), modelName, rawJSON, false)
respBody, err := c.APIRequest(ctx, modelName, "/codex/responses", rawJSON, alt, false)
respBody, err := c.APIRequest(ctx, modelName, "/responses", rawJSON, alt, false)
if err != nil {
if err.StatusCode == 429 {
now := time.Now()
@@ -193,7 +193,7 @@ func (c *CodexClient) SendRawMessageStream(ctx context.Context, modelName string
}
var err *interfaces.ErrorMessage
stream, err = c.APIRequest(ctx, modelName, "/codex/responses", rawJSON, alt, true)
stream, err = c.APIRequest(ctx, modelName, "/responses", rawJSON, alt, true)
if err != nil {
if err.StatusCode == 429 {
now := time.Now()