internal

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package internal provides shared utilities for the genai library.

Index

Constants

This section is empty.

Variables

View Source
var BeLenient = true

BeLenient is used by all clients to enable or disable httpjson.Client.Lenient.

It is true by default. Tests must manually set it to false.

Functions

func DecodeJSON

func DecodeJSON(d *json.Decoder, out any, r io.ReadSeeker) (bool, error)

DecodeJSON is duplicate from httpjson.go in https://github.com/maruel/httpjson.

func Logger

func Logger(ctx context.Context) *slog.Logger

Logger retrieves a slog.Logger from the context if any, otherwise returns slog.Default().

func MimeByExt

func MimeByExt(ext string) string

MimeByExt returns the mime type for the given extension.

It works around OS-specific bugs for audio and markdown.

func TypeName

func TypeName(v any) string

TypeName returns the unqualified type name, dereferencing pointers as needed.

func UnmarshalJSON added in v0.4.1

func UnmarshalJSON(data []byte, out any) error

UnmarshalJSON is like json.Unmarshal but respects BeLenient.

When strict (!BeLenient), it uses DisallowUnknownFields and provides detailed error messages about extra keys via DecodeJSON.

func WithLogger

func WithLogger(ctx context.Context, logger *slog.Logger) context.Context

WithLogger injects a slog.Logger into the context. It can be retrieved with Logger().

Types

type BadError

type BadError struct {
	Err error
}

BadError is a bad error that must stop the smoke test.

func (*BadError) Error

func (b *BadError) Error() string

func (*BadError) Unwrap

func (b *BadError) Unwrap() error

type Validatable

type Validatable interface {
	// Validate ensures the object is valid.
	Validate() error
}

Validatable is an interface to an object that can be validated.

Directories

Path Synopsis
Package bb is a separate package so it can be imported by genai while being internal and exported so cmp.Diff() isn't unhappy.
Package bb is a separate package so it can be imported by genai while being internal and exported so cmp.Diff() isn't unhappy.
Package cli provides process helpers for CLI-based providers.
Package cli provides process helpers for CLI-based providers.
cmd
autofix-weekly-regen command
Command autofix-weekly-regen asks pi.dev to repair weekly model regeneration failures.
Command autofix-weekly-regen asks pi.dev to repair weekly model regeneration failures.
gen-realtimespeech command
Command gen-realtimespeech regenerates the realtime speech FLAC fixtures with llama-tts.
Command gen-realtimespeech regenerates the realtime speech FLAC fixtures with llama-tts.
update-servers command
Command update-servers checks for newer releases of llama.cpp and ollama servers used by llamacppsrv and ollamasrv, updates the version constants, and regenerates test recordings.
Command update-servers checks for newer releases of llama.cpp and ollama servers used by llamacppsrv and ollamasrv, updates the version constants, and regenerates test recordings.
Package ghrelease provides shared helpers for downloading and extracting GitHub release assets.
Package ghrelease provides shared helpers for downloading and extracting GitHub release assets.
Package internaltest is awesome sauce for unit testing.
Package internaltest is awesome sauce for unit testing.
Package msgutil provides shared message utilities for subprocess-based providers.
Package msgutil provides shared message utilities for subprocess-based providers.
Package myrecorder has HTTP recording logic.
Package myrecorder has HTTP recording logic.
Package realtime provides cancellable WebSocket I/O with bounded reads for realtime providers.
Package realtime provides cancellable WebSocket I/O with bounded reads for realtime providers.
Package realtimetest provides scripted WebSocket peers, session checks and a fake session.
Package realtimetest provides scripted WebSocket peers, session checks and a fake session.
Package sse provides Server-Sent Events (SSE) processing utilities.
Package sse provides Server-Sent Events (SSE) processing utilities.

Jump to

Keyboard shortcuts

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