protocol

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DecodeJSONWithExtraFromBody               = core.DecodeJSONWithExtraFromBody
	DecodeStreamJSON                          = core.DecodeStreamJSON
	JSONRequest                               = core.JSONRequest
	MergeJSONPayload                          = core.MergeJSONPayload
	NormalizeRequestForConversion             = core.NormalizeRequestForConversion
	NormalizeRequestForConversionWithWarnings = core.NormalizeRequestForConversionWithWarnings
	NormalizeToolCallFinish                   = core.NormalizeToolCallFinish
	ResponsesTextFromChatResponseFormat       = core.ResponsesTextFromChatResponseFormat
	ResponsesReasoningFromChatReasoningEffort = core.ResponsesReasoningFromChatReasoningEffort
	ChatReasoningEffortFromResponsesReasoning = core.ChatReasoningEffortFromResponsesReasoning
	ResponsesTextWithVerbosity                = core.ResponsesTextWithVerbosity
	VerbosityFromResponsesText                = core.VerbosityFromResponsesText
	ChatResponseFormatFromResponsesText       = core.ChatResponseFormatFromResponsesText
	ResponsesTextFromOllamaFormat             = core.ResponsesTextFromOllamaFormat
	OllamaFormatFromResponsesText             = core.OllamaFormatFromResponsesText
	StopAsSequences                           = core.StopAsSequences
	JoinURL                                   = core.JoinURL
	ImageAsDataURI                            = core.ImageAsDataURI
	ParseImageURL                             = core.ParseImageURL
	ParseDataURI                              = core.ParseDataURI
	ResolveImageData                          = core.ResolveImageData
	RawFromObject                             = core.RawFromObject
	RawToObject                               = core.RawToObject
	RawToJSONString                           = core.RawToJSONString
	DefaultToolParameters                     = core.DefaultToolParameters
	TextFromParts                             = core.TextFromParts
	FirstText                                 = core.FirstText
	AppendSystem                              = core.AppendSystem
	MapFinishFromOpenAI                       = core.MapFinishFromOpenAI
	MapFinishToOpenAI                         = core.MapFinishToOpenAI
	MapFinishFromClaude                       = core.MapFinishFromClaude
	MapFinishToClaude                         = core.MapFinishToClaude
	MapFinishFromGemini                       = core.MapFinishFromGemini
	MapFinishToGemini                         = core.MapFinishToGemini
	GeminiModelPath                           = core.GeminiModelPath
	ResponseID                                = core.ResponseID
	IsStandardUsageField                      = core.IsStandardUsageField
)
View Source
var (
	NewSSEReader    = core.NewSSEReader
	WriteSSEJSONTo  = core.WriteSSEJSONTo
	WriteSSEDataTo  = core.WriteSSEDataTo
	WriteJSONLineTo = core.WriteJSONLineTo
)

Functions

func DecodeJSONWithExtra

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

DecodeJSONWithExtra reads the request body from a gin context and decodes it into dst, returning the unknown keys as an extra map. This is the only gin-aware helper; everything else is gin-free and lives in protocolcore.

func Flush

func Flush(c *gin.Context) error

Flush flushes the gin response writer when the underlying writer supports flushing. SSE/NDJSON writers depend on this.

func WriteJSONLine

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

func WriteSSEData

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

func WriteSSEJSON

func WriteSSEJSON(c *gin.Context, 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 = core.SSEMessage

Aliases re-export the gin-free SSE primitives from protocolcore so existing callers under internal/protocol can keep using these names. The actual implementation lives in protocolcore.

type SSEReader

type SSEReader = core.SSEReader

Aliases re-export the gin-free SSE primitives from protocolcore so existing callers under internal/protocol can keep using these names. The actual implementation lives in protocolcore.

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