Documentation
¶
Overview ¶
Package ir defines the gateway-owned chat internal representation.
Index ¶
- Constants
- func EncodeAnthropic(req ChatRequest, targetModel string) ([]byte, error)
- func EncodeAnthropicResponse(resp ChatResponse) ([]byte, error)
- func EncodeOpenAI(req ChatRequest) ([]byte, error)
- func EncodeOpenAIResponse(resp ChatResponse) ([]byte, error)
- func MapAnthropicStopReason(r string) string
- func Unsupported(feature, message string) error
- type ChatRequest
- type ChatResponse
- type ChatResult
- type ContentPart
- type ContentPartType
- type Dialect
- type ImageSource
- type Message
- type StreamEvent
- type StreamEventKind
- type Tool
- type ToolCall
- type ToolChoice
- type ToolChoiceMode
- type UnsupportedError
- type Usage
Constants ¶
const ( DialectOpenAI = chatir.DialectOpenAI DialectAnthropic = chatir.DialectAnthropic DialectGemini = chatir.DialectGemini )
const ( ContentText = chatir.ContentText ContentImage = chatir.ContentImage )
const ( ToolChoiceAuto = chatir.ToolChoiceAuto ToolChoiceNone = chatir.ToolChoiceNone ToolChoiceRequired = chatir.ToolChoiceRequired ToolChoiceTool = chatir.ToolChoiceTool )
const ( StreamMessageStart = chatir.StreamMessageStart StreamTextDelta = chatir.StreamTextDelta StreamToolCallStart = chatir.StreamToolCallStart StreamToolCallDelta = chatir.StreamToolCallDelta StreamMessageEnd = chatir.StreamMessageEnd StreamError = chatir.StreamError )
const ( DialectSupportsTools = true DialectSupportsVision = true )
Gateway dialect IR capabilities for the current chat IR version. Catalog advertising and request validation must stay in sync with these.
Variables ¶
This section is empty.
Functions ¶
func EncodeAnthropic ¶
func EncodeAnthropic(req ChatRequest, targetModel string) ([]byte, error)
EncodeAnthropic marshals a ChatRequest to Anthropic messages JSON.
func EncodeAnthropicResponse ¶
func EncodeAnthropicResponse(resp ChatResponse) ([]byte, error)
EncodeAnthropicResponse marshals ChatResponse to Anthropic message JSON.
func EncodeOpenAI ¶
func EncodeOpenAI(req ChatRequest) ([]byte, error)
EncodeOpenAI marshals a ChatRequest to OpenAI chat.completions JSON.
This is the canonical bridge format used between hooks and provider adapters, so it must faithfully carry tools, multimodal content, and tool messages.
func EncodeOpenAIResponse ¶
func EncodeOpenAIResponse(resp ChatResponse) ([]byte, error)
EncodeOpenAIResponse marshals ChatResponse to OpenAI chat.completion JSON.
func MapAnthropicStopReason ¶
MapAnthropicStopReason maps Anthropic stop_reason to IR finish_reason.
func Unsupported ¶
Unsupported returns a new UnsupportedError.
Types ¶
type ChatRequest ¶
ChatRequest is the dialect-neutral chat request.
func DecodeAnthropicRequest ¶
func DecodeAnthropicRequest(body []byte) (ChatRequest, error)
DecodeAnthropicRequest parses Anthropic messages JSON into ChatRequest.
func DecodeOpenAIRequest ¶
func DecodeOpenAIRequest(body []byte) (ChatRequest, error)
DecodeOpenAIRequest parses OpenAI chat.completions JSON into ChatRequest.
type ChatResponse ¶
ChatResponse is a non-streaming assistant reply.
func DecodeAnthropicResponse ¶
func DecodeAnthropicResponse(body []byte) (ChatResponse, error)
DecodeAnthropicResponse parses Anthropic message JSON into ChatResponse.
func DecodeOpenAIResponse ¶
func DecodeOpenAIResponse(body []byte) (ChatResponse, error)
DecodeOpenAIResponse parses OpenAI chat.completion JSON into ChatResponse.
type ChatResult ¶
ChatResult is either a completed response, a stream of events, or an upstream HTTP error body.
type ContentPart ¶
type ContentPart = chatir.ContentPart
ContentPart is one piece of multimodal message content.
type ContentPartType ¶
type ContentPartType = chatir.ContentPartType
ContentPartType enumerates supported content part kinds.
type ImageSource ¶
type ImageSource = chatir.ImageSource
ImageSource references image bytes either by URL or inline base64 data.
type StreamEventKind ¶
type StreamEventKind = chatir.StreamEventKind
StreamEventKind classifies streaming IR events.
type ToolChoice ¶
type ToolChoice = chatir.ToolChoice
ToolChoice expresses tool_choice across dialects.
type ToolChoiceMode ¶
type ToolChoiceMode = chatir.ToolChoiceMode
ToolChoiceMode controls whether/which tool the model must call.
type UnsupportedError ¶
UnsupportedError is returned when a client request uses a feature chat IR cannot serve yet.
func AsUnsupported ¶
func AsUnsupported(err error) (*UnsupportedError, bool)
AsUnsupported extracts UnsupportedError from err.
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string