vlm

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactedEndpoint

func RedactedEndpoint(value string) string

func StripLeadingReasoningBlocks

func StripLeadingReasoningBlocks(value string) (string, bool)

StripLeadingReasoningBlocks removes model-internal reasoning emitted before the user-visible answer. Tags inside the document body are preserved.

Types

type AgentMessage

type AgentMessage struct {
	Role       string          `json:"role"`
	Content    string          `json:"content,omitempty"`
	ToolCallID string          `json:"tool_call_id,omitempty"`
	ToolCalls  []AgentToolCall `json:"tool_calls,omitempty"`
}

type AgentResponse

type AgentResponse struct {
	Content      string
	ToolCalls    []AgentToolCall
	Usage        Usage
	RawModel     string
	FinishReason string
}

func CompleteAgentChatOpenAICompatible

func CompleteAgentChatOpenAICompatible(
	ctx context.Context,
	config Config,
	messages []AgentMessage,
	tools []AgentTool,
	httpClient *http.Client,
) (AgentResponse, error)

type AgentTool

type AgentTool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Parameters  json.RawMessage `json:"parameters"`
}

type AgentToolCall

type AgentToolCall struct {
	ID       string            `json:"id"`
	Type     string            `json:"type"`
	Function AgentToolFunction `json:"function"`
}

type AgentToolFunction

type AgentToolFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type AppError

type AppError struct {
	Kind      ErrorKind `json:"kind"`
	Message   string    `json:"message"`
	Retryable bool      `json:"retryable"`
	Usage     *Usage    `json:"usage,omitempty"`
	Cause     error     `json:"-"`
}

func NewError

func NewError(kind ErrorKind, message string, retryable bool, cause error) *AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) Unwrap

func (e *AppError) Unwrap() error

type Client

type Client interface {
	Complete(ctx context.Context, request Request) (Response, error)
}

func NewOpenAICompatible

func NewOpenAICompatible(config Config, httpClient *http.Client) (Client, error)

type Config

type Config struct {
	Provider          string
	BaseURL           string
	Model             string
	APIKey            string
	ImageDetail       string
	MaxImageBytes     int64
	MaxTokens         int
	ContextFallbacks  int
	MinImageDimension int
	Timeout           time.Duration
	ExtraBody         map[string]json.RawMessage
}

type ErrorKind

type ErrorKind string
const (
	ConfigError     ErrorKind = "ConfigError"
	DependencyError ErrorKind = "DependencyError"
	RenderError     ErrorKind = "RenderError"
	RateLimitError  ErrorKind = "RateLimitError"
	ServerError     ErrorKind = "ServerError"
	TimeoutError    ErrorKind = "TimeoutError"
	AuthError       ErrorKind = "AuthError"
	ModelError      ErrorKind = "ModelError"
	ParseError      ErrorKind = "ParseError"
	PartialError    ErrorKind = "PartialError"
)

type ModelInfo

type ModelInfo struct {
	ID      string `json:"id"`
	Object  string `json:"object,omitempty"`
	OwnedBy string `json:"owned_by,omitempty"`
}

func ListModelsOpenAICompatible

func ListModelsOpenAICompatible(ctx context.Context, config Config, httpClient *http.Client) ([]ModelInfo, error)

type Request

type Request struct {
	Prompt      string
	ImagePath   string
	ImageMIME   string
	ImageDetail string
}

type Response

type Response struct {
	Content                  string
	Usage                    Usage
	RawModel                 string
	FinishReason             string
	RequestImageMaxDimension int
	ContextFallbacksUsed     int
}

func CompleteTextOpenAICompatible

func CompleteTextOpenAICompatible(ctx context.Context, config Config, prompt string, httpClient *http.Client) (Response, error)

type Usage

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

func UsageFromError

func UsageFromError(err error) (Usage, bool)

Jump to

Keyboard shortcuts

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