gateway

package
v0.0.1-beta1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgTypeChat    = "chat"
	MsgTypeChunk   = "chunk"
	MsgTypeDone    = "done"
	MsgTypeError   = "error"
	MsgTypePing    = "ping"
	MsgTypePong    = "pong"
	MsgTypeHistory = "history"
)

WebSocket message types

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Model    string             `json:"model"`
	Messages []rpcproto.Message `json:"messages"`
}

type ChatResponse

type ChatResponse struct {
	ID      string   `json:"id"`
	Object  string   `json:"object"`
	Created int64    `json:"created"`
	Model   string   `json:"model"`
	Choices []Choice `json:"choices"`
	Usage   Usage    `json:"usage"`
}

type Choice

type Choice struct {
	Index        int              `json:"index"`
	Message      rpcproto.Message `json:"message"`
	FinishReason string           `json:"finish_reason"`
}

type Config

type Config struct {
	Host        string `json:"host"`
	Port        int    `json:"port"`
	AgentAddr   string `json:"agentAddr"`
	UIAuthToken string `json:"uiAuthToken"`
}

Config for Gateway

type Gateway

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

func New

func New(cfg Config) *Gateway

func (*Gateway) Config

func (g *Gateway) Config() Config

func (*Gateway) HandleWebSocket

func (g *Gateway) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket handles WebSocket upgrade requests

func (*Gateway) SetClient

func (g *Gateway) SetClient(c *rpc.Client)

func (*Gateway) Start

func (g *Gateway) Start() error

func (*Gateway) Stop

func (g *Gateway) Stop()

type GatewayAgentRPC

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

GatewayAgentRPC implements channels.AgentRPCInterface for gateway-agent communication

func (*GatewayAgentRPC) Chat

func (r *GatewayAgentRPC) Chat(messages []channels.Message) (string, error)

Chat sends a chat request to the agent via RPC

func (*GatewayAgentRPC) GetStats

func (r *GatewayAgentRPC) GetStats() (map[string]int, error)

GetStats gets statistics from the agent via RPC

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type WSChatRequest

type WSChatRequest struct {
	Model    string             `json:"model"`
	Messages []rpcproto.Message `json:"messages"`
}

WSChatRequest represents a chat request via WebSocket

type WSChatResponse

type WSChatResponse struct {
	Content     string `json:"content"`
	Finish      bool   `json:"finish"`
	Error       string `json:"error,omitempty"`
	TotalTokens int    `json:"totalTokens,omitempty"`
}

WSChatResponse represents a chat response via WebSocket

type WSMessage

type WSMessage struct {
	Type    string          `json:"type"`
	Content json.RawMessage `json:"content,omitempty"`
}

WSMessage represents a WebSocket message

type WebSocketHub

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

WebSocketHub manages WebSocket connections

func NewWebSocketHub

func NewWebSocketHub(g *Gateway) *WebSocketHub

func (*WebSocketHub) Run

func (h *WebSocketHub) Run()

Directories

Path Synopsis
Package channels - Channel adapter system for communication platforms Provides plugin-based channel integration with hot-reload support
Package channels - Channel adapter system for communication platforms Provides plugin-based channel integration with hot-reload support

Jump to

Keyboard shortcuts

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