Documentation
¶
Overview ¶
Package ociaitoopenai is a Traefik plugin that transforms OpenAI API requests to OCI GenAI format.
The plugin intercepts OpenAI ChatCompletion requests and transforms them to OCI GenAI format, enabling OpenAI-compatible clients to work with Oracle Cloud Infrastructure Generative AI services.
Key features: - Seamless OCI GenAI to OpenAI API translation - Request and response format transformation - Comprehensive error handling and logging
This plugin is the reverse counterpart to ocigenai, handling the transformation in the opposite direction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConfig ¶
CreateConfig creates the default plugin configuration. This function is required by Traefik's plugin system.
func New ¶
func New(ctx context.Context, next http.Handler, cfg *config.Config, name string) (http.Handler, error)
New creates a new Proxy plugin instance. It validates the configuration and initializes the transformer.
Parameters:
- ctx: Context for the plugin initialization
- next: Next HTTP handler in the middleware chain
- cfg: Plugin configuration
- name: Name of the plugin instance
Returns the configured plugin handler or an error if configuration is invalid.
Types ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy represents the main plugin instance that handles request transformation. It contains all the necessary components for transforming requests and responses.
func (*Proxy) ServeHTTP ¶
func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface and processes incoming requests.
The plugin only processes POST requests to paths ending with "/chat/completions". All other requests are passed through to the next handler unchanged.
For matching requests, the plugin: 1. Parses the OpenAI ChatCompletion request 2. Transforms it to OCI GenAI format 3. Updates the request URL to point to the OCI GenAI endpoint 4. Forwards the request to the next handler 5. Transforms the response back to OpenAI format
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
config
Package config provides configuration management for the OCI to OpenAI transformation plugin.
|
Package config provides configuration management for the OCI to OpenAI transformation plugin. |
|
transform
It provides functionality to transform OpenAI ChatCompletion requests into the format expected by Oracle Cloud's Generative AI service.
|
It provides functionality to transform OpenAI ChatCompletion requests into the format expected by Oracle Cloud's Generative AI service. |
|
pkg
|
|
|
types
Package types defines the data structures used throughout the OCI to OpenAI transformation plugin.
|
Package types defines the data structures used throughout the OCI to OpenAI transformation plugin. |