protocol

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSystem

func AppendSystem(existing, next string) string

func ChatReasoningEffortFromResponsesReasoning

func ChatReasoningEffortFromResponsesReasoning(value any) any

func ChatResponseFormatFromResponsesText

func ChatResponseFormatFromResponsesText(value any) any

func DecodeJSONWithExtra

func DecodeJSONWithExtra(c *gin.Context, dst any, knownKeys ...string) (map[string]any, error)

func DecodeJSONWithExtraFromBody

func DecodeJSONWithExtraFromBody(body []byte, dst any, knownKeys ...string) (map[string]any, error)

func DecodeStreamJSON

func DecodeStreamJSON(data string, dst any) (bool, error)

func DefaultToolParameters

func DefaultToolParameters(raw json.RawMessage) json.RawMessage

func FirstText

func FirstText(parts []ir.ContentPart) string

func Flush

func Flush(c *gin.Context) error

func GeminiModelPath

func GeminiModelPath(model string) string

func ImageAsDataURI

func ImageAsDataURI(img *ir.Image) string

func JSONRequest

func JSONRequest(ctx context.Context, method, baseURL, route, token string, payload any, auth func(*http.Request, string)) (*http.Request, error)

func JoinURL

func JoinURL(baseURL, route string, query url.Values) (string, error)

func MapFinishFromClaude

func MapFinishFromClaude(reason string) ir.FinishReason

func MapFinishFromGemini

func MapFinishFromGemini(reason string) ir.FinishReason

func MapFinishFromOpenAI

func MapFinishFromOpenAI(reason string) ir.FinishReason

func MapFinishToClaude

func MapFinishToClaude(reason ir.FinishReason) string

func MapFinishToGemini

func MapFinishToGemini(reason ir.FinishReason) string

func MapFinishToOpenAI

func MapFinishToOpenAI(reason ir.FinishReason) string

func MergeJSONPayload

func MergeJSONPayload(payload any, extra map[string]any) any

func NormalizeRequestForConversion

func NormalizeRequestForConversion(r *ir.Request, sourceProtocol, targetProtocol string)

func OllamaFormatFromResponsesText

func OllamaFormatFromResponsesText(value any) any

func ParseDataURI

func ParseDataURI(raw string) (mediaType, data string, ok bool)

func ParseImageURL

func ParseImageURL(raw string) *ir.Image

func RawFromObject

func RawFromObject(v any) json.RawMessage

func RawToJSONString

func RawToJSONString(raw json.RawMessage) string

func RawToObject

func RawToObject(raw json.RawMessage) map[string]any

func ResolveImageData

func ResolveImageData(ctx context.Context, img *ir.Image) (*ir.Image, error)

func ResponseID

func ResponseID(existing, prefix string) string

func ResponsesReasoningFromChatReasoningEffort

func ResponsesReasoningFromChatReasoningEffort(value any) any

func ResponsesTextFromChatResponseFormat

func ResponsesTextFromChatResponseFormat(value any) any

func ResponsesTextFromOllamaFormat

func ResponsesTextFromOllamaFormat(value any) any

func ResponsesTextWithVerbosity

func ResponsesTextWithVerbosity(text any, verbosity any) any

func StopAsSequences

func StopAsSequences(value any) any

func TextFromParts

func TextFromParts(parts []ir.ContentPart) string

func VerbosityFromResponsesText

func VerbosityFromResponsesText(value any) any

func WriteJSONLine

func WriteJSONLine(c *gin.Context, payload any) error

func WriteJSONLineTo

func WriteJSONLineTo(w io.Writer, payload any) error

func WriteSSEData

func WriteSSEData(c *gin.Context, event, data string) error

func WriteSSEDataTo

func WriteSSEDataTo(w io.Writer, event, data string) error

func WriteSSEJSON

func WriteSSEJSON(c *gin.Context, event string, payload any) error

func WriteSSEJSONTo

func WriteSSEJSONTo(w io.Writer, event string, payload any) error

Types

type Converter

type Converter = core.Converter

Converter is the gin-free protocol interface for format conversion. It is used by pkg/modelbridge to avoid importing gin.

type Options

type Options = core.Options

type Protocol

type Protocol interface {
	Name() string
	Route() RouteSpec

	DecodeRequest(c *gin.Context) (*ir.Request, error)
	WriteResponse(c *gin.Context, r *ir.Response) error
	NewStreamWriter(c *gin.Context) StreamWriter

	BuildHTTPRequest(ctx context.Context, baseURL, token string, r *ir.Request) (*http.Request, error)
	DecodeResponse(body []byte) (*ir.Response, error)
	NewStreamReader(resp *http.Response) StreamReader
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(protocols ...Protocol) (*Registry, error)

func (*Registry) All

func (r *Registry) All() []Protocol

func (*Registry) Get

func (r *Registry) Get(name string) (Protocol, bool)

func (*Registry) GetConverter

func (r *Registry) GetConverter(name string) (Converter, bool)

type RouteSpec

type RouteSpec = core.RouteSpec

type SSEMessage

type SSEMessage struct {
	Event string
	Data  string
}

type SSEReader

type SSEReader struct {
	// contains filtered or unexported fields
}

func NewSSEReader

func NewSSEReader(r io.Reader) *SSEReader

func (*SSEReader) Read

func (r *SSEReader) Read() (*SSEMessage, error)

type StreamReader

type StreamReader = core.StreamReader

type StreamWriter

type StreamWriter = core.StreamWriter

Source Files

  • helpers.go
  • protocol.go
  • registry.go
  • sse.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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