Documentation
¶
Index ¶
- func ExtractExpireAt(responseExpiration *string) (time.Time, error)
- func NewMergedModelsHandler(logger *slog.Logger, backends []config.OpenAIBackend) http.Handler
- func NewOpenAIProxyHandler(backends config.OpenAIBackends, baseLogger *zerolog.Logger, endpoint string) http.Handler
- type FileDownloadHandler
- type FileUploadHandler
- type FileUploadResponse
- type S3Downloader
- type S3Uploader
- type TimeToFirstByteResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractExpireAt ¶
ExtractExpireAt extracts the expiration date from the x-amz-expiration response header from S3 PutObject API response.
func NewMergedModelsHandler ¶
NewMergedModelsHandler creates a new handler that merges responses from multiple OpenAI API compatible backends
func NewOpenAIProxyHandler ¶
func NewOpenAIProxyHandler( backends config.OpenAIBackends, baseLogger *zerolog.Logger, endpoint string, ) http.Handler
NewOpenAIProxyHandler creates a new handler that proxies requests to the OpenAI API
Types ¶
type FileDownloadHandler ¶
type FileDownloadHandler struct {
// contains filtered or unexported fields
}
FileDownloadHandler is a HTTP handler for file downloads from S3.
func NewFileDownloadHandler ¶
func NewFileDownloadHandler( bucketName string, s3PathStyleRequests bool, baseLogger *zerolog.Logger, ) *FileDownloadHandler
NewFileDownloadHandler creates a new FileDownloadHandler with the given bucket name.
func (*FileDownloadHandler) ServeHTTP ¶
func (h *FileDownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for the FileDownloadHandler.
type FileUploadHandler ¶
type FileUploadHandler struct {
// contains filtered or unexported fields
}
FileUploadHandler is a HTTP handler for file uploads to S3.
func NewFileUploadHandler ¶
func NewFileUploadHandler( bucketName string, s3PathStyleRequests bool, publicURL string, baseLogger *zerolog.Logger, ) *FileUploadHandler
NewFileUploadHandler creates a new FileUploadHandler with the given bucket name,
func (*FileUploadHandler) ServeHTTP ¶
func (h *FileUploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for the FileUploadHandler.
type FileUploadResponse ¶
type FileUploadResponse struct { ID string `json:"id"` URL string `json:"url"` Bytes int64 `json:"bytes"` CreatedAt time.Time `json:"created_at"` ExpireAt time.Time `json:"expire_at"` }
FileUploadResponse is the response format for a successful file upload.
type S3Downloader ¶
type S3Downloader interface {
GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
}
S3Downloader implements the GetObject method from the AWS SDK.
type S3Uploader ¶
type S3Uploader interface {
PutObject(context.Context, *s3.PutObjectInput, ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}
S3Uploader implements the PutObject method from the AWS SDK.
type TimeToFirstByteResponseWriter ¶
type TimeToFirstByteResponseWriter struct { http.ResponseWriter ResponseSpan trace.Span // contains filtered or unexported fields }
TimeToFirstByteResponseWriter is a wrapper around http.ResponseWriter that records the time to first byte (TTFB) for a response
func NewTimeToFirstByteResponseWriter ¶
func NewTimeToFirstByteResponseWriter( ctx context.Context, w http.ResponseWriter, tracer trace.Tracer, model string, backend string, ) *TimeToFirstByteResponseWriter
NewTimeToFirstByteResponseWriter creates a new TimeToFirstByteResponseWriter
func (*TimeToFirstByteResponseWriter) End ¶
func (w *TimeToFirstByteResponseWriter) End()
End ends the response span if it exists and records response size metric