maxim

package module
v1.5.20 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package maxim provides integration for Maxim's SDK as a Bifrost plugin. This file contains the main plugin implementation.

Index

Constants

View Source
const (
	PluginName         string = "maxim"
	PluginLoggerPrefix string = "[Maxim Plugin]"
)

PluginName is the canonical name for the maxim plugin.

View Source
const (
	SessionIDKey      schemas.BifrostContextKey = "session-id"
	TraceIDKey        schemas.BifrostContextKey = "trace-id"
	TraceNameKey      schemas.BifrostContextKey = "trace-name"
	GenerationIDKey   schemas.BifrostContextKey = "generation-id"
	GenerationNameKey schemas.BifrostContextKey = "generation-name"
	TagsKey           schemas.BifrostContextKey = "maxim-tags"
	LogRepoIDKey      schemas.BifrostContextKey = "log-repo-id"
)

TraceIDKey is the context key used to store and retrieve trace IDs. This constant provides a consistent key for tracking request traces throughout the request/response lifecycle.

Variables

This section is empty.

Functions

func Init added in v1.3.0

func Init(config *Config, logger schemas.Logger) (schemas.LLMPlugin, error)

Init initializes and returns a Plugin instance for Maxim's logger.

Parameters:

  • config: Configuration for the maxim plugin

Returns:

  • schemas.LLMPlugin: A configured plugin instance for request/response tracing
  • error: Any error that occurred during plugin initialization

Types

type Config added in v1.3.0

type Config struct {
	LogRepoID string `json:"log_repo_id,omitempty"` // Optional - can be empty
	APIKey    string `json:"api_key"`
}

Config is the configuration for the maxim plugin.

  • APIKey: API key for Maxim SDK authentication
  • LogRepoID: Optional default ID for the Maxim logger instance

type Plugin

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

Plugin implements the schemas.LLMPlugin interface for Maxim's logger. It provides request and response tracing functionality using Maxim logger, allowing detailed tracking of requests and responses across different log repositories.

Fields:

  • mx: The Maxim SDK instance for creating new loggers
  • defaultLogRepoId: Default log repository ID from config (optional)
  • loggers: Map of log repo ID to logger instances
  • loggerMutex: RW mutex for thread-safe access to loggers map

func (*Plugin) Cleanup added in v1.0.4

func (plugin *Plugin) Cleanup() error

func (*Plugin) GetName added in v1.0.5

func (plugin *Plugin) GetName() string

GetName returns the name of the plugin.

func (*Plugin) HTTPTransportPostHook added in v1.5.9

func (plugin *Plugin) HTTPTransportPostHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, resp *schemas.HTTPResponse) error

HTTPTransportPostHook is not used for this plugin

func (*Plugin) HTTPTransportPreHook added in v1.5.9

func (plugin *Plugin) HTTPTransportPreHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest) (*schemas.HTTPResponse, error)

HTTPTransportPreHook is not used for this plugin

func (*Plugin) HTTPTransportStreamChunkHook added in v1.5.14

func (plugin *Plugin) HTTPTransportStreamChunkHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, chunk *schemas.BifrostStreamChunk) (*schemas.BifrostStreamChunk, error)

HTTPTransportStreamChunkHook passes through streaming chunks unchanged

func (*Plugin) PostLLMHook added in v1.5.16

PostLLMHook is called after a request has been processed by Bifrost. It completes the request trace by: - Adding response data to the generation if a generation ID exists - Logging error details if bifrostErr is provided - Ending the generation if it exists - Ending the trace if a trace ID exists - Flushing all pending log data

The function gracefully handles cases where trace or generation IDs may be missing, ensuring that partial logging is still performed when possible.

Parameters:

  • ctx: Pointer to the schemas.BifrostContext containing trace/generation IDs
  • result: The Bifrost response to be traced
  • bifrostErr: The BifrostError returned by the request, if any

Returns:

  • *schemas.BifrostResponse: The original response, unmodified
  • *schemas.BifrostError: The original error, unmodified
  • error: Never returns an error as it handles missing IDs gracefully

func (*Plugin) PreLLMHook added in v1.5.16

PreLLMHook is called before a request is processed by Bifrost. It manages trace and generation tracking for incoming requests by either: - Creating a new trace if none exists - Reusing an existing trace ID from the context - Creating a new generation within an existing trace - Skipping trace/generation creation if they already exist

The function handles both chat completion and text completion requests, capturing relevant metadata such as: - Request type (chat/text completion) - Model information - Message content and role - Model parameters

Parameters:

  • ctx: Pointer to the schemas.BifrostContext that may contain existing trace/generation IDs
  • req: The incoming Bifrost request to be traced

Returns:

  • *schemas.BifrostRequest: The original request, unmodified
  • error: Any error that occurred during trace/generation creation

Jump to

Keyboard shortcuts

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