chat

package
v0.22.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CONTENT_BATCH_SIZE = 150                    // characters - smaller for more responsive streaming
	CONTENT_BATCH_TIME = 100 * time.Millisecond // shorter time for more responsive streaming
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	Role       string            `json:"role"` // "user", "assistant", "system", "tool"
	Content    string            `json:"content"`
	Timestamp  int64             `json:"timestamp"`
	ToolCalls  []openai.ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string            `json:"tool_call_id,omitempty"`
}

type ChatRequest

type ChatRequest struct {
	Messages []ChatMessage `json:"messages"`
}

type SSEEvent

type SSEEvent struct {
	Type string `json:"type"`
	Data any    `json:"data"`
}

type Service

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

func NewService

func NewService(config config.ChatConfig, mcpServer *mcp.Server) (*Service, error)

func (*Service) GetOpenAIClient

func (s *Service) GetOpenAIClient() *openai.Client

func (*Service) HandleChatStream

func (s *Service) HandleChatStream(w http.ResponseWriter, r *http.Request)

type ToolResult

type ToolResult struct {
	ToolCallID string `json:"tool_call_id"`
	Content    string `json:"content"`
}

type WebChatToolHandler

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

WebChatToolHandler handles tool events for the web chat

func NewWebChatToolHandler

func NewWebChatToolHandler(streamWriter *rest.StreamWriter) *WebChatToolHandler

func (*WebChatToolHandler) OnToolCall

func (h *WebChatToolHandler) OnToolCall(toolCall openai.ToolCall) error

func (*WebChatToolHandler) OnToolResult

func (h *WebChatToolHandler) OnToolResult(toolCallID, toolName, result string) error

Jump to

Keyboard shortcuts

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