types

package
v0.0.0-...-a3e7db3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTX_CLIENT_REQ_MODEL_KEY   = "model"
	CTX_CLIENT_REQ_BACKEND_KEY = "backend"
)

Variables

This section is empty.

Functions

func AddBackendToContext

func AddBackendToContext(ctx context.Context, backend string) context.Context

AddBackendToContext adds the backend string to the context

func AddModelToContext

func AddModelToContext(ctx context.Context, model string) context.Context

AddModelToContext adds the model string to the context

Types

type ErrorResponse

type ErrorResponse struct {
	ErrorBody *openai.Error `json:"error"`
}

ErrorResponse is the response body for an error

type OpenAIPassthroughClient

type OpenAIPassthroughClient struct {
	BaseURL string
	APIKey  string
	// contains filtered or unexported fields
}

OpenAIPassthroughClient is a client for the OpenAI API

func NewOpenAIClient

func NewOpenAIClient(baseURL, apiKey string) *OpenAIPassthroughClient

NewOpenAIClient creates a new OpenAI client with the given base URL and API key

func (*OpenAIPassthroughClient) DoRequest

func (c *OpenAIPassthroughClient) DoRequest(
	ctx context.Context,
	method,
	path string,
	body *bytes.Reader,
) (*http.Response, error)

DoRequest performs an HTTP request to the upstream API, use raw client request to do a passthrough instead of using the OpenAI client which does custom handling, retries, etc and would need manual handling of the response and streaming.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL