bipkit

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 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.

README

Bipkit Go SDK

Official, zero-dependency Go SDK for the Bipkit System One Decision Engine API.

Installation

go get github.com/bipware-org/bipkit-go@v0.1.0

Quickstart

package main

import (
	"context"
	"fmt"
	"log"

	bipkit "github.com/bipware-org/bipkit-go"
)

func main() {
	// Reads BIPKIT_API_KEY from the environment by default
	client := bipkit.NewClient()

	res, err := client.Decide(context.Background(), bipkit.DecisionRequest{
		State:  "Customer asks to cancel their enterprise contract and requests a refund.",
		Engine: "bip-cascade",
		Choices: []any{
			bipkit.Candidate{ID: "billing_retention", Label: "Billing & Retention"},
			bipkit.Candidate{ID: "technical_support", Label: "Technical Support"},
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.TopChoice != nil {
		fmt.Println("Top choice:", *res.TopChoice)
	}
	if bipkit.ShouldEscalateDecision(res, bipkit.EscalationOptions{MinConfidenceTier: "medium"}) {
		fmt.Println("Low confidence — escalate to System Two LLM")
	}
}

Documentation & Support

Documentation

Index

Constants

View Source
const (
	SDKVersion        = "0.1.0"
	DefaultBaseURL    = "https://api.bipkit.io"
	DefaultTimeout    = 30 * time.Second
	DefaultMaxRetries = 2
)

Variables

This section is empty.

Functions

func IsAuthenticationError

func IsAuthenticationError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func IsPermissionError

func IsPermissionError(err error) bool

func IsRateLimitError

func IsRateLimitError(err error) bool

func IsValidationError

func IsValidationError(err error) bool

func ShouldEscalateDecision

func ShouldEscalateDecision(resp *DecisionResponse, opts EscalationOptions) bool

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	RequestID  string
	RetryAfter *float64
	Body       []byte
}

APIError represents an error returned by the Bipkit HTTP API.

func (*APIError) Error

func (e *APIError) Error() string

type APIKeyInfo

type APIKeyInfo struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	KeyPrefix   string   `json:"key_prefix"`
	Environment string   `json:"environment"`
	Scopes      []string `json:"scopes"`
	IsActive    bool     `json:"is_active"`
	LastUsedAt  *string  `json:"last_used_at,omitempty"`
	ExpiresAt   *string  `json:"expires_at,omitempty"`
	CreatedAt   string   `json:"created_at"`
}

type APIKeysService

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

func (*APIKeysService) Create

func (*APIKeysService) List

func (s *APIKeysService) List(ctx context.Context) ([]APIKeyInfo, error)

func (*APIKeysService) Revoke

func (s *APIKeysService) Revoke(ctx context.Context, keyID string) (map[string]any, error)

func (*APIKeysService) Rotate

type BatchRecordOutcomeRequest

type BatchRecordOutcomeRequest struct {
	Items []RecordOutcomeRequest `json:"items"`
}

type Candidate

type Candidate struct {
	ID          string `json:"id"`
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`
}

type Client

type Client struct {
	Feedback   *FeedbackService
	Engines    *EnginesService
	APIKeys    *APIKeysService
	Usage      *UsageService
	Provenance *ProvenanceService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Option) *Client

func (*Client) Decide

func (c *Client) Decide(ctx context.Context, req DecisionRequest) (*DecisionResponse, error)

func (*Client) Evaluate

func (c *Client) Evaluate(ctx context.Context, req EvaluateRequest) (*EvaluateResponse, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context) (map[string]any, error)

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	Name        string   `json:"name"`
	Environment string   `json:"environment,omitempty"`
	Scopes      []string `json:"scopes,omitempty"`
}

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Key         string   `json:"key"`
	KeyPrefix   string   `json:"key_prefix"`
	Environment string   `json:"environment"`
	Scopes      []string `json:"scopes"`
	CreatedAt   string   `json:"created_at"`
}

type CustomerFeedbackRequest

type CustomerFeedbackRequest struct {
	RequestID        string  `json:"request_id"`
	VerifiedDecision any     `json:"verified_decision"`
	WasAccurate      bool    `json:"was_accurate"`
	OperatorNotes    *string `json:"operator_notes,omitempty"`
}

type CustomerFeedbackResponse

type CustomerFeedbackResponse struct {
	Status     string `json:"status"`
	RequestID  string `json:"request_id"`
	RecordedAt string `json:"recorded_at"`
}

type DecisionItem

type DecisionItem struct {
	CandidateID     string   `json:"candidate_id"`
	Probability     float64  `json:"probability"`
	ConfidenceTier  string   `json:"confidence_tier"`
	ConfidenceIndex float64  `json:"confidence_index"`
	Margin          *float64 `json:"margin,omitempty"`
}

type DecisionRequest

type DecisionRequest struct {
	State       string   `json:"state"`
	Choices     []any    `json:"choices"`
	Engine      string   `json:"engine,omitempty"`
	TopK        *int     `json:"top_k,omitempty"`
	Temperature *float64 `json:"temperature,omitempty"`
}

type DecisionResponse

type DecisionResponse struct {
	RequestID          string         `json:"request_id"`
	State              string         `json:"state"`
	Engine             string         `json:"engine"`
	UncertaintyEntropy float64        `json:"uncertainty_entropy"`
	TopChoice          *string        `json:"top_choice,omitempty"`
	Decisions          []DecisionItem `json:"decisions"`
}

type DplBundle

type DplBundle struct {
	SchemaVersion   string         `json:"schema_version,omitempty"`
	Record          map[string]any `json:"record"`
	StateDisclosure map[string]any `json:"state_disclosure,omitempty"`
	Outcome         map[string]any `json:"outcome,omitempty"`
	Manifest        map[string]any `json:"manifest"`
	Signature       map[string]any `json:"signature,omitempty"`
}

type EngineStatus

type EngineStatus struct {
	Name        string   `json:"name"`
	Tier        string   `json:"tier"`
	Description string   `json:"description"`
	Enabled     bool     `json:"enabled"`
	Status      string   `json:"status"`
	IsTrained   *bool    `json:"is_trained,omitempty"`
	Classes     []string `json:"classes,omitempty"`
}

type EnginesService

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

func (*EnginesService) List

func (s *EnginesService) List(ctx context.Context) ([]EngineStatus, error)

type EscalationOptions

type EscalationOptions struct {
	MinConfidenceTier string
	MaxEntropy        *float64
	MinMargin         *float64
}

type EvaluateRequest

type EvaluateRequest struct {
	State       string         `json:"state"`
	Evaluations map[string]any `json:"evaluations"`
	Engine      string         `json:"engine,omitempty"`
	Temperature *float64       `json:"temperature,omitempty"`
}

type EvaluateResponse

type EvaluateResponse struct {
	RequestID string                    `json:"request_id"`
	State     string                    `json:"state"`
	Engine    string                    `json:"engine"`
	Usage     UsageModel                `json:"usage"`
	Results   map[string]map[string]any `json:"results"`
}

type ExportBundleRequest

type ExportBundleRequest struct {
	RequestID      string  `json:"request_id"`
	OutputName     *string `json:"output_name,omitempty"`
	PresentedState *string `json:"presented_state,omitempty"`
}

type FeedbackService

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

func (*FeedbackService) Submit

type Option

type Option func(*Client)

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

func WithHeader

func WithHeader(key, value string) Option

func WithMaxRetries

func WithMaxRetries(retries int) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type ProvenanceRecordsParams

type ProvenanceRecordsParams struct {
	Status         string
	PrimitiveType  string
	ExecutionStage string
	RequestID      string
	FromSeq        *int
	ToSeq          *int
	Limit          *int
	Offset         *int
	Order          string
}

type ProvenanceService

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

func (*ProvenanceService) Calibration

func (s *ProvenanceService) Calibration(ctx context.Context) (map[string]any, error)

func (*ProvenanceService) Chain

func (s *ProvenanceService) Chain(ctx context.Context, fromSeq, limit *int) (map[string]any, error)

func (*ProvenanceService) Export

func (*ProvenanceService) GetRecord

func (s *ProvenanceService) GetRecord(ctx context.Context, entryID string) (map[string]any, error)

func (*ProvenanceService) GetRequest

func (s *ProvenanceService) GetRequest(ctx context.Context, requestID string) (map[string]any, error)

func (*ProvenanceService) Keys

func (s *ProvenanceService) Keys(ctx context.Context) (map[string]any, error)

func (*ProvenanceService) Manifest

func (s *ProvenanceService) Manifest(ctx context.Context) (map[string]any, error)

func (*ProvenanceService) Metrics

func (s *ProvenanceService) Metrics(ctx context.Context) (map[string]any, error)

func (*ProvenanceService) RecordOutcome

func (s *ProvenanceService) RecordOutcome(ctx context.Context, req RecordOutcomeRequest) (map[string]any, error)

func (*ProvenanceService) RecordOutcomesBatch

func (s *ProvenanceService) RecordOutcomesBatch(ctx context.Context, req BatchRecordOutcomeRequest) (map[string]any, error)

func (*ProvenanceService) Records

func (s *ProvenanceService) Records(ctx context.Context, params ProvenanceRecordsParams) (map[string]any, error)

func (*ProvenanceService) Verify

func (s *ProvenanceService) Verify(ctx context.Context, bundle DplBundle) (map[string]any, error)

type RecordOutcomeRequest

type RecordOutcomeRequest struct {
	RequestID      string  `json:"request_id"`
	OutputName     *string `json:"output_name,omitempty"`
	ObservedEffect any     `json:"observed_effect"`
}

type RotateAPIKeyRequest

type RotateAPIKeyRequest struct {
	GracePeriodMinutes int `json:"grace_period_minutes"`
}

type RotateAPIKeyResponse

type RotateAPIKeyResponse struct {
	NewKey                        CreateAPIKeyResponse `json:"new_key"`
	RotatedKeyID                  string               `json:"rotated_key_id"`
	PreviousKeyRevokedImmediately bool                 `json:"previous_key_revoked_immediately"`
	PreviousKeyExpiresAt          *string              `json:"previous_key_expires_at,omitempty"`
}

type UsageEngineBreakdown

type UsageEngineBreakdown struct {
	Engine      string `json:"engine"`
	Decisions   int    `json:"decisions"`
	Evaluations int    `json:"evaluations"`
	Tokens      int    `json:"tokens"`
}

type UsageModel

type UsageModel struct {
	EvaluationsCount int     `json:"evaluations_count"`
	StateTokens      int     `json:"state_tokens"`
	EvaluationTokens int     `json:"evaluation_tokens"`
	TotalTokens      int     `json:"total_tokens"`
	LatencyMs        float64 `json:"latency_ms,omitempty"`
}

type UsageService

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

func (*UsageService) Summary

func (*UsageService) Timeseries

func (s *UsageService) Timeseries(ctx context.Context, days *int) (*UsageTimeseriesResponse, error)

type UsageSummaryResponse

type UsageSummaryResponse struct {
	OrganizationID     string                 `json:"organization_id"`
	PeriodYM           string                 `json:"period_ym"`
	PlanSlug           string                 `json:"plan_slug"`
	PlanName           string                 `json:"plan_name"`
	SubscriptionStatus string                 `json:"subscription_status"`
	DecisionsUsed      int                    `json:"decisions_used"`
	EvaluationsUsed    int                    `json:"evaluations_used"`
	TotalTokens        int                    `json:"total_tokens"`
	MonthlyLimit       int                    `json:"monthly_limit"`
	RemainingQuota     int                    `json:"remaining_quota"`
	AvgLatencyMs       float64                `json:"avg_latency_ms"`
	ByEngine           []UsageEngineBreakdown `json:"by_engine"`
}

type UsageTimeseriesPoint

type UsageTimeseriesPoint struct {
	Date         string  `json:"date"`
	Decisions    int     `json:"decisions"`
	Evaluations  int     `json:"evaluations"`
	Tokens       int     `json:"tokens"`
	AvgLatencyMs float64 `json:"avg_latency_ms"`
}

type UsageTimeseriesResponse

type UsageTimeseriesResponse struct {
	OrganizationID string                 `json:"organization_id"`
	Days           int                    `json:"days"`
	Points         []UsageTimeseriesPoint `json:"points"`
}

Jump to

Keyboard shortcuts

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