ai

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// Tool call arguments could not be unmarshaled from JSON.
	ErrorInfoReasonToolCallArgumentUnmarshal = "TOOL_CALL_ARGUMENT_UNMARSHAL"
	// Tool call references a tool that was not provided in the request.
	ErrorInfoReasonToolCallUnknownTool = "TOOL_CALL_UNKNOWN_TOOL"
)

Variables

This section is empty.

Functions

func AggregateModelUsage

func AggregateModelUsage(aggregateModelUsage *aipb.ModelUsage, modelUsages ...*aipb.ModelUsage)

func ExtractJSONString

func ExtractJSONString(content string) (string, error)

ExtractJSONString finds and extracts the first JSON object from LLM output

func FilterBlocks

func FilterBlocks(blocks []*aipb.Block, blockTypes ...BlockType) []*aipb.Block

func IsModelUsageEmpty

func IsModelUsageEmpty(modelUsage *aipb.ModelUsage) bool

func ModelUsageCost

func ModelUsageCost(modelUsage *aipb.ModelUsage) float64

func NewAssistantMessage

func NewAssistantMessage(blocks ...*aipb.Block) *aipb.Message

func NewErrorToolResult

func NewErrorToolResult(toolName, toolCallID string, err error) *aipb.ToolResult

func NewImageBlock

func NewImageBlock(image *aipb.Image) *aipb.Block

func NewImageFromData

func NewImageFromData(data []byte, mediaType string) *aipb.Image

func NewImageFromURL

func NewImageFromURL(url string) *aipb.Image

func NewResourceConsumption

func NewResourceConsumption(quantity int32) *aipb.ResourceConsumption

func NewStructuredToolResult

func NewStructuredToolResult(toolName, toolCallID string, content *structpb.Value) *aipb.ToolResult

func NewSystemMessage

func NewSystemMessage(blocks ...*aipb.Block) *aipb.Message

func NewTextBlock

func NewTextBlock(text string) *aipb.Block

func NewThoughtBlock

func NewThoughtBlock(thought string) *aipb.Block

func NewToolCallBlock

func NewToolCallBlock(toolCall *aipb.ToolCall) *aipb.Block

func NewToolMessage

func NewToolMessage(blocks ...*aipb.Block) *aipb.Message

func NewToolResult

func NewToolResult(toolName, toolCallID, content string) *aipb.ToolResult

func NewToolResultBlock

func NewToolResultBlock(toolResult *aipb.ToolResult) *aipb.Block

func NewUserMessage

func NewUserMessage(blocks ...*aipb.Block) *aipb.Message

func ParseToolResult

func ParseToolResult(toolResult *aipb.ToolResult) (string, error)

func SetModelUsagePrices

func SetModelUsagePrices(usage *aipb.ModelUsage, pricing *aipb.TttModelPricing)

Types

type BlockType

type BlockType int
const (
	BlockTypeText BlockType = iota
	BlockTypeThought
	BlockTypeToolCall
	BlockTypeToolResult
	BlockTypeImage
	BlockTypePartialToolCall
)

type MessageAccumulator

type MessageAccumulator struct {
	Message           *aipb.Message
	StopReason        pb.StopReason
	ModelUsage        *aipb.ModelUsage
	GenerationMetrics *aipb.GenerationMetrics
	// contains filtered or unexported fields
}

MessageAccumulator accumulates StreamMessage events into a complete message.

func NewMessageAccumulator

func NewMessageAccumulator() *MessageAccumulator

func (*MessageAccumulator) Add

Directories

Path Synopsis
provider/mock
Package mock implements a scriptable in-process AI provider for system acceptance tests.
Package mock implements a scriptable in-process AI provider for system acceptance tests.
Code generated by protoc-gen-api.
Code generated by protoc-gen-api.

Jump to

Keyboard shortcuts

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