utils

package
v0.0.0-...-7a8aca8 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ImageScannerBufferSize = 50 * 1024 * 1024

Variables

This section is empty.

Functions

func BuildAudioSpeechRequest

func BuildAudioSpeechRequest(model string) (io.Reader, error)

func BuildChatCompletionRequest

func BuildChatCompletionRequest(model string) (io.Reader, error)

func BuildCompletionsRequest

func BuildCompletionsRequest(model string) (io.Reader, error)

func BuildEmbeddingsRequest

func BuildEmbeddingsRequest(model string) (io.Reader, error)

func BuildImagesGenerationsRequest

func BuildImagesGenerationsRequest(modelConfig model.ModelConfig) (io.Reader, error)

func BuildModerationsRequest

func BuildModerationsRequest(model string) (io.Reader, error)

func BuildRequest

func BuildRequest(modelConfig model.ModelConfig) (io.Reader, mode.Mode, error)

func BuildRerankRequest

func BuildRerankRequest(model string) (io.Reader, error)

func DoRequest

func DoRequest(req *http.Request, timeout time.Duration) (*http.Response, error)

func GetImageScannerBuffer

func GetImageScannerBuffer() *[]byte

func GetScannerBuffer

func GetScannerBuffer() *[]byte

func IsGeminiStreamRequest

func IsGeminiStreamRequest(path string) bool

IsGeminiStreamRequest checks if the request path ends with :streamGenerateContent

func IsImageModel

func IsImageModel(modelName string) bool

IsImageModel checks if the model name indicates an image generation model

func IsStreamResponse

func IsStreamResponse(resp *http.Response) bool

func IsStreamResponseWithHeader

func IsStreamResponseWithHeader(header http.Header) bool

func NewScanner

func NewScanner(r io.Reader) (*bufio.Scanner, func())

NewScanner creates a bufio.Scanner with standard buffer size. Returns the scanner and a cleanup function that must be called when done.

func NewStreamScanner

func NewStreamScanner(r io.Reader, modelName string) (*bufio.Scanner, func())

NewStreamScanner creates a bufio.Scanner with appropriate buffer size based on model type. Returns the scanner and a cleanup function that must be called when done.

func PutImageScannerBuffer

func PutImageScannerBuffer(buf *[]byte)

func PutScannerBuffer

func PutScannerBuffer(buf *[]byte)

func UnmarshalAnthropicMessageRequest

func UnmarshalAnthropicMessageRequest(req *http.Request) (*model.AnthropicMessageRequest, error)

func UnmarshalGeminiChatRequest

func UnmarshalGeminiChatRequest(req *http.Request) (*model.GeminiChatRequest, error)

func UnmarshalGeneralOpenAIRequest

func UnmarshalGeneralOpenAIRequest(req *http.Request) (*model.GeneralOpenAIRequest, error)

func UnmarshalGeneralThinking

func UnmarshalGeneralThinking(req *http.Request) (model.GeneralOpenAIThinkingRequest, error)

func UnmarshalGeneralThinkingFromNode

func UnmarshalGeneralThinkingFromNode(node *ast.Node) (model.GeneralOpenAIThinkingRequest, error)

func UnmarshalImageRequest

func UnmarshalImageRequest(req *http.Request) (*model.ImageRequest, error)

func UnmarshalMap

func UnmarshalMap(req *http.Request) (map[string]any, error)

func UnmarshalRerankRequest

func UnmarshalRerankRequest(req *http.Request) (*model.RerankRequest, error)

func UnmarshalTTSRequest

func UnmarshalTTSRequest(req *http.Request) (*model.TextToSpeechRequest, error)

func UnmarshalVideoGenerationJobRequest

func UnmarshalVideoGenerationJobRequest(
	req *http.Request,
) (*model.VideoGenerationJobRequest, error)

Types

type UnsupportedModelTypeError

type UnsupportedModelTypeError struct {
	ModelType string
}

func NewErrUnsupportedModelType

func NewErrUnsupportedModelType(modelType string) *UnsupportedModelTypeError

func (*UnsupportedModelTypeError) Error

func (e *UnsupportedModelTypeError) Error() string

Jump to

Keyboard shortcuts

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