mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
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:
@@ -3,7 +3,7 @@
|
||||
// extracting model information, system instructions, message contents, and tool declarations.
|
||||
// The package performs JSON data transformation to ensure compatibility
|
||||
// between OpenAI API format and Claude Code API's expected format.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@@ -3,7 +3,7 @@
|
||||
// JSON format, transforming streaming events and non-streaming responses into the format
|
||||
// expected by OpenAI API clients. It supports both streaming and non-streaming modes,
|
||||
// handling text content, tool calls, reasoning content, and usage metadata appropriately.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -1,4 +1,4 @@
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
. "github.com/luispater/CLIProxyAPI/internal/constant"
|
||||
@@ -4,7 +4,7 @@
|
||||
// The package handles the conversion of OpenAI API requests into the format
|
||||
// expected by the OpenAI Responses API, including proper mapping of messages,
|
||||
// tools, and generation parameters.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"github.com/luispater/CLIProxyAPI/internal/misc"
|
||||
@@ -3,7 +3,7 @@
|
||||
// JSON format, transforming streaming events and non-streaming responses into the format
|
||||
// expected by OpenAI API clients. It supports both streaming and non-streaming modes,
|
||||
// handling text content, tool calls, reasoning content, and usage metadata appropriately.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -1,4 +1,4 @@
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
. "github.com/luispater/CLIProxyAPI/internal/constant"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
|
||||
// It converts OpenAI Chat Completions requests into Gemini CLI compatible JSON using gjson/sjson only.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -3,7 +3,7 @@
|
||||
// JSON format, transforming streaming events and non-streaming responses into the format
|
||||
// expected by OpenAI API clients. It supports both streaming and non-streaming modes,
|
||||
// handling text content, tool calls, reasoning content, and usage metadata appropriately.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
. "github.com/luispater/CLIProxyAPI/internal/translator/gemini/openai"
|
||||
. "github.com/luispater/CLIProxyAPI/internal/translator/gemini/openai/chat-completions"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/tidwall/sjson"
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
. "github.com/luispater/CLIProxyAPI/internal/constant"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package openai provides request translation functionality for OpenAI to Gemini API compatibility.
|
||||
// It converts OpenAI Chat Completions requests into Gemini compatible JSON using gjson/sjson only.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -3,7 +3,7 @@
|
||||
// JSON format, transforming streaming events and non-streaming responses into the format
|
||||
// expected by OpenAI API clients. It supports both streaming and non-streaming modes,
|
||||
// handling text content, tool calls, reasoning content, and usage metadata appropriately.
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package openai
|
||||
package chat_completions
|
||||
|
||||
import (
|
||||
. "github.com/luispater/CLIProxyAPI/internal/constant"
|
||||
@@ -3,18 +3,18 @@ package translator
|
||||
import (
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/claude/gemini"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/claude/gemini-cli"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/claude/openai"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/claude/openai/chat-completions"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/codex/claude"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/codex/gemini"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/codex/gemini-cli"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/codex/openai"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/codex/openai/chat-completions"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini-cli/claude"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini-cli/gemini"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini-cli/openai"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini-cli/openai/chat-completions"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini/claude"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini/gemini"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini/gemini-cli"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini/openai"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/gemini/openai/chat-completions"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/openai/claude"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/openai/gemini"
|
||||
_ "github.com/luispater/CLIProxyAPI/internal/translator/openai/gemini-cli"
|
||||
|
||||
Reference in New Issue
Block a user