grokbuild

package
v7.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGrokClientContext added in v7.2.140

func IsGrokClientContext(ctx context.Context, headers http.Header) bool

IsGrokClientContext checks if either the context (e.g. Gin context) or headers indicate a Grok client.

func IsGrokClientHeaders added in v7.2.140

func IsGrokClientHeaders(headers http.Header) bool

IsGrokClientHeaders checks if the provided HTTP headers indicate a Grok client.

func IsGrokClientUserAgent added in v7.2.140

func IsGrokClientUserAgent(userAgent string) bool

IsGrokClientUserAgent checks if the user agent contains "grok-pager" or "grok-shell".

func IsGrokShellUserAgent

func IsGrokShellUserAgent(userAgent string) bool

IsGrokShellUserAgent checks if the User-Agent header indicates a Grok Shell client.

func IsKeepalivePayload added in v7.2.140

func IsKeepalivePayload(payload []byte) bool

IsKeepalivePayload reports whether a JSON payload has type "keepalive".

func IsKeepaliveSSELine added in v7.2.140

func IsKeepaliveSSELine(line []byte) bool

IsKeepaliveSSELine reports whether an SSE line represents a keepalive event or data frame.

func KeepaliveSSEComment added in v7.2.140

func KeepaliveSSEComment() []byte

KeepaliveSSEComment returns the standard SSE comment used for keepalive.

func TransformKeepaliveSSELine added in v7.2.140

func TransformKeepaliveSSELine(line []byte, isGrokClient bool) ([]byte, bool)

TransformKeepaliveSSELine transforms a keepalive SSE line into an SSE comment line when isGrokClient is true. If the line is not a keepalive line or isGrokClient is false, it returns the original line and false.

Types

type ModelEntry

type ModelEntry struct {
	ID               string            `json:"id"`
	Model            string            `json:"model"`
	Name             string            `json:"name"`
	ContextWindow    int               `json:"context_window,omitempty"`
	APIBackend       string            `json:"api_backend"`
	SupportedInAPI   bool              `json:"supported_in_api"`
	ReasoningEfforts []ReasoningEffort `json:"reasoning_efforts,omitempty"`
}

ModelEntry represents a single model entry formatted for Grok Shell.

type ModelInfo

type ModelInfo struct {
	ID              string
	DisplayName     string
	ContextLength   int
	ReasoningLevels []string
}

ModelInfo represents input model information to be formatted.

type ReasoningEffort

type ReasoningEffort struct {
	Value string `json:"value"`
}

ReasoningEffort represents reasoning effort level in Grok Shell model entries.

type Response

type Response struct {
	Object string       `json:"object"`
	Data   []ModelEntry `json:"data"`
}

Response represents the model list response envelope formatted for Grok Shell.

func BuildResponse

func BuildResponse(models []ModelInfo) Response

BuildResponse constructs the Grok Shell formatted model list response.

Jump to

Keyboard shortcuts

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